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

Percentage Accurate: 99.5% → 99.7%
Time: 10.6s
Alternatives: 13
Speedup: 1.2×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 alternatives:

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

Initial Program: 99.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 49.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -3400000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4.2 \cdot 10^{-215}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{-255}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-306}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-223}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-183}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-78}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.0092:\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -6.0 (* y z))))
   (if (<= z -3400000000000.0)
     t_0
     (if (<= z -4.2e-215)
       (* y 4.0)
       (if (<= z -1.55e-255)
         (* x -3.0)
         (if (<= z 3.6e-306)
           (* y 4.0)
           (if (<= z 3.6e-223)
             (* x -3.0)
             (if (<= z 1.65e-183)
               (* y 4.0)
               (if (<= z 1.3e-78)
                 (* x -3.0)
                 (if (<= z 0.0092) (* y 4.0) t_0))))))))))
double code(double x, double y, double z) {
	double t_0 = -6.0 * (y * z);
	double tmp;
	if (z <= -3400000000000.0) {
		tmp = t_0;
	} else if (z <= -4.2e-215) {
		tmp = y * 4.0;
	} else if (z <= -1.55e-255) {
		tmp = x * -3.0;
	} else if (z <= 3.6e-306) {
		tmp = y * 4.0;
	} else if (z <= 3.6e-223) {
		tmp = x * -3.0;
	} else if (z <= 1.65e-183) {
		tmp = y * 4.0;
	} else if (z <= 1.3e-78) {
		tmp = x * -3.0;
	} else if (z <= 0.0092) {
		tmp = y * 4.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (-6.0d0) * (y * z)
    if (z <= (-3400000000000.0d0)) then
        tmp = t_0
    else if (z <= (-4.2d-215)) then
        tmp = y * 4.0d0
    else if (z <= (-1.55d-255)) then
        tmp = x * (-3.0d0)
    else if (z <= 3.6d-306) then
        tmp = y * 4.0d0
    else if (z <= 3.6d-223) then
        tmp = x * (-3.0d0)
    else if (z <= 1.65d-183) then
        tmp = y * 4.0d0
    else if (z <= 1.3d-78) then
        tmp = x * (-3.0d0)
    else if (z <= 0.0092d0) then
        tmp = y * 4.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = -6.0 * (y * z);
	double tmp;
	if (z <= -3400000000000.0) {
		tmp = t_0;
	} else if (z <= -4.2e-215) {
		tmp = y * 4.0;
	} else if (z <= -1.55e-255) {
		tmp = x * -3.0;
	} else if (z <= 3.6e-306) {
		tmp = y * 4.0;
	} else if (z <= 3.6e-223) {
		tmp = x * -3.0;
	} else if (z <= 1.65e-183) {
		tmp = y * 4.0;
	} else if (z <= 1.3e-78) {
		tmp = x * -3.0;
	} else if (z <= 0.0092) {
		tmp = y * 4.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = -6.0 * (y * z)
	tmp = 0
	if z <= -3400000000000.0:
		tmp = t_0
	elif z <= -4.2e-215:
		tmp = y * 4.0
	elif z <= -1.55e-255:
		tmp = x * -3.0
	elif z <= 3.6e-306:
		tmp = y * 4.0
	elif z <= 3.6e-223:
		tmp = x * -3.0
	elif z <= 1.65e-183:
		tmp = y * 4.0
	elif z <= 1.3e-78:
		tmp = x * -3.0
	elif z <= 0.0092:
		tmp = y * 4.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 <= -3400000000000.0)
		tmp = t_0;
	elseif (z <= -4.2e-215)
		tmp = Float64(y * 4.0);
	elseif (z <= -1.55e-255)
		tmp = Float64(x * -3.0);
	elseif (z <= 3.6e-306)
		tmp = Float64(y * 4.0);
	elseif (z <= 3.6e-223)
		tmp = Float64(x * -3.0);
	elseif (z <= 1.65e-183)
		tmp = Float64(y * 4.0);
	elseif (z <= 1.3e-78)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.0092)
		tmp = Float64(y * 4.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 <= -3400000000000.0)
		tmp = t_0;
	elseif (z <= -4.2e-215)
		tmp = y * 4.0;
	elseif (z <= -1.55e-255)
		tmp = x * -3.0;
	elseif (z <= 3.6e-306)
		tmp = y * 4.0;
	elseif (z <= 3.6e-223)
		tmp = x * -3.0;
	elseif (z <= 1.65e-183)
		tmp = y * 4.0;
	elseif (z <= 1.3e-78)
		tmp = x * -3.0;
	elseif (z <= 0.0092)
		tmp = y * 4.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3400000000000.0], t$95$0, If[LessEqual[z, -4.2e-215], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -1.55e-255], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 3.6e-306], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 3.6e-223], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 1.65e-183], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 1.3e-78], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.0092], N[(y * 4.0), $MachinePrecision], t$95$0]]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq -1.55 \cdot 10^{-255}:\\
