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

Percentage Accurate: 99.5% → 99.7%
Time: 10.2s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 99.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.9× speedup?

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

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

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Taylor expanded in z around 0 99.8%

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

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

Alternative 2: 50.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(x \cdot z\right)\\ t_1 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -1.75 \cdot 10^{+123}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-142}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-192}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -1.76 \cdot 10^{-217}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -4.8 \cdot 10^{-241}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 340000000000:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* x z))) (t_1 (* -6.0 (* y z))))
   (if (<= z -1.75e+123)
     t_0
     (if (<= z -4.5e+42)
       t_1
       (if (<= z -3.5e+16)
         t_0
         (if (<= z -3.6e-142)
           (* 4.0 y)
           (if (<= z -5.8e-192)
             (* x -3.0)
             (if (<= z -1.76e-217)
               (* 4.0 y)
               (if (<= z -4.8e-241)
                 (* x -3.0)
                 (if (<= z 340000000000.0) (* 4.0 y) t_1))))))))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (x * z);
	double t_1 = -6.0 * (y * z);
	double tmp;
	if (z <= -1.75e+123) {
		tmp = t_0;
	} else if (z <= -4.5e+42) {
		tmp = t_1;
	} else if (z <= -3.5e+16) {
		tmp = t_0;
	} else if (z <= -3.6e-142) {
		tmp = 4.0 * y;
	} else if (z <= -5.8e-192) {
		tmp = x * -3.0;
	} else if (z <= -1.76e-217) {
		tmp = 4.0 * y;
	} else if (z <= -4.8e-241) {
		tmp = x * -3.0;
	} else if (z <= 340000000000.0) {
		tmp = 4.0 * y;
	} 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 = 6.0d0 * (x * z)
    t_1 = (-6.0d0) * (y * z)
    if (z <= (-1.75d+123)) then
        tmp = t_0
    else if (z <= (-4.5d+42)) then
        tmp = t_1
    else if (z <= (-3.5d+16)) then
        tmp = t_0
    else if (z <= (-3.6d-142)) then
        tmp = 4.0d0 * y
    else if (z <= (-5.8d-192)) then
        tmp = x * (-3.0d0)
    else if (z <= (-1.76d-217)) then
        tmp = 4.0d0 * y
    else if (z <= (-4.8d-241)) then
        tmp = x * (-3.0d0)
    else if (z <= 340000000000.0d0) then
        tmp = 4.0d0 * y
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 6.0 * (x * z);
	double t_1 = -6.0 * (y * z);
	double tmp;
	if (z <= -1.75e+123) {
		tmp = t_0;
	} else if (z <= -4.5e+42) {
		tmp = t_1;
	} else if (z <= -3.5e+16) {
		tmp = t_0;
	} else if (z <= -3.6e-142) {
		tmp = 4.0 * y;
	} else if (z <= -5.8e-192) {
		tmp = x * -3.0;
	} else if (z <= -1.76e-217) {
		tmp = 4.0 * y;
	} else if (z <= -4.8e-241) {
		tmp = x * -3.0;
	} else if (z <= 340000000000.0) {
		tmp = 4.0 * y;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 6.0 * (x * z)
	t_1 = -6.0 * (y * z)
	tmp = 0
	if z <= -1.75e+123:
		tmp = t_0
	elif z <= -4.5e+42:
		tmp = t_1
	elif z <= -3.5e+16:
		tmp = t_0
	elif z <= -3.6e-142:
		tmp = 4.0 * y
	elif z <= -5.8e-192:
		tmp = x * -3.0
	elif z <= -1.76e-217:
		tmp = 4.0 * y
	elif z <= -4.8e-241:
		tmp = x * -3.0
	elif z <= 340000000000.0:
		tmp = 4.0 * y
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(6.0 * Float64(x * z))
	t_1 = Float64(-6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -1.75e+123)
		tmp = t_0;
	elseif (z <= -4.5e+42)
		tmp = t_1;
	elseif (z <= -3.5e+16)
		tmp = t_0;
	elseif (z <= -3.6e-142)
		tmp = Float64(4.0 * y);
	elseif (z <= -5.8e-192)
		tmp = Float64(x * -3.0);
	elseif (z <= -1.76e-217)
		tmp = Float64(4.0 * y);
	elseif (z <= -4.8e-241)
		tmp = Float64(x * -3.0);
	elseif (z <= 340000000000.0)
		tmp = Float64(4.0 * y);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 6.0 * (x * z);
	t_1 = -6.0 * (y * z);
	tmp = 0.0;
	if (z <= -1.75e+123)
		tmp = t_0;
	elseif (z <= -4.5e+42)
		tmp = t_1;
	elseif (z <= -3.5e+16)
		tmp = t_0;
	elseif (z <= -3.6e-142)
		tmp = 4.0 * y;
	elseif (z <= -5.8e-192)
		tmp = x * -3.0;
	elseif (z <= -1.76e-217)
		tmp = 4.0 * y;
	elseif (z <= -4.8e-241)
		tmp = x * -3.0;
	elseif (z <= 340000000000.0)
		tmp = 4.0 * y;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.75e+123], t$95$0, If[LessEqual[z, -4.5e+42], t$95$1, If[LessEqual[z, -3.5e+16], t$95$0, If[LessEqual[z, -3.6e-142], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -5.8e-192], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -1.76e-217], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -4.8e-241], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 340000000000.0], N[(4.0 * y), $MachinePrecision], t$95$1]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -4.5 \cdot 10^{+42}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq -3.5 \cdot 10^{+16}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -3.6 \cdot 10^{-142}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq -5.8 \cdot 10^{-192}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -1.76 \cdot 10^{-217}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq -4.8 \cdot 10^{-241}:\\
