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

Percentage Accurate: 99.5% → 99.7%
Time: 11.6s
Alternatives: 12
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * ((2.0 / 3.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) * ((2.0d0 / 3.0d0) - z))
end function
public static double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
def code(x, y, z):
	return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
function code(x, y, z)
	return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z)))
end
function tmp = code(x, y, z)
	tmp = x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\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 12 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.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * ((2.0 / 3.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) * ((2.0d0 / 3.0d0) - z))
end function
public static double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
def code(x, y, z):
	return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
function code(x, y, z)
	return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z)))
end
function tmp = code(x, y, z)
	tmp = x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma (- y x) (fma z -6.0 4.0) x))
double code(double x, double y, double z) {
	return fma((y - x), fma(z, -6.0, 4.0), x);
}
function code(x, y, z)
	return fma(Float64(y - x), fma(z, -6.0, 4.0), x)
end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(z * -6.0 + 4.0), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right)
\end{array}
Derivation
  1. Initial program 99.6%

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Step-by-step derivation
    1. +-commutative99.6%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
    4. sub-neg99.8%

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

      \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\left(-z\right) + \frac{2}{3}\right)}, x\right) \]
    6. distribute-lft-in99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{6 \cdot \left(-z\right) + 6 \cdot \frac{2}{3}}, x\right) \]
    7. distribute-rgt-neg-out99.8%

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

      \[\leadsto \mathsf{fma}\left(y - x, \left(-\color{blue}{z \cdot 6}\right) + 6 \cdot \frac{2}{3}, x\right) \]
    9. distribute-rgt-neg-in99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{z \cdot \left(-6\right)} + 6 \cdot \frac{2}{3}, x\right) \]
    10. fma-define99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\mathsf{fma}\left(z, -6, 6 \cdot \frac{2}{3}\right)}, x\right) \]
    11. metadata-eval99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, \color{blue}{-6}, 6 \cdot \frac{2}{3}\right), x\right) \]
    12. metadata-eval99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 6 \cdot \color{blue}{0.6666666666666666}\right), x\right) \]
    13. metadata-eval99.8%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 99.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right) \end{array} \]
(FPCore (x y z) :precision binary64 (fma (- y x) (+ 4.0 (* z -6.0)) x))
double code(double x, double y, double z) {
	return fma((y - x), (4.0 + (z * -6.0)), x);
}
function code(x, y, z)
	return fma(Float64(y - x), Float64(4.0 + Float64(z * -6.0)), x)
end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)
\end{array}
Derivation
  1. Initial program 99.6%

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Step-by-step derivation
    1. +-commutative99.6%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
    4. sub-neg99.8%

      \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
    5. distribute-rgt-in99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
    6. metadata-eval99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
    7. metadata-eval99.8%

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
    8. distribute-lft-neg-out99.8%

      \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
    9. distribute-rgt-neg-in99.8%

      \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
    10. metadata-eval99.8%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4 + z \cdot -6, x\right)} \]
  4. Add Preprocessing
  5. Add Preprocessing

Alternative 3: 51.7% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(z \cdot -6\right)\\ t_1 := x \cdot \left(z \cdot 6\right)\\ \mathbf{if}\;z \leq -2.45 \cdot 10^{+262}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+200}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -2.3 \cdot 10^{+168}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{+116}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{+53}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{+18}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -0.67:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{-194}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{-288}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.68:\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (* z -6.0))) (t_1 (* x (* z 6.0))))
   (if (<= z -2.45e+262)
     t_0
     (if (<= z -3.5e+200)
       t_1
       (if (<= z -2.3e+168)
         t_0
         (if (<= z -2.2e+116)
           t_1
           (if (<= z -1.15e+53)
             t_0
             (if (<= z -9.5e+18)
               t_1
               (if (<= z -0.67)
                 t_0
                 (if (<= z -1.3e-194)
                   (* y 4.0)
                   (if (<= z -4.6e-288)
                     (* x -3.0)
                     (if (<= z 0.68) (* y 4.0) t_0))))))))))))
