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

Percentage Accurate: 99.5% → 99.7%
Time: 10.7s
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.5%

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

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

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

Alternative 2: 50.7% accurate, 0.6× speedup?

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

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

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

\mathbf{elif}\;z \leq 0.0026:\\
\;\;\;\;x + y \cdot 4\\

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


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

    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. Add Preprocessing
    5. Taylor expanded in x around inf 41.0%

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

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

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

        \[\leadsto x \cdot \left(1 - \color{blue}{\left(0.6666666666666666 - z\right) \cdot 6}\right) \]
      4. cancel-sign-sub-inv41.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6500 < z < 2.6000000000000002e-192

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

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

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

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

        \[\leadsto x \cdot \left(1 - \color{blue}{\left(0.6666666666666666 - z\right) \cdot 6}\right) \]
      4. cancel-sign-sub-inv54.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    10. Simplified52.9%

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

    if 2.6000000000000002e-192 < z < 0.0025999999999999999

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.6%

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

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

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

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

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

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

    if 0.0025999999999999999 < 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. Add Preprocessing
    5. Taylor expanded in x around inf 46.8%

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

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

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

        \[\leadsto x \cdot \left(1 - \color{blue}{\left(0.6666666666666666 - z\right) \cdot 6}\right) \]
      4. cancel-sign-sub-inv46.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6500:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-192}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 0.0026:\\ \;\;\;\;x + y \cdot 4\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 97.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.68 \lor \neg \left(z \leq 0.53\right):\\ \;\;\;\;x + \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.68) (not (<= z 0.53)))
   (+ x (* (- y x) (* z -6.0)))
   (+ x (* (- y x) 4.0))))
