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

Percentage Accurate: 99.5% → 99.8%
Time: 9.7s
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.8% 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: 51.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -3.7 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-119}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{-181}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-269}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.35 \cdot 10^{+113} \lor \neg \left(z \leq 7 \cdot 10^{+206}\right) \land z \leq 7.4 \cdot 10^{+245}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -6.0 (* y z))))
   (if (<= z -3.7e-5)
     t_0
     (if (<= z -3.6e-119)
       (* 4.0 y)
       (if (<= z -1.5e-181)
         (* x -3.0)
         (if (<= z -3.2e-275)
           (* 4.0 y)
           (if (<= z 4.9e-269)
             (* x -3.0)
             (if (<= z 0.66)
               (* 4.0 y)
               (if (or (<= z 2.35e+113)
                       (and (not (<= z 7e+206)) (<= z 7.4e+245)))
                 t_0
                 (* 6.0 (* x z)))))))))))
double code(double x, double y, double z) {
	double t_0 = -6.0 * (y * z);
	double tmp;
	if (z <= -3.7e-5) {
		tmp = t_0;
	} else if (z <= -3.6e-119) {
		tmp = 4.0 * y;
	} else if (z <= -1.5e-181) {
		tmp = x * -3.0;
	} else if (z <= -3.2e-275) {
		tmp = 4.0 * y;
	} else if (z <= 4.9e-269) {
		tmp = x * -3.0;
	} else if (z <= 0.66) {
		tmp = 4.0 * y;
	} else if ((z <= 2.35e+113) || (!(z <= 7e+206) && (z <= 7.4e+245))) {
		tmp = t_0;
	} else {
		tmp = 6.0 * (x * z);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-6.0d0) * (y * z)
    if (z <= (-3.7d-5)) then
        tmp = t_0
    else if (z <= (-3.6d-119)) then
        tmp = 4.0d0 * y
    else if (z <= (-1.5d-181)) then
        tmp = x * (-3.0d0)
    else if (z <= (-3.2d-275)) then
        tmp = 4.0d0 * y
    else if (z <= 4.9d-269) then
        tmp = x * (-3.0d0)
    else if (z <= 0.66d0) then
        tmp = 4.0d0 * y
    else if ((z <= 2.35d+113) .or. (.not. (z <= 7d+206)) .and. (z <= 7.4d+245)) then
        tmp = t_0
    else
        tmp = 6.0d0 * (x * z)
    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 <= -3.7e-5) {
		tmp = t_0;
	} else if (z <= -3.6e-119) {
		tmp = 4.0 * y;
	} else if (z <= -1.5e-181) {
		tmp = x * -3.0;
	} else if (z <= -3.2e-275) {
		tmp = 4.0 * y;
	} else if (z <= 4.9e-269) {
		tmp = x * -3.0;
	} else if (z <= 0.66) {
		tmp = 4.0 * y;
	} else if ((z <= 2.35e+113) || (!(z <= 7e+206) && (z <= 7.4e+245))) {
		tmp = t_0;
	} else {
		tmp = 6.0 * (x * z);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -6.0 * (y * z)
	tmp = 0
	if z <= -3.7e-5:
		tmp = t_0
	elif z <= -3.6e-119:
		tmp = 4.0 * y
	elif z <= -1.5e-181:
		tmp = x * -3.0
	elif z <= -3.2e-275:
		tmp = 4.0 * y
	elif z <= 4.9e-269:
		tmp = x * -3.0
	elif z <= 0.66:
		tmp = 4.0 * y
	elif (z <= 2.35e+113) or (not (z <= 7e+206) and (z <= 7.4e+245)):
		tmp = t_0
	else:
		tmp = 6.0 * (x * z)
	return tmp
function code(x, y, z)
	t_0 = Float64(-6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -3.7e-5)
		tmp = t_0;
	elseif (z <= -3.6e-119)
		tmp = Float64(4.0 * y);
	elseif (z <= -1.5e-181)
		tmp = Float64(x * -3.0);
	elseif (z <= -3.2e-275)
		tmp = Float64(4.0 * y);
	elseif (z <= 4.9e-269)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.66)
		tmp = Float64(4.0 * y);
	elseif ((z <= 2.35e+113) || (!(z <= 7e+206) && (z <= 7.4e+245)))
		tmp = t_0;
	else
		tmp = Float64(6.0 * Float64(x * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = -6.0 * (y * z);
	tmp = 0.0;
	if (z <= -3.7e-5)
		tmp = t_0;
	elseif (z <= -3.6e-119)
		tmp = 4.0 * y;
	elseif (z <= -1.5e-181)
		tmp = x * -3.0;
	elseif (z <= -3.2e-275)
		tmp = 4.0 * y;
	elseif (z <= 4.9e-269)
		tmp = x * -3.0;
	elseif (z <= 0.66)
		tmp = 4.0 * y;
	elseif ((z <= 2.35e+113) || (~((z <= 7e+206)) && (z <= 7.4e+245)))
		tmp = t_0;
	else
		tmp = 6.0 * (x * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.7e-5], t$95$0, If[LessEqual[z, -3.6e-119], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -1.5e-181], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -3.2e-275], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 4.9e-269], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.66], N[(4.0 * y), $MachinePrecision], If[Or[LessEqual[z, 2.35e+113], And[N[Not[LessEqual[z, 7e+206]], $MachinePrecision], LessEqual[z, 7.4e+245]]], t$95$0, N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq -1.5 \cdot 10^{-181}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -3.2 \cdot 10^{-275}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq 4.9 \cdot 10^{-269}:\\
\;\;\;\;x \cdot -3\\

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

\mathbf{elif}\;z \leq 2.35 \cdot 10^{+113} \lor \neg \left(z \leq 7 \cdot 10^{+206}\right) \land z \leq 7.4 \cdot 10^{+245}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -3.69999999999999981e-5 or 0.660000000000000031 < z < 2.3499999999999999e113 or 7.00000000000000027e206 < z < 7.4000000000000002e245

    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.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 x around 0 65.7%

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

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

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

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

    if -3.69999999999999981e-5 < z < -3.6e-119 or -1.49999999999999987e-181 < z < -3.2e-275 or 4.89999999999999999e-269 < z < 0.660000000000000031

    1. Initial program 99.4%

      \[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 x around 0 63.6%

      \[\leadsto \color{blue}{4 \cdot y + -6 \cdot \left(y \cdot z\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.6e-119 < z < -1.49999999999999987e-181 or -3.2e-275 < z < 4.89999999999999999e-269

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.3499999999999999e113 < z < 7.00000000000000027e206 or 7.4000000000000002e245 < 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.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.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{-5}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -3.6 \cdot 10^{-119}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{-181}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-269}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.35 \cdot 10^{+113} \lor \neg \left(z \leq 7 \cdot 10^{+206}\right) \land z \leq 7.4 \cdot 10^{+245}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]

Alternative 3: 51.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -3.7 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-119}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -9.2 \cdot 10^{-182}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-268}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{+112} \lor \neg \left(z \leq 7.5 \cdot 10^{+206}\right) \land z \leq 3.4 \cdot 10^{+250}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -6.0 (* y z))))
   (if (<= z -3.7e-5)
     t_0
     (if (<= z -2.5e-119)
       (* 4.0 y)
       (if (<= z -9.2e-182)
         (* x -3.0)
         (if (<= z -6.5e-275)
           (* 4.0 y)
           (if (<= z 2.4e-268)
             (* x -3.0)
             (if (<= z 0.66)
               (* 4.0 y)
               (if (or (<= z 4.2e+112)
                       (and (not (<= z 7.5e+206)) (<= z 3.4e+250)))
                 t_0
                 (* x (* z 6.0)))))))))))