double code(double x, double y, double z) {
	double t_0 = y * (z * -6.0);
	double t_1 = x * (z * 6.0);
	double tmp;
	if (z <= -2.45e+262) {
		tmp = t_0;
	} else if (z <= -3.5e+200) {
		tmp = t_1;
	} else if (z <= -2.3e+168) {
		tmp = t_0;
	} else if (z <= -2.2e+116) {
		tmp = t_1;
	} else if (z <= -1.15e+53) {
		tmp = t_0;
	} else if (z <= -9.5e+18) {
		tmp = t_1;
	} else if (z <= -0.67) {
		tmp = t_0;
	} else if (z <= -1.3e-194) {
		tmp = y * 4.0;
	} else if (z <= -4.6e-288) {
		tmp = x * -3.0;
	} else if (z <= 0.68) {
		tmp = y * 4.0;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = y * (z * (-6.0d0))
    t_1 = x * (z * 6.0d0)
    if (z <= (-2.45d+262)) then
        tmp = t_0
    else if (z <= (-3.5d+200)) then
        tmp = t_1
    else if (z <= (-2.3d+168)) then
        tmp = t_0
    else if (z <= (-2.2d+116)) then
        tmp = t_1
    else if (z <= (-1.15d+53)) then
        tmp = t_0
    else if (z <= (-9.5d+18)) then
        tmp = t_1
    else if (z <= (-0.67d0)) then
        tmp = t_0
    else if (z <= (-1.3d-194)) then
        tmp = y * 4.0d0
    else if (z <= (-4.6d-288)) then
        tmp = x * (-3.0d0)
    else if (z <= 0.68d0) then
        tmp = y * 4.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (z * -6.0);
	double t_1 = x * (z * 6.0);
	double tmp;
	if (z <= -2.45e+262) {
		tmp = t_0;
	} else if (z <= -3.5e+200) {
		tmp = t_1;
	} else if (z <= -2.3e+168) {
		tmp = t_0;
	} else if (z <= -2.2e+116) {
		tmp = t_1;
	} else if (z <= -1.15e+53) {
		tmp = t_0;
	} else if (z <= -9.5e+18) {
		tmp = t_1;
	} else if (z <= -0.67) {
		tmp = t_0;
	} else if (z <= -1.3e-194) {
		tmp = y * 4.0;
	} else if (z <= -4.6e-288) {
		tmp = x * -3.0;
	} else if (z <= 0.68) {
		tmp = y * 4.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (z * -6.0)
	t_1 = x * (z * 6.0)
	tmp = 0
	if z <= -2.45e+262:
		tmp = t_0
	elif z <= -3.5e+200:
		tmp = t_1
	elif z <= -2.3e+168:
		tmp = t_0
	elif z <= -2.2e+116:
		tmp = t_1
	elif z <= -1.15e+53:
		tmp = t_0
	elif z <= -9.5e+18:
		tmp = t_1
	elif z <= -0.67:
		tmp = t_0
	elif z <= -1.3e-194:
		tmp = y * 4.0
	elif z <= -4.6e-288:
		tmp = x * -3.0
	elif z <= 0.68:
		tmp = y * 4.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(z * -6.0))
	t_1 = Float64(x * Float64(z * 6.0))
	tmp = 0.0
	if (z <= -2.45e+262)
		tmp = t_0;
	elseif (z <= -3.5e+200)
		tmp = t_1;
	elseif (z <= -2.3e+168)
		tmp = t_0;
	elseif (z <= -2.2e+116)
		tmp = t_1;
	elseif (z <= -1.15e+53)
		tmp = t_0;
	elseif (z <= -9.5e+18)
		tmp = t_1;
	elseif (z <= -0.67)
		tmp = t_0;
	elseif (z <= -1.3e-194)
		tmp = Float64(y * 4.0);
	elseif (z <= -4.6e-288)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.68)
		tmp = Float64(y * 4.0);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (z * -6.0);
	t_1 = x * (z * 6.0);
	tmp = 0.0;
	if (z <= -2.45e+262)
		tmp = t_0;
	elseif (z <= -3.5e+200)
		tmp = t_1;
	elseif (z <= -2.3e+168)
		tmp = t_0;
	elseif (z <= -2.2e+116)
		tmp = t_1;
	elseif (z <= -1.15e+53)
		tmp = t_0;
	elseif (z <= -9.5e+18)
		tmp = t_1;
	elseif (z <= -0.67)
		tmp = t_0;
	elseif (z <= -1.3e-194)
		tmp = y * 4.0;
	elseif (z <= -4.6e-288)
		tmp = x * -3.0;
	elseif (z <= 0.68)
		tmp = y * 4.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.45e+262], t$95$0, If[LessEqual[z, -3.5e+200], t$95$1, If[LessEqual[z, -2.3e+168], t$95$0, If[LessEqual[z, -2.2e+116], t$95$1, If[LessEqual[z, -1.15e+53], t$95$0, If[LessEqual[z, -9.5e+18], t$95$1, If[LessEqual[z, -0.67], t$95$0, If[LessEqual[z, -1.3e-194], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -4.6e-288], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.68], N[(y * 4.0), $MachinePrecision], t$95$0]]]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \left(z \cdot -6\right)\\
t_1 := x \cdot \left(z \cdot 6\right)\\
\mathbf{if}\;z \leq -2.45 \cdot 10^{+262}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq -3.5 \cdot 10^{+200}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq -2.3 \cdot 10^{+168}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq -2.2 \cdot 10^{+116}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq -1.15 \cdot 10^{+53}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq -9.5 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq -0.67:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq -1.3 \cdot 10^{-194}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq -4.6 \cdot 10^{-288}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq 0.68:\\
\;\;\;\;y \cdot 4\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -2.4499999999999999e262 or -3.50000000000000006e200 < z < -2.2999999999999999e168 or -2.2e116 < z < -1.1500000000000001e53 or -9.5e18 < z < -0.67000000000000004 or 0.680000000000000049 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.8%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.7%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.7%

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

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

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

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

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

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

    if -2.4499999999999999e262 < z < -3.50000000000000006e200 or -2.2999999999999999e168 < z < -2.2e116 or -1.1500000000000001e53 < z < -9.5e18

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.7%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 77.9%

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg77.9%

        \[\leadsto x \cdot \left(1 + -6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      2. distribute-rgt-in77.9%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)}\right) \]
      3. metadata-eval77.9%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right)\right) \]
      4. distribute-lft-neg-in77.9%

        \[\leadsto x \cdot \left(1 + \left(-4 + \color{blue}{\left(-z \cdot -6\right)}\right)\right) \]
      5. associate-+r+77.9%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-z \cdot -6\right)\right)} \]
      6. metadata-eval77.9%

        \[\leadsto x \cdot \left(\color{blue}{-3} + \left(-z \cdot -6\right)\right) \]
      7. distribute-rgt-neg-in77.9%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot 6\right)} \cdot z \]
      3. associate-*r*77.9%

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

        \[\leadsto x \cdot \color{blue}{\left(z \cdot 6\right)} \]
    10. Simplified77.9%

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

    if -0.67000000000000004 < z < -1.30000000000000001e-194 or -4.6e-288 < z < 0.680000000000000049

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.4%

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) + x} \]
      2. associate-*l*99.9%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.9%

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

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

      \[\leadsto y \cdot \color{blue}{4} \]

    if -1.30000000000000001e-194 < z < -4.6e-288

    1. Initial program 99.3%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.3%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 67.0%

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg67.0%

        \[\leadsto x \cdot \left(1 + -6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      2. distribute-rgt-in67.0%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)}\right) \]
      3. metadata-eval67.0%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right)\right) \]
      4. distribute-lft-neg-in67.0%

        \[\leadsto x \cdot \left(1 + \left(-4 + \color{blue}{\left(-z \cdot -6\right)}\right)\right) \]
      5. associate-+r+67.0%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-z \cdot -6\right)\right)} \]
      6. metadata-eval67.0%

        \[\leadsto x \cdot \left(\color{blue}{-3} + \left(-z \cdot -6\right)\right) \]
      7. distribute-rgt-neg-in67.0%

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

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

      \[\leadsto \color{blue}{x \cdot \left(-3 + z \cdot 6\right)} \]
    8. Taylor expanded in z around 0 67.0%

      \[\leadsto \color{blue}{-3 \cdot x} \]
    9. Step-by-step derivation
      1. *-commutative67.0%

        \[\leadsto \color{blue}{x \cdot -3} \]
    10. Simplified67.0%

      \[\leadsto \color{blue}{x \cdot -3} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 4: 49.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{+15}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -6 \cdot 10^{-153}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{-180}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-195}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.62 \cdot 10^{-286}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.68:\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.4e+15)
   (* x (* z 6.0))
   (if (<= z -6e-153)
     (* y 4.0)
     (if (<= z -1.15e-180)
       (* x -3.0)
       (if (<= z -3.1e-195)
         (* y 4.0)
         (if (<= z -1.62e-286)
           (* x -3.0)
           (if (<= z 0.68) (* y 4.0) (* 6.0 (* x z)))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.4e+15) {
		tmp = x * (z * 6.0);
	} else if (z <= -6e-153) {
		tmp = y * 4.0;
	} else if (z <= -1.15e-180) {
		tmp = x * -3.0;
	} else if (z <= -3.1e-195) {
		tmp = y * 4.0;
	} else if (z <= -1.62e-286) {
		tmp = x * -3.0;
	} else if (z <= 0.68) {
		tmp = y * 4.0;
	} else {
		tmp = 6.0 * (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 <= (-1.4d+15)) then
        tmp = x * (z * 6.0d0)
    else if (z <= (-6d-153)) then
        tmp = y * 4.0d0
    else if (z <= (-1.15d-180)) then
        tmp = x * (-3.0d0)
    else if (z <= (-3.1d-195)) then
        tmp = y * 4.0d0
    else if (z <= (-1.62d-286)) then
        tmp = x * (-3.0d0)
    else if (z <= 0.68d0) then
        tmp = y * 4.0d0
    else
        tmp = 6.0d0 * (x * z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -1.4e+15) {
		tmp = x * (z * 6.0);
	} else if (z <= -6e-153) {
		tmp = y * 4.0;
	} else if (z <= -1.15e-180) {
		tmp = x * -3.0;
	} else if (z <= -3.1e-195) {
		tmp = y * 4.0;
	} else if (z <= -1.62e-286) {
		tmp = x * -3.0;
	} else if (z <= 0.68) {
		tmp = y * 4.0;
	} else {
		tmp = 6.0 * (x * z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -1.4e+15:
		tmp = x * (z * 6.0)
	elif z <= -6e-153:
		tmp = y * 4.0
	elif z <= -1.15e-180:
		tmp = x * -3.0
	elif z <= -3.1e-195:
		tmp = y * 4.0
	elif z <= -1.62e-286:
		tmp = x * -3.0
	elif z <= 0.68:
		tmp = y * 4.0
	else:
		tmp = 6.0 * (x * z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -1.4e+15)
		tmp = Float64(x * Float64(z * 6.0));
	elseif (z <= -6e-153)
		tmp = Float64(y * 4.0);
	elseif (z <= -1.15e-180)
		tmp = Float64(x * -3.0);
	elseif (z <= -3.1e-195)
		tmp = Float64(y * 4.0);
	elseif (z <= -1.62e-286)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.68)
		tmp = Float64(y * 4.0);
	else
		tmp = Float64(6.0 * Float64(x * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -1.4e+15)
		tmp = x * (z * 6.0);
	elseif (z <= -6e-153)
		tmp = y * 4.0;
	elseif (z <= -1.15e-180)
		tmp = x * -3.0;
	elseif (z <= -3.1e-195)
		tmp = y * 4.0;
	elseif (z <= -1.62e-286)
		tmp = x * -3.0;
	elseif (z <= 0.68)
		tmp = y * 4.0;
	else
		tmp = 6.0 * (x * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -1.4e+15], N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -6e-153], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -1.15e-180], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -3.1e-195], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -1.62e-286], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.68], N[(y * 4.0), $MachinePrecision], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{+15}:\\
\;\;\;\;x \cdot \left(z \cdot 6\right)\\

\mathbf{elif}\;z \leq -6 \cdot 10^{-153}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq -1.15 \cdot 10^{-180}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -3.1 \cdot 10^{-195}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq -1.62 \cdot 10^{-286}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq 0.68:\\
\;\;\;\;y \cdot 4\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.4e15

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.8%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 50.1%

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg50.1%

        \[\leadsto x \cdot \left(1 + -6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      2. distribute-rgt-in50.1%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)}\right) \]
      3. metadata-eval50.1%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right)\right) \]
      4. distribute-lft-neg-in50.1%

        \[\leadsto x \cdot \left(1 + \left(-4 + \color{blue}{\left(-z \cdot -6\right)}\right)\right) \]
      5. associate-+r+50.1%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-z \cdot -6\right)\right)} \]
      6. metadata-eval50.1%

        \[\leadsto x \cdot \left(\color{blue}{-3} + \left(-z \cdot -6\right)\right) \]
      7. distribute-rgt-neg-in50.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot 6\right)} \cdot z \]
      3. associate-*r*50.1%

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

        \[\leadsto x \cdot \color{blue}{\left(z \cdot 6\right)} \]
    10. Simplified50.1%

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

    if -1.4e15 < z < -6e-153 or -1.14999999999999998e-180 < z < -3.10000000000000002e-195 or -1.6199999999999999e-286 < z < 0.680000000000000049

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.4%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.9%

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

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

      \[\leadsto y \cdot \color{blue}{4} \]

    if -6e-153 < z < -1.14999999999999998e-180 or -3.10000000000000002e-195 < z < -1.6199999999999999e-286

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.4%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 71.7%

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg71.7%

        \[\leadsto x \cdot \left(1 + -6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      2. distribute-rgt-in71.7%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)}\right) \]
      3. metadata-eval71.7%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right)\right) \]
      4. distribute-lft-neg-in71.7%

        \[\leadsto x \cdot \left(1 + \left(-4 + \color{blue}{\left(-z \cdot -6\right)}\right)\right) \]
      5. associate-+r+71.7%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-z \cdot -6\right)\right)} \]
      6. metadata-eval71.7%

        \[\leadsto x \cdot \left(\color{blue}{-3} + \left(-z \cdot -6\right)\right) \]
      7. distribute-rgt-neg-in71.7%

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

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

      \[\leadsto \color{blue}{x \cdot \left(-3 + z \cdot 6\right)} \]
    8. Taylor expanded in z around 0 71.7%

      \[\leadsto \color{blue}{-3 \cdot x} \]
    9. Step-by-step derivation
      1. *-commutative71.7%

        \[\leadsto \color{blue}{x \cdot -3} \]
    10. Simplified71.7%

      \[\leadsto \color{blue}{x \cdot -3} \]

    if 0.680000000000000049 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.8%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 51.3%

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg51.3%

        \[\leadsto x \cdot \left(1 + -6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      2. distribute-rgt-in51.3%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)}\right) \]
      3. metadata-eval51.3%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right)\right) \]
      4. distribute-lft-neg-in51.3%

        \[\leadsto x \cdot \left(1 + \left(-4 + \color{blue}{\left(-z \cdot -6\right)}\right)\right) \]
      5. associate-+r+51.3%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-z \cdot -6\right)\right)} \]
      6. metadata-eval51.3%

        \[\leadsto x \cdot \left(\color{blue}{-3} + \left(-z \cdot -6\right)\right) \]
      7. distribute-rgt-neg-in51.3%

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

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

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

      \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 5: 49.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -1.4 \cdot 10^{+15}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-152}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{-180}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -8 \cdot 10^{-195}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.6 \cdot 10^{-288}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.65:\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* x z))))
   (if (<= z -1.4e+15)
     t_0
     (if (<= z -2e-152)
       (* y 4.0)
       (if (<= z -1.15e-180)
         (* x -3.0)
         (if (<= z -8e-195)
           (* y 4.0)
           (if (<= z -1.6e-288)
             (* x -3.0)
             (if (<= z 0.65) (* y 4.0) t_0))))))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (x * z);
	double tmp;
	if (z <= -1.4e+15) {
		tmp = t_0;
	} else if (z <= -2e-152) {
		tmp = y * 4.0;
	} else if (z <= -1.15e-180) {
		tmp = x * -3.0;
	} else if (z <= -8e-195) {
		tmp = y * 4.0;
	} else if (z <= -1.6e-288) {
		tmp = x * -3.0;
	} else if (z <= 0.65) {
		tmp = y * 4.0;
	} 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 * (x * z)
    if (z <= (-1.4d+15)) then
        tmp = t_0
    else if (z <= (-2d-152)) then
        tmp = y * 4.0d0
    else if (z <= (-1.15d-180)) then
        tmp = x * (-3.0d0)
    else if (z <= (-8d-195)) then
        tmp = y * 4.0d0
    else if (z <= (-1.6d-288)) then
        tmp = x * (-3.0d0)
    else if (z <= 0.65d0) then
        tmp = y * 4.0d0
    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 * (x * z);
	double tmp;
	if (z <= -1.4e+15) {
		tmp = t_0;
	} else if (z <= -2e-152) {
		tmp = y * 4.0;
	} else if (z <= -1.15e-180) {
		tmp = x * -3.0;
	} else if (z <= -8e-195) {
		tmp = y * 4.0;
	} else if (z <= -1.6e-288) {
		tmp = x * -3.0;
	} else if (z <= 0.65) {
		tmp = y * 4.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 6.0 * (x * z)
	tmp = 0
	if z <= -1.4e+15:
		tmp = t_0
	elif z <= -2e-152:
		tmp = y * 4.0
	elif z <= -1.15e-180:
		tmp = x * -3.0
	elif z <= -8e-195:
		tmp = y * 4.0
	elif z <= -1.6e-288:
		tmp = x * -3.0
	elif z <= 0.65:
		tmp = y * 4.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(6.0 * Float64(x * z))
	tmp = 0.0
	if (z <= -1.4e+15)
		tmp = t_0;
	elseif (z <= -2e-152)
		tmp = Float64(y * 4.0);
	elseif (z <= -1.15e-180)
		tmp = Float64(x * -3.0);
	elseif (z <= -8e-195)
		tmp = Float64(y * 4.0);
	elseif (z <= -1.6e-288)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.65)
		tmp = Float64(y * 4.0);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 6.0 * (x * z);
	tmp = 0.0;
	if (z <= -1.4e+15)
		tmp = t_0;
	elseif (z <= -2e-152)
		tmp = y * 4.0;
	elseif (z <= -1.15e-180)
		tmp = x * -3.0;
	elseif (z <= -8e-195)
		tmp = y * 4.0;
	elseif (z <= -1.6e-288)
		tmp = x * -3.0;
	elseif (z <= 0.65)
		tmp = y * 4.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.4e+15], t$95$0, If[LessEqual[z, -2e-152], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -1.15e-180], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -8e-195], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -1.6e-288], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.65], N[(y * 4.0), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;z \leq -1.4 \cdot 10^{+15}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq -2 \cdot 10^{-152}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq -1.15 \cdot 10^{-180}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -8 \cdot 10^{-195}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq -1.6 \cdot 10^{-288}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq 0.65:\\
\;\;\;\;y \cdot 4\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.4e15 or 0.650000000000000022 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.8%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 50.7%

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg50.7%

        \[\leadsto x \cdot \left(1 + -6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      2. distribute-rgt-in50.7%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)}\right) \]
      3. metadata-eval50.7%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right)\right) \]
      4. distribute-lft-neg-in50.7%

        \[\leadsto x \cdot \left(1 + \left(-4 + \color{blue}{\left(-z \cdot -6\right)}\right)\right) \]
      5. associate-+r+50.7%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-z \cdot -6\right)\right)} \]
      6. metadata-eval50.7%

        \[\leadsto x \cdot \left(\color{blue}{-3} + \left(-z \cdot -6\right)\right) \]
      7. distribute-rgt-neg-in50.7%

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

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

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

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

    if -1.4e15 < z < -2.00000000000000013e-152 or -1.14999999999999998e-180 < z < -8.0000000000000007e-195 or -1.6e-288 < z < 0.650000000000000022

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.4%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.9%

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

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

      \[\leadsto y \cdot \color{blue}{4} \]

    if -2.00000000000000013e-152 < z < -1.14999999999999998e-180 or -8.0000000000000007e-195 < z < -1.6e-288

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.4%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 71.7%

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg71.7%

        \[\leadsto x \cdot \left(1 + -6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      2. distribute-rgt-in71.7%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)}\right) \]
      3. metadata-eval71.7%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right)\right) \]
      4. distribute-lft-neg-in71.7%

        \[\leadsto x \cdot \left(1 + \left(-4 + \color{blue}{\left(-z \cdot -6\right)}\right)\right) \]
      5. associate-+r+71.7%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-z \cdot -6\right)\right)} \]
      6. metadata-eval71.7%

        \[\leadsto x \cdot \left(\color{blue}{-3} + \left(-z \cdot -6\right)\right) \]
      7. distribute-rgt-neg-in71.7%

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

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

      \[\leadsto \color{blue}{x \cdot \left(-3 + z \cdot 6\right)} \]
    8. Taylor expanded in z around 0 71.7%

      \[\leadsto \color{blue}{-3 \cdot x} \]
    9. Step-by-step derivation
      1. *-commutative71.7%

        \[\leadsto \color{blue}{x \cdot -3} \]
    10. Simplified71.7%

      \[\leadsto \color{blue}{x \cdot -3} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 55.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(z \cdot -6\right)\\ \mathbf{if}\;y \leq -5.1 \cdot 10^{+227}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{+213}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq -5.9 \cdot 10^{-49}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{+80}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (* z -6.0))))
   (if (<= y -5.1e+227)
     (* y 4.0)
     (if (<= y -8.5e+213)
       t_0
       (if (<= y -5.9e-49)
         (* y 4.0)
         (if (<= y 2.3e+80) (* x (+ -3.0 (* z 6.0))) t_0))))))