\;\;\;\;x \cdot -3\\

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

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

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

\mathbf{elif}\;z \leq 1.3 \cdot 10^{-78}:\\
\;\;\;\;x \cdot -3\\

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.4e12 < z < -4.2e-215 or -1.54999999999999999e-255 < z < 3.59999999999999991e-306 or 3.6000000000000004e-223 < z < 1.65e-183 or 1.3000000000000001e-78 < z < 0.0091999999999999998

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.2e-215 < z < -1.54999999999999999e-255 or 3.59999999999999991e-306 < z < 3.6000000000000004e-223 or 1.65e-183 < z < 1.3000000000000001e-78

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3400000000000:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -4.2 \cdot 10^{-215}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{-255}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-306}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-223}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-183}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-78}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.0092:\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \end{array} \]

Alternative 3: 49.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := y \cdot \left(z \cdot -6\right)\\ \mathbf{if}\;z \leq -3400000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.18 \cdot 10^{-220}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{-254}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-308}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-223}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-183}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-80}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.0092:\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* y (* z -6.0))))
   (if (<= z -3400000000000.0)
     t_0
     (if (<= z -1.18e-220)
       (* y 4.0)
       (if (<= z -1.9e-254)
         (* x -3.0)
         (if (<= z 2.4e-308)
           (* y 4.0)
           (if (<= z 3.3e-223)
             (* x -3.0)
             (if (<= z 1.2e-183)
               (* y 4.0)
               (if (<= z 6.5e-80)
                 (* x -3.0)
                 (if (<= z 0.0092) (* y 4.0) t_0))))))))))
