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

Percentage Accurate: 99.5% → 99.8%
Time: 10.6s
Alternatives: 13
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 13 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.8% 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.5%

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

      \[\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-def99.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-def99.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. Final simplification99.8%

    \[\leadsto \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right) \]

Alternative 2: 99.7% accurate, 0.1× speedup?

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

\\
\mathsf{fma}\left(y - x, 6 \cdot \left(0.6666666666666666 - z\right), x\right)
\end{array}
Derivation
  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. +-commutative99.5%

      \[\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-def99.8%

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

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

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

    \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \left(0.6666666666666666 - z\right), x\right) \]

Alternative 3: 50.2% accurate, 0.4× 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.5 \cdot 10^{+186}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{-6}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-90}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-239}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -6.6 \cdot 10^{-267}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-303}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-113}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.019:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+124}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+165}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+225}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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.5e+186)
     t_0
     (if (<= z -3.5e-6)
       t_1
       (if (<= z -9.5e-90)
         (* y 4.0)
         (if (<= z -3.8e-239)
           (* x -3.0)
           (if (<= z -6.6e-267)
             (* y 4.0)
             (if (<= z 2.7e-303)
               (* x -3.0)
               (if (<= z 3.8e-113)
                 (* y 4.0)
                 (if (<= z 0.019)
                   (* x -3.0)
                   (if (<= z 1.2e+100)
                     t_1
                     (if (<= z 6.5e+124)
                       t_0
                       (if (<= z 6.2e+165)
                         (* 6.0 (* x z))
                         (if (<= z 6.5e+225) t_0 t_1))))))))))))))
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.5e+186) {
		tmp = t_0;
	} else if (z <= -3.5e-6) {
		tmp = t_1;
	} else if (z <= -9.5e-90) {
		tmp = y * 4.0;
	} else if (z <= -3.8e-239) {
		tmp = x * -3.0;
	} else if (z <= -6.6e-267) {
		tmp = y * 4.0;
	} else if (z <= 2.7e-303) {
		tmp = x * -3.0;
	} else if (z <= 3.8e-113) {
		tmp = y * 4.0;
	} else if (z <= 0.019) {
		tmp = x * -3.0;
	} else if (z <= 1.2e+100) {
		tmp = t_1;
	} else if (z <= 6.5e+124) {
		tmp = t_0;
	} else if (z <= 6.2e+165) {
		tmp = 6.0 * (x * z);
	} else if (z <= 6.5e+225) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	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.5d+186)) then
        tmp = t_0
    else if (z <= (-3.5d-6)) then
        tmp = t_1
    else if (z <= (-9.5d-90)) then
        tmp = y * 4.0d0
    else if (z <= (-3.8d-239)) then
        tmp = x * (-3.0d0)
    else if (z <= (-6.6d-267)) then
        tmp = y * 4.0d0
    else if (z <= 2.7d-303) then
        tmp = x * (-3.0d0)
    else if (z <= 3.8d-113) then
        tmp = y * 4.0d0
    else if (z <= 0.019d0) then
        tmp = x * (-3.0d0)
    else if (z <= 1.2d+100) then
        tmp = t_1
    else if (z <= 6.5d+124) then
        tmp = t_0
    else if (z <= 6.2d+165) then
        tmp = 6.0d0 * (x * z)
    else if (z <= 6.5d+225) then
        tmp = t_0
    else
        tmp = t_1
    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.5e+186) {
		tmp = t_0;
	} else if (z <= -3.5e-6) {
		tmp = t_1;
	} else if (z <= -9.5e-90) {
		tmp = y * 4.0;
	} else if (z <= -3.8e-239) {
		tmp = x * -3.0;
	} else if (z <= -6.6e-267) {
		tmp = y * 4.0;
	} else if (z <= 2.7e-303) {
		tmp = x * -3.0;
	} else if (z <= 3.8e-113) {
		tmp = y * 4.0;
	} else if (z <= 0.019) {
		tmp = x * -3.0;
	} else if (z <= 1.2e+100) {
		tmp = t_1;
	} else if (z <= 6.5e+124) {
		tmp = t_0;
	} else if (z <= 6.2e+165) {
		tmp = 6.0 * (x * z);
	} else if (z <= 6.5e+225) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (z * -6.0)
	t_1 = x * (z * 6.0)
	tmp = 0
	if z <= -2.5e+186:
		tmp = t_0
	elif z <= -3.5e-6:
		tmp = t_1
	elif z <= -9.5e-90:
		tmp = y * 4.0
	elif z <= -3.8e-239:
		tmp = x * -3.0
	elif z <= -6.6e-267:
		tmp = y * 4.0
	elif z <= 2.7e-303:
		tmp = x * -3.0
	elif z <= 3.8e-113:
		tmp = y * 4.0
	elif z <= 0.019:
		tmp = x * -3.0
	elif z <= 1.2e+100:
		tmp = t_1
	elif z <= 6.5e+124:
		tmp = t_0
	elif z <= 6.2e+165:
		tmp = 6.0 * (x * z)
	elif z <= 6.5e+225:
		tmp = t_0
	else:
		tmp = t_1
	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.5e+186)
		tmp = t_0;
	elseif (z <= -3.5e-6)
		tmp = t_1;
	elseif (z <= -9.5e-90)
		tmp = Float64(y * 4.0);
	elseif (z <= -3.8e-239)
		tmp = Float64(x * -3.0);
	elseif (z <= -6.6e-267)
		tmp = Float64(y * 4.0);
	elseif (z <= 2.7e-303)
		tmp = Float64(x * -3.0);
	elseif (z <= 3.8e-113)
		tmp = Float64(y * 4.0);
	elseif (z <= 0.019)
		tmp = Float64(x * -3.0);
	elseif (z <= 1.2e+100)
		tmp = t_1;
	elseif (z <= 6.5e+124)
		tmp = t_0;
	elseif (z <= 6.2e+165)
		tmp = Float64(6.0 * Float64(x * z));
	elseif (z <= 6.5e+225)
		tmp = t_0;
	else
		tmp = t_1;
	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.5e+186)
		tmp = t_0;
	elseif (z <= -3.5e-6)
		tmp = t_1;
	elseif (z <= -9.5e-90)
		tmp = y * 4.0;
	elseif (z <= -3.8e-239)
		tmp = x * -3.0;
	elseif (z <= -6.6e-267)
		tmp = y * 4.0;
	elseif (z <= 2.7e-303)
		tmp = x * -3.0;
	elseif (z <= 3.8e-113)
		tmp = y * 4.0;
	elseif (z <= 0.019)
		tmp = x * -3.0;
	elseif (z <= 1.2e+100)
		tmp = t_1;
	elseif (z <= 6.5e+124)
		tmp = t_0;
	elseif (z <= 6.2e+165)
		tmp = 6.0 * (x * z);
	elseif (z <= 6.5e+225)
		tmp = t_0;
	else
		tmp = t_1;
	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.5e+186], t$95$0, If[LessEqual[z, -3.5e-6], t$95$1, If[LessEqual[z, -9.5e-90], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -3.8e-239], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -6.6e-267], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 2.7e-303], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 3.8e-113], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.019], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 1.2e+100], t$95$1, If[LessEqual[z, 6.5e+124], t$95$0, If[LessEqual[z, 6.2e+165], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.5e+225], t$95$0, t$95$1]]]]]]]]]]]]]]