double code(double x, double y, double z) {
	double t_0 = -6.0 * (y * z);
	double tmp;
	if (z <= -3.7e-5) {
		tmp = t_0;
	} else if (z <= -2.5e-119) {
		tmp = 4.0 * y;
	} else if (z <= -9.2e-182) {
		tmp = x * -3.0;
	} else if (z <= -6.5e-275) {
		tmp = 4.0 * y;
	} else if (z <= 2.4e-268) {
		tmp = x * -3.0;
	} else if (z <= 0.66) {
		tmp = 4.0 * y;
	} else if ((z <= 4.2e+112) || (!(z <= 7.5e+206) && (z <= 3.4e+250))) {
		tmp = t_0;
	} else {
		tmp = x * (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 * z)
    if (z <= (-3.7d-5)) then
        tmp = t_0
    else if (z <= (-2.5d-119)) then
        tmp = 4.0d0 * y
    else if (z <= (-9.2d-182)) then
        tmp = x * (-3.0d0)
    else if (z <= (-6.5d-275)) then
        tmp = 4.0d0 * y
    else if (z <= 2.4d-268) then
        tmp = x * (-3.0d0)
    else if (z <= 0.66d0) then
        tmp = 4.0d0 * y
    else if ((z <= 4.2d+112) .or. (.not. (z <= 7.5d+206)) .and. (z <= 3.4d+250)) then
        tmp = t_0
    else
        tmp = x * (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 * z);
	double tmp;
	if (z <= -3.7e-5) {
		tmp = t_0;
	} else if (z <= -2.5e-119) {
		tmp = 4.0 * y;
	} else if (z <= -9.2e-182) {
		tmp = x * -3.0;
	} else if (z <= -6.5e-275) {
		tmp = 4.0 * y;
	} else if (z <= 2.4e-268) {
		tmp = x * -3.0;
	} else if (z <= 0.66) {
		tmp = 4.0 * y;
	} else if ((z <= 4.2e+112) || (!(z <= 7.5e+206) && (z <= 3.4e+250))) {
		tmp = t_0;
	} else {
		tmp = x * (z * 6.0);
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -6.0 * (y * z)
	tmp = 0
	if z <= -3.7e-5:
		tmp = t_0
	elif z <= -2.5e-119:
		tmp = 4.0 * y
	elif z <= -9.2e-182:
		tmp = x * -3.0
	elif z <= -6.5e-275:
		tmp = 4.0 * y
	elif z <= 2.4e-268:
		tmp = x * -3.0
	elif z <= 0.66:
		tmp = 4.0 * y
	elif (z <= 4.2e+112) or (not (z <= 7.5e+206) and (z <= 3.4e+250)):
		tmp = t_0
	else:
		tmp = x * (z * 6.0)
	return tmp
function code(x, y, z)
	t_0 = Float64(-6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -3.7e-5)
		tmp = t_0;
	elseif (z <= -2.5e-119)
		tmp = Float64(4.0 * y);
	elseif (z <= -9.2e-182)
		tmp = Float64(x * -3.0);
	elseif (z <= -6.5e-275)
		tmp = Float64(4.0 * y);
	elseif (z <= 2.4e-268)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.66)
		tmp = Float64(4.0 * y);
	elseif ((z <= 4.2e+112) || (!(z <= 7.5e+206) && (z <= 3.4e+250)))
		tmp = t_0;
	else
		tmp = Float64(x * Float64(z * 6.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = -6.0 * (y * z);
	tmp = 0.0;
	if (z <= -3.7e-5)
		tmp = t_0;
	elseif (z <= -2.5e-119)
		tmp = 4.0 * y;
	elseif (z <= -9.2e-182)
		tmp = x * -3.0;
	elseif (z <= -6.5e-275)
		tmp = 4.0 * y;
	elseif (z <= 2.4e-268)
		tmp = x * -3.0;
	elseif (z <= 0.66)
		tmp = 4.0 * y;
	elseif ((z <= 4.2e+112) || (~((z <= 7.5e+206)) && (z <= 3.4e+250)))
		tmp = t_0;
	else
		tmp = x * (z * 6.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, -3.7e-5], t$95$0, If[LessEqual[z, -2.5e-119], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -9.2e-182], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -6.5e-275], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 2.4e-268], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.66], N[(4.0 * y), $MachinePrecision], If[Or[LessEqual[z, 4.2e+112], And[N[Not[LessEqual[z, 7.5e+206]], $MachinePrecision], LessEqual[z, 3.4e+250]]], t$95$0, N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq -9.2 \cdot 10^{-182}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -6.5 \cdot 10^{-275}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq 2.4 \cdot 10^{-268}:\\
\;\;\;\;x \cdot -3\\

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

\mathbf{elif}\;z \leq 4.2 \cdot 10^{+112} \lor \neg \left(z \leq 7.5 \cdot 10^{+206}\right) \land z \leq 3.4 \cdot 10^{+250}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -3.69999999999999981e-5 or 0.660000000000000031 < z < 4.1999999999999998e112 or 7.49999999999999958e206 < z < 3.39999999999999973e250

    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.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 x around 0 65.7%

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

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

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

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

    if -3.69999999999999981e-5 < z < -2.49999999999999996e-119 or -9.1999999999999996e-182 < z < -6.500000000000001e-275 or 2.3999999999999999e-268 < z < 0.660000000000000031

    1. Initial program 99.4%

      \[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 x around 0 63.6%

      \[\leadsto \color{blue}{4 \cdot y + -6 \cdot \left(y \cdot z\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 -2.49999999999999996e-119 < z < -9.1999999999999996e-182 or -6.500000000000001e-275 < z < 2.3999999999999999e-268

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.1999999999999998e112 < z < 7.49999999999999958e206 or 3.39999999999999973e250 < 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 x around inf 83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{-5}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-119}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -9.2 \cdot 10^{-182}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -6.5 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-268}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{+112} \lor \neg \left(z \leq 7.5 \cdot 10^{+206}\right) \land z \leq 3.4 \cdot 10^{+250}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \end{array} \]

Alternative 4: 51.4% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{-5}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-120}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-182}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-267}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+114} \lor \neg \left(z \leq 6.4 \cdot 10^{+206}\right) \land z \leq 2.2 \cdot 10^{+247}:\\ \;\;\;\;z \cdot \left(y \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -3.7e-5)
   (* -6.0 (* y z))
   (if (<= z -9.5e-120)
     (* 4.0 y)
     (if (<= z -3.3e-182)
       (* x -3.0)
       (if (<= z -3e-275)
         (* 4.0 y)
         (if (<= z 1.1e-267)
           (* x -3.0)
           (if (<= z 0.66)
             (* 4.0 y)
             (if (or (<= z 1.2e+114)
                     (and (not (<= z 6.4e+206)) (<= z 2.2e+247)))
               (* z (* y -6.0))
               (* x (* z 6.0))))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -3.7e-5) {
		tmp = -6.0 * (y * z);
	} else if (z <= -9.5e-120) {
		tmp = 4.0 * y;
	} else if (z <= -3.3e-182) {
		tmp = x * -3.0;
	} else if (z <= -3e-275) {
		tmp = 4.0 * y;
	} else if (z <= 1.1e-267) {
		tmp = x * -3.0;
	} else if (z <= 0.66) {
		tmp = 4.0 * y;
	} else if ((z <= 1.2e+114) || (!(z <= 6.4e+206) && (z <= 2.2e+247))) {
		tmp = z * (y * -6.0);
	} else {
		tmp = x * (z * 6.0);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-3.7d-5)) then
        tmp = (-6.0d0) * (y * z)
    else if (z <= (-9.5d-120)) then
        tmp = 4.0d0 * y
    else if (z <= (-3.3d-182)) then
        tmp = x * (-3.0d0)
    else if (z <= (-3d-275)) then
        tmp = 4.0d0 * y
    else if (z <= 1.1d-267) then
        tmp = x * (-3.0d0)
    else if (z <= 0.66d0) then
        tmp = 4.0d0 * y
    else if ((z <= 1.2d+114) .or. (.not. (z <= 6.4d+206)) .and. (z <= 2.2d+247)) then
        tmp = z * (y * (-6.0d0))
    else
        tmp = x * (z * 6.0d0)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -3.7e-5) {
		tmp = -6.0 * (y * z);
	} else if (z <= -9.5e-120) {
		tmp = 4.0 * y;
	} else if (z <= -3.3e-182) {
		tmp = x * -3.0;
	} else if (z <= -3e-275) {
		tmp = 4.0 * y;
	} else if (z <= 1.1e-267) {
		tmp = x * -3.0;
	} else if (z <= 0.66) {
		tmp = 4.0 * y;
	} else if ((z <= 1.2e+114) || (!(z <= 6.4e+206) && (z <= 2.2e+247))) {
		tmp = z * (y * -6.0);
	} else {
		tmp = x * (z * 6.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -3.7e-5:
		tmp = -6.0 * (y * z)
	elif z <= -9.5e-120:
		tmp = 4.0 * y
	elif z <= -3.3e-182:
		tmp = x * -3.0
	elif z <= -3e-275:
		tmp = 4.0 * y
	elif z <= 1.1e-267:
		tmp = x * -3.0
	elif z <= 0.66:
		tmp = 4.0 * y
	elif (z <= 1.2e+114) or (not (z <= 6.4e+206) and (z <= 2.2e+247)):
		tmp = z * (y * -6.0)
	else:
		tmp = x * (z * 6.0)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -3.7e-5)
		tmp = Float64(-6.0 * Float64(y * z));
	elseif (z <= -9.5e-120)
		tmp = Float64(4.0 * y);
	elseif (z <= -3.3e-182)
		tmp = Float64(x * -3.0);
	elseif (z <= -3e-275)
		tmp = Float64(4.0 * y);
	elseif (z <= 1.1e-267)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.66)
		tmp = Float64(4.0 * y);
	elseif ((z <= 1.2e+114) || (!(z <= 6.4e+206) && (z <= 2.2e+247)))
		tmp = Float64(z * Float64(y * -6.0));
	else
		tmp = Float64(x * Float64(z * 6.0));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -3.7e-5)
		tmp = -6.0 * (y * z);
	elseif (z <= -9.5e-120)
		tmp = 4.0 * y;
	elseif (z <= -3.3e-182)
		tmp = x * -3.0;
	elseif (z <= -3e-275)
		tmp = 4.0 * y;
	elseif (z <= 1.1e-267)
		tmp = x * -3.0;
	elseif (z <= 0.66)
		tmp = 4.0 * y;
	elseif ((z <= 1.2e+114) || (~((z <= 6.4e+206)) && (z <= 2.2e+247)))
		tmp = z * (y * -6.0);
	else
		tmp = x * (z * 6.0);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -3.7e-5], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -9.5e-120], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -3.3e-182], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -3e-275], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 1.1e-267], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.66], N[(4.0 * y), $MachinePrecision], If[Or[LessEqual[z, 1.2e+114], And[N[Not[LessEqual[z, 6.4e+206]], $MachinePrecision], LessEqual[z, 2.2e+247]]], N[(z * N[(y * -6.0), $MachinePrecision]), $MachinePrecision], N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;z \leq -3 \cdot 10^{-275}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{-267}:\\
\;\;\;\;x \cdot -3\\

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

\mathbf{elif}\;z \leq 1.2 \cdot 10^{+114} \lor \neg \left(z \leq 6.4 \cdot 10^{+206}\right) \land z \leq 2.2 \cdot 10^{+247}:\\
\;\;\;\;z \cdot \left(y \cdot -6\right)\\

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


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

    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 x around 0 62.3%

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

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

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

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

    if -3.69999999999999981e-5 < z < -9.49999999999999937e-120 or -3.29999999999999996e-182 < z < -3e-275 or 1.09999999999999994e-267 < z < 0.660000000000000031

    1. Initial program 99.4%

      \[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 x around 0 63.6%

      \[\leadsto \color{blue}{4 \cdot y + -6 \cdot \left(y \cdot z\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 -9.49999999999999937e-120 < z < -3.29999999999999996e-182 or -3e-275 < z < 1.09999999999999994e-267

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.660000000000000031 < z < 1.2e114 or 6.40000000000000011e206 < z < 2.20000000000000011e247

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

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

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

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

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

    if 1.2e114 < z < 6.40000000000000011e206 or 2.20000000000000011e247 < 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 x around inf 83.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{-5}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-120}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-182}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-267}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+114} \lor \neg \left(z \leq 6.4 \cdot 10^{+206}\right) \land z \leq 2.2 \cdot 10^{+247}:\\ \;\;\;\;z \cdot \left(y \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \end{array} \]

Alternative 5: 74.6% 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 -3.6 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-119}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{-182}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-269}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;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 -3.6e-5)
     t_0
     (if (<= z -4e-119)
       (* 4.0 y)
       (if (<= z -4.4e-182)
         (* x -3.0)
         (if (<= z -3.8e-275)
           (* 4.0 y)
           (if (<= z 5e-269) (* x -3.0) (if (<= z 0.5) (* 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 <= -3.6e-5) {
		tmp = t_0;
	} else if (z <= -4e-119) {
		tmp = 4.0 * y;
	} else if (z <= -4.4e-182) {
		tmp = x * -3.0;
	} else if (z <= -3.8e-275) {
		tmp = 4.0 * y;
	} else if (z <= 5e-269) {
		tmp = x * -3.0;
	} else if (z <= 0.5) {
		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 <= (-3.6d-5)) then
        tmp = t_0
    else if (z <= (-4d-119)) then
        tmp = 4.0d0 * y
    else if (z <= (-4.4d-182)) then
        tmp = x * (-3.0d0)
    else if (z <= (-3.8d-275)) then
        tmp = 4.0d0 * y
    else if (z <= 5d-269) then
        tmp = x * (-3.0d0)
    else if (z <= 0.5d0) 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 <= -3.6e-5) {
		tmp = t_0;
	} else if (z <= -4e-119) {
		tmp = 4.0 * y;
	} else if (z <= -4.4e-182) {
		tmp = x * -3.0;
	} else if (z <= -3.8e-275) {
		tmp = 4.0 * y;
	} else if (z <= 5e-269) {
		tmp = x * -3.0;
	} else if (z <= 0.5) {
		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 <= -3.6e-5:
		tmp = t_0
	elif z <= -4e-119:
		tmp = 4.0 * y
	elif z <= -4.4e-182:
		tmp = x * -3.0
	elif z <= -3.8e-275:
		tmp = 4.0 * y
	elif z <= 5e-269:
		tmp = x * -3.0
	elif z <= 0.5:
		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 <= -3.6e-5)
		tmp = t_0;
	elseif (z <= -4e-119)
		tmp = Float64(4.0 * y);
	elseif (z <= -4.4e-182)
		tmp = Float64(x * -3.0);
	elseif (z <= -3.8e-275)
		tmp = Float64(4.0 * y);
	elseif (z <= 5e-269)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.5)
		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 <= -3.6e-5)
		tmp = t_0;
	elseif (z <= -4e-119)
		tmp = 4.0 * y;
	elseif (z <= -4.4e-182)
		tmp = x * -3.0;
	elseif (z <= -3.8e-275)
		tmp = 4.0 * y;
	elseif (z <= 5e-269)
		tmp = x * -3.0;
	elseif (z <= 0.5)
		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, -3.6e-5], t$95$0, If[LessEqual[z, -4e-119], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -4.4e-182], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -3.8e-275], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 5e-269], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.5], 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 -3.6 \cdot 10^{-5}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;z \leq -4.4 \cdot 10^{-182}:\\