double code(double x, double y, double z) {
	double t_0 = y * (z * -6.0);
	double tmp;
	if (z <= -3400000000000.0) {
		tmp = t_0;
	} else if (z <= -1.18e-220) {
		tmp = y * 4.0;
	} else if (z <= -1.9e-254) {
		tmp = x * -3.0;
	} else if (z <= 2.4e-308) {
		tmp = y * 4.0;
	} else if (z <= 3.3e-223) {
		tmp = x * -3.0;
	} else if (z <= 1.2e-183) {
		tmp = y * 4.0;
	} else if (z <= 6.5e-80) {
		tmp = x * -3.0;
	} else if (z <= 0.0092) {
		tmp = y * 4.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: tmp
    t_0 = y * (z * (-6.0d0))
    if (z <= (-3400000000000.0d0)) then
        tmp = t_0
    else if (z <= (-1.18d-220)) then
        tmp = y * 4.0d0
    else if (z <= (-1.9d-254)) then
        tmp = x * (-3.0d0)
    else if (z <= 2.4d-308) then
        tmp = y * 4.0d0
    else if (z <= 3.3d-223) then
        tmp = x * (-3.0d0)
    else if (z <= 1.2d-183) then
        tmp = y * 4.0d0
    else if (z <= 6.5d-80) then
        tmp = x * (-3.0d0)
    else if (z <= 0.0092d0) then
        tmp = y * 4.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = y * (z * -6.0);
	double tmp;
	if (z <= -3400000000000.0) {
		tmp = t_0;
	} else if (z <= -1.18e-220) {
		tmp = y * 4.0;
	} else if (z <= -1.9e-254) {
		tmp = x * -3.0;
	} else if (z <= 2.4e-308) {
		tmp = y * 4.0;
	} else if (z <= 3.3e-223) {
		tmp = x * -3.0;
	} else if (z <= 1.2e-183) {
		tmp = y * 4.0;
	} else if (z <= 6.5e-80) {
		tmp = x * -3.0;
	} else if (z <= 0.0092) {
		tmp = y * 4.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = y * (z * -6.0)
	tmp = 0
	if z <= -3400000000000.0:
		tmp = t_0
	elif z <= -1.18e-220:
		tmp = y * 4.0
	elif z <= -1.9e-254:
		tmp = x * -3.0
	elif z <= 2.4e-308:
		tmp = y * 4.0
	elif z <= 3.3e-223:
		tmp = x * -3.0
	elif z <= 1.2e-183:
		tmp = y * 4.0
	elif z <= 6.5e-80:
		tmp = x * -3.0
	elif z <= 0.0092:
		tmp = y * 4.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(y * Float64(z * -6.0))
	tmp = 0.0
	if (z <= -3400000000000.0)
		tmp = t_0;
	elseif (z <= -1.18e-220)
		tmp = Float64(y * 4.0);
	elseif (z <= -1.9e-254)
		tmp = Float64(x * -3.0);
	elseif (z <= 2.4e-308)
		tmp = Float64(y * 4.0);
	elseif (z <= 3.3e-223)
		tmp = Float64(x * -3.0);
	elseif (z <= 1.2e-183)
		tmp = Float64(y * 4.0);
	elseif (z <= 6.5e-80)
		tmp = Float64(x * -3.0);
	elseif (z <= 0.0092)
		tmp = Float64(y * 4.0);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = y * (z * -6.0);
	tmp = 0.0;
	if (z <= -3400000000000.0)
		tmp = t_0;
	elseif (z <= -1.18e-220)
		tmp = y * 4.0;
	elseif (z <= -1.9e-254)
		tmp = x * -3.0;
	elseif (z <= 2.4e-308)
		tmp = y * 4.0;
	elseif (z <= 3.3e-223)
		tmp = x * -3.0;
	elseif (z <= 1.2e-183)
		tmp = y * 4.0;
	elseif (z <= 6.5e-80)
		tmp = x * -3.0;
	elseif (z <= 0.0092)
		tmp = y * 4.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3400000000000.0], t$95$0, If[LessEqual[z, -1.18e-220], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, -1.9e-254], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 2.4e-308], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 3.3e-223], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 1.2e-183], N[(y * 4.0), $MachinePrecision], If[LessEqual[z, 6.5e-80], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 0.0092], N[(y * 4.0), $MachinePrecision], t$95$0]]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;z \leq -1.9 \cdot 10^{-254}:\\
\;\;\;\;x \cdot -3\\

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

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

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

\mathbf{elif}\;z \leq 6.5 \cdot 10^{-80}:\\
\;\;\;\;x \cdot -3\\

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.4e12 < z < -1.1799999999999999e-220 or -1.9000000000000001e-254 < z < 2.40000000000000008e-308 or 3.29999999999999994e-223 < z < 1.19999999999999996e-183 or 6.49999999999999984e-80 < z < 0.0091999999999999998

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.1799999999999999e-220 < z < -1.9000000000000001e-254 or 2.40000000000000008e-308 < z < 3.29999999999999994e-223 or 1.19999999999999996e-183 < z < 6.49999999999999984e-80

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3400000000000:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq -1.18 \cdot 10^{-220}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{-254}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-308}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-223}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{-183}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{-80}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.0092:\\ \;\;\;\;y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \end{array} \]