\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.5 \cdot 10^{+186}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -3.5 \cdot 10^{-6}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq -9.5 \cdot 10^{-90}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq -3.8 \cdot 10^{-239}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -6.6 \cdot 10^{-267}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq 2.7 \cdot 10^{-303}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq 3.8 \cdot 10^{-113}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq 0.019:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq 1.2 \cdot 10^{+100}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 6.5 \cdot 10^{+124}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 6.2 \cdot 10^{+165}:\\
\;\;\;\;6 \cdot \left(x \cdot z\right)\\

\mathbf{elif}\;z \leq 6.5 \cdot 10^{+225}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if z < -2.49999999999999977e186 or 1.20000000000000006e100 < z < 6.50000000000000008e124 or 6.2000000000000003e165 < z < 6.5000000000000006e225

    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-def99.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-def99.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. Taylor expanded in y around inf 70.1%

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

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

    if -2.49999999999999977e186 < z < -3.49999999999999995e-6 or 0.0189999999999999995 < z < 1.20000000000000006e100 or 6.5000000000000006e225 < z

    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. Taylor expanded in x around inf 65.2%

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

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

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

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-1 \cdot 4} + \left(-z\right) \cdot -6\right)\right) \]
      5. neg-mul-165.2%

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(-3 + \color{blue}{6} \cdot z\right) \]
      15. *-commutative65.2%

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

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

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

    if -3.49999999999999995e-6 < z < -9.5000000000000003e-90 or -3.8000000000000002e-239 < z < -6.60000000000000007e-267 or 2.69999999999999986e-303 < z < 3.79999999999999983e-113

    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. +-commutative99.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(6, \left(y - x\right) \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Taylor expanded in z around 0 99.1%

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative66.1%

        \[\leadsto \color{blue}{y \cdot 4} \]
    7. Simplified66.1%

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

    if -9.5000000000000003e-90 < z < -3.8000000000000002e-239 or -6.60000000000000007e-267 < z < 2.69999999999999986e-303 or 3.79999999999999983e-113 < z < 0.0189999999999999995

    1. Initial program 99.2%

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-1 \cdot 4} + \left(-z\right) \cdot -6\right)\right) \]
      5. neg-mul-169.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    9. Simplified67.5%

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

    if 6.50000000000000008e124 < z < 6.2000000000000003e165

    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. Taylor expanded in x around inf 87.8%

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

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

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

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-1 \cdot 4} + \left(-z\right) \cdot -6\right)\right) \]
      5. neg-mul-187.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{+186}:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{-6}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-90}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-239}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -6.6 \cdot 10^{-267}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{-303}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-113}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.019:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+100}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+124}:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+165}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+225}:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \end{array} \]