\;\;\;\;x \cdot -3\\

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

\mathbf{elif}\;z \leq 5 \cdot 10^{-269}:\\
\;\;\;\;x \cdot -3\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.60000000000000009e-5 or 0.5 < 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.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 96.3%

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

    if -3.60000000000000009e-5 < z < -4.00000000000000005e-119 or -4.3999999999999999e-182 < z < -3.79999999999999972e-275 or 4.99999999999999979e-269 < z < 0.5

    1. Initial program 99.4%

      \[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 x around 0 63.6%

      \[\leadsto \color{blue}{4 \cdot y + -6 \cdot \left(y \cdot z\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 -4.00000000000000005e-119 < z < -4.3999999999999999e-182 or -3.79999999999999972e-275 < z < 4.99999999999999979e-269

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.6 \cdot 10^{-5}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-119}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{-182}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-269}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \]

Alternative 6: 74.9% 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 -4.1 \cdot 10^{+14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-119}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-181}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-269}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 145000000:\\ \;\;\;\;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 -4.1e+14)
     t_1
     (if (<= z -4e-119)
       t_0
       (if (<= z -1.75e-181)
         (* x -3.0)
         (if (<= z -8.5e-275)
           (* 4.0 y)
           (if (<= z 4.2e-269)
             (* x -3.0)
             (if (<= z 145000000.0) 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 <= -4.1e+14) {
		tmp = t_1;
	} else if (z <= -4e-119) {
		tmp = t_0;
	} else if (z <= -1.75e-181) {
		tmp = x * -3.0;
	} else if (z <= -8.5e-275) {
		tmp = 4.0 * y;
	} else if (z <= 4.2e-269) {
		tmp = x * -3.0;
	} else if (z <= 145000000.0) {
		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 <= (-4.1d+14)) then
        tmp = t_1
    else if (z <= (-4d-119)) then
        tmp = t_0
    else if (z <= (-1.75d-181)) then
        tmp = x * (-3.0d0)
    else if (z <= (-8.5d-275)) then
        tmp = 4.0d0 * y
    else if (z <= 4.2d-269) then
        tmp = x * (-3.0d0)
    else if (z <= 145000000.0d0) 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 <= -4.1e+14) {
		tmp = t_1;
	} else if (z <= -4e-119) {
		tmp = t_0;
	} else if (z <= -1.75e-181) {
		tmp = x * -3.0;
	} else if (z <= -8.5e-275) {
		tmp = 4.0 * y;
	} else if (z <= 4.2e-269) {
		tmp = x * -3.0;
	} else if (z <= 145000000.0) {
		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 <= -4.1e+14:
		tmp = t_1
	elif z <= -4e-119:
		tmp = t_0
	elif z <= -1.75e-181:
		tmp = x * -3.0
	elif z <= -8.5e-275:
		tmp = 4.0 * y
	elif z <= 4.2e-269:
		tmp = x * -3.0
	elif z <= 145000000.0:
		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 <= -4.1e+14)
		tmp = t_1;
	elseif (z <= -4e-119)
		tmp = t_0;
	elseif (z <= -1.75e-181)
		tmp = Float64(x * -3.0);
	elseif (z <= -8.5e-275)
		tmp = Float64(4.0 * y);
	elseif (z <= 4.2e-269)
		tmp = Float64(x * -3.0);
	elseif (z <= 145000000.0)
		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 <= -4.1e+14)
		tmp = t_1;
	elseif (z <= -4e-119)
		tmp = t_0;
	elseif (z <= -1.75e-181)
		tmp = x * -3.0;
	elseif (z <= -8.5e-275)
		tmp = 4.0 * y;
	elseif (z <= 4.2e-269)
		tmp = x * -3.0;
	elseif (z <= 145000000.0)
		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, -4.1e+14], t$95$1, If[LessEqual[z, -4e-119], t$95$0, If[LessEqual[z, -1.75e-181], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -8.5e-275], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 4.2e-269], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 145000000.0], 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 -4.1 \cdot 10^{+14}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq -4 \cdot 10^{-119}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -1.75 \cdot 10^{-181}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -8.5 \cdot 10^{-275}:\\
