Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E

Percentage Accurate: 99.7% → 99.8%
Time: 9.3s
Alternatives: 10
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ x + \left(\left(y - x\right) \cdot 6\right) \cdot z \end{array} \]
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * z);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + (((y - x) * 6.0d0) * z)
end function
public static double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * z);
}
def code(x, y, z):
	return x + (((y - x) * 6.0) * z)
function code(x, y, z)
	return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z))
end
function tmp = code(x, y, z)
	tmp = x + (((y - x) * 6.0) * z);
end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 10 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 99.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(\left(y - x\right) \cdot 6\right) \cdot z \end{array} \]
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * z);
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + (((y - x) * 6.0d0) * z)
end function
public static double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * z);
}
def code(x, y, z):
	return x + (((y - x) * 6.0) * z)
function code(x, y, z)
	return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z))
end
function tmp = code(x, y, z)
	tmp = x + (((y - x) * 6.0) * z);
end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(y - x\right) \cdot \left(6 \cdot z\right) \end{array} \]
(FPCore (x y z) :precision binary64 (+ x (* (- y x) (* 6.0 z))))
double code(double x, double y, double z) {
	return x + ((y - x) * (6.0 * z));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + ((y - x) * (6.0d0 * z))
end function
public static double code(double x, double y, double z) {
	return x + ((y - x) * (6.0 * z));
}
def code(x, y, z):
	return x + ((y - x) * (6.0 * z))
function code(x, y, z)
	return Float64(x + Float64(Float64(y - x) * Float64(6.0 * z)))
end
function tmp = code(x, y, z)
	tmp = x + ((y - x) * (6.0 * z));
end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(y - x\right) \cdot \left(6 \cdot z\right)
\end{array}
Derivation
  1. Initial program 99.8%

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
  2. Step-by-step derivation
    1. associate-*l*99.8%

      \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
  3. Simplified99.8%

    \[\leadsto \color{blue}{x + \left(y - x\right) \cdot \left(6 \cdot z\right)} \]
  4. Add Preprocessing
  5. Final simplification99.8%

    \[\leadsto x + \left(y - x\right) \cdot \left(6 \cdot z\right) \]
  6. Add Preprocessing

Alternative 2: 53.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;y \leq -5.2 \cdot 10^{-112}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-227}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-134}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-78}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* y z))))
   (if (<= y -5.2e-112)
     t_0
     (if (<= y 5.2e-227)
       x
       (if (<= y 1.3e-134) (* -6.0 (* x z)) (if (<= y 1.5e-78) x t_0))))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (y * z);
	double tmp;
	if (y <= -5.2e-112) {
		tmp = t_0;
	} else if (y <= 5.2e-227) {
		tmp = x;
	} else if (y <= 1.3e-134) {
		tmp = -6.0 * (x * z);
	} else if (y <= 1.5e-78) {
		tmp = x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 6.0d0 * (y * z)
    if (y <= (-5.2d-112)) then
        tmp = t_0
    else if (y <= 5.2d-227) then
        tmp = x
    else if (y <= 1.3d-134) then
        tmp = (-6.0d0) * (x * z)
    else if (y <= 1.5d-78) then
        tmp = x
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 6.0 * (y * z);
	double tmp;
	if (y <= -5.2e-112) {
		tmp = t_0;
	} else if (y <= 5.2e-227) {
		tmp = x;
	} else if (y <= 1.3e-134) {
		tmp = -6.0 * (x * z);
	} else if (y <= 1.5e-78) {
		tmp = x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 6.0 * (y * z)
	tmp = 0
	if y <= -5.2e-112:
		tmp = t_0
	elif y <= 5.2e-227:
		tmp = x
	elif y <= 1.3e-134:
		tmp = -6.0 * (x * z)
	elif y <= 1.5e-78:
		tmp = x
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(6.0 * Float64(y * z))
	tmp = 0.0
	if (y <= -5.2e-112)
		tmp = t_0;
	elseif (y <= 5.2e-227)
		tmp = x;
	elseif (y <= 1.3e-134)
		tmp = Float64(-6.0 * Float64(x * z));
	elseif (y <= 1.5e-78)
		tmp = x;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 6.0 * (y * z);
	tmp = 0.0;
	if (y <= -5.2e-112)
		tmp = t_0;
	elseif (y <= 5.2e-227)
		tmp = x;
	elseif (y <= 1.3e-134)
		tmp = -6.0 * (x * z);
	elseif (y <= 1.5e-78)
		tmp = x;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.2e-112], t$95$0, If[LessEqual[y, 5.2e-227], x, If[LessEqual[y, 1.3e-134], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e-78], x, t$95$0]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 6 \cdot \left(y \cdot z\right)\\
\mathbf{if}\;y \leq -5.2 \cdot 10^{-112}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;y \leq 5.2 \cdot 10^{-227}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 1.3 \cdot 10^{-134}:\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\

\mathbf{elif}\;y \leq 1.5 \cdot 10^{-78}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.19999999999999983e-112 or 1.49999999999999994e-78 < y

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r*99.8%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. +-commutative99.8%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right) + x} \]
      3. *-commutative99.8%

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(z \cdot 6\right)} + x \]
      4. associate-*r*99.8%

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot z\right) \cdot 6} + x \]
      5. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    5. Taylor expanded in y around inf 64.8%

      \[\leadsto \color{blue}{6 \cdot \left(y \cdot z\right)} \]
    6. Step-by-step derivation
      1. *-commutative64.8%

        \[\leadsto 6 \cdot \color{blue}{\left(z \cdot y\right)} \]
    7. Simplified64.8%

      \[\leadsto \color{blue}{6 \cdot \left(z \cdot y\right)} \]

    if -5.19999999999999983e-112 < y < 5.20000000000000023e-227 or 1.30000000000000011e-134 < y < 1.49999999999999994e-78

    1. Initial program 99.9%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 66.3%

      \[\leadsto \color{blue}{x} \]

    if 5.20000000000000023e-227 < y < 1.30000000000000011e-134

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 99.9%

      \[\leadsto x + \color{blue}{-6 \cdot \left(x \cdot z\right)} \]
    4. Taylor expanded in z around inf 63.1%

      \[\leadsto \color{blue}{-6 \cdot \left(x \cdot z\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification65.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{-112}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-227}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-134}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-78}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 53.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4.1 \cdot 10^{-112}:\\ \;\;\;\;y \cdot \left(6 \cdot z\right)\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-227}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-131}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-75}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -4.1e-112)
   (* y (* 6.0 z))
   (if (<= y 3.5e-227)
     x
     (if (<= y 9e-131)
       (* -6.0 (* x z))
       (if (<= y 8.2e-75) x (* 6.0 (* y z)))))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -4.1e-112) {
		tmp = y * (6.0 * z);
	} else if (y <= 3.5e-227) {
		tmp = x;
	} else if (y <= 9e-131) {
		tmp = -6.0 * (x * z);
	} else if (y <= 8.2e-75) {
		tmp = x;
	} else {
		tmp = 6.0 * (y * z);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-4.1d-112)) then
        tmp = y * (6.0d0 * z)
    else if (y <= 3.5d-227) then
        tmp = x
    else if (y <= 9d-131) then
        tmp = (-6.0d0) * (x * z)
    else if (y <= 8.2d-75) then
        tmp = x
    else
        tmp = 6.0d0 * (y * z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -4.1e-112) {
		tmp = y * (6.0 * z);
	} else if (y <= 3.5e-227) {
		tmp = x;
	} else if (y <= 9e-131) {
		tmp = -6.0 * (x * z);
	} else if (y <= 8.2e-75) {
		tmp = x;
	} else {
		tmp = 6.0 * (y * z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if y <= -4.1e-112:
		tmp = y * (6.0 * z)
	elif y <= 3.5e-227:
		tmp = x
	elif y <= 9e-131:
		tmp = -6.0 * (x * z)
	elif y <= 8.2e-75:
		tmp = x
	else:
		tmp = 6.0 * (y * z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (y <= -4.1e-112)
		tmp = Float64(y * Float64(6.0 * z));
	elseif (y <= 3.5e-227)
		tmp = x;
	elseif (y <= 9e-131)
		tmp = Float64(-6.0 * Float64(x * z));
	elseif (y <= 8.2e-75)
		tmp = x;
	else
		tmp = Float64(6.0 * Float64(y * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -4.1e-112)
		tmp = y * (6.0 * z);
	elseif (y <= 3.5e-227)
		tmp = x;
	elseif (y <= 9e-131)
		tmp = -6.0 * (x * z);
	elseif (y <= 8.2e-75)
		tmp = x;
	else
		tmp = 6.0 * (y * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[y, -4.1e-112], N[(y * N[(6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.5e-227], x, If[LessEqual[y, 9e-131], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.2e-75], x, N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.1 \cdot 10^{-112}:\\
\;\;\;\;y \cdot \left(6 \cdot z\right)\\

\mathbf{elif}\;y \leq 3.5 \cdot 10^{-227}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 9 \cdot 10^{-131}:\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\

\mathbf{elif}\;y \leq 8.2 \cdot 10^{-75}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;6 \cdot \left(y \cdot z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -4.09999999999999996e-112

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r*99.8%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. +-commutative99.8%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right) + x} \]
      3. *-commutative99.8%

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(z \cdot 6\right)} + x \]
      4. associate-*r*99.8%

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot z\right) \cdot 6} + x \]
      5. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    5. Taylor expanded in y around inf 63.0%

      \[\leadsto \color{blue}{6 \cdot \left(y \cdot z\right)} \]
    6. Step-by-step derivation
      1. *-commutative63.0%

        \[\leadsto \color{blue}{\left(y \cdot z\right) \cdot 6} \]
      2. associate-*r*63.1%

        \[\leadsto \color{blue}{y \cdot \left(z \cdot 6\right)} \]
    7. Simplified63.1%

      \[\leadsto \color{blue}{y \cdot \left(z \cdot 6\right)} \]

    if -4.09999999999999996e-112 < y < 3.5000000000000001e-227 or 9.0000000000000004e-131 < y < 8.20000000000000005e-75

    1. Initial program 99.9%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 66.3%

      \[\leadsto \color{blue}{x} \]

    if 3.5000000000000001e-227 < y < 9.0000000000000004e-131

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 99.9%

      \[\leadsto x + \color{blue}{-6 \cdot \left(x \cdot z\right)} \]
    4. Taylor expanded in z around inf 63.1%

      \[\leadsto \color{blue}{-6 \cdot \left(x \cdot z\right)} \]

    if 8.20000000000000005e-75 < y

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r*99.7%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. +-commutative99.7%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right) + x} \]
      3. *-commutative99.7%

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(z \cdot 6\right)} + x \]
      4. associate-*r*99.8%

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot z\right) \cdot 6} + x \]
      5. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    5. Taylor expanded in y around inf 66.8%

      \[\leadsto \color{blue}{6 \cdot \left(y \cdot z\right)} \]
    6. Step-by-step derivation
      1. *-commutative66.8%

        \[\leadsto 6 \cdot \color{blue}{\left(z \cdot y\right)} \]
    7. Simplified66.8%

      \[\leadsto \color{blue}{6 \cdot \left(z \cdot y\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification65.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.1 \cdot 10^{-112}:\\ \;\;\;\;y \cdot \left(6 \cdot z\right)\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-227}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-131}:\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-75}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 84.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.1 \cdot 10^{-58} \lor \neg \left(z \leq 1.8 \cdot 10^{-24}\right):\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -1.1e-58) (not (<= z 1.8e-24))) (* 6.0 (* (- y x) z)) x))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.1e-58) || !(z <= 1.8e-24)) {
		tmp = 6.0 * ((y - x) * z);
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-1.1d-58)) .or. (.not. (z <= 1.8d-24))) then
        tmp = 6.0d0 * ((y - x) * z)
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -1.1e-58) || !(z <= 1.8e-24)) {
		tmp = 6.0 * ((y - x) * z);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -1.1e-58) or not (z <= 1.8e-24):
		tmp = 6.0 * ((y - x) * z)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -1.1e-58) || !(z <= 1.8e-24))
		tmp = Float64(6.0 * Float64(Float64(y - x) * z));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -1.1e-58) || ~((z <= 1.8e-24)))
		tmp = 6.0 * ((y - x) * z);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.1e-58], N[Not[LessEqual[z, 1.8e-24]], $MachinePrecision]], N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{-58} \lor \neg \left(z \leq 1.8 \cdot 10^{-24}\right):\\