\;\;\;\;x \cdot -3\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.75e123 or -4.50000000000000012e42 < z < -3.5e16

    1. Initial program 99.9%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in z around 0 99.8%

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

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

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

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

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

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

    if -1.75e123 < z < -4.50000000000000012e42 or 3.4e11 < z

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in z around 0 99.8%

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

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

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

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

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

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

    if -3.5e16 < z < -3.6e-142 or -5.80000000000000033e-192 < z < -1.76000000000000006e-217 or -4.8e-241 < z < 3.4e11

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in y around inf 61.7%

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

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

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

        \[\leadsto \color{blue}{y \cdot 4} \]
    6. Simplified59.8%

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

    if -3.6e-142 < z < -5.80000000000000033e-192 or -1.76000000000000006e-217 < z < -4.8e-241

    1. Initial program 99.2%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in x around inf 83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    7. Simplified83.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.75 \cdot 10^{+123}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{+42}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+16}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-142}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -5.8 \cdot 10^{-192}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -1.76 \cdot 10^{-217}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -4.8 \cdot 10^{-241}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 340000000000:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \end{array} \]

Alternative 3: 50.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(z \cdot 6\right)\\ t_1 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -1.32 \cdot 10^{+122}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -5.5 \cdot 10^{-142}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-190}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.55 \cdot 10^{-217}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -2.25 \cdot 10^{-237}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 340000000000:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (* z 6.0))) (t_1 (* -6.0 (* y z))))
   (if (<= z -1.32e+122)
     t_0
     (if (<= z -4.4e+42)
       t_1
       (if (<= z -3.5e+16)
         t_0
         (if (<= z -5.5e-142)
           (* 4.0 y)
           (if (<= z -3.3e-190)
             (* x -3.0)
             (if (<= z -2.55e-217)
               (* 4.0 y)
               (if (<= z -2.25e-237)
                 (* x -3.0)
                 (if (<= z 340000000000.0) (* 4.0 y) t_1))))))))))
double code(double x, double y, double z) {
	double t_0 = x * (z * 6.0);
	double t_1 = -6.0 * (y * z);
	double tmp;
	if (z <= -1.32e+122) {
		tmp = t_0;
	} else if (z <= -4.4e+42) {
		tmp = t_1;
	} else if (z <= -3.5e+16) {
		tmp = t_0;
	} else if (z <= -5.5e-142) {
		tmp = 4.0 * y;
	} else if (z <= -3.3e-190) {
		tmp = x * -3.0;
	} else if (z <= -2.55e-217) {
		tmp = 4.0 * y;
	} else if (z <= -2.25e-237) {
		tmp = x * -3.0;
	} else if (z <= 340000000000.0) {
		tmp = 4.0 * y;
	} 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 = x * (z * 6.0d0)
    t_1 = (-6.0d0) * (y * z)
    if (z <= (-1.32d+122)) then
        tmp = t_0
    else if (z <= (-4.4d+42)) then
        tmp = t_1
    else if (z <= (-3.5d+16)) then
        tmp = t_0
    else if (z <= (-5.5d-142)) then
        tmp = 4.0d0 * y
    else if (z <= (-3.3d-190)) then
        tmp = x * (-3.0d0)
    else if (z <= (-2.55d-217)) then
        tmp = 4.0d0 * y
    else if (z <= (-2.25d-237)) then
        tmp = x * (-3.0d0)
    else if (z <= 340000000000.0d0) then
        tmp = 4.0d0 * y
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x * (z * 6.0);
	double t_1 = -6.0 * (y * z);
	double tmp;
	if (z <= -1.32e+122) {
		tmp = t_0;
	} else if (z <= -4.4e+42) {
		tmp = t_1;
	} else if (z <= -3.5e+16) {
		tmp = t_0;
	} else if (z <= -5.5e-142) {
		tmp = 4.0 * y;
	} else if (z <= -3.3e-190) {
		tmp = x * -3.0;
	} else if (z <= -2.55e-217) {
		tmp = 4.0 * y;
	} else if (z <= -2.25e-237) {
		tmp = x * -3.0;
	} else if (z <= 340000000000.0) {
		tmp = 4.0 * y;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x * (z * 6.0)
	t_1 = -6.0 * (y * z)
	tmp = 0
	if z <= -1.32e+122:
		tmp = t_0
	elif z <= -4.4e+42:
		tmp = t_1
	elif z <= -3.5e+16:
		tmp = t_0
	elif z <= -5.5e-142:
		tmp = 4.0 * y
	elif z <= -3.3e-190:
		tmp = x * -3.0
	elif z <= -2.55e-217:
		tmp = 4.0 * y
	elif z <= -2.25e-237:
		tmp = x * -3.0
	elif z <= 340000000000.0:
		tmp = 4.0 * y
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(x * Float64(z * 6.0))
	t_1 = Float64(-6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -1.32e+122)
		tmp = t_0;
	elseif (z <= -4.4e+42)
		tmp = t_1;
	elseif (z <= -3.5e+16)
		tmp = t_0;
	elseif (z <= -5.5e-142)
		tmp = Float64(4.0 * y);
	elseif (z <= -3.3e-190)
		tmp = Float64(x * -3.0);
	elseif (z <= -2.55e-217)
		tmp = Float64(4.0 * y);
	elseif (z <= -2.25e-237)
		tmp = Float64(x * -3.0);
	elseif (z <= 340000000000.0)
		tmp = Float64(4.0 * y);
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x * (z * 6.0);
	t_1 = -6.0 * (y * z);
	tmp = 0.0;
	if (z <= -1.32e+122)
		tmp = t_0;
	elseif (z <= -4.4e+42)
		tmp = t_1;
	elseif (z <= -3.5e+16)
		tmp = t_0;
	elseif (z <= -5.5e-142)
		tmp = 4.0 * y;
	elseif (z <= -3.3e-190)
		tmp = x * -3.0;
	elseif (z <= -2.55e-217)
		tmp = 4.0 * y;
	elseif (z <= -2.25e-237)
		tmp = x * -3.0;
	elseif (z <= 340000000000.0)
		tmp = 4.0 * y;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.32e+122], t$95$0, If[LessEqual[z, -4.4e+42], t$95$1, If[LessEqual[z, -3.5e+16], t$95$0, If[LessEqual[z, -5.5e-142], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -3.3e-190], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -2.55e-217], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -2.25e-237], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 340000000000.0], N[(4.0 * y), $MachinePrecision], t$95$1]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -4.4 \cdot 10^{+42}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq -3.5 \cdot 10^{+16}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -5.5 \cdot 10^{-142}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq -3.3 \cdot 10^{-190}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -2.55 \cdot 10^{-217}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq -2.25 \cdot 10^{-237}:\\
