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

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

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 99.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 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.5%

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

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

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

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

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

Alternative 2: 49.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -2.4 \cdot 10^{-16}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -6.3 \cdot 10^{-257}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-287}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 5.1 \cdot 10^{-306}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-104}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+156} \lor \neg \left(z \leq 1.75 \cdot 10^{+239}\right):\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* x z))))
   (if (<= z -2.4e-16)
     t_0
     (if (<= z -6.3e-257)
       (* x -3.0)
       (if (<= z -2.6e-287)
         (* y 4.0)
         (if (<= z 5.1e-306)
           (* x -3.0)
           (if (<= z 4.5e-104)
             (* y 4.0)
             (if (<= z 0.5)
               (* x -3.0)
               (if (or (<= z 4.8e+156) (not (<= z 1.75e+239)))
                 (* -6.0 (* y z))
                 t_0)))))))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (x * z);
	double tmp;
	if (z <= -2.4e-16) {
		tmp = t_0;
	} else if (z <= -6.3e-257) {
		tmp = x * -3.0;
	} else if (z <= -2.6e-287) {
		tmp = y * 4.0;
	} else if (z <= 5.1e-306) {
		tmp = x * -3.0;
	} else if (z <= 4.5e-104) {
		tmp = y * 4.0;
	} else if (z <= 0.5) {
		tmp = x * -3.0;
	} else if ((z <= 4.8e+156) || !(z <= 1.75e+239)) {
		tmp = -6.0 * (y * z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 6.0d0 * (x * z)
    if (z <= (-2.4d-16)) then
        tmp = t_0
    else if (z <= (-6.3d-257)) then
        tmp = x * (-3.0d0)
    else if (z <= (-2.6d-287)) then
        tmp = y * 4.0d0
    else if (z <= 5.1d-306) then
        tmp = x * (-3.0d0)
    else if (z <= 4.5d-104) then
        tmp = y * 4.0d0
    else if (z <= 0.5d0) then
        tmp = x * (-3.0d0)
    else if ((z <= 4.8d+156) .or. (.not. (z <= 1.75d+239))) then
        tmp = (-6.0d0) * (y * z)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = 6.0 * (x * z);
	double tmp;
	if (z <= -2.4e-16) {
		tmp = t_0;
	} else if (z <= -6.3e-257) {
		tmp = x * -3.0;
	} else if (z <= -2.6e-287) {
		tmp = y * 4.0;
	} else if (z <= 5.1e-306) {
		tmp = x * -3.0;
	} else if (z <= 4.5e-104) {
		tmp = y * 4.0;
	} else if (z <= 0.5) {
		tmp = x * -3.0;
	} else if ((z <= 4.8e+156) || !(z <= 1.75e+239)) {
		tmp = -6.0 * (y * z);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 6.0 * (x * z)
	tmp = 0
	if z <= -2.4e-16:
		tmp = t_0
	elif z <= -6.3e-257:
		tmp = x * -3.0
	elif z <= -2.6e-287:
		tmp = y * 4.0
	elif z <= 5.1e-306:
		tmp = x * -3.0
	elif z <= 4.5e-104:
		tmp = y * 4.0
	elif z <= 0.5:
		tmp = x * -3.0
	elif (z <= 4.8e+156) or not (z <= 1.75e+239):
		tmp = -6.0 * (y * z)
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(6.0 * Float64(x * z))
	tmp = 0.0
	if (z <= -2.4e-16)
		tmp = t_0;
	elseif (z <= -6.3e-257)
		tmp = Float64(x * -3.0);
	elseif (z <= -2.6e-287)
		tmp = Float64(y * 4.0);
	elseif (z <= 5.1e-306)
		tmp = Float64(x * -3.0);
	elseif (z <= 4.5e-104)
		tmp = Float64(y * 4.0);
	elseif (z <= 0.5)
		tmp = Float64(x * -3.0);
	elseif ((z <= 4.8e+156) || !(z <= 1.75e+239))
		tmp = Float64(-6.0 * Float64(y * z));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = 6.0 * (x * z);
	tmp = 0.0;
	if (z <= -2.4e-16)
		tmp = t_0;
	elseif (z <= -6.3e-257)
		tmp = x * -3.0;
	elseif (z <= -2.6e-287)
		tmp = y * 4.0;
	elseif (z <= 5.1e-306)
		tmp = x * -3.0;
	elseif (z <= 4.5e-104)
		tmp = y * 4.0;
	elseif (z <= 0.5)
		tmp = x * -3.0;
	elseif ((z <= 4.8e+156) || ~((z <= 1.75e+239)))
		tmp = -6.0 * (y * z);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.4e-16], t$95$0, If[LessEqual[z, -6.3e-257], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -2.6e-287], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 5.1e-306], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 4.5e-104], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.5], N[(x * -3.0), $MachinePrecision], If[Or[LessEqual[z, 4.8e+156], N[Not[LessEqual[z, 1.75e+239]], $MachinePrecision]], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -6.3 \cdot 10^{-257}:\\
\;\;\;\;x \cdot -3\\

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

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

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

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

\mathbf{elif}\;z \leq 4.8 \cdot 10^{+156} \lor \neg \left(z \leq 1.75 \cdot 10^{+239}\right):\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -2.40000000000000005e-16 or 4.8000000000000002e156 < z < 1.7500000000000001e239

    1. Initial program 99.9%

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

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

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

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

    if -2.40000000000000005e-16 < z < -6.29999999999999993e-257 or -2.6e-287 < z < 5.09999999999999972e-306 or 4.4999999999999997e-104 < z < 0.5

    1. Initial program 99.2%

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

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

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

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

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

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

    if -6.29999999999999993e-257 < z < -2.6e-287 or 5.09999999999999972e-306 < z < 4.4999999999999997e-104

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.5 < z < 4.8000000000000002e156 or 1.7500000000000001e239 < z

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.4 \cdot 10^{-16}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -6.3 \cdot 10^{-257}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-287}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 5.1 \cdot 10^{-306}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-104}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{+156} \lor \neg \left(z \leq 1.75 \cdot 10^{+239}\right):\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]