Alternative 4: 50.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -3.5 \cdot 10^{-6}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.25 \cdot 10^{-88}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{-239}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -4.45 \cdot 10^{-268}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 5.1 \cdot 10^{-304}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-113}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.019:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* x z))))
   (if (<= z -3.5e-6)
     t_0
     (if (<= z -2.25e-88)
       (* y 4.0)
       (if (<= z -2.2e-239)
         (* x -3.0)
         (if (<= z -4.45e-268)
           (* y 4.0)
           (if (<= z 5.1e-304)
             (* x -3.0)
             (if (<= z 1.4e-113)
               (* y 4.0)
               (if (<= z 0.019) (* x -3.0) t_0)))))))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (x * z);
	double tmp;
	if (z <= -3.5e-6) {
		tmp = t_0;
	} else if (z <= -2.25e-88) {
		tmp = y * 4.0;
	} else if (z <= -2.2e-239) {
		tmp = x * -3.0;
	} else if (z <= -4.45e-268) {
		tmp = y * 4.0;
	} else if (z <= 5.1e-304) {
		tmp = x * -3.0;
	} else if (z <= 1.4e-113) {
		tmp = y * 4.0;
	} else if (z <= 0.019) {
		tmp = x * -3.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 <= (-3.5d-6)) then
        tmp = t_0
    else if (z <= (-2.25d-88)) then
        tmp = y * 4.0d0
    else if (z <= (-2.2d-239)) then
        tmp = x * (-3.0d0)
    else if (z <= (-4.45d-268)) then
        tmp = y * 4.0d0
    else if (z <= 5.1d-304) then
        tmp = x * (-3.0d0)
    else if (z <= 1.4d-113) then
        tmp = y * 4.0d0
    else if (z <= 0.019d0) then
        tmp = x * (-3.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 <= -3.5e-6) {
		tmp = t_0;
	} else if (z <= -2.25e-88) {
		tmp = y * 4.0;
	} else if (z <= -2.2e-239) {
		tmp = x * -3.0;
	} else if (z <= -4.45e-268) {
		tmp = y * 4.0;
	} else if (z <= 5.1e-304) {
		tmp = x * -3.0;
	} else if (z <= 1.4e-113) {
		tmp = y * 4.0;
	} else if (z <= 0.019) {
		tmp = x * -3.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 6.0 * (x * z)
	tmp = 0
	if z <= -3.5e-6:
		tmp = t_0
	elif z <= -2.25e-88:
		tmp = y * 4.0
	elif z <= -2.2e-239:
		tmp = x * -3.0
	elif z <= -4.45e-268:
		tmp = y * 4.0
	elif z <= 5.1e-304:
		tmp = x * -3.0
	elif z <= 1.4e-113:
		tmp = y * 4.0
	elif z <= 0.019:
		tmp = x * -3.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 <= -3.5e-6)
		tmp = t_0;
	elseif (z <= -2.25e-88)
		tmp = Float64(y * 4.0);
	elseif (z <= -2.2e-239)
		tmp = Float64(x * -3.0);
	elseif (z <= -4.45e-268)
		tmp = Float64(y * 4.0);
	elseif (z <= 5.1e-304)
		tmp = Float64(x * -3.0);
	elseif (z <= 1.4e-113)
		tmp = Float64(y * 4.0);
	elseif (z <= 0.019)
		tmp = Float64(x * -3.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 <= -3.5e-6)
		tmp = t_0;
	elseif (z <= -2.25e-88)
		tmp = y * 4.0;
	elseif (z <= -2.2e-239)
		tmp = x * -3.0;
	elseif (z <= -4.45e-268)
		tmp = y * 4.0;
	elseif (z <= 5.1e-304)
		tmp = x * -3.0;
	elseif (z <= 1.4e-113)
		tmp = y * 4.0;
	elseif (z <= 0.019)
		tmp = x * -3.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, -3.5e-6], t$95$0, If[LessEqual[z, -2.25e-88], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -2.2e-239], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -4.45e-268], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 5.1e-304], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 1.4e-113], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.019], N[(x * -3.0), $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.25 \cdot 10^{-88}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq -2.2 \cdot 10^{-239}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -4.45 \cdot 10^{-268}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq 5.1 \cdot 10^{-304}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq 1.4 \cdot 10^{-113}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq 0.019:\\
\;\;\;\;x \cdot -3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.49999999999999995e-6 or 0.0189999999999999995 < z

    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. Taylor expanded in x around inf 54.6%

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

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

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

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-1 \cdot 4} + \left(-z\right) \cdot -6\right)\right) \]
      5. neg-mul-154.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.49999999999999995e-6 < z < -2.24999999999999996e-88 or -2.19999999999999983e-239 < z < -4.4499999999999998e-268 or 5.09999999999999979e-304 < z < 1.4e-113

    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. +-commutative99.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(6, \left(y - x\right) \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Taylor expanded in z around 0 99.1%

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative66.1%

        \[\leadsto \color{blue}{y \cdot 4} \]
    7. Simplified66.1%

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

    if -2.24999999999999996e-88 < z < -2.19999999999999983e-239 or -4.4499999999999998e-268 < z < 5.09999999999999979e-304 or 1.4e-113 < z < 0.0189999999999999995

    1. Initial program 99.2%

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-1 \cdot 4} + \left(-z\right) \cdot -6\right)\right) \]
      5. neg-mul-169.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    9. Simplified67.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{-6}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -2.25 \cdot 10^{-88}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{-239}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -4.45 \cdot 10^{-268}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 5.1 \cdot 10^{-304}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{-113}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.019:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]