\;\;\;\;x \cdot -3\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.31999999999999992e122 or -4.4000000000000003e42 < z < -3.5e16

    1. Initial program 99.9%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in x around inf 66.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.31999999999999992e122 < z < -4.4000000000000003e42 or 3.4e11 < z

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in z around 0 99.8%

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

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

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

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

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

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

    if -3.5e16 < z < -5.50000000000000023e-142 or -3.30000000000000019e-190 < z < -2.5499999999999998e-217 or -2.25000000000000005e-237 < z < 3.4e11

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in y around inf 61.7%

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

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

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

        \[\leadsto \color{blue}{y \cdot 4} \]
    6. Simplified59.8%

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

    if -5.50000000000000023e-142 < z < -3.30000000000000019e-190 or -2.5499999999999998e-217 < z < -2.25000000000000005e-237

    1. Initial program 99.2%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in x around inf 83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    7. Simplified83.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.32 \cdot 10^{+122}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{+42}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+16}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -5.5 \cdot 10^{-142}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-190}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.55 \cdot 10^{-217}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -2.25 \cdot 10^{-237}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 340000000000:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \end{array} \]

Alternative 4: 50.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -7.8 \cdot 10^{+121}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{+42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+16}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -4.9 \cdot 10^{-142}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-190}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-216}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-241}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 340000000000:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -6.0 (* y z))))
   (if (<= z -7.8e+121)
     (* z (* x 6.0))
     (if (<= z -4.5e+42)
       t_0
       (if (<= z -3.5e+16)
         (* x (* z 6.0))
         (if (<= z -4.9e-142)
           (* 4.0 y)
           (if (<= z -1.25e-190)
             (* x -3.0)
             (if (<= z -2.5e-216)
               (* 4.0 y)
               (if (<= z -1.8e-241)
                 (* x -3.0)
                 (if (<= z 340000000000.0) (* 4.0 y) t_0))))))))))
double code(double x, double y, double z) {
	double t_0 = -6.0 * (y * z);
	double tmp;
	if (z <= -7.8e+121) {
		tmp = z * (x * 6.0);
	} else if (z <= -4.5e+42) {
		tmp = t_0;
	} else if (z <= -3.5e+16) {
		tmp = x * (z * 6.0);
	} else if (z <= -4.9e-142) {
		tmp = 4.0 * y;
	} else if (z <= -1.25e-190) {
		tmp = x * -3.0;
	} else if (z <= -2.5e-216) {
		tmp = 4.0 * y;
	} else if (z <= -1.8e-241) {
		tmp = x * -3.0;
	} else if (z <= 340000000000.0) {
		tmp = 4.0 * y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-6.0d0) * (y * z)
    if (z <= (-7.8d+121)) then
        tmp = z * (x * 6.0d0)
    else if (z <= (-4.5d+42)) then
        tmp = t_0
    else if (z <= (-3.5d+16)) then
        tmp = x * (z * 6.0d0)
    else if (z <= (-4.9d-142)) then
        tmp = 4.0d0 * y
    else if (z <= (-1.25d-190)) then
        tmp = x * (-3.0d0)
    else if (z <= (-2.5d-216)) then
        tmp = 4.0d0 * y
    else if (z <= (-1.8d-241)) then
        tmp = x * (-3.0d0)
    else if (z <= 340000000000.0d0) then
        tmp = 4.0d0 * y
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = -6.0 * (y * z);
	double tmp;
	if (z <= -7.8e+121) {
		tmp = z * (x * 6.0);
	} else if (z <= -4.5e+42) {
		tmp = t_0;
	} else if (z <= -3.5e+16) {
		tmp = x * (z * 6.0);
	} else if (z <= -4.9e-142) {
		tmp = 4.0 * y;
	} else if (z <= -1.25e-190) {
		tmp = x * -3.0;
	} else if (z <= -2.5e-216) {
		tmp = 4.0 * y;
	} else if (z <= -1.8e-241) {
		tmp = x * -3.0;
	} else if (z <= 340000000000.0) {
		tmp = 4.0 * y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -6.0 * (y * z)
	tmp = 0
	if z <= -7.8e+121:
		tmp = z * (x * 6.0)
	elif z <= -4.5e+42:
		tmp = t_0
	elif z <= -3.5e+16:
		tmp = x * (z * 6.0)
	elif z <= -4.9e-142:
		tmp = 4.0 * y
	elif z <= -1.25e-190:
		tmp = x * -3.0
	elif z <= -2.5e-216:
		tmp = 4.0 * y
	elif z <= -1.8e-241:
		tmp = x * -3.0
	elif z <= 340000000000.0:
		tmp = 4.0 * y
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(-6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -7.8e+121)
		tmp = Float64(z * Float64(x * 6.0));
	elseif (z <= -4.5e+42)
		tmp = t_0;
	elseif (z <= -3.5e+16)
		tmp = Float64(x * Float64(z * 6.0));
	elseif (z <= -4.9e-142)
		tmp = Float64(4.0 * y);
	elseif (z <= -1.25e-190)
		tmp = Float64(x * -3.0);
	elseif (z <= -2.5e-216)
		tmp = Float64(4.0 * y);
	elseif (z <= -1.8e-241)
		tmp = Float64(x * -3.0);
	elseif (z <= 340000000000.0)
		tmp = Float64(4.0 * y);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = -6.0 * (y * z);
	tmp = 0.0;
	if (z <= -7.8e+121)
		tmp = z * (x * 6.0);
	elseif (z <= -4.5e+42)
		tmp = t_0;
	elseif (z <= -3.5e+16)
		tmp = x * (z * 6.0);
	elseif (z <= -4.9e-142)
		tmp = 4.0 * y;
	elseif (z <= -1.25e-190)
		tmp = x * -3.0;
	elseif (z <= -2.5e-216)
		tmp = 4.0 * y;
	elseif (z <= -1.8e-241)
		tmp = x * -3.0;
	elseif (z <= 340000000000.0)
		tmp = 4.0 * y;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.8e+121], N[(z * N[(x * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -4.5e+42], t$95$0, If[LessEqual[z, -3.5e+16], N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -4.9e-142], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -1.25e-190], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -2.5e-216], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -1.8e-241], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 340000000000.0], N[(4.0 * y), $MachinePrecision], t$95$0]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -4.5 \cdot 10^{+42}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -3.5 \cdot 10^{+16}:\\