double code(double x, double y, double z) {
	double t_0 = y * (z * -6.0);
	double tmp;
	if (y <= -5.1e+227) {
		tmp = y * 4.0;
	} else if (y <= -8.5e+213) {
		tmp = t_0;
	} else if (y <= -5.9e-49) {
		tmp = y * 4.0;
	} else if (y <= 2.3e+80) {
		tmp = x * (-3.0 + (z * 6.0));
	} 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 = y * (z * (-6.0d0))
    if (y <= (-5.1d+227)) then
        tmp = y * 4.0d0
    else if (y <= (-8.5d+213)) then
        tmp = t_0
    else if (y <= (-5.9d-49)) then
        tmp = y * 4.0d0
    else if (y <= 2.3d+80) then
        tmp = x * ((-3.0d0) + (z * 6.0d0))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (z * -6.0);
	double tmp;
	if (y <= -5.1e+227) {
		tmp = y * 4.0;
	} else if (y <= -8.5e+213) {
		tmp = t_0;
	} else if (y <= -5.9e-49) {
		tmp = y * 4.0;
	} else if (y <= 2.3e+80) {
		tmp = x * (-3.0 + (z * 6.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (z * -6.0)
	tmp = 0
	if y <= -5.1e+227:
		tmp = y * 4.0
	elif y <= -8.5e+213:
		tmp = t_0
	elif y <= -5.9e-49:
		tmp = y * 4.0
	elif y <= 2.3e+80:
		tmp = x * (-3.0 + (z * 6.0))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(z * -6.0))
	tmp = 0.0
	if (y <= -5.1e+227)
		tmp = Float64(y * 4.0);
	elseif (y <= -8.5e+213)
		tmp = t_0;
	elseif (y <= -5.9e-49)
		tmp = Float64(y * 4.0);
	elseif (y <= 2.3e+80)
		tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (z * -6.0);
	tmp = 0.0;
	if (y <= -5.1e+227)
		tmp = y * 4.0;
	elseif (y <= -8.5e+213)
		tmp = t_0;
	elseif (y <= -5.9e-49)
		tmp = y * 4.0;
	elseif (y <= 2.3e+80)
		tmp = x * (-3.0 + (z * 6.0));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.1e+227], N[(y * 4.0), $MachinePrecision], If[LessEqual[y, -8.5e+213], t$95$0, If[LessEqual[y, -5.9e-49], N[(y * 4.0), $MachinePrecision], If[LessEqual[y, 2.3e+80], N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -8.5 \cdot 10^{+213}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;y \leq -5.9 \cdot 10^{-49}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;y \leq 2.3 \cdot 10^{+80}:\\
\;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -5.1000000000000001e227 or -8.4999999999999995e213 < y < -5.90000000000000037e-49

    1. Initial program 99.6%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.6%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + z \cdot \color{blue}{-6}, x\right) \]
    3. Simplified99.9%

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

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

      \[\leadsto y \cdot \color{blue}{4} \]

    if -5.1000000000000001e227 < y < -8.4999999999999995e213 or 2.30000000000000004e80 < y

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.8%

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

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

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

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

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

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

    if -5.90000000000000037e-49 < y < 2.30000000000000004e80

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.5%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 73.9%

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg73.9%

        \[\leadsto x \cdot \left(1 + -6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      2. distribute-rgt-in73.9%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)}\right) \]
      3. metadata-eval73.9%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right)\right) \]
      4. distribute-lft-neg-in73.9%

        \[\leadsto x \cdot \left(1 + \left(-4 + \color{blue}{\left(-z \cdot -6\right)}\right)\right) \]
      5. associate-+r+73.9%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-z \cdot -6\right)\right)} \]
      6. metadata-eval73.9%

        \[\leadsto x \cdot \left(\color{blue}{-3} + \left(-z \cdot -6\right)\right) \]
      7. distribute-rgt-neg-in73.9%

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

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

      \[\leadsto \color{blue}{x \cdot \left(-3 + z \cdot 6\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 97.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.67 \lor \neg \left(z \leq 0.68\right):\\ \;\;\;\;x + -6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot -3 + y \cdot 4\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= z -0.67) (not (<= z 0.68)))
   (+ x (* -6.0 (* (- y x) z)))
   (+ (* x -3.0) (* y 4.0))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -0.67) || !(z <= 0.68)) {
		tmp = x + (-6.0 * ((y - x) * z));
	} else {
		tmp = (x * -3.0) + (y * 4.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) :: tmp
    if ((z <= (-0.67d0)) .or. (.not. (z <= 0.68d0))) then
        tmp = x + ((-6.0d0) * ((y - x) * z))
    else
        tmp = (x * (-3.0d0)) + (y * 4.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((z <= -0.67) || !(z <= 0.68)) {
		tmp = x + (-6.0 * ((y - x) * z));
	} else {
		tmp = (x * -3.0) + (y * 4.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -0.67) or not (z <= 0.68):
		tmp = x + (-6.0 * ((y - x) * z))
	else:
		tmp = (x * -3.0) + (y * 4.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((z <= -0.67) || !(z <= 0.68))
		tmp = Float64(x + Float64(-6.0 * Float64(Float64(y - x) * z)));
	else
		tmp = Float64(Float64(x * -3.0) + Float64(y * 4.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((z <= -0.67) || ~((z <= 0.68)))
		tmp = x + (-6.0 * ((y - x) * z));
	else
		tmp = (x * -3.0) + (y * 4.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[z, -0.67], N[Not[LessEqual[z, 0.68]], $MachinePrecision]], N[(x + N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * -3.0), $MachinePrecision] + N[(y * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;x \cdot -3 + y \cdot 4\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.67000000000000004 or 0.680000000000000049 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.8%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 96.9%

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

    if -0.67000000000000004 < z < 0.680000000000000049

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.4%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 99.4%

      \[\leadsto x + \color{blue}{\left(-6 \cdot \left(x \cdot \left(0.6666666666666666 - z\right)\right) + 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\right)} \]
    6. Taylor expanded in z around 0 99.2%

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

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

      \[\leadsto x + \left(\color{blue}{x \cdot -4} + 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\right) \]
    9. Taylor expanded in z around 0 98.5%

      \[\leadsto \color{blue}{x + \left(-4 \cdot x + 4 \cdot y\right)} \]
    10. Step-by-step derivation
      1. associate-+r+98.5%

        \[\leadsto \color{blue}{\left(x + -4 \cdot x\right) + 4 \cdot y} \]
      2. distribute-rgt1-in98.5%

        \[\leadsto \color{blue}{\left(-4 + 1\right) \cdot x} + 4 \cdot y \]
      3. metadata-eval98.5%

        \[\leadsto \color{blue}{-3} \cdot x + 4 \cdot y \]
      4. *-commutative98.5%

        \[\leadsto \color{blue}{x \cdot -3} + 4 \cdot y \]
      5. *-commutative98.5%

        \[\leadsto x \cdot -3 + \color{blue}{y \cdot 4} \]
    11. Simplified98.5%

      \[\leadsto \color{blue}{x \cdot -3 + y \cdot 4} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.7%

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

Alternative 8: 97.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.67:\\ \;\;\;\;x + \left(y - x\right) \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq 0.64:\\ \;\;\;\;x \cdot -3 + y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;x + -6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -0.67)
   (+ x (* (- y x) (* z -6.0)))
   (if (<= z 0.64) (+ (* x -3.0) (* y 4.0)) (+ x (* -6.0 (* (- y x) z))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -0.67) {
		tmp = x + ((y - x) * (z * -6.0));
	} else if (z <= 0.64) {
		tmp = (x * -3.0) + (y * 4.0);
	} else {
		tmp = x + (-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 <= (-0.67d0)) then
        tmp = x + ((y - x) * (z * (-6.0d0)))
    else if (z <= 0.64d0) then
        tmp = (x * (-3.0d0)) + (y * 4.0d0)
    else
        tmp = x + ((-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 <= -0.67) {
		tmp = x + ((y - x) * (z * -6.0));
	} else if (z <= 0.64) {
		tmp = (x * -3.0) + (y * 4.0);
	} else {
		tmp = x + (-6.0 * ((y - x) * z));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -0.67:
		tmp = x + ((y - x) * (z * -6.0))
	elif z <= 0.64:
		tmp = (x * -3.0) + (y * 4.0)
	else:
		tmp = x + (-6.0 * ((y - x) * z))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -0.67)
		tmp = Float64(x + Float64(Float64(y - x) * Float64(z * -6.0)));
	elseif (z <= 0.64)
		tmp = Float64(Float64(x * -3.0) + Float64(y * 4.0));
	else
		tmp = Float64(x + Float64(-6.0 * Float64(Float64(y - x) * z)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -0.67)
		tmp = x + ((y - x) * (z * -6.0));
	elseif (z <= 0.64)
		tmp = (x * -3.0) + (y * 4.0);
	else
		tmp = x + (-6.0 * ((y - x) * z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -0.67], N[(x + N[(N[(y - x), $MachinePrecision] * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.64], N[(N[(x * -3.0), $MachinePrecision] + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], N[(x + N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.67:\\
\;\;\;\;x + \left(y - x\right) \cdot \left(z \cdot -6\right)\\

\mathbf{elif}\;z \leq 0.64:\\
\;\;\;\;x \cdot -3 + y \cdot 4\\

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


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

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.8%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 95.8%

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

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

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

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

    if -0.67000000000000004 < z < 0.640000000000000013

    1. Initial program 99.4%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.4%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 99.4%

      \[\leadsto x + \color{blue}{\left(-6 \cdot \left(x \cdot \left(0.6666666666666666 - z\right)\right) + 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\right)} \]
    6. Taylor expanded in z around 0 99.2%

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

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

      \[\leadsto x + \left(\color{blue}{x \cdot -4} + 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\right) \]
    9. Taylor expanded in z around 0 98.5%

      \[\leadsto \color{blue}{x + \left(-4 \cdot x + 4 \cdot y\right)} \]
    10. Step-by-step derivation
      1. associate-+r+98.5%

        \[\leadsto \color{blue}{\left(x + -4 \cdot x\right) + 4 \cdot y} \]
      2. distribute-rgt1-in98.5%

        \[\leadsto \color{blue}{\left(-4 + 1\right) \cdot x} + 4 \cdot y \]
      3. metadata-eval98.5%

        \[\leadsto \color{blue}{-3} \cdot x + 4 \cdot y \]
      4. *-commutative98.5%

        \[\leadsto \color{blue}{x \cdot -3} + 4 \cdot y \]
      5. *-commutative98.5%

        \[\leadsto x \cdot -3 + \color{blue}{y \cdot 4} \]
    11. Simplified98.5%

      \[\leadsto \color{blue}{x \cdot -3 + y \cdot 4} \]

    if 0.640000000000000013 < z

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.8%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in z around inf 98.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.67:\\ \;\;\;\;x + \left(y - x\right) \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq 0.64:\\ \;\;\;\;x \cdot -3 + y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;x + -6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 74.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{-52} \lor \neg \left(y \leq 1.02 \cdot 10^{+80}\right):\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -8.5e-52) (not (<= y 1.02e+80)))
   (* y (+ 4.0 (* z -6.0)))
   (* x (+ -3.0 (* z 6.0)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -8.5e-52) || !(y <= 1.02e+80)) {
		tmp = y * (4.0 + (z * -6.0));
	} else {
		tmp = x * (-3.0 + (z * 6.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) :: tmp
    if ((y <= (-8.5d-52)) .or. (.not. (y <= 1.02d+80))) then
        tmp = y * (4.0d0 + (z * (-6.0d0)))
    else
        tmp = x * ((-3.0d0) + (z * 6.0d0))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -8.5e-52) || !(y <= 1.02e+80)) {
		tmp = y * (4.0 + (z * -6.0));
	} else {
		tmp = x * (-3.0 + (z * 6.0));
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -8.5e-52) or not (y <= 1.02e+80):
		tmp = y * (4.0 + (z * -6.0))
	else:
		tmp = x * (-3.0 + (z * 6.0))
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -8.5e-52) || !(y <= 1.02e+80))
		tmp = Float64(y * Float64(4.0 + Float64(z * -6.0)));
	else
		tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -8.5e-52) || ~((y <= 1.02e+80)))
		tmp = y * (4.0 + (z * -6.0));
	else
		tmp = x * (-3.0 + (z * 6.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.5e-52], N[Not[LessEqual[y, 1.02e+80]], $MachinePrecision]], N[(y * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{-52} \lor \neg \left(y \leq 1.02 \cdot 10^{+80}\right):\\
\;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -8.50000000000000006e-52 or 1.02e80 < y

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.8%

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

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

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

    if -8.50000000000000006e-52 < y < 1.02e80

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.5%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 73.9%

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg73.9%

        \[\leadsto x \cdot \left(1 + -6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      2. distribute-rgt-in73.9%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)}\right) \]
      3. metadata-eval73.9%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right)\right) \]
      4. distribute-lft-neg-in73.9%

        \[\leadsto x \cdot \left(1 + \left(-4 + \color{blue}{\left(-z \cdot -6\right)}\right)\right) \]
      5. associate-+r+73.9%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-z \cdot -6\right)\right)} \]
      6. metadata-eval73.9%

        \[\leadsto x \cdot \left(\color{blue}{-3} + \left(-z \cdot -6\right)\right) \]
      7. distribute-rgt-neg-in73.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{-52} \lor \neg \left(y \leq 1.02 \cdot 10^{+80}\right):\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 37.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-55} \lor \neg \left(y \leq 5.3 \cdot 10^{+82}\right):\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;x \cdot -3\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -1.6e-55) (not (<= y 5.3e+82))) (* y 4.0) (* x -3.0)))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.6e-55) || !(y <= 5.3e+82)) {
		tmp = y * 4.0;
	} else {
		tmp = x * -3.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) :: tmp
    if ((y <= (-1.6d-55)) .or. (.not. (y <= 5.3d+82))) then
        tmp = y * 4.0d0
    else
        tmp = x * (-3.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.6e-55) || !(y <= 5.3e+82)) {
		tmp = y * 4.0;
	} else {
		tmp = x * -3.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (y <= -1.6e-55) or not (y <= 5.3e+82):
		tmp = y * 4.0
	else:
		tmp = x * -3.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if ((y <= -1.6e-55) || !(y <= 5.3e+82))
		tmp = Float64(y * 4.0);
	else
		tmp = Float64(x * -3.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -1.6e-55) || ~((y <= 5.3e+82)))
		tmp = y * 4.0;
	else
		tmp = x * -3.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.6e-55], N[Not[LessEqual[y, 5.3e+82]], $MachinePrecision]], N[(y * 4.0), $MachinePrecision], N[(x * -3.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.6 \cdot 10^{-55} \lor \neg \left(y \leq 5.3 \cdot 10^{+82}\right):\\
\;\;\;\;y \cdot 4\\

\mathbf{else}:\\
\;\;\;\;x \cdot -3\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.6000000000000001e-55 or 5.29999999999999977e82 < y

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. +-commutative99.7%

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)} \]
      4. sub-neg99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. distribute-rgt-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{2}{3} \cdot 6 + \left(-z\right) \cdot 6}, x\right) \]
      6. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{0.6666666666666666} \cdot 6 + \left(-z\right) \cdot 6, x\right) \]
      7. metadata-eval99.8%

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{4} + \left(-z\right) \cdot 6, x\right) \]
      8. distribute-lft-neg-out99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{\left(-z \cdot 6\right)}, x\right) \]
      9. distribute-rgt-neg-in99.8%

        \[\leadsto \mathsf{fma}\left(y - x, 4 + \color{blue}{z \cdot \left(-6\right)}, x\right) \]
      10. metadata-eval99.8%

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

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

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

      \[\leadsto y \cdot \color{blue}{4} \]

    if -1.6000000000000001e-55 < y < 5.29999999999999977e82

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Step-by-step derivation
      1. metadata-eval99.5%

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

      \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 73.3%

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
    6. Step-by-step derivation
      1. sub-neg73.3%

        \[\leadsto x \cdot \left(1 + -6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
      2. distribute-rgt-in73.3%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)}\right) \]
      3. metadata-eval73.3%

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right)\right) \]
      4. distribute-lft-neg-in73.3%

        \[\leadsto x \cdot \left(1 + \left(-4 + \color{blue}{\left(-z \cdot -6\right)}\right)\right) \]
      5. associate-+r+73.3%

        \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-z \cdot -6\right)\right)} \]
      6. metadata-eval73.3%

        \[\leadsto x \cdot \left(\color{blue}{-3} + \left(-z \cdot -6\right)\right) \]
      7. distribute-rgt-neg-in73.3%

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

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

      \[\leadsto \color{blue}{x \cdot \left(-3 + z \cdot 6\right)} \]
    8. Taylor expanded in z around 0 38.4%

      \[\leadsto \color{blue}{-3 \cdot x} \]
    9. Step-by-step derivation
      1. *-commutative38.4%

        \[\leadsto \color{blue}{x \cdot -3} \]
    10. Simplified38.4%

      \[\leadsto \color{blue}{x \cdot -3} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification43.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-55} \lor \neg \left(y \leq 5.3 \cdot 10^{+82}\right):\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;x \cdot -3\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 99.5% accurate, 1.2× speedup?