Alternative 5: 50.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(z \cdot 6\right)\\ \mathbf{if}\;z \leq -3.5 \cdot 10^{-6}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-91}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-243}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -5.6 \cdot 10^{-268}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 8.4 \cdot 10^{-302}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-114}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.019:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (* z 6.0))))
   (if (<= z -3.5e-6)
     t_0
     (if (<= z -2e-91)
       (* y 4.0)
       (if (<= z -3.1e-243)
         (* x -3.0)
         (if (<= z -5.6e-268)
           (* y 4.0)
           (if (<= z 8.4e-302)
             (* x -3.0)
             (if (<= z 8e-114)
               (* y 4.0)
               (if (<= z 0.019) (* x -3.0) t_0)))))))))
double code(double x, double y, double z) {
	double t_0 = x * (z * 6.0);
	double tmp;
	if (z <= -3.5e-6) {
		tmp = t_0;
	} else if (z <= -2e-91) {
		tmp = y * 4.0;
	} else if (z <= -3.1e-243) {
		tmp = x * -3.0;
	} else if (z <= -5.6e-268) {
		tmp = y * 4.0;
	} else if (z <= 8.4e-302) {
		tmp = x * -3.0;
	} else if (z <= 8e-114) {
		tmp = y * 4.0;
	} else if (z <= 0.019) {
		tmp = x * -3.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 = x * (z * 6.0d0)
    if (z <= (-3.5d-6)) then
        tmp = t_0
    else if (z <= (-2d-91)) then
        tmp = y * 4.0d0
    else if (z <= (-3.1d-243)) then
        tmp = x * (-3.0d0)
    else if (z <= (-5.6d-268)) then
        tmp = y * 4.0d0
    else if (z <= 8.4d-302) then
        tmp = x * (-3.0d0)
    else if (z <= 8d-114) then
        tmp = y * 4.0d0
    else if (z <= 0.019d0) then
        tmp = x * (-3.0d0)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (z * 6.0);
	double tmp;
	if (z <= -3.5e-6) {
		tmp = t_0;
	} else if (z <= -2e-91) {
		tmp = y * 4.0;
	} else if (z <= -3.1e-243) {
		tmp = x * -3.0;
	} else if (z <= -5.6e-268) {
		tmp = y * 4.0;
	} else if (z <= 8.4e-302) {
		tmp = x * -3.0;
	} else if (z <= 8e-114) {
		tmp = y * 4.0;
	} else if (z <= 0.019) {
		tmp = x * -3.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (z * 6.0)
	tmp = 0
	if z <= -3.5e-6:
		tmp = t_0
	elif z <= -2e-91:
		tmp = y * 4.0
	elif z <= -3.1e-243:
		tmp = x * -3.0
	elif z <= -5.6e-268:
		tmp = y * 4.0
	elif z <= 8.4e-302:
		tmp = x * -3.0
	elif z <= 8e-114:
		tmp = y * 4.0
	elif z <= 0.019:
		tmp = x * -3.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(z * 6.0))
	tmp = 0.0
	if (z <= -3.5e-6)
		tmp = t_0;
	elseif (z <= -2e-91)
		tmp = Float64(y * 4.0);
	elseif (z <= -3.1e-243)
		tmp = Float64(x * -3.0);
	elseif (z <= -5.6e-268)
		tmp = Float64(y * 4.0);
	elseif (z <= 8.4e-302)
		tmp = Float64(x * -3.0);
	elseif (z <= 8e-114)
		tmp = Float64(y * 4.0);
	elseif (z <= 0.019)
		tmp = Float64(x * -3.0);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (z * 6.0);
	tmp = 0.0;
	if (z <= -3.5e-6)
		tmp = t_0;
	elseif (z <= -2e-91)
		tmp = y * 4.0;
	elseif (z <= -3.1e-243)
		tmp = x * -3.0;
	elseif (z <= -5.6e-268)
		tmp = y * 4.0;
	elseif (z <= 8.4e-302)
		tmp = x * -3.0;
	elseif (z <= 8e-114)
		tmp = y * 4.0;
	elseif (z <= 0.019)
		tmp = x * -3.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.5e-6], t$95$0, If[LessEqual[z, -2e-91], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -3.1e-243], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -5.6e-268], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 8.4e-302], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 8e-114], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.019], N[(x * -3.0), $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq -3.1 \cdot 10^{-243}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -5.6 \cdot 10^{-268}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;z \leq 8.4 \cdot 10^{-302}:\\
\;\;\;\;x \cdot -3\\

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

\mathbf{elif}\;z \leq 0.019:\\
\;\;\;\;x \cdot -3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.49999999999999995e-6 or 0.0189999999999999995 < z

    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. Taylor expanded in x around inf 54.6%

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

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

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

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-1 \cdot 4} + \left(-z\right) \cdot -6\right)\right) \]
      5. neg-mul-154.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.49999999999999995e-6 < z < -2.00000000000000004e-91 or -3.0999999999999999e-243 < z < -5.6000000000000003e-268 or 8.40000000000000052e-302 < z < 8.0000000000000004e-114

    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. +-commutative99.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(6, \left(y - x\right) \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Taylor expanded in z around 0 99.1%

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative66.1%

        \[\leadsto \color{blue}{y \cdot 4} \]
    7. Simplified66.1%

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

    if -2.00000000000000004e-91 < z < -3.0999999999999999e-243 or -5.6000000000000003e-268 < z < 8.40000000000000052e-302 or 8.0000000000000004e-114 < z < 0.0189999999999999995

    1. Initial program 99.2%

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-1 \cdot 4} + \left(-z\right) \cdot -6\right)\right) \]
      5. neg-mul-169.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    9. Simplified67.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{-6}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -2 \cdot 10^{-91}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -3.1 \cdot 10^{-243}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -5.6 \cdot 10^{-268}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 8.4 \cdot 10^{-302}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-114}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.019:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \end{array} \]