\;\;\;\;4 \cdot y\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -4.1e14 or 1.45e8 < 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.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.6%

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

    if -4.1e14 < z < -4.00000000000000005e-119 or 4.20000000000000009e-269 < z < 1.45e8

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

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

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

    if -4.00000000000000005e-119 < z < -1.74999999999999998e-181 or -8.49999999999999952e-275 < z < 4.20000000000000009e-269

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.74999999999999998e-181 < z < -8.49999999999999952e-275

    1. Initial program 99.1%

      \[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 x around 0 67.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.1 \cdot 10^{+14}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-119}:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{elif}\;z \leq -1.75 \cdot 10^{-181}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-269}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 145000000:\\ \;\;\;\;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: 51.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -3.7 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-119}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -4.7 \cdot 10^{-181}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{-269}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;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 -3.7e-5)
     t_0
     (if (<= z -1e-119)
       (* 4.0 y)
       (if (<= z -4.7e-181)
         (* x -3.0)
         (if (<= z -3.2e-275)
           (* 4.0 y)
           (if (<= z 7.6e-269) (* x -3.0) (if (<= z 0.66) (* 4.0 y) t_0))))))))
double code(double x, double y, double z) {
	double t_0 = -6.0 * (y * z);
	double tmp;
	if (z <= -3.7e-5) {
		tmp = t_0;
	} else if (z <= -1e-119) {
		tmp = 4.0 * y;
	} else if (z <= -4.7e-181) {
		tmp = x * -3.0;
	} else if (z <= -3.2e-275) {
		tmp = 4.0 * y;
	} else if (z <= 7.6e-269) {
		tmp = x * -3.0;
	} else if (z <= 0.66) {
		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 <= (-3.7d-5)) then
        tmp = t_0
    else if (z <= (-1d-119)) then
        tmp = 4.0d0 * y
    else if (z <= (-4.7d-181)) then
        tmp = x * (-3.0d0)
    else if (z <= (-3.2d-275)) then
        tmp = 4.0d0 * y
    else if (z <= 7.6d-269) then
        tmp = x * (-3.0d0)
    else if (z <= 0.66d0) 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 <= -3.7e-5) {
		tmp = t_0;
	} else if (z <= -1e-119) {
		tmp = 4.0 * y;
	} else if (z <= -4.7e-181) {
		tmp = x * -3.0;
	} else if (z <= -3.2e-275) {
		tmp = 4.0 * y;
	} else if (z <= 7.6e-269) {
		tmp = x * -3.0;
	} else if (z <= 0.66) {
		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 <= -3.7e-5:
		tmp = t_0
	elif z <= -1e-119:
		tmp = 4.0 * y
	elif z <= -4.7e-181:
		tmp = x * -3.0
	elif z <= -3.2e-275:
		tmp = 4.0 * y
	elif z <= 7.6e-269:
		tmp = x * -3.0
	elif z <= 0.66:
		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 <= -3.7e-5)
		tmp = t_0;
	elseif (z <= -1e-119)
		tmp = Float64(4.0 * y);
	elseif (z <= -4.7e-181)
		tmp = Float64(x * -3.0);
	elseif (z <= -3.2e-275)
		tmp = Float64(4.0 * y);
	elseif (z <= 7.6e-269)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.66)
		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 <= -3.7e-5)
		tmp = t_0;
	elseif (z <= -1e-119)
		tmp = 4.0 * y;
	elseif (z <= -4.7e-181)
		tmp = x * -3.0;
	elseif (z <= -3.2e-275)
		tmp = 4.0 * y;
	elseif (z <= 7.6e-269)
		tmp = x * -3.0;
	elseif (z <= 0.66)
		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, -3.7e-5], t$95$0, If[LessEqual[z, -1e-119], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, -4.7e-181], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -3.2e-275], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 7.6e-269], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.66], 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 -3.7 \cdot 10^{-5}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq -1 \cdot 10^{-119}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq -4.7 \cdot 10^{-181}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;z \leq -3.2 \cdot 10^{-275}:\\