\[\begin{array}{l} \\ x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right) \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (* (* (- y x) 6.0) (- 0.6666666666666666 z))))
double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * (0.6666666666666666 - 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) * (0.6666666666666666d0 - z))
end function
public static double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * (0.6666666666666666 - z));
}
def code(x, y, z):
	return x + (((y - x) * 6.0) * (0.6666666666666666 - z))
function code(x, y, z)
	return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(0.6666666666666666 - z)))
end
function tmp = code(x, y, z)
	tmp = x + (((y - x) * 6.0) * (0.6666666666666666 - z));
end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Step-by-step derivation
    1. metadata-eval99.6%

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

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

Alternative 12: 25.4% accurate, 4.3× speedup?

\[\begin{array}{l} \\ x \cdot -3 \end{array} \]
(FPCore (x y z) :precision binary64 (* x -3.0))
double code(double x, double y, double z) {
	return x * -3.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 * (-3.0d0)
end function
public static double code(double x, double y, double z) {
	return x * -3.0;
}
def code(x, y, z):
	return x * -3.0
function code(x, y, z)
	return Float64(x * -3.0)
end
function tmp = code(x, y, z)
	tmp = x * -3.0;
end
code[x_, y_, z_] := N[(x * -3.0), $MachinePrecision]
\begin{array}{l}

\\
x \cdot -3
\end{array}
Derivation
  1. Initial program 99.6%

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Step-by-step derivation
    1. metadata-eval99.6%

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

    \[\leadsto \color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around inf 47.0%

    \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right)} \]
  6. Step-by-step derivation
    1. sub-neg47.0%

      \[\leadsto x \cdot \left(1 + -6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right) \]
    2. distribute-rgt-in47.0%

      \[\leadsto x \cdot \left(1 + \color{blue}{\left(0.6666666666666666 \cdot -6 + \left(-z\right) \cdot -6\right)}\right) \]
    3. metadata-eval47.0%

      \[\leadsto x \cdot \left(1 + \left(\color{blue}{-4} + \left(-z\right) \cdot -6\right)\right) \]
    4. distribute-lft-neg-in47.0%

      \[\leadsto x \cdot \left(1 + \left(-4 + \color{blue}{\left(-z \cdot -6\right)}\right)\right) \]
    5. associate-+r+47.0%

      \[\leadsto x \cdot \color{blue}{\left(\left(1 + -4\right) + \left(-z \cdot -6\right)\right)} \]
    6. metadata-eval47.0%

      \[\leadsto x \cdot \left(\color{blue}{-3} + \left(-z \cdot -6\right)\right) \]
    7. distribute-rgt-neg-in47.0%

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

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

    \[\leadsto \color{blue}{x \cdot \left(-3 + z \cdot 6\right)} \]
  8. Taylor expanded in z around 0 24.1%

    \[\leadsto \color{blue}{-3 \cdot x} \]
  9. Step-by-step derivation
    1. *-commutative24.1%

      \[\leadsto \color{blue}{x \cdot -3} \]
  10. Simplified24.1%

    \[\leadsto \color{blue}{x \cdot -3} \]
  11. Add Preprocessing

Reproduce

?
herbie shell --seed 2024108 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D"
  :precision binary64
  (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))