double code(double x, double y, double z) {
	double tmp;
	if ((z <= -0.68) || !(z <= 0.53)) {
		tmp = x + ((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.68d0)) .or. (.not. (z <= 0.53d0))) then
        tmp = x + ((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.68) || !(z <= 0.53)) {
		tmp = x + ((y - x) * (z * -6.0));
	} else {
		tmp = x + ((y - x) * 4.0);
	}
	return tmp;
}
def code(x, y, z):
	tmp = 0
	if (z <= -0.68) or not (z <= 0.53):
		tmp = x + ((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.68) || !(z <= 0.53))
		tmp = Float64(x + 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.68) || ~((z <= 0.53)))
		tmp = x + ((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.68], N[Not[LessEqual[z, 0.53]], $MachinePrecision]], N[(x + N[(N[(y - x), $MachinePrecision] * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y - x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.68 \lor \neg \left(z \leq 0.53\right):\\
\;\;\;\;x + \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.680000000000000049 or 0.53000000000000003 < 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-define99.8%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.8%

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

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

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

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

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

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

    if -0.680000000000000049 < z < 0.53000000000000003

    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. Add Preprocessing
    5. Taylor expanded in z around 0 96.0%

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

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

Alternative 4: 97.7% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.68 \lor \neg \left(z \leq 0.6\right):\\
\;\;\;\;x + -6 \cdot \left(\left(y - x\right) \cdot z\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.680000000000000049 or 0.599999999999999978 < 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. Add Preprocessing
    5. Taylor expanded in z around inf 97.0%

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

    if -0.680000000000000049 < z < 0.599999999999999978

    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. Add Preprocessing
    5. Taylor expanded in z around 0 96.0%

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

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

Alternative 5: 75.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.18 \lor \neg \left(z \leq 3.4 \cdot 10^{-10}\right):\\
\;\;\;\;y \cdot \left(4 + 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.17999999999999999 or 3.40000000000000015e-10 < 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.7%

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

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

        \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right) \]
      5. 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. Add Preprocessing
    5. Taylor expanded in y around inf 62.5%

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

    if -0.17999999999999999 < z < 3.40000000000000015e-10

    1. Initial program 99.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.18 \lor \neg \left(z \leq 3.4 \cdot 10^{-10}\right):\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - x\right) \cdot 4\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 74.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{-78} \lor \neg \left(y \leq 3.6 \cdot 10^{+30}\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 -5.8e-78) (not (<= y 3.6e+30)))
   (* y (+ 4.0 (* z -6.0)))
   (* x (+ -3.0 (* z 6.0)))))
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -5.8e-78) || !(y <= 3.6e+30)) {
		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 <= (-5.8d-78)) .or. (.not. (y <= 3.6d+30))) 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 <= -5.8e-78) || !(y <= 3.6e+30)) {
		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 <= -5.8e-78) or not (y <= 3.6e+30):
		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 <= -5.8e-78) || !(y <= 3.6e+30))
		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 <= -5.8e-78) || ~((y <= 3.6e+30)))
		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, -5.8e-78], N[Not[LessEqual[y, 3.6e+30]], $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 -5.8 \cdot 10^{-78} \lor \neg \left(y \leq 3.6 \cdot 10^{+30}\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 < -5.8000000000000001e-78 or 3.6000000000000002e30 < y

    1. Initial program 99.6%

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

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. fma-define99.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. Add Preprocessing
    5. Taylor expanded in y around inf 79.2%

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

    if -5.8000000000000001e-78 < y < 3.6000000000000002e30

    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. Add Preprocessing
    5. Taylor expanded in x around inf 76.7%

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

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

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

        \[\leadsto x \cdot \left(1 - \color{blue}{\left(0.6666666666666666 - z\right) \cdot 6}\right) \]
      4. cancel-sign-sub-inv76.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{-78} \lor \neg \left(y \leq 3.6 \cdot 10^{+30}\right):\\ \;\;\;\;y \cdot \left(4 + z \cdot -6\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 59.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.5 \cdot 10^{-109} \lor \neg \left(x \leq 1.6 \cdot 10^{-174}\right):\\
\;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.5000000000000001e-109 or 1.6e-174 < x

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.5000000000000001e-109 < x < 1.6e-174

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(0.6666666666666666 - z\right), x\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-undefine99.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{-109} \lor \neg \left(x \leq 1.6 \cdot 10^{-174}\right):\\ \;\;\;\;x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot 4\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 50.5% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

        \[\leadsto x \cdot \left(1 - \color{blue}{\left(0.6666666666666666 - z\right) \cdot 6}\right) \]
      4. cancel-sign-sub-inv43.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6500 < z < 0.5

    1. Initial program 99.2%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. 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. Add Preprocessing
    5. Taylor expanded in x around inf 49.3%

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

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

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

        \[\leadsto x \cdot \left(1 - \color{blue}{\left(0.6666666666666666 - z\right) \cdot 6}\right) \]
      4. cancel-sign-sub-inv49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    10. Simplified47.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6500 \lor \neg \left(z \leq 0.5\right):\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot -3\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 50.5% accurate, 0.9× speedup?

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

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

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

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


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

    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. Add Preprocessing
    5. Taylor expanded in x around inf 41.0%

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

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

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

        \[\leadsto x \cdot \left(1 - \color{blue}{\left(0.6666666666666666 - z\right) \cdot 6}\right) \]
      4. cancel-sign-sub-inv41.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6500 < z < 0.5

    1. Initial program 99.2%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. 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. Add Preprocessing
    5. Taylor expanded in x around inf 49.3%

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

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

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

        \[\leadsto x \cdot \left(1 - \color{blue}{\left(0.6666666666666666 - z\right) \cdot 6}\right) \]
      4. cancel-sign-sub-inv49.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot -3} \]
    10. Simplified47.4%

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

    if 0.5 < z

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. 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. Add Preprocessing
    5. Taylor expanded in x around inf 45.9%

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

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

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

        \[\leadsto x \cdot \left(1 - \color{blue}{\left(0.6666666666666666 - z\right) \cdot 6}\right) \]
      4. cancel-sign-sub-inv45.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 99.7% accurate, 1.2× speedup?

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(0.6666666666666666 - z\right), x\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. fma-undefine99.8%

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

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

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

Alternative 11: 99.5% accurate, 1.2× speedup?

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

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

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

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

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

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

Alternative 12: 26.3% accurate, 4.3× speedup?

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

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

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

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

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

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

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

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

      \[\leadsto x \cdot \left(1 - \color{blue}{\left(0.6666666666666666 - z\right) \cdot 6}\right) \]
    4. cancel-sign-sub-inv46.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot -3} \]
  10. Simplified24.3%

    \[\leadsto \color{blue}{x \cdot -3} \]
  11. Add Preprocessing

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

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

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

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

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

    \[\leadsto \color{blue}{x} \]
  7. Add Preprocessing

Reproduce

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