Alternative 3: 49.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.4 \cdot 10^{-16}:\\ \;\;\;\;x \cdot \left(1 + 6 \cdot z\right)\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-260}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{-282}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-306}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-107}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+156} \lor \neg \left(z \leq 1.75 \cdot 10^{+239}\right):\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= z -2.4e-16)
   (* x (+ 1.0 (* 6.0 z)))
   (if (<= z -7e-260)
     (* x -3.0)
     (if (<= z -3.5e-282)
       (* y 4.0)
       (if (<= z 3.6e-306)
         (* x -3.0)
         (if (<= z 1.3e-107)
           (* y 4.0)
           (if (<= z 0.5)
             (* x -3.0)
             (if (or (<= z 9e+156) (not (<= z 1.75e+239)))
               (* -6.0 (* y z))
               (* 6.0 (* x z))))))))))
double code(double x, double y, double z) {
	double tmp;
	if (z <= -2.4e-16) {
		tmp = x * (1.0 + (6.0 * z));
	} else if (z <= -7e-260) {
		tmp = x * -3.0;
	} else if (z <= -3.5e-282) {
		tmp = y * 4.0;
	} else if (z <= 3.6e-306) {
		tmp = x * -3.0;
	} else if (z <= 1.3e-107) {
		tmp = y * 4.0;
	} else if (z <= 0.5) {
		tmp = x * -3.0;
	} else if ((z <= 9e+156) || !(z <= 1.75e+239)) {
		tmp = -6.0 * (y * z);
	} else {
		tmp = 6.0 * (x * z);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (z <= (-2.4d-16)) then
        tmp = x * (1.0d0 + (6.0d0 * z))
    else if (z <= (-7d-260)) then
        tmp = x * (-3.0d0)
    else if (z <= (-3.5d-282)) then
        tmp = y * 4.0d0
    else if (z <= 3.6d-306) then
        tmp = x * (-3.0d0)
    else if (z <= 1.3d-107) then
        tmp = y * 4.0d0
    else if (z <= 0.5d0) then
        tmp = x * (-3.0d0)
    else if ((z <= 9d+156) .or. (.not. (z <= 1.75d+239))) then
        tmp = (-6.0d0) * (y * z)
    else
        tmp = 6.0d0 * (x * z)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double tmp;
	if (z <= -2.4e-16) {
		tmp = x * (1.0 + (6.0 * z));
	} else if (z <= -7e-260) {
		tmp = x * -3.0;
	} else if (z <= -3.5e-282) {
		tmp = y * 4.0;
	} else if (z <= 3.6e-306) {
		tmp = x * -3.0;
	} else if (z <= 1.3e-107) {
		tmp = y * 4.0;
	} else if (z <= 0.5) {
		tmp = x * -3.0;
	} else if ((z <= 9e+156) || !(z <= 1.75e+239)) {
		tmp = -6.0 * (y * z);
	} else {
		tmp = 6.0 * (x * z);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if z <= -2.4e-16:
		tmp = x * (1.0 + (6.0 * z))
	elif z <= -7e-260:
		tmp = x * -3.0
	elif z <= -3.5e-282:
		tmp = y * 4.0
	elif z <= 3.6e-306:
		tmp = x * -3.0
	elif z <= 1.3e-107:
		tmp = y * 4.0
	elif z <= 0.5:
		tmp = x * -3.0
	elif (z <= 9e+156) or not (z <= 1.75e+239):
		tmp = -6.0 * (y * z)
	else:
		tmp = 6.0 * (x * z)
	return tmp
function code(x, y, z)
	tmp = 0.0
	if (z <= -2.4e-16)
		tmp = Float64(x * Float64(1.0 + Float64(6.0 * z)));
	elseif (z <= -7e-260)
		tmp = Float64(x * -3.0);
	elseif (z <= -3.5e-282)
		tmp = Float64(y * 4.0);
	elseif (z <= 3.6e-306)
		tmp = Float64(x * -3.0);
	elseif (z <= 1.3e-107)
		tmp = Float64(y * 4.0);
	elseif (z <= 0.5)
		tmp = Float64(x * -3.0);
	elseif ((z <= 9e+156) || !(z <= 1.75e+239))
		tmp = Float64(-6.0 * Float64(y * z));
	else
		tmp = Float64(6.0 * Float64(x * z));
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (z <= -2.4e-16)
		tmp = x * (1.0 + (6.0 * z));
	elseif (z <= -7e-260)
		tmp = x * -3.0;
	elseif (z <= -3.5e-282)
		tmp = y * 4.0;
	elseif (z <= 3.6e-306)
		tmp = x * -3.0;
	elseif (z <= 1.3e-107)
		tmp = y * 4.0;
	elseif (z <= 0.5)
		tmp = x * -3.0;
	elseif ((z <= 9e+156) || ~((z <= 1.75e+239)))
		tmp = -6.0 * (y * z);
	else
		tmp = 6.0 * (x * z);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := If[LessEqual[z, -2.4e-16], N[(x * N[(1.0 + N[(6.0 * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -7e-260], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -3.5e-282], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 3.6e-306], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 1.3e-107], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.5], N[(x * -3.0), $MachinePrecision], If[Or[LessEqual[z, 9e+156], N[Not[LessEqual[z, 1.75e+239]], $MachinePrecision]], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -7 \cdot 10^{-260}:\\
\;\;\;\;x \cdot -3\\

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

\mathbf{elif}\;z \leq 3.6 \cdot 10^{-306}:\\
\;\;\;\;x \cdot -3\\

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

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

\mathbf{elif}\;z \leq 9 \cdot 10^{+156} \lor \neg \left(z \leq 1.75 \cdot 10^{+239}\right):\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\

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


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

    1. Initial program 99.9%

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

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

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

    if -2.40000000000000005e-16 < z < -6.9999999999999999e-260 or -3.50000000000000006e-282 < z < 3.59999999999999991e-306 or 1.3e-107 < z < 0.5

    1. Initial program 99.2%

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

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

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

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

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

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

    if -6.9999999999999999e-260 < z < -3.50000000000000006e-282 or 3.59999999999999991e-306 < z < 1.3e-107

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.5 < z < 9.00000000000000061e156 or 1.7500000000000001e239 < z

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

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

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

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

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

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

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

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

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

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

    if 9.00000000000000061e156 < z < 1.7500000000000001e239

    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 inf 99.8%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.4 \cdot 10^{-16}:\\ \;\;\;\;x \cdot \left(1 + 6 \cdot z\right)\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-260}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{-282}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-306}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-107}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+156} \lor \neg \left(z \leq 1.75 \cdot 10^{+239}\right):\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]

Alternative 4: 49.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -4.8 \cdot 10^{+24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -9.6 \cdot 10^{-258}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -5.6 \cdot 10^{-274}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-307}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{-105}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.62:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -6.0 (* y z))))
   (if (<= z -4.8e+24)
     t_0
     (if (<= z -9.6e-258)
       (* x -3.0)
       (if (<= z -5.6e-274)
         (* y 4.0)
         (if (<= z 5.5e-307)
           (* x -3.0)
           (if (<= z 1.75e-105)
             (* y 4.0)
             (if (<= z 0.62) (* x -3.0) t_0))))))))