Alternative 4: 58.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{if}\;y \leq -4.4 \cdot 10^{-121}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-271}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-155}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* y (- 0.6666666666666666 z)))))
   (if (<= y -4.4e-121)
     t_0
     (if (<= y 1.45e-271)
       (* z (* x 6.0))
       (if (<= y 1.5e-155) (* x -3.0) t_0)))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (y * (0.6666666666666666 - z));
	double tmp;
	if (y <= -4.4e-121) {
		tmp = t_0;
	} else if (y <= 1.45e-271) {
		tmp = z * (x * 6.0);
	} else if (y <= 1.5e-155) {
		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 * (0.6666666666666666d0 - z))
    if (y <= (-4.4d-121)) then
        tmp = t_0
    else if (y <= 1.45d-271) then
        tmp = z * (x * 6.0d0)
    else if (y <= 1.5d-155) 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 * (0.6666666666666666 - z));
	double tmp;
	if (y <= -4.4e-121) {
		tmp = t_0;
	} else if (y <= 1.45e-271) {
		tmp = z * (x * 6.0);
	} else if (y <= 1.5e-155) {
		tmp = x * -3.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = 6.0 * (y * (0.6666666666666666 - z))
	tmp = 0
	if y <= -4.4e-121:
		tmp = t_0
	elif y <= 1.45e-271:
		tmp = z * (x * 6.0)
	elif y <= 1.5e-155:
		tmp = x * -3.0
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	t_0 = Float64(6.0 * Float64(y * Float64(0.6666666666666666 - z)))
	tmp = 0.0
	if (y <= -4.4e-121)
		tmp = t_0;
	elseif (y <= 1.45e-271)
		tmp = Float64(z * Float64(x * 6.0));
	elseif (y <= 1.5e-155)
		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 * (0.6666666666666666 - z));
	tmp = 0.0;
	if (y <= -4.4e-121)
		tmp = t_0;
	elseif (y <= 1.45e-271)
		tmp = z * (x * 6.0);
	elseif (y <= 1.5e-155)
		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 * N[(0.6666666666666666 - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.4e-121], t$95$0, If[LessEqual[y, 1.45e-271], N[(z * N[(x * 6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e-155], N[(x * -3.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;y \leq 1.5 \cdot 10^{-155}:\\
\;\;\;\;x \cdot -3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.40000000000000042e-121 or 1.49999999999999992e-155 < 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. metadata-eval99.6%

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

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

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

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

    if -4.40000000000000042e-121 < y < 1.45000000000000007e-271

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot x}{x - \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)} - \frac{{\left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right)}^{2}}{x - \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)}} \]
    5. Applied egg-rr51.2%

      \[\leadsto \color{blue}{\frac{x \cdot x}{x - \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)} - \frac{{\left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)}} \]
    6. Step-by-step derivation
      1. div-sub51.1%

        \[\leadsto \color{blue}{\frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)}} \]
      2. *-commutative51.1%

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

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \color{blue}{\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)}} \]
      4. associate-*r*51.1%

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

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

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

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(\color{blue}{4} + 6 \cdot \left(-z\right)\right)} \]
      8. distribute-rgt-neg-in51.1%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(4 + \color{blue}{\left(-6 \cdot z\right)}\right)} \]
      9. distribute-lft-neg-in51.1%

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

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(4 + \color{blue}{-6} \cdot z\right)} \]
      11. +-commutative51.1%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \color{blue}{\left(-6 \cdot z + 4\right)}} \]
      12. *-commutative51.1%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(\color{blue}{z \cdot -6} + 4\right)} \]
      13. fma-udef51.0%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \color{blue}{\mathsf{fma}\left(z, -6, 4\right)}} \]
      14. fma-udef51.1%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \color{blue}{\left(z \cdot -6 + 4\right)}} \]
      15. *-commutative51.1%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(\color{blue}{-6 \cdot z} + 4\right)} \]
      16. +-commutative51.1%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \color{blue}{\left(4 + -6 \cdot z\right)}} \]
    7. Simplified51.1%

      \[\leadsto \color{blue}{\frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)}} \]
    8. Step-by-step derivation
      1. unpow251.1%

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

        \[\leadsto \frac{x \cdot x - \left(\left(y - x\right) \cdot \color{blue}{\left(6 \cdot \left(0.6666666666666666 - z\right)\right)}\right) \cdot \left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)} \]
      3. *-commutative51.1%

        \[\leadsto \frac{x \cdot x - \left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right) \cdot \left(\left(y - x\right) \cdot \color{blue}{\left(6 \cdot \left(0.6666666666666666 - z\right)\right)}\right)}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)} \]
      4. associate-*r*51.2%

        \[\leadsto \frac{x \cdot x - \color{blue}{\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right)} \cdot \left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right)}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)} \]
      5. associate-*r*50.9%

        \[\leadsto \frac{x \cdot x - \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right) \cdot \color{blue}{\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right)}}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)} \]
    9. Applied egg-rr50.9%

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

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

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

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

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

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

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

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

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

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

    if 1.45000000000000007e-271 < y < 1.49999999999999992e-155

    1. Initial program 99.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    9. Simplified59.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.4 \cdot 10^{-121}:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-271}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-155}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \end{array} \]