Alternative 6: 59.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(z \cdot -6\right)\\ t_1 := x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{if}\;x \leq -2.5 \cdot 10^{-141}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.06 \cdot 10^{-198}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{-220}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-130}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (* z -6.0))) (t_1 (* x (+ -3.0 (* z 6.0)))))
   (if (<= x -2.5e-141)
     t_1
     (if (<= x -1.06e-198)
       t_0
       (if (<= x -3.4e-220) (* y 4.0) (if (<= x 1.7e-130) t_0 t_1))))))
double code(double x, double y, double z) {
	double t_0 = y * (z * -6.0);
	double t_1 = x * (-3.0 + (z * 6.0));
	double tmp;
	if (x <= -2.5e-141) {
		tmp = t_1;
	} else if (x <= -1.06e-198) {
		tmp = t_0;
	} else if (x <= -3.4e-220) {
		tmp = y * 4.0;
	} else if (x <= 1.7e-130) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	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 * ((-3.0d0) + (z * 6.0d0))
    if (x <= (-2.5d-141)) then
        tmp = t_1
    else if (x <= (-1.06d-198)) then
        tmp = t_0
    else if (x <= (-3.4d-220)) then
        tmp = y * 4.0d0
    else if (x <= 1.7d-130) then
        tmp = t_0
    else
        tmp = t_1
    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 * (-3.0 + (z * 6.0));
	double tmp;
	if (x <= -2.5e-141) {
		tmp = t_1;
	} else if (x <= -1.06e-198) {
		tmp = t_0;
	} else if (x <= -3.4e-220) {
		tmp = y * 4.0;
	} else if (x <= 1.7e-130) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (z * -6.0)
	t_1 = x * (-3.0 + (z * 6.0))
	tmp = 0
	if x <= -2.5e-141:
		tmp = t_1
	elif x <= -1.06e-198:
		tmp = t_0
	elif x <= -3.4e-220:
		tmp = y * 4.0
	elif x <= 1.7e-130:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(z * -6.0))
	t_1 = Float64(x * Float64(-3.0 + Float64(z * 6.0)))
	tmp = 0.0
	if (x <= -2.5e-141)
		tmp = t_1;
	elseif (x <= -1.06e-198)
		tmp = t_0;
	elseif (x <= -3.4e-220)
		tmp = Float64(y * 4.0);
	elseif (x <= 1.7e-130)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (z * -6.0);
	t_1 = x * (-3.0 + (z * 6.0));
	tmp = 0.0;
	if (x <= -2.5e-141)
		tmp = t_1;
	elseif (x <= -1.06e-198)
		tmp = t_0;
	elseif (x <= -3.4e-220)
		tmp = y * 4.0;
	elseif (x <= 1.7e-130)
		tmp = t_0;
	else
		tmp = t_1;
	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[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.5e-141], t$95$1, If[LessEqual[x, -1.06e-198], t$95$0, If[LessEqual[x, -3.4e-220], N[(y * 4.0), $MachinePrecision], If[LessEqual[x, 1.7e-130], t$95$0, t$95$1]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := y \cdot \left(z \cdot -6\right)\\
t_1 := x \cdot \left(-3 + z \cdot 6\right)\\
\mathbf{if}\;x \leq -2.5 \cdot 10^{-141}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -1.06 \cdot 10^{-198}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq -3.4 \cdot 10^{-220}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;x \leq 1.7 \cdot 10^{-130}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.5e-141 or 1.70000000000000003e-130 < x

    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. Taylor expanded in x around inf 70.8%

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

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

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

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-1 \cdot 4} + \left(-z\right) \cdot -6\right)\right) \]
      5. neg-mul-170.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.5e-141 < x < -1.06000000000000009e-198 or -3.39999999999999993e-220 < x < 1.70000000000000003e-130

    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.7%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-def99.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. +-commutative99.7%

        \[\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-def99.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. Taylor expanded in y around inf 90.2%

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

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

    if -1.06000000000000009e-198 < x < -3.39999999999999993e-220

    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. *-commutative99.6%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(6, \left(y - x\right) \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Taylor expanded in z around 0 86.1%

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative72.8%

        \[\leadsto \color{blue}{y \cdot 4} \]
    7. Simplified72.8%

      \[\leadsto \color{blue}{y \cdot 4} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification67.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{-141}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{elif}\;x \leq -1.06 \cdot 10^{-198}:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{-220}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-130}:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \]

Alternative 7: 97.6% accurate, 1.0× speedup?

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

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

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


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

    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. Taylor expanded in z around inf 98.2%

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

    if -0.680000000000000049 < z < 0.5

    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. +-commutative99.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(6, \left(y - x\right) \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Taylor expanded in z around 0 95.7%

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

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

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

Alternative 8: 97.6% accurate, 1.0× speedup?

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

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

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

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


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

    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. Taylor expanded in z around 0 99.8%

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

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

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

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

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

    if -0.680000000000000049 < z < 0.55000000000000004

    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. +-commutative99.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(6, \left(y - x\right) \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Taylor expanded in z around 0 95.7%

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

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

    if 0.55000000000000004 < z

    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. Taylor expanded in z around inf 97.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.68:\\ \;\;\;\;x + \left(y - x\right) \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq 0.55:\\ \;\;\;\;y \cdot 4 + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;x - -6 \cdot \left(z \cdot \left(x - y\right)\right)\\ \end{array} \]

Alternative 9: 97.6% accurate, 1.0× speedup?

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

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

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

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


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

    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. Taylor expanded in z around 0 99.8%

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

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

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

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

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

    if -0.680000000000000049 < z < 0.640000000000000013

    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. +-commutative99.3%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(6, \left(y - x\right) \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Taylor expanded in z around 0 95.7%

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

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

    if 0.640000000000000013 < z

    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. Taylor expanded in z around inf 97.7%

      \[\leadsto x + \left(\left(y - x\right) \cdot 6\right) \cdot \color{blue}{\left(-1 \cdot z\right)} \]
    5. Step-by-step derivation
      1. neg-mul-197.7%

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

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

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

Alternative 10: 74.9% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{+42} \lor \neg \left(y \leq 1.16 \cdot 10^{+24}\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 -2.15e+42) (not (<= y 1.16e+24)))
   (* y (+ 4.0 (* z -6.0)))
   (* x (+ -3.0 (* z 6.0)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -2.15e+42) || !(y <= 1.16e+24)) {
		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 <= (-2.15d+42)) .or. (.not. (y <= 1.16d+24))) 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 <= -2.15e+42) || !(y <= 1.16e+24)) {
		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 <= -2.15e+42) or not (y <= 1.16e+24):
		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 <= -2.15e+42) || !(y <= 1.16e+24))
		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 <= -2.15e+42) || ~((y <= 1.16e+24)))
		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, -2.15e+42], N[Not[LessEqual[y, 1.16e+24]], $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 -2.15 \cdot 10^{+42} \lor \neg \left(y \leq 1.16 \cdot 10^{+24}\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 < -2.1499999999999999e42 or 1.16000000000000005e24 < 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.9%

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-def99.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. +-commutative99.9%

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

        \[\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.9%

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

        \[\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.9%

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

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

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

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

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

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

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

    if -2.1499999999999999e42 < y < 1.16000000000000005e24

    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. Taylor expanded in x around inf 79.8%

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

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

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

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-1 \cdot 4} + \left(-z\right) \cdot -6\right)\right) \]
      5. neg-mul-179.8%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.15 \cdot 10^{+42} \lor \neg \left(y \leq 1.16 \cdot 10^{+24}\right):\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \]