\;\;\;\;x \cdot \left(z \cdot 6\right)\\

\mathbf{elif}\;z \leq -4.9 \cdot 10^{-142}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq -1.25 \cdot 10^{-190}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -2.5 \cdot 10^{-216}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq -1.8 \cdot 10^{-241}:\\
\;\;\;\;x \cdot -3\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if z < -7.79999999999999967e121

    1. Initial program 99.9%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in z around 0 99.8%

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

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

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

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

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

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

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

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

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

    if -7.79999999999999967e121 < z < -4.50000000000000012e42 or 3.4e11 < z

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in z around 0 99.8%

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

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

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

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

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

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

    if -4.50000000000000012e42 < z < -3.5e16

    1. Initial program 100.0%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in x around inf 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(\left(-6 \cdot z\right) \cdot -1 + 3 \cdot -1\right)} \]
      18. *-commutative100.0%

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

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

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

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

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

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

    if -3.5e16 < z < -4.9000000000000003e-142 or -1.25000000000000009e-190 < z < -2.5000000000000001e-216 or -1.7999999999999999e-241 < z < 3.4e11

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in y around inf 61.7%

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

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

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

        \[\leadsto \color{blue}{y \cdot 4} \]
    6. Simplified59.8%

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

    if -4.9000000000000003e-142 < z < -1.25000000000000009e-190 or -2.5000000000000001e-216 < z < -1.7999999999999999e-241

    1. Initial program 99.2%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in x around inf 83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    7. Simplified83.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.8 \cdot 10^{+121}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{+42}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+16}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -4.9 \cdot 10^{-142}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.25 \cdot 10^{-190}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-216}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-241}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 340000000000:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \end{array} \]

Alternative 5: 74.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{if}\;z \leq -0.0265:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-142}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{-191}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -1.02 \cdot 10^{-218}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-241}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.52:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -6.0 (* (- y x) z))))
   (if (<= z -0.0265)
     t_0
     (if (<= z -3.8e-142)
       (* 4.0 y)
       (if (<= z -3.7e-191)
         (* x -3.0)
         (if (<= z -1.02e-218)
           (* 4.0 y)
           (if (<= z -3.2e-241)
             (* x -3.0)
             (if (<= z 0.52) (* 4.0 y) t_0))))))))