double code(double x, double y, double z) {
	double t_0 = -6.0 * (y * z);
	double tmp;
	if (z <= -4.8e+24) {
		tmp = t_0;
	} else if (z <= -9.6e-258) {
		tmp = x * -3.0;
	} else if (z <= -5.6e-274) {
		tmp = y * 4.0;
	} else if (z <= 5.5e-307) {
		tmp = x * -3.0;
	} else if (z <= 1.75e-105) {
		tmp = y * 4.0;
	} else if (z <= 0.62) {
		tmp = x * -3.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-6.0d0) * (y * z)
    if (z <= (-4.8d+24)) then
        tmp = t_0
    else if (z <= (-9.6d-258)) then
        tmp = x * (-3.0d0)
    else if (z <= (-5.6d-274)) then
        tmp = y * 4.0d0
    else if (z <= 5.5d-307) then
        tmp = x * (-3.0d0)
    else if (z <= 1.75d-105) then
        tmp = y * 4.0d0
    else if (z <= 0.62d0) then
        tmp = x * (-3.0d0)
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = -6.0 * (y * z);
	double tmp;
	if (z <= -4.8e+24) {
		tmp = t_0;
	} else if (z <= -9.6e-258) {
		tmp = x * -3.0;
	} else if (z <= -5.6e-274) {
		tmp = y * 4.0;
	} else if (z <= 5.5e-307) {
		tmp = x * -3.0;
	} else if (z <= 1.75e-105) {
		tmp = y * 4.0;
	} else if (z <= 0.62) {
		tmp = x * -3.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -6.0 * (y * z)
	tmp = 0
	if z <= -4.8e+24:
		tmp = t_0
	elif z <= -9.6e-258:
		tmp = x * -3.0
	elif z <= -5.6e-274:
		tmp = y * 4.0
	elif z <= 5.5e-307:
		tmp = x * -3.0
	elif z <= 1.75e-105:
		tmp = y * 4.0
	elif z <= 0.62:
		tmp = x * -3.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(-6.0 * Float64(y * z))
	tmp = 0.0
	if (z <= -4.8e+24)
		tmp = t_0;
	elseif (z <= -9.6e-258)
		tmp = Float64(x * -3.0);
	elseif (z <= -5.6e-274)
		tmp = Float64(y * 4.0);
	elseif (z <= 5.5e-307)
		tmp = Float64(x * -3.0);
	elseif (z <= 1.75e-105)
		tmp = Float64(y * 4.0);
	elseif (z <= 0.62)
		tmp = Float64(x * -3.0);
	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 <= -4.8e+24)
		tmp = t_0;
	elseif (z <= -9.6e-258)
		tmp = x * -3.0;
	elseif (z <= -5.6e-274)
		tmp = y * 4.0;
	elseif (z <= 5.5e-307)
		tmp = x * -3.0;
	elseif (z <= 1.75e-105)
		tmp = y * 4.0;
	elseif (z <= 0.62)
		tmp = x * -3.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.8e+24], t$95$0, If[LessEqual[z, -9.6e-258], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -5.6e-274], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 5.5e-307], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 1.75e-105], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 0.62], N[(x * -3.0), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -9.6 \cdot 10^{-258}:\\
\;\;\;\;x \cdot -3\\

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

\mathbf{elif}\;z \leq 5.5 \cdot 10^{-307}:\\
\;\;\;\;x \cdot -3\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -4.8000000000000001e24 or 0.619999999999999996 < z

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.8000000000000001e24 < z < -9.6000000000000007e-258 or -5.5999999999999995e-274 < z < 5.50000000000000039e-307 or 1.75e-105 < z < 0.619999999999999996

    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 y around 0 99.2%

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

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

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

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

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

    if -9.6000000000000007e-258 < z < -5.5999999999999995e-274 or 5.50000000000000039e-307 < z < 1.75e-105

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.8 \cdot 10^{+24}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -9.6 \cdot 10^{-258}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -5.6 \cdot 10^{-274}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{-307}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{-105}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.62:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \end{array} \]