Alternative 11: 99.5% accurate, 1.2× speedup?

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

\\
x + \left(0.6666666666666666 - z\right) \cdot \left(\left(y - x\right) \cdot 6\right)
\end{array}
Derivation
  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. Final simplification99.5%

    \[\leadsto x + \left(0.6666666666666666 - z\right) \cdot \left(\left(y - x\right) \cdot 6\right) \]

Alternative 12: 36.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.05 \cdot 10^{+41} \lor \neg \left(y \leq 3.7 \cdot 10^{-73}\right):\\
\;\;\;\;y \cdot 4\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.04999999999999999e41 or 3.7000000000000001e-73 < y

    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. *-commutative99.6%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(6, \left(y - x\right) \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Taylor expanded in z around 0 51.8%

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    6. Step-by-step derivation
      1. *-commutative39.8%

        \[\leadsto \color{blue}{y \cdot 4} \]
    7. Simplified39.8%

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

    if -3.04999999999999999e41 < y < 3.7000000000000001e-73

    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. Taylor expanded in x around inf 82.4%

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

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

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

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

        \[\leadsto x \cdot \left(1 + \left(\color{blue}{-1 \cdot 4} + \left(-z\right) \cdot -6\right)\right) \]
      5. neg-mul-182.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \left(-3 + \color{blue}{6} \cdot z\right) \]
      15. *-commutative82.5%

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    9. Simplified42.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.05 \cdot 10^{+41} \lor \neg \left(y \leq 3.7 \cdot 10^{-73}\right):\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;x \cdot -3\\ \end{array} \]

Alternative 13: 25.9% 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.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. Taylor expanded in x around inf 53.7%

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

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

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

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

      \[\leadsto x \cdot \left(1 + \left(\color{blue}{-1 \cdot 4} + \left(-z\right) \cdot -6\right)\right) \]
    5. neg-mul-153.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot -3} \]
  9. Simplified27.2%

    \[\leadsto \color{blue}{x \cdot -3} \]
  10. Final simplification27.2%

    \[\leadsto x \cdot -3 \]

Reproduce

?
herbie shell --seed 2023336 
(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))))