double code(double x, double y, double z) {
	double t_0 = -6.0 * ((y - x) * z);
	double tmp;
	if (z <= -0.0265) {
		tmp = t_0;
	} else if (z <= -3.8e-142) {
		tmp = 4.0 * y;
	} else if (z <= -3.7e-191) {
		tmp = x * -3.0;
	} else if (z <= -1.02e-218) {
		tmp = 4.0 * y;
	} else if (z <= -3.2e-241) {
		tmp = x * -3.0;
	} else if (z <= 0.52) {
		tmp = 4.0 * y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-6.0d0) * ((y - x) * z)
    if (z <= (-0.0265d0)) then
        tmp = t_0
    else if (z <= (-3.8d-142)) then
        tmp = 4.0d0 * y
    else if (z <= (-3.7d-191)) then
        tmp = x * (-3.0d0)
    else if (z <= (-1.02d-218)) then
        tmp = 4.0d0 * y
    else if (z <= (-3.2d-241)) then
        tmp = x * (-3.0d0)
    else if (z <= 0.52d0) then
        tmp = 4.0d0 * y
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = -6.0 * ((y - x) * z);
	double tmp;
	if (z <= -0.0265) {
		tmp = t_0;
	} else if (z <= -3.8e-142) {
		tmp = 4.0 * y;
	} else if (z <= -3.7e-191) {
		tmp = x * -3.0;
	} else if (z <= -1.02e-218) {
		tmp = 4.0 * y;
	} else if (z <= -3.2e-241) {
		tmp = x * -3.0;
	} else if (z <= 0.52) {
		tmp = 4.0 * y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -6.0 * ((y - x) * z)
	tmp = 0
	if z <= -0.0265:
		tmp = t_0
	elif z <= -3.8e-142:
		tmp = 4.0 * y
	elif z <= -3.7e-191:
		tmp = x * -3.0
	elif z <= -1.02e-218:
		tmp = 4.0 * y
	elif z <= -3.2e-241:
		tmp = x * -3.0
	elif z <= 0.52:
		tmp = 4.0 * y
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(-6.0 * Float64(Float64(y - x) * z))
	tmp = 0.0
	if (z <= -0.0265)
		tmp = t_0;
	elseif (z <= -3.8e-142)
		tmp = Float64(4.0 * y);
	elseif (z <= -3.7e-191)
		tmp = Float64(x * -3.0);
	elseif (z <= -1.02e-218)
		tmp = Float64(4.0 * y);
	elseif (z <= -3.2e-241)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.52)
		tmp = Float64(4.0 * y);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = -6.0 * ((y - x) * z);
	tmp = 0.0;
	if (z <= -0.0265)
		tmp = t_0;
	elseif (z <= -3.8e-142)
		tmp = 4.0 * y;
	elseif (z <= -3.7e-191)
		tmp = x * -3.0;
	elseif (z <= -1.02e-218)
		tmp = 4.0 * y;
	elseif (z <= -3.2e-241)
		tmp = x * -3.0;
	elseif (z <= 0.52)
		tmp = 4.0 * y;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.0265], t$95$0, If[LessEqual[z, -3.8e-142], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -3.7e-191], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -1.02e-218], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -3.2e-241], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.52], N[(4.0 * y), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq -3.7 \cdot 10^{-191}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -1.02 \cdot 10^{-218}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq -3.2 \cdot 10^{-241}:\\
\;\;\;\;x \cdot -3\\

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

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


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

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in z around 0 99.8%

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

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

    if -0.0264999999999999993 < z < -3.79999999999999972e-142 or -3.6999999999999997e-191 < z < -1.02e-218 or -3.2e-241 < z < 0.52000000000000002

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in y around inf 61.9%

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

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

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

        \[\leadsto \color{blue}{y \cdot 4} \]
    6. Simplified61.9%

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

    if -3.79999999999999972e-142 < z < -3.6999999999999997e-191 or -1.02e-218 < z < -3.2e-241

    1. Initial program 99.2%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in x around inf 83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    7. Simplified83.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.0265:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-142}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{-191}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -1.02 \cdot 10^{-218}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-241}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.52:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \]

Alternative 6: 74.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ t_1 := -6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{if}\;z \leq -3.5 \cdot 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{-142}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.08 \cdot 10^{-190}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-220}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-236}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.55:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* y (- 0.6666666666666666 z))))
        (t_1 (* -6.0 (* (- y x) z))))
   (if (<= z -3.5e+16)
     t_1
     (if (<= z -4.6e-142)
       t_0
       (if (<= z -1.08e-190)
         (* x -3.0)
         (if (<= z -7e-220)
           (* 4.0 y)
           (if (<= z -1.8e-236) (* x -3.0) (if (<= z 0.55) t_0 t_1))))))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (y * (0.6666666666666666 - z));
	double t_1 = -6.0 * ((y - x) * z);
	double tmp;
	if (z <= -3.5e+16) {
		tmp = t_1;
	} else if (z <= -4.6e-142) {
		tmp = t_0;
	} else if (z <= -1.08e-190) {
		tmp = x * -3.0;
	} else if (z <= -7e-220) {
		tmp = 4.0 * y;
	} else if (z <= -1.8e-236) {
		tmp = x * -3.0;
	} else if (z <= 0.55) {
		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 = 6.0d0 * (y * (0.6666666666666666d0 - z))
    t_1 = (-6.0d0) * ((y - x) * z)
    if (z <= (-3.5d+16)) then
        tmp = t_1
    else if (z <= (-4.6d-142)) then
        tmp = t_0
    else if (z <= (-1.08d-190)) then
        tmp = x * (-3.0d0)
    else if (z <= (-7d-220)) then
        tmp = 4.0d0 * y
    else if (z <= (-1.8d-236)) then
        tmp = x * (-3.0d0)
    else if (z <= 0.55d0) 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 = 6.0 * (y * (0.6666666666666666 - z));
	double t_1 = -6.0 * ((y - x) * z);
	double tmp;
	if (z <= -3.5e+16) {
		tmp = t_1;
	} else if (z <= -4.6e-142) {
		tmp = t_0;
	} else if (z <= -1.08e-190) {
		tmp = x * -3.0;
	} else if (z <= -7e-220) {
		tmp = 4.0 * y;
	} else if (z <= -1.8e-236) {
		tmp = x * -3.0;
	} else if (z <= 0.55) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 6.0 * (y * (0.6666666666666666 - z))
	t_1 = -6.0 * ((y - x) * z)
	tmp = 0
	if z <= -3.5e+16:
		tmp = t_1
	elif z <= -4.6e-142:
		tmp = t_0
	elif z <= -1.08e-190:
		tmp = x * -3.0
	elif z <= -7e-220:
		tmp = 4.0 * y
	elif z <= -1.8e-236:
		tmp = x * -3.0
	elif z <= 0.55:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(6.0 * Float64(y * Float64(0.6666666666666666 - z)))
	t_1 = Float64(-6.0 * Float64(Float64(y - x) * z))
	tmp = 0.0
	if (z <= -3.5e+16)
		tmp = t_1;
	elseif (z <= -4.6e-142)
		tmp = t_0;
	elseif (z <= -1.08e-190)
		tmp = Float64(x * -3.0);
	elseif (z <= -7e-220)
		tmp = Float64(4.0 * y);
	elseif (z <= -1.8e-236)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.55)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 6.0 * (y * (0.6666666666666666 - z));
	t_1 = -6.0 * ((y - x) * z);
	tmp = 0.0;
	if (z <= -3.5e+16)
		tmp = t_1;
	elseif (z <= -4.6e-142)
		tmp = t_0;
	elseif (z <= -1.08e-190)
		tmp = x * -3.0;
	elseif (z <= -7e-220)
		tmp = 4.0 * y;
	elseif (z <= -1.8e-236)
		tmp = x * -3.0;
	elseif (z <= 0.55)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(y * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.5e+16], t$95$1, If[LessEqual[z, -4.6e-142], t$95$0, If[LessEqual[z, -1.08e-190], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -7e-220], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -1.8e-236], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.55], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -4.6 \cdot 10^{-142}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -1.08 \cdot 10^{-190}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -7 \cdot 10^{-220}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq -1.8 \cdot 10^{-236}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq 0.55:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -3.5e16 or 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. Taylor expanded in z around 0 99.8%

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

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

    if -3.5e16 < z < -4.60000000000000005e-142 or -1.80000000000000004e-236 < z < 0.55000000000000004

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in y around inf 61.0%

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

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

    if -4.60000000000000005e-142 < z < -1.08e-190 or -6.99999999999999975e-220 < z < -1.80000000000000004e-236

    1. Initial program 99.2%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in x around inf 83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    7. Simplified83.8%

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

    if -1.08e-190 < z < -6.99999999999999975e-220

    1. Initial program 99.6%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in y around inf 85.3%

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

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

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

        \[\leadsto \color{blue}{y \cdot 4} \]
    6. Simplified85.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{+16}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{-142}:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{elif}\;z \leq -1.08 \cdot 10^{-190}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-220}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{-236}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.55:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \]