\;\;\;\;4 \cdot y\\

\mathbf{elif}\;z \leq 7.6 \cdot 10^{-269}:\\
\;\;\;\;x \cdot -3\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.69999999999999981e-5 or 0.660000000000000031 < 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.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 x around 0 56.8%

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

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

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

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

    if -3.69999999999999981e-5 < z < -1.00000000000000001e-119 or -4.6999999999999998e-181 < z < -3.2e-275 or 7.6000000000000005e-269 < z < 0.660000000000000031

    1. Initial program 99.4%

      \[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 x around 0 63.6%

      \[\leadsto \color{blue}{4 \cdot y + -6 \cdot \left(y \cdot z\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 -1.00000000000000001e-119 < z < -4.6999999999999998e-181 or -3.2e-275 < z < 7.6000000000000005e-269

    1. Initial program 99.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{-5}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-119}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq -4.7 \cdot 10^{-181}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-275}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{-269}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \end{array} \]

Alternative 8: 75.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ t_1 := x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{if}\;x \leq -3.6 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -20000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-54}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;x \leq 51000000000:\\ \;\;\;\;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 (* x (+ -3.0 (* z 6.0)))))
   (if (<= x -3.6e+40)
     t_1
     (if (<= x -20000.0)
       t_0
       (if (<= x -3.8e-54)
         (* -6.0 (* (- y x) z))
         (if (<= x 51000000000.0) t_0 t_1))))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (y * (0.6666666666666666 - z));
	double t_1 = x * (-3.0 + (z * 6.0));
	double tmp;
	if (x <= -3.6e+40) {
		tmp = t_1;
	} else if (x <= -20000.0) {
		tmp = t_0;
	} else if (x <= -3.8e-54) {
		tmp = -6.0 * ((y - x) * z);
	} else if (x <= 51000000000.0) {
		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 = x * ((-3.0d0) + (z * 6.0d0))
    if (x <= (-3.6d+40)) then
        tmp = t_1
    else if (x <= (-20000.0d0)) then
        tmp = t_0
    else if (x <= (-3.8d-54)) then
        tmp = (-6.0d0) * ((y - x) * z)
    else if (x <= 51000000000.0d0) 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 = x * (-3.0 + (z * 6.0));
	double tmp;
	if (x <= -3.6e+40) {
		tmp = t_1;
	} else if (x <= -20000.0) {
		tmp = t_0;
	} else if (x <= -3.8e-54) {
		tmp = -6.0 * ((y - x) * z);
	} else if (x <= 51000000000.0) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 6.0 * (y * (0.6666666666666666 - z))
	t_1 = x * (-3.0 + (z * 6.0))
	tmp = 0
	if x <= -3.6e+40:
		tmp = t_1
	elif x <= -20000.0:
		tmp = t_0
	elif x <= -3.8e-54:
		tmp = -6.0 * ((y - x) * z)
	elif x <= 51000000000.0:
		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(x * Float64(-3.0 + Float64(z * 6.0)))
	tmp = 0.0
	if (x <= -3.6e+40)
		tmp = t_1;
	elseif (x <= -20000.0)
		tmp = t_0;
	elseif (x <= -3.8e-54)
		tmp = Float64(-6.0 * Float64(Float64(y - x) * z));
	elseif (x <= 51000000000.0)
		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 = x * (-3.0 + (z * 6.0));
	tmp = 0.0;
	if (x <= -3.6e+40)
		tmp = t_1;
	elseif (x <= -20000.0)
		tmp = t_0;
	elseif (x <= -3.8e-54)
		tmp = -6.0 * ((y - x) * z);
	elseif (x <= 51000000000.0)
		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[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.6e+40], t$95$1, If[LessEqual[x, -20000.0], t$95$0, If[LessEqual[x, -3.8e-54], N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 51000000000.0], 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 := x \cdot \left(-3 + z \cdot 6\right)\\
\mathbf{if}\;x \leq -3.6 \cdot 10^{+40}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -20000:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 51000000000:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.59999999999999996e40 or 5.1e10 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.59999999999999996e40 < x < -2e4 or -3.8000000000000002e-54 < x < 5.1e10

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

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

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

    if -2e4 < x < -3.8000000000000002e-54

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

      \[\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 90.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+40}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{elif}\;x \leq -20000:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-54}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;x \leq 51000000000:\\ \;\;\;\;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.9% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(4 + -6 \cdot z\right)\\ t_1 := x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{if}\;x \leq -1.55 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1100:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-54}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;x \leq 31500000000:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (+ 4.0 (* -6.0 z)))) (t_1 (* x (+ -3.0 (* z 6.0)))))
   (if (<= x -1.55e+41)
     t_1
     (if (<= x -1100.0)
       t_0
       (if (<= x -1.4e-54)
         (* -6.0 (* (- y x) z))
         (if (<= x 31500000000.0) t_0 t_1))))))