\;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.10000000000000003e-58 or 1.8e-24 < z

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r*99.8%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. +-commutative99.8%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right) + x} \]
      3. *-commutative99.8%

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(z \cdot 6\right)} + x \]
      4. associate-*r*99.7%

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot z\right) \cdot 6} + x \]
      5. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    5. Taylor expanded in z around inf 95.3%

      \[\leadsto \color{blue}{6 \cdot \left(z \cdot \left(y - x\right)\right)} \]

    if -1.10000000000000003e-58 < z < 1.8e-24

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 73.4%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.1 \cdot 10^{-58} \lor \neg \left(z \leq 1.8 \cdot 10^{-24}\right):\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 98.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2600000000 \lor \neg \left(z \leq 0.165\right):\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -2600000000.0) (not (<= z 0.165)))
   (* (- y x) (* 6.0 z))
   (+ x (* 6.0 (* y z)))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -2600000000.0) || !(z <= 0.165)) {
		tmp = (y - x) * (6.0 * z);
	} else {
		tmp = x + (6.0 * (y * z));
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-2600000000.0d0)) .or. (.not. (z <= 0.165d0))) then
        tmp = (y - x) * (6.0d0 * z)
    else
        tmp = x + (6.0d0 * (y * z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -2600000000.0) || !(z <= 0.165)) {
		tmp = (y - x) * (6.0 * z);
	} else {
		tmp = x + (6.0 * (y * z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -2600000000.0) or not (z <= 0.165):
		tmp = (y - x) * (6.0 * z)
	else:
		tmp = x + (6.0 * (y * z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -2600000000.0) || !(z <= 0.165))
		tmp = Float64(Float64(y - x) * Float64(6.0 * z));
	else
		tmp = Float64(x + Float64(6.0 * Float64(y * z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -2600000000.0) || ~((z <= 0.165)))
		tmp = (y - x) * (6.0 * z);
	else
		tmp = x + (6.0 * (y * z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -2600000000.0], N[Not[LessEqual[z, 0.165]], $MachinePrecision]], N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision], N[(x + N[(6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2600000000 \lor \neg \left(z \leq 0.165\right):\\
\;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.6e9 or 0.165000000000000008 < z

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r*99.8%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. +-commutative99.8%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right) + x} \]
      3. *-commutative99.8%

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(z \cdot 6\right)} + x \]
      4. associate-*r*99.7%

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot z\right) \cdot 6} + x \]
      5. fma-def99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    5. Taylor expanded in z around inf 98.3%

      \[\leadsto \color{blue}{6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*98.4%

        \[\leadsto \color{blue}{\left(6 \cdot z\right) \cdot \left(y - x\right)} \]
      2. *-commutative98.4%

        \[\leadsto \color{blue}{\left(z \cdot 6\right)} \cdot \left(y - x\right) \]
      3. *-commutative98.4%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(z \cdot 6\right)} \]
    7. Simplified98.4%

      \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(z \cdot 6\right)} \]

    if -2.6e9 < z < 0.165000000000000008

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf 99.6%

      \[\leadsto x + \color{blue}{6 \cdot \left(y \cdot z\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto x + 6 \cdot \color{blue}{\left(z \cdot y\right)} \]
    5. Simplified99.6%

      \[\leadsto x + \color{blue}{6 \cdot \left(z \cdot y\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2600000000 \lor \neg \left(z \leq 0.165\right):\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 84.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{-59}:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-24}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -2.9e-59)
   (* (- y x) (* 6.0 z))
   (if (<= z 4.2e-24) x (* 6.0 (* (- y x) z)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -2.9e-59) {
		tmp = (y - x) * (6.0 * z);
	} else if (z <= 4.2e-24) {
		tmp = x;
	} else {
		tmp = 6.0 * ((y - x) * z);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-2.9d-59)) then
        tmp = (y - x) * (6.0d0 * z)
    else if (z <= 4.2d-24) then
        tmp = x
    else
        tmp = 6.0d0 * ((y - x) * z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -2.9e-59) {
		tmp = (y - x) * (6.0 * z);
	} else if (z <= 4.2e-24) {
		tmp = x;
	} else {
		tmp = 6.0 * ((y - x) * z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -2.9e-59:
		tmp = (y - x) * (6.0 * z)
	elif z <= 4.2e-24:
		tmp = x
	else:
		tmp = 6.0 * ((y - x) * z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -2.9e-59)
		tmp = Float64(Float64(y - x) * Float64(6.0 * z));
	elseif (z <= 4.2e-24)
		tmp = x;
	else
		tmp = Float64(6.0 * Float64(Float64(y - x) * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -2.9e-59)
		tmp = (y - x) * (6.0 * z);
	elseif (z <= 4.2e-24)
		tmp = x;
	else
		tmp = 6.0 * ((y - x) * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -2.9e-59], N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4.2e-24], x, N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.9 \cdot 10^{-59}:\\
\;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\

\mathbf{elif}\;z \leq 4.2 \cdot 10^{-24}:\\
\;\;\;\;x\\

\mathbf{else}:\\
\;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.90000000000000016e-59

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r*99.8%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. +-commutative99.8%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right) + x} \]
      3. *-commutative99.8%

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(z \cdot 6\right)} + x \]
      4. associate-*r*99.7%

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot z\right) \cdot 6} + x \]
      5. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    5. Taylor expanded in z around inf 94.3%

      \[\leadsto \color{blue}{6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*94.4%

        \[\leadsto \color{blue}{\left(6 \cdot z\right) \cdot \left(y - x\right)} \]
      2. *-commutative94.4%

        \[\leadsto \color{blue}{\left(z \cdot 6\right)} \cdot \left(y - x\right) \]
      3. *-commutative94.4%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(z \cdot 6\right)} \]
    7. Simplified94.4%

      \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(z \cdot 6\right)} \]

    if -2.90000000000000016e-59 < z < 4.1999999999999999e-24

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 73.4%

      \[\leadsto \color{blue}{x} \]

    if 4.1999999999999999e-24 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r*99.7%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. +-commutative99.7%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right) + x} \]
      3. *-commutative99.7%

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(z \cdot 6\right)} + x \]
      4. associate-*r*99.8%

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot z\right) \cdot 6} + x \]
      5. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    5. Taylor expanded in z around inf 96.3%

      \[\leadsto \color{blue}{6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.9 \cdot 10^{-59}:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-24}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 84.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -9.2 \cdot 10^{-60}:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{elif}\;z \leq 32000:\\ \;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -9.2e-60)
   (* (- y x) (* 6.0 z))
   (if (<= z 32000.0) (+ x (* -6.0 (* x z))) (* 6.0 (* (- y x) z)))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -9.2e-60) {
		tmp = (y - x) * (6.0 * z);
	} else if (z <= 32000.0) {
		tmp = x + (-6.0 * (x * z));
	} else {
		tmp = 6.0 * ((y - x) * z);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-9.2d-60)) then
        tmp = (y - x) * (6.0d0 * z)
    else if (z <= 32000.0d0) then
        tmp = x + ((-6.0d0) * (x * z))
    else
        tmp = 6.0d0 * ((y - x) * z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -9.2e-60) {
		tmp = (y - x) * (6.0 * z);
	} else if (z <= 32000.0) {
		tmp = x + (-6.0 * (x * z));
	} else {
		tmp = 6.0 * ((y - x) * z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -9.2e-60:
		tmp = (y - x) * (6.0 * z)
	elif z <= 32000.0:
		tmp = x + (-6.0 * (x * z))
	else:
		tmp = 6.0 * ((y - x) * z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -9.2e-60)
		tmp = Float64(Float64(y - x) * Float64(6.0 * z));
	elseif (z <= 32000.0)
		tmp = Float64(x + Float64(-6.0 * Float64(x * z)));
	else
		tmp = Float64(6.0 * Float64(Float64(y - x) * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -9.2e-60)
		tmp = (y - x) * (6.0 * z);
	elseif (z <= 32000.0)
		tmp = x + (-6.0 * (x * z));
	else
		tmp = 6.0 * ((y - x) * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -9.2e-60], N[(N[(y - x), $MachinePrecision] * N[(6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 32000.0], N[(x + N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.2 \cdot 10^{-60}:\\
\;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\

\mathbf{elif}\;z \leq 32000:\\
\;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -9.2000000000000005e-60

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r*99.8%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. +-commutative99.8%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right) + x} \]
      3. *-commutative99.8%

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(z \cdot 6\right)} + x \]
      4. associate-*r*99.7%

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot z\right) \cdot 6} + x \]
      5. fma-def99.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    5. Taylor expanded in z around inf 94.3%

      \[\leadsto \color{blue}{6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
    6. Step-by-step derivation
      1. associate-*r*94.4%

        \[\leadsto \color{blue}{\left(6 \cdot z\right) \cdot \left(y - x\right)} \]
      2. *-commutative94.4%

        \[\leadsto \color{blue}{\left(z \cdot 6\right)} \cdot \left(y - x\right) \]
      3. *-commutative94.4%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(z \cdot 6\right)} \]
    7. Simplified94.4%

      \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(z \cdot 6\right)} \]

    if -9.2000000000000005e-60 < z < 32000

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 72.9%

      \[\leadsto x + \color{blue}{-6 \cdot \left(x \cdot z\right)} \]

    if 32000 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-*r*99.8%

        \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right)} \]
      2. +-commutative99.8%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot z\right) + x} \]
      3. *-commutative99.8%

        \[\leadsto \left(y - x\right) \cdot \color{blue}{\left(z \cdot 6\right)} + x \]
      4. associate-*r*99.8%

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot z\right) \cdot 6} + x \]
      5. fma-def99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot z, 6, x\right)} \]
    5. Taylor expanded in z around inf 99.8%

      \[\leadsto \color{blue}{6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification86.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9.2 \cdot 10^{-60}:\\ \;\;\;\;\left(y - x\right) \cdot \left(6 \cdot z\right)\\ \mathbf{elif}\;z \leq 32000:\\ \;\;\;\;x + -6 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 61.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -3.6 \cdot 10^{-9} \lor \neg \left(z \leq 0.165\right):\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -3.6e-9) (not (<= z 0.165))) (* -6.0 (* x z)) x))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -3.6e-9) || !(z <= 0.165)) {
		tmp = -6.0 * (x * z);
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((z <= (-3.6d-9)) .or. (.not. (z <= 0.165d0))) then
        tmp = (-6.0d0) * (x * z)
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -3.6e-9) || !(z <= 0.165)) {
		tmp = -6.0 * (x * z);
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -3.6e-9) or not (z <= 0.165):
		tmp = -6.0 * (x * z)
	else:
		tmp = x
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -3.6e-9) || !(z <= 0.165))
		tmp = Float64(-6.0 * Float64(x * z));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -3.6e-9) || ~((z <= 0.165)))
		tmp = -6.0 * (x * z);
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.6e-9], N[Not[LessEqual[z, 0.165]], $MachinePrecision]], N[(-6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.6 \cdot 10^{-9} \lor \neg \left(z \leq 0.165\right):\\
\;\;\;\;-6 \cdot \left(x \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.6e-9 or 0.165000000000000008 < z

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Taylor expanded in y around 0 49.1%

      \[\leadsto x + \color{blue}{-6 \cdot \left(x \cdot z\right)} \]
    4. Taylor expanded in z around inf 47.7%

      \[\leadsto \color{blue}{-6 \cdot \left(x \cdot z\right)} \]

    if -3.6e-9 < z < 0.165000000000000008

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
    2. Add Preprocessing
    3. Taylor expanded in z around 0 70.8%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification58.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.6 \cdot 10^{-9} \lor \neg \left(z \leq 0.165\right):\\ \;\;\;\;-6 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 99.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + z \cdot \left(\left(y - x\right) \cdot 6\right) \end{array} \]
(FPCore (x y z) :precision binary64 (+ x (* z (* (- y x) 6.0))))
double code(double x, double y, double z) {
	return x + (z * ((y - x) * 6.0));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + (z * ((y - x) * 6.0d0))
end function
public static double code(double x, double y, double z) {
	return x + (z * ((y - x) * 6.0));
}
def code(x, y, z):
	return x + (z * ((y - x) * 6.0))
function code(x, y, z)
	return Float64(x + Float64(z * Float64(Float64(y - x) * 6.0)))
end
function tmp = code(x, y, z)
	tmp = x + (z * ((y - x) * 6.0));
end
code[x_, y_, z_] := N[(x + N[(z * N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + z \cdot \left(\left(y - x\right) \cdot 6\right)
\end{array}
Derivation
  1. Initial program 99.8%

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
  2. Add Preprocessing
  3. Final simplification99.8%

    \[\leadsto x + z \cdot \left(\left(y - x\right) \cdot 6\right) \]
  4. Add Preprocessing

Alternative 10: 36.1% accurate, 9.0× speedup?

\[\begin{array}{l} \\ x \end{array} \]
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
	return x;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x
end function
public static double code(double x, double y, double z) {
	return x;
}
def code(x, y, z):
	return x
function code(x, y, z)
	return x
end
function tmp = code(x, y, z)
	tmp = x;
end
code[x_, y_, z_] := x
\begin{array}{l}

\\
x
\end{array}
Derivation
  1. Initial program 99.8%

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
  2. Add Preprocessing
  3. Taylor expanded in z around 0 35.3%

    \[\leadsto \color{blue}{x} \]
  4. Final simplification35.3%

    \[\leadsto x \]
  5. Add Preprocessing

Developer target: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x - \left(6 \cdot z\right) \cdot \left(x - y\right) \end{array} \]
(FPCore (x y z) :precision binary64 (- x (* (* 6.0 z) (- x y))))
double code(double x, double y, double z) {
	return x - ((6.0 * z) * (x - y));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x - ((6.0d0 * z) * (x - y))
end function
public static double code(double x, double y, double z) {
	return x - ((6.0 * z) * (x - y));
}
def code(x, y, z):
	return x - ((6.0 * z) * (x - y))
function code(x, y, z)
	return Float64(x - Float64(Float64(6.0 * z) * Float64(x - y)))
end
function tmp = code(x, y, z)
	tmp = x - ((6.0 * z) * (x - y));
end
code[x_, y_, z_] := N[(x - N[(N[(6.0 * z), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x - \left(6 \cdot z\right) \cdot \left(x - y\right)
\end{array}

Reproduce

?
herbie shell --seed 2024020 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
  :precision binary64

  :herbie-target
  (- x (* (* 6.0 z) (- x y)))

  (+ x (* (* (- y x) 6.0) z)))