Alternative 7: 49.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -0.65:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-142}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -2.3 \cdot 10^{-192}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -8.2 \cdot 10^{-218}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-236}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 340000000000:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -6.0 (* y z))))
   (if (<= z -0.65)
     t_0
     (if (<= z -4.5e-142)
       (* 4.0 y)
       (if (<= z -2.3e-192)
         (* x -3.0)
         (if (<= z -8.2e-218)
           (* 4.0 y)
           (if (<= z -3.3e-236)
             (* x -3.0)
             (if (<= z 340000000000.0) (* 4.0 y) t_0))))))))
double code(double x, double y, double z) {
	double t_0 = -6.0 * (y * z);
	double tmp;
	if (z <= -0.65) {
		tmp = t_0;
	} else if (z <= -4.5e-142) {
		tmp = 4.0 * y;
	} else if (z <= -2.3e-192) {
		tmp = x * -3.0;
	} else if (z <= -8.2e-218) {
		tmp = 4.0 * y;
	} else if (z <= -3.3e-236) {
		tmp = x * -3.0;
	} else if (z <= 340000000000.0) {
		tmp = 4.0 * y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-6.0d0) * (y * z)
    if (z <= (-0.65d0)) then
        tmp = t_0
    else if (z <= (-4.5d-142)) then
        tmp = 4.0d0 * y
    else if (z <= (-2.3d-192)) then
        tmp = x * (-3.0d0)
    else if (z <= (-8.2d-218)) then
        tmp = 4.0d0 * y
    else if (z <= (-3.3d-236)) then
        tmp = x * (-3.0d0)
    else if (z <= 340000000000.0d0) then
        tmp = 4.0d0 * y
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = -6.0 * (y * z);
	double tmp;
	if (z <= -0.65) {
		tmp = t_0;
	} else if (z <= -4.5e-142) {
		tmp = 4.0 * y;
	} else if (z <= -2.3e-192) {
		tmp = x * -3.0;
	} else if (z <= -8.2e-218) {
		tmp = 4.0 * y;
	} else if (z <= -3.3e-236) {
		tmp = x * -3.0;
	} else if (z <= 340000000000.0) {
		tmp = 4.0 * y;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -6.0 * (y * z)
	tmp = 0
	if z <= -0.65:
		tmp = t_0
	elif z <= -4.5e-142:
		tmp = 4.0 * y
	elif z <= -2.3e-192:
		tmp = x * -3.0
	elif z <= -8.2e-218:
		tmp = 4.0 * y
	elif z <= -3.3e-236:
		tmp = x * -3.0
	elif z <= 340000000000.0:
		tmp = 4.0 * y
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(-6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -0.65)
		tmp = t_0;
	elseif (z <= -4.5e-142)
		tmp = Float64(4.0 * y);
	elseif (z <= -2.3e-192)
		tmp = Float64(x * -3.0);
	elseif (z <= -8.2e-218)
		tmp = Float64(4.0 * y);
	elseif (z <= -3.3e-236)
		tmp = Float64(x * -3.0);
	elseif (z <= 340000000000.0)
		tmp = Float64(4.0 * y);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = -6.0 * (y * z);
	tmp = 0.0;
	if (z <= -0.65)
		tmp = t_0;
	elseif (z <= -4.5e-142)
		tmp = 4.0 * y;
	elseif (z <= -2.3e-192)
		tmp = x * -3.0;
	elseif (z <= -8.2e-218)
		tmp = 4.0 * y;
	elseif (z <= -3.3e-236)
		tmp = x * -3.0;
	elseif (z <= 340000000000.0)
		tmp = 4.0 * y;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.65], t$95$0, If[LessEqual[z, -4.5e-142], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -2.3e-192], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -8.2e-218], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -3.3e-236], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 340000000000.0], N[(4.0 * y), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -4.5 \cdot 10^{-142}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq -2.3 \cdot 10^{-192}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -8.2 \cdot 10^{-218}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq -3.3 \cdot 10^{-236}:\\
\;\;\;\;x \cdot -3\\

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

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


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

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in z around 0 99.8%

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

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

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

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

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

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

    if -0.650000000000000022 < z < -4.50000000000000019e-142 or -2.30000000000000018e-192 < z < -8.1999999999999995e-218 or -3.3000000000000001e-236 < z < 3.4e11

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in y around inf 61.0%

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

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

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

        \[\leadsto \color{blue}{y \cdot 4} \]
    6. Simplified60.8%

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

    if -4.50000000000000019e-142 < z < -2.30000000000000018e-192 or -8.1999999999999995e-218 < z < -3.3000000000000001e-236

    1. Initial program 99.2%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in x around inf 83.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    7. Simplified83.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.65:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -4.5 \cdot 10^{-142}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -2.3 \cdot 10^{-192}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -8.2 \cdot 10^{-218}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-236}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 340000000000:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \end{array} \]