Alternative 5: 72.6% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{-120} \lor \neg \left(y \leq 1.95 \cdot 10^{-45}\right):\\
\;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.9e-120 or 1.95e-45 < 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. metadata-eval99.6%

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

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

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

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

    if -2.9e-120 < y < 1.95e-45

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{-120} \lor \neg \left(y \leq 1.95 \cdot 10^{-45}\right):\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \]

Alternative 6: 72.7% accurate, 1.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{-120} \lor \neg \left(y \leq 1.7 \cdot 10^{-47}\right):\\
\;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.9e-120 or 1.7000000000000001e-47 < 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.9%

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

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

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

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

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

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

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

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

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

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

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

    if -2.9e-120 < y < 1.7000000000000001e-47

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 97.4% accurate, 1.2× speedup?

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

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

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


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

    1. Initial program 99.7%

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot x - \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right)}{x - \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)}} \]
      2. div-sub31.7%

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

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

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

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

        \[\leadsto \frac{x \cdot x}{x - \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)} - \frac{{\left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right)}^{2}}{x - \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)}} \]
    5. Applied egg-rr31.7%

      \[\leadsto \color{blue}{\frac{x \cdot x}{x - \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)} - \frac{{\left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)}} \]
    6. Step-by-step derivation
      1. div-sub31.7%

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

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

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \color{blue}{\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)}} \]
      4. associate-*r*31.7%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)}} \]
      5. sub-neg31.7%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right)} \]
      6. distribute-lft-in31.6%

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

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(\color{blue}{4} + 6 \cdot \left(-z\right)\right)} \]
      8. distribute-rgt-neg-in31.6%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(4 + \color{blue}{\left(-6 \cdot z\right)}\right)} \]
      9. distribute-lft-neg-in31.6%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(4 + \color{blue}{\left(-6\right) \cdot z}\right)} \]
      10. metadata-eval31.6%

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

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \color{blue}{\left(-6 \cdot z + 4\right)}} \]
      12. *-commutative31.6%

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

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \color{blue}{\mathsf{fma}\left(z, -6, 4\right)}} \]
      14. fma-udef31.6%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \color{blue}{\left(z \cdot -6 + 4\right)}} \]
      15. *-commutative31.6%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)}} \]
    8. Step-by-step derivation
      1. unpow231.7%

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

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

        \[\leadsto \frac{x \cdot x - \left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right) \cdot \left(\left(y - x\right) \cdot \color{blue}{\left(6 \cdot \left(0.6666666666666666 - z\right)\right)}\right)}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)} \]
      4. associate-*r*31.7%

        \[\leadsto \frac{x \cdot x - \color{blue}{\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right)} \cdot \left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right)}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)} \]
      5. associate-*r*31.5%

        \[\leadsto \frac{x \cdot x - \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right) \cdot \color{blue}{\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right)}}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)} \]
    9. Applied egg-rr31.5%

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

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

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

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

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

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

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

    if -0.56000000000000005 < z < 0.57999999999999996

    1. Initial program 99.4%

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

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

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

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

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