double code(double x, double y, double z) {
	double t_0 = y * (4.0 + (-6.0 * z));
	double t_1 = x * (-3.0 + (z * 6.0));
	double tmp;
	if (x <= -1.55e+41) {
		tmp = t_1;
	} else if (x <= -1100.0) {
		tmp = t_0;
	} else if (x <= -1.4e-54) {
		tmp = -6.0 * ((y - x) * z);
	} else if (x <= 31500000000.0) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = y * (4.0d0 + ((-6.0d0) * z))
    t_1 = x * ((-3.0d0) + (z * 6.0d0))
    if (x <= (-1.55d+41)) then
        tmp = t_1
    else if (x <= (-1100.0d0)) then
        tmp = t_0
    else if (x <= (-1.4d-54)) then
        tmp = (-6.0d0) * ((y - x) * z)
    else if (x <= 31500000000.0d0) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (4.0 + (-6.0 * z));
	double t_1 = x * (-3.0 + (z * 6.0));
	double tmp;
	if (x <= -1.55e+41) {
		tmp = t_1;
	} else if (x <= -1100.0) {
		tmp = t_0;
	} else if (x <= -1.4e-54) {
		tmp = -6.0 * ((y - x) * z);
	} else if (x <= 31500000000.0) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (4.0 + (-6.0 * z))
	t_1 = x * (-3.0 + (z * 6.0))
	tmp = 0
	if x <= -1.55e+41:
		tmp = t_1
	elif x <= -1100.0:
		tmp = t_0
	elif x <= -1.4e-54:
		tmp = -6.0 * ((y - x) * z)
	elif x <= 31500000000.0:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(4.0 + Float64(-6.0 * z)))
	t_1 = Float64(x * Float64(-3.0 + Float64(z * 6.0)))
	tmp = 0.0
	if (x <= -1.55e+41)
		tmp = t_1;
	elseif (x <= -1100.0)
		tmp = t_0;
	elseif (x <= -1.4e-54)
		tmp = Float64(-6.0 * Float64(Float64(y - x) * z));
	elseif (x <= 31500000000.0)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (4.0 + (-6.0 * z));
	t_1 = x * (-3.0 + (z * 6.0));
	tmp = 0.0;
	if (x <= -1.55e+41)
		tmp = t_1;
	elseif (x <= -1100.0)
		tmp = t_0;
	elseif (x <= -1.4e-54)
		tmp = -6.0 * ((y - x) * z);
	elseif (x <= 31500000000.0)
		tmp = t_0;
	else
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(x * N[(-3.0 + N[(z * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.55e+41], t$95$1, If[LessEqual[x, -1100.0], t$95$0, If[LessEqual[x, -1.4e-54], N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 31500000000.0], t$95$0, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -1100:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 31500000000:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.55e41 or 3.15e10 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55e41 < x < -1100 or -1.4000000000000001e-54 < x < 3.15e10

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1100 < x < -1.4000000000000001e-54

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

      \[\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 90.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{+41}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{elif}\;x \leq -1100:\\ \;\;\;\;y \cdot \left(4 + -6 \cdot z\right)\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-54}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;x \leq 31500000000:\\ \;\;\;\;y \cdot \left(4 + -6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \]

Alternative 10: 97.8% accurate, 1.2× speedup?

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

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

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

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


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

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

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

    if -0.57999999999999996 < z < 0.5

    1. Initial program 99.4%

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

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

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

    if 0.5 < z

    1. Initial program 99.7%

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

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

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

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

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

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

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

Alternative 11: 99.5% accurate, 1.2× speedup?

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

\\
x + \left(0.6666666666666666 - z\right) \cdot \left(\left(y - x\right) \cdot 6\right)
\end{array}
Derivation
  1. Initial program 99.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: 38.7% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;x \leq 3000000000000:\\
\;\;\;\;4 \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -3.5e19 or 3e12 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.5e19 < x < 3e12

    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. Taylor expanded in x around 0 79.6%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{+19}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;x \leq 3000000000000:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot -3\\ \end{array} \]

Alternative 14: 26.0% 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 47.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto x \cdot -3 \]

Reproduce

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