Alternative 8: 75.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{if}\;y \leq -1150000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -5.5 \cdot 10^{-99}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-108} \lor \neg \left(y \leq 5.5 \cdot 10^{-17}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* y (- 0.6666666666666666 z)))))
   (if (<= y -1150000000.0)
     t_0
     (if (<= y -5.5e-99)
       (* -6.0 (* (- y x) z))
       (if (or (<= y -1e-108) (not (<= y 5.5e-17)))
         t_0
         (* x (+ -3.0 (* z 6.0))))))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (y * (0.6666666666666666 - z));
	double tmp;
	if (y <= -1150000000.0) {
		tmp = t_0;
	} else if (y <= -5.5e-99) {
		tmp = -6.0 * ((y - x) * z);
	} else if ((y <= -1e-108) || !(y <= 5.5e-17)) {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = 6.0d0 * (y * (0.6666666666666666d0 - z))
    if (y <= (-1150000000.0d0)) then
        tmp = t_0
    else if (y <= (-5.5d-99)) then
        tmp = (-6.0d0) * ((y - x) * z)
    else if ((y <= (-1d-108)) .or. (.not. (y <= 5.5d-17))) then
        tmp = t_0
    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 t_0 = 6.0 * (y * (0.6666666666666666 - z));
	double tmp;
	if (y <= -1150000000.0) {
		tmp = t_0;
	} else if (y <= -5.5e-99) {
		tmp = -6.0 * ((y - x) * z);
	} else if ((y <= -1e-108) || !(y <= 5.5e-17)) {
		tmp = t_0;
	} else {
		tmp = x * (-3.0 + (z * 6.0));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 6.0 * (y * (0.6666666666666666 - z))
	tmp = 0
	if y <= -1150000000.0:
		tmp = t_0
	elif y <= -5.5e-99:
		tmp = -6.0 * ((y - x) * z)
	elif (y <= -1e-108) or not (y <= 5.5e-17):
		tmp = t_0
	else:
		tmp = x * (-3.0 + (z * 6.0))
	return tmp
function code(x, y, z)
	t_0 = Float64(6.0 * Float64(y * Float64(0.6666666666666666 - z)))
	tmp = 0.0
	if (y <= -1150000000.0)
		tmp = t_0;
	elseif (y <= -5.5e-99)
		tmp = Float64(-6.0 * Float64(Float64(y - x) * z));
	elseif ((y <= -1e-108) || !(y <= 5.5e-17))
		tmp = t_0;
	else
		tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 6.0 * (y * (0.6666666666666666 - z));
	tmp = 0.0;
	if (y <= -1150000000.0)
		tmp = t_0;
	elseif (y <= -5.5e-99)
		tmp = -6.0 * ((y - x) * z);
	elseif ((y <= -1e-108) || ~((y <= 5.5e-17)))
		tmp = t_0;
	else
		tmp = x * (-3.0 + (z * 6.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(y * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1150000000.0], t$95$0, If[LessEqual[y, -5.5e-99], N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -1e-108], N[Not[LessEqual[y, 5.5e-17]], $MachinePrecision]], t$95$0, N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\
\mathbf{if}\;y \leq -1150000000:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;y \leq -1 \cdot 10^{-108} \lor \neg \left(y \leq 5.5 \cdot 10^{-17}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.15e9 or -5.49999999999999991e-99 < y < -1.00000000000000004e-108 or 5.50000000000000001e-17 < y

    1. Initial program 99.6%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in y around inf 81.9%

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

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

    if -1.15e9 < y < -5.49999999999999991e-99

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in z around 0 99.7%

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

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

    if -1.00000000000000004e-108 < y < 5.50000000000000001e-17

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in x around inf 82.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1150000000:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{elif}\;y \leq -5.5 \cdot 10^{-99}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-108} \lor \neg \left(y \leq 5.5 \cdot 10^{-17}\right):\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \]

Alternative 9: 75.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(4 + -6 \cdot z\right)\\ \mathbf{if}\;y \leq -145000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{-99}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;y \leq -1.02 \cdot 10^{-108} \lor \neg \left(y \leq 5.6 \cdot 10^{-17}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (+ 4.0 (* -6.0 z)))))
   (if (<= y -145000000.0)
     t_0
     (if (<= y -4.6e-99)
       (* -6.0 (* (- y x) z))
       (if (or (<= y -1.02e-108) (not (<= y 5.6e-17)))
         t_0
         (* x (+ -3.0 (* z 6.0))))))))