Alternative 8: 97.4% accurate, 1.2× speedup?

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

    1. Initial program 99.7%

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

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

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

        \[\leadsto \color{blue}{\frac{x \cdot x - \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right)}{x - \left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)}} \]
      2. div-sub31.7%

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

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

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

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

        \[\leadsto \frac{x \cdot x}{x - \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)} - \frac{{\left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right)}^{2}}{x - \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)}} \]
    5. Applied egg-rr31.7%

      \[\leadsto \color{blue}{\frac{x \cdot x}{x - \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)} - \frac{{\left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)}} \]
    6. Step-by-step derivation
      1. div-sub31.7%

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

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

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \color{blue}{\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)}} \]
      4. associate-*r*31.7%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)}} \]
      5. sub-neg31.7%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(6 \cdot \color{blue}{\left(0.6666666666666666 + \left(-z\right)\right)}\right)} \]
      6. distribute-lft-in31.6%

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

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(\color{blue}{4} + 6 \cdot \left(-z\right)\right)} \]
      8. distribute-rgt-neg-in31.6%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(4 + \color{blue}{\left(-6 \cdot z\right)}\right)} \]
      9. distribute-lft-neg-in31.6%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(4 + \color{blue}{\left(-6\right) \cdot z}\right)} \]
      10. metadata-eval31.6%

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

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \color{blue}{\left(-6 \cdot z + 4\right)}} \]
      12. *-commutative31.6%

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

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \color{blue}{\mathsf{fma}\left(z, -6, 4\right)}} \]
      14. fma-udef31.6%

        \[\leadsto \frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \color{blue}{\left(z \cdot -6 + 4\right)}} \]
      15. *-commutative31.6%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot x - {\left(\left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)\right)}^{2}}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)}} \]
    8. Step-by-step derivation
      1. unpow231.7%

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

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

        \[\leadsto \frac{x \cdot x - \left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right) \cdot \left(\left(y - x\right) \cdot \color{blue}{\left(6 \cdot \left(0.6666666666666666 - z\right)\right)}\right)}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)} \]
      4. associate-*r*31.7%

        \[\leadsto \frac{x \cdot x - \color{blue}{\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right)} \cdot \left(\left(y - x\right) \cdot \left(6 \cdot \left(0.6666666666666666 - z\right)\right)\right)}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)} \]
      5. associate-*r*31.5%

        \[\leadsto \frac{x \cdot x - \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right) \cdot \color{blue}{\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.6666666666666666 - z\right)\right)}}{x - \left(y - x\right) \cdot \left(\left(0.6666666666666666 - z\right) \cdot 6\right)} \]
    9. Applied egg-rr31.5%

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

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

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

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

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

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

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

    if -0.57999999999999996 < z < 0.660000000000000031

    1. Initial program 99.4%

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

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

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

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

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

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

Alternative 9: 99.5% accurate, 1.2× speedup?

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

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

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

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

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

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

Alternative 10: 99.7% accurate, 1.2× speedup?

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

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

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

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

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

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

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

      \[\leadsto x + \frac{\left(\left(y - x\right) \cdot 6\right) \cdot \left(\color{blue}{0.4444444444444444} - z \cdot z\right)}{0.6666666666666666 + z} \]
  5. Applied egg-rr87.2%

    \[\leadsto x + \color{blue}{\frac{\left(\left(y - x\right) \cdot 6\right) \cdot \left(0.4444444444444444 - z \cdot z\right)}{0.6666666666666666 + z}} \]
  6. Step-by-step derivation
    1. associate-/l*89.4%

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

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

      \[\leadsto x + \color{blue}{\frac{6}{\frac{\frac{0.6666666666666666 + z}{0.4444444444444444 - z \cdot z}}{y - x}}} \]
  7. Simplified89.5%

    \[\leadsto x + \color{blue}{\frac{6}{\frac{\frac{0.6666666666666666 + z}{0.4444444444444444 - z \cdot z}}{y - x}}} \]
  8. Taylor expanded in z around inf 99.8%

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

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

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

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

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

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

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

Alternative 11: 36.7% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;y \leq 5 \cdot 10^{-23}:\\
\;\;\;\;x \cdot -3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.9500000000000001e-120 or 5.0000000000000002e-23 < 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.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9500000000000001e-120 < y < 5.0000000000000002e-23

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    9. Simplified38.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.95 \cdot 10^{-120}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-23}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4\\ \end{array} \]

Alternative 12: 26.2% accurate, 4.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto x \cdot -3 \]

Alternative 13: 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.6%

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

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

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

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

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

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

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

    \[\leadsto x \]

Reproduce

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