Alternative 5: 75.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x + z \cdot \left(x \cdot 6\right)\\ \mathbf{if}\;z \leq -46:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-7}:\\ \;\;\;\;x \cdot -3 + y \cdot 4\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+155} \lor \neg \left(z \leq 1.25 \cdot 10^{+242}\right):\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (+ x (* z (* x 6.0)))))
   (if (<= z -46.0)
     t_0
     (if (<= z 8.5e-7)
       (+ (* x -3.0) (* y 4.0))
       (if (or (<= z 9e+155) (not (<= z 1.25e+242)))
         (* y (+ 4.0 (* z -6.0)))
         t_0)))))
double code(double x, double y, double z) {
	double t_0 = x + (z * (x * 6.0));
	double tmp;
	if (z <= -46.0) {
		tmp = t_0;
	} else if (z <= 8.5e-7) {
		tmp = (x * -3.0) + (y * 4.0);
	} else if ((z <= 9e+155) || !(z <= 1.25e+242)) {
		tmp = y * (4.0 + (z * -6.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x + (z * (x * 6.0d0))
    if (z <= (-46.0d0)) then
        tmp = t_0
    else if (z <= 8.5d-7) then
        tmp = (x * (-3.0d0)) + (y * 4.0d0)
    else if ((z <= 9d+155) .or. (.not. (z <= 1.25d+242))) then
        tmp = y * (4.0d0 + (z * (-6.0d0)))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = x + (z * (x * 6.0));
	double tmp;
	if (z <= -46.0) {
		tmp = t_0;
	} else if (z <= 8.5e-7) {
		tmp = (x * -3.0) + (y * 4.0);
	} else if ((z <= 9e+155) || !(z <= 1.25e+242)) {
		tmp = y * (4.0 + (z * -6.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = x + (z * (x * 6.0))
	tmp = 0
	if z <= -46.0:
		tmp = t_0
	elif z <= 8.5e-7:
		tmp = (x * -3.0) + (y * 4.0)
	elif (z <= 9e+155) or not (z <= 1.25e+242):
		tmp = y * (4.0 + (z * -6.0))
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(x + Float64(z * Float64(x * 6.0)))
	tmp = 0.0
	if (z <= -46.0)
		tmp = t_0;
	elseif (z <= 8.5e-7)
		tmp = Float64(Float64(x * -3.0) + Float64(y * 4.0));
	elseif ((z <= 9e+155) || !(z <= 1.25e+242))
		tmp = Float64(y * Float64(4.0 + Float64(z * -6.0)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = x + (z * (x * 6.0));
	tmp = 0.0;
	if (z <= -46.0)
		tmp = t_0;
	elseif (z <= 8.5e-7)
		tmp = (x * -3.0) + (y * 4.0);
	elseif ((z <= 9e+155) || ~((z <= 1.25e+242)))
		tmp = y * (4.0 + (z * -6.0));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(z * N[(x * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -46.0], t$95$0, If[LessEqual[z, 8.5e-7], N[(N[(x * -3.0), $MachinePrecision] + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 9e+155], N[Not[LessEqual[z, 1.25e+242]], $MachinePrecision]], N[(y * N[(4.0 + N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 8.5 \cdot 10^{-7}:\\
\;\;\;\;x \cdot -3 + y \cdot 4\\

\mathbf{elif}\;z \leq 9 \cdot 10^{+155} \lor \neg \left(z \leq 1.25 \cdot 10^{+242}\right):\\
\;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -46 or 8.99999999999999947e155 < z < 1.2500000000000001e242

    1. Initial program 99.9%

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

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

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

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

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

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

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

    if -46 < z < 8.50000000000000014e-7

    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 0 99.5%

      \[\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. Step-by-step derivation
      1. fma-def99.6%

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

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

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

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

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

    if 8.50000000000000014e-7 < z < 8.99999999999999947e155 or 1.2500000000000001e242 < z

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -46:\\ \;\;\;\;x + z \cdot \left(x \cdot 6\right)\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{-7}:\\ \;\;\;\;x \cdot -3 + y \cdot 4\\ \mathbf{elif}\;z \leq 9 \cdot 10^{+155} \lor \neg \left(z \leq 1.25 \cdot 10^{+242}\right):\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(x \cdot 6\right)\\ \end{array} \]

Alternative 6: 75.4% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;z \leq 6 \cdot 10^{-7}:\\
\;\;\;\;x \cdot -3 + y \cdot 4\\

\mathbf{elif}\;z \leq 6 \cdot 10^{+157} \lor \neg \left(z \leq 3.15 \cdot 10^{+242}\right):\\
\;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.55e-6

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55e-6 < z < 5.9999999999999997e-7

    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 0 99.5%

      \[\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. Step-by-step derivation
      1. fma-def99.6%

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

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

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

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

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

    if 5.9999999999999997e-7 < z < 6.00000000000000021e157 or 3.1499999999999999e242 < z

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

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

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

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

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

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

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

    if 6.00000000000000021e157 < z < 3.1499999999999999e242

    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 inf 99.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.55 \cdot 10^{-6}:\\ \;\;\;\;x \cdot \left(\left(-z \cdot -6\right) - 3\right)\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-7}:\\ \;\;\;\;x \cdot -3 + y \cdot 4\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+157} \lor \neg \left(z \leq 3.15 \cdot 10^{+242}\right):\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(x \cdot 6\right)\\ \end{array} \]

Alternative 7: 75.4% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{-5}:\\
\;\;\;\;x \cdot \left(1 + \left(0.6666666666666666 - z\right) \cdot -6\right)\\

\mathbf{elif}\;z \leq 2.1 \cdot 10^{-6}:\\
\;\;\;\;x \cdot -3 + y \cdot 4\\

\mathbf{elif}\;z \leq 4.6 \cdot 10^{+155} \lor \neg \left(z \leq 1.8 \cdot 10^{+242}\right):\\
\;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\

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


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

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

    if -5.19999999999999968e-5 < z < 2.0999999999999998e-6

    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 0 99.5%

      \[\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. Step-by-step derivation
      1. fma-def99.6%

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

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

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

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

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

    if 2.0999999999999998e-6 < z < 4.59999999999999996e155 or 1.79999999999999997e242 < z

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

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

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

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

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

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

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

    if 4.59999999999999996e155 < z < 1.79999999999999997e242

    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 inf 99.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.2 \cdot 10^{-5}:\\ \;\;\;\;x \cdot \left(1 + \left(0.6666666666666666 - z\right) \cdot -6\right)\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-6}:\\ \;\;\;\;x \cdot -3 + y \cdot 4\\ \mathbf{elif}\;z \leq 4.6 \cdot 10^{+155} \lor \neg \left(z \leq 1.8 \cdot 10^{+242}\right):\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(x \cdot 6\right)\\ \end{array} \]

Alternative 8: 59.7% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;y \leq -1.4 \cdot 10^{-179}:\\
\;\;\;\;x \cdot -3\\

\mathbf{elif}\;y \leq -1.36 \cdot 10^{-179}:\\
\;\;\;\;y \cdot \left(z \cdot -6\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -3.15000000000000014e-93 or 2.45e-119 < y

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

    if -3.15000000000000014e-93 < y < -1.4e-179

    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 0 99.3%

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

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

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

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

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

    if -1.4e-179 < y < -1.35999999999999993e-179

    1. Initial program 98.4%

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

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

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

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

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

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

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

        \[\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*100.0%

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

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

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

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

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

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

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

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

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

    if -1.35999999999999993e-179 < y < 2.45e-119

    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 inf 55.8%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.15 \cdot 10^{-93}:\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{elif}\;y \leq -1.4 \cdot 10^{-179}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;y \leq -1.36 \cdot 10^{-179}:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;y \leq 2.45 \cdot 10^{-119}:\\ \;\;\;\;x \cdot \left(6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \end{array} \]

Alternative 9: 97.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.8%

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

      \[\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. Step-by-step derivation
      1. fma-def98.8%

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

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

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

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

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

    if -0.599999999999999978 < z < 0.52000000000000002

    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 0 99.5%

      \[\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. Step-by-step derivation
      1. fma-def99.6%

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

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

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

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

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

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

Alternative 10: 37.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{-88}:\\
\;\;\;\;y \cdot 4\\

\mathbf{elif}\;y \leq 8.8 \cdot 10^{+63}:\\
\;\;\;\;x \cdot -3\\

\mathbf{else}:\\
\;\;\;\;y \cdot 4\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.0999999999999998e-88 or 8.7999999999999995e63 < y

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.0999999999999998e-88 < y < 8.7999999999999995e63

    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 0 99.4%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.1 \cdot 10^{-88}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;y \leq 8.8 \cdot 10^{+63}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4\\ \end{array} \]

Alternative 11: 26.7% accurate, 4.3× speedup?

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-3 \cdot x} \]
  7. Final simplification30.0%

    \[\leadsto x \cdot -3 \]

Alternative 12: 2.6% accurate, 13.0× speedup?

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

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

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

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification2.7%

    \[\leadsto x \]

Reproduce

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