double code(double x, double y, double z) {
	double t_0 = y * (4.0 + (-6.0 * z));
	double tmp;
	if (y <= -145000000.0) {
		tmp = t_0;
	} else if (y <= -4.6e-99) {
		tmp = -6.0 * ((y - x) * z);
	} else if ((y <= -1.02e-108) || !(y <= 5.6e-17)) {
		tmp = t_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) :: t_0
    real(8) :: tmp
    t_0 = y * (4.0d0 + ((-6.0d0) * z))
    if (y <= (-145000000.0d0)) then
        tmp = t_0
    else if (y <= (-4.6d-99)) then
        tmp = (-6.0d0) * ((y - x) * z)
    else if ((y <= (-1.02d-108)) .or. (.not. (y <= 5.6d-17))) then
        tmp = t_0
    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 t_0 = y * (4.0 + (-6.0 * z));
	double tmp;
	if (y <= -145000000.0) {
		tmp = t_0;
	} else if (y <= -4.6e-99) {
		tmp = -6.0 * ((y - x) * z);
	} else if ((y <= -1.02e-108) || !(y <= 5.6e-17)) {
		tmp = t_0;
	} else {
		tmp = x * (-3.0 + (z * 6.0));
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (4.0 + (-6.0 * z))
	tmp = 0
	if y <= -145000000.0:
		tmp = t_0
	elif y <= -4.6e-99:
		tmp = -6.0 * ((y - x) * z)
	elif (y <= -1.02e-108) or not (y <= 5.6e-17):
		tmp = t_0
	else:
		tmp = x * (-3.0 + (z * 6.0))
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(4.0 + Float64(-6.0 * z)))
	tmp = 0.0
	if (y <= -145000000.0)
		tmp = t_0;
	elseif (y <= -4.6e-99)
		tmp = Float64(-6.0 * Float64(Float64(y - x) * z));
	elseif ((y <= -1.02e-108) || !(y <= 5.6e-17))
		tmp = t_0;
	else
		tmp = Float64(x * Float64(-3.0 + Float64(z * 6.0)));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (4.0 + (-6.0 * z));
	tmp = 0.0;
	if (y <= -145000000.0)
		tmp = t_0;
	elseif (y <= -4.6e-99)
		tmp = -6.0 * ((y - x) * z);
	elseif ((y <= -1.02e-108) || ~((y <= 5.6e-17)))
		tmp = t_0;
	else
		tmp = x * (-3.0 + (z * 6.0));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(4.0 + N[(-6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -145000000.0], t$95$0, If[LessEqual[y, -4.6e-99], N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, -1.02e-108], N[Not[LessEqual[y, 5.6e-17]], $MachinePrecision]], t$95$0, N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq -1.02 \cdot 10^{-108} \lor \neg \left(y \leq 5.6 \cdot 10^{-17}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.45e8 or -4.5999999999999997e-99 < y < -1.02000000000000008e-108 or 5.5999999999999998e-17 < 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. 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. neg-mul-199.8%

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

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

        \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{z \cdot \left(6 \cdot -1\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 \cdot -1, 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.3%

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

    if -1.45e8 < y < -4.5999999999999997e-99

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in z around 0 99.7%

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

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

    if -1.02000000000000008e-108 < y < 5.5999999999999998e-17

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in x around inf 82.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -145000000:\\ \;\;\;\;y \cdot \left(4 + -6 \cdot z\right)\\ \mathbf{elif}\;y \leq -4.6 \cdot 10^{-99}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;y \leq -1.02 \cdot 10^{-108} \lor \neg \left(y \leq 5.6 \cdot 10^{-17}\right):\\ \;\;\;\;y \cdot \left(4 + -6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \]

Alternative 10: 97.7% accurate, 1.2× speedup?

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

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

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

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


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

    1. Initial program 99.8%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in z around 0 99.7%

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

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

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

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

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

    if -0.55000000000000004 < z < 0.55000000000000004

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in z around 0 98.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.55:\\ \;\;\;\;z \cdot \left(\left(y - x\right) \cdot -6\right)\\ \mathbf{elif}\;z \leq 0.55:\\ \;\;\;\;x \cdot -3 + 4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\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.6%

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Taylor expanded in z around 0 99.6%

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

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

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

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

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

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

Alternative 12: 99.7% accurate, 1.2× speedup?

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

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

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

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

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

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

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

Alternative 13: 37.0% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{-44}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-32}:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot -3\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= x -3e-44) (* x -3.0) (if (<= x 1.02e-32) (* 4.0 y) (* x -3.0))))
double code(double x, double y, double z) {
	double tmp;
	if (x <= -3e-44) {
		tmp = x * -3.0;
	} else if (x <= 1.02e-32) {
		tmp = 4.0 * y;
	} 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 (x <= (-3d-44)) then
        tmp = x * (-3.0d0)
    else if (x <= 1.02d-32) then
        tmp = 4.0d0 * y
    else
        tmp = x * (-3.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -3e-44) {
		tmp = x * -3.0;
	} else if (x <= 1.02e-32) {
		tmp = 4.0 * y;
	} else {
		tmp = x * -3.0;
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if x <= -3e-44:
		tmp = x * -3.0
	elif x <= 1.02e-32:
		tmp = 4.0 * y
	else:
		tmp = x * -3.0
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (x <= -3e-44)
		tmp = Float64(x * -3.0);
	elseif (x <= 1.02e-32)
		tmp = Float64(4.0 * y);
	else
		tmp = Float64(x * -3.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -3e-44)
		tmp = x * -3.0;
	elseif (x <= 1.02e-32)
		tmp = 4.0 * y;
	else
		tmp = x * -3.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[x, -3e-44], N[(x * -3.0), $MachinePrecision], If[LessEqual[x, 1.02e-32], N[(4.0 * y), $MachinePrecision], N[(x * -3.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{-44}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;x \leq 1.02 \cdot 10^{-32}:\\
\;\;\;\;4 \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.0000000000000002e-44 or 1.02000000000000002e-32 < x

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in x around inf 75.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.0000000000000002e-44 < x < 1.02000000000000002e-32

    1. Initial program 99.6%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Taylor expanded in y around inf 82.7%

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

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

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

        \[\leadsto \color{blue}{y \cdot 4} \]
    6. Simplified43.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{-44}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-32}:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot -3\\ \end{array} \]

Alternative 14: 25.5% accurate, 4.3× speedup?

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

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

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Taylor expanded in x around inf 49.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot -3} \]
  7. Simplified22.1%

    \[\leadsto \color{blue}{x \cdot -3} \]
  8. Final simplification22.1%

    \[\leadsto x \cdot -3 \]

Reproduce

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