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

Percentage Accurate: 99.5% → 99.6%
Time: 16.2s
Alternatives: 17
Speedup: 1.7×

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 17 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.6% accurate, 0.8× speedup?

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

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

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. flip3-+N/A

      \[\leadsto \color{blue}{\frac{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}} \]
    2. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}}} \]
    3. /-lowering-/.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}}} \]
    4. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}}}} \]
    5. flip3-+N/A

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)}}} \]
  4. Applied egg-rr99.7%

    \[\leadsto \color{blue}{\frac{1}{\frac{1}{\mathsf{fma}\left(y - x, \mathsf{fma}\left(-6, z, 4\right), x\right)}}} \]
  5. Add Preprocessing

Alternative 2: 97.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{3} - z\\ \mathbf{if}\;t\_0 \leq -20000000:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot \left(x - y\right), 6, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (/ 2.0 3.0) z)))
   (if (<= t_0 -20000000.0)
     (* -6.0 (* (- y x) z))
     (if (<= t_0 1.0) (fma x -3.0 (* y 4.0)) (fma (* z (- x y)) 6.0 x)))))
double code(double x, double y, double z) {
	double t_0 = (2.0 / 3.0) - z;
	double tmp;
	if (t_0 <= -20000000.0) {
		tmp = -6.0 * ((y - x) * z);
	} else if (t_0 <= 1.0) {
		tmp = fma(x, -3.0, (y * 4.0));
	} else {
		tmp = fma((z * (x - y)), 6.0, x);
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(2.0 / 3.0) - z)
	tmp = 0.0
	if (t_0 <= -20000000.0)
		tmp = Float64(-6.0 * Float64(Float64(y - x) * z));
	elseif (t_0 <= 1.0)
		tmp = fma(x, -3.0, Float64(y * 4.0));
	else
		tmp = fma(Float64(z * Float64(x - y)), 6.0, x);
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -20000000.0], N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(x * -3.0 + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(x - y), $MachinePrecision]), $MachinePrecision] * 6.0 + x), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -20000000:\\
\;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -2e7

    1. Initial program 99.6%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip3-+N/A

        \[\leadsto \color{blue}{\frac{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}}} \]
      4. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}}}} \]
      5. flip3-+N/A

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

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

      \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
      2. *-lowering-*.f64N/A

        \[\leadsto -6 \cdot \color{blue}{\left(z \cdot \left(y - x\right)\right)} \]
      3. --lowering--.f6498.9

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

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

    if -2e7 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1

    1. Initial program 99.3%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6497.8

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified97.8%

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

      \[\leadsto \color{blue}{x + \left(-4 \cdot x + 4 \cdot y\right)} \]
    7. Step-by-step derivation
      1. associate-+r+N/A

        \[\leadsto \color{blue}{\left(x + -4 \cdot x\right) + 4 \cdot y} \]
      2. distribute-rgt1-inN/A

        \[\leadsto \color{blue}{\left(-4 + 1\right) \cdot x} + 4 \cdot y \]
      3. metadata-evalN/A

        \[\leadsto \color{blue}{-3} \cdot x + 4 \cdot y \]
      4. *-commutativeN/A

        \[\leadsto \color{blue}{x \cdot -3} + 4 \cdot y \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, -3, 4 \cdot y\right)} \]
      6. *-lowering-*.f6497.8

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, -3, 4 \cdot y\right)} \]

    if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z)

    1. Initial program 99.6%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. *-commutativeN/A

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

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot 6} + x \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot \left(\frac{2}{3} - z\right), 6, x\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y - x\right) \cdot \left(\frac{2}{3} - z\right)}, 6, x\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y - x\right)} \cdot \left(\frac{2}{3} - z\right), 6, x\right) \]
      8. --lowering--.f64N/A

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{-1 \cdot \left(z \cdot \left(y - x\right)\right)}, 6, x\right) \]
    6. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{neg}\left(z \cdot \left(y - x\right)\right)}, 6, x\right) \]
      2. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)}, 6, x\right) \]
      3. sub-negN/A

        \[\leadsto \mathsf{fma}\left(z \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right), 6, x\right) \]
      4. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(z \cdot \left(\mathsf{neg}\left(\left(y + \color{blue}{-1 \cdot x}\right)\right)\right), 6, x\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + y\right)}\right)\right), 6, x\right) \]
      6. distribute-neg-inN/A

        \[\leadsto \mathsf{fma}\left(z \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)}, 6, x\right) \]
      7. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(z \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right), 6, x\right) \]
      8. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z \cdot \left(\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right), 6, x\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{fma}\left(z \cdot \color{blue}{\left(x - y\right)}, 6, x\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot \left(x - y\right)}, 6, x\right) \]
      11. --lowering--.f6498.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{2}{3} - z \leq -20000000:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;\frac{2}{3} - z \leq 1:\\ \;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot \left(x - y\right), 6, x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 75.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{3} - z\\ \mathbf{if}\;t\_0 \leq -20000000:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (/ 2.0 3.0) z)))
   (if (<= t_0 -20000000.0)
     (* 6.0 (* x z))
     (if (<= t_0 1.0) (fma 4.0 (- y x) x) (* x (* z 6.0))))))
double code(double x, double y, double z) {
	double t_0 = (2.0 / 3.0) - z;
	double tmp;
	if (t_0 <= -20000000.0) {
		tmp = 6.0 * (x * z);
	} else if (t_0 <= 1.0) {
		tmp = fma(4.0, (y - x), x);
	} else {
		tmp = x * (z * 6.0);
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(2.0 / 3.0) - z)
	tmp = 0.0
	if (t_0 <= -20000000.0)
		tmp = Float64(6.0 * Float64(x * z));
	elseif (t_0 <= 1.0)
		tmp = fma(4.0, Float64(y - x), x);
	else
		tmp = Float64(x * Float64(z * 6.0));
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, If[LessEqual[t$95$0, -20000000.0], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(x * N[(z * 6.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
\mathbf{if}\;t\_0 \leq -20000000:\\
\;\;\;\;6 \cdot \left(x \cdot z\right)\\

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -2e7

    1. Initial program 99.6%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-6 \cdot \left(y - x\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(y - x\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      9. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right)\right) \]
      10. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\left(y + \color{blue}{-1 \cdot x}\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + y\right)}\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      13. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. remove-double-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(x - y\right)}\right) \]
      16. --lowering--.f6498.8

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

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

      \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
      2. *-commutativeN/A

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

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

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

    if -2e7 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1

    1. Initial program 99.3%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6497.8

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified97.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]

    if 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z)

    1. Initial program 99.6%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-6 \cdot \left(y - x\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(y - x\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      9. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right)\right) \]
      10. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\left(y + \color{blue}{-1 \cdot x}\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + y\right)}\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      13. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. remove-double-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(x - y\right)}\right) \]
      16. --lowering--.f6498.1

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

      \[\leadsto \color{blue}{z \cdot \left(6 \cdot \left(x - y\right)\right)} \]
    6. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(x + \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      2. +-commutativeN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(y\right)\right) + x\right)}\right) \]
      3. distribute-lft-inN/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(y\right)\right) + 6 \cdot x\right)} \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(6 \cdot y\right)\right)} + 6 \cdot x\right) \]
      5. *-commutativeN/A

        \[\leadsto z \cdot \left(\left(\mathsf{neg}\left(\color{blue}{y \cdot 6}\right)\right) + 6 \cdot x\right) \]
      6. metadata-evalN/A

        \[\leadsto z \cdot \left(\left(\mathsf{neg}\left(y \cdot 6\right)\right) + \color{blue}{\left(\mathsf{neg}\left(-6\right)\right)} \cdot x\right) \]
      7. distribute-lft-neg-inN/A

        \[\leadsto z \cdot \left(\left(\mathsf{neg}\left(y \cdot 6\right)\right) + \color{blue}{\left(\mathsf{neg}\left(-6 \cdot x\right)\right)}\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \left(\color{blue}{y \cdot \left(\mathsf{neg}\left(6\right)\right)} + \left(\mathsf{neg}\left(-6 \cdot x\right)\right)\right) \]
      9. metadata-evalN/A

        \[\leadsto z \cdot \left(y \cdot \color{blue}{-6} + \left(\mathsf{neg}\left(-6 \cdot x\right)\right)\right) \]
      10. accelerator-lowering-fma.f64N/A

        \[\leadsto z \cdot \color{blue}{\mathsf{fma}\left(y, -6, \mathsf{neg}\left(-6 \cdot x\right)\right)} \]
      11. *-commutativeN/A

        \[\leadsto z \cdot \mathsf{fma}\left(y, -6, \mathsf{neg}\left(\color{blue}{x \cdot -6}\right)\right) \]
      12. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \mathsf{fma}\left(y, -6, \color{blue}{x \cdot \left(\mathsf{neg}\left(-6\right)\right)}\right) \]
      13. metadata-evalN/A

        \[\leadsto z \cdot \mathsf{fma}\left(y, -6, x \cdot \color{blue}{6}\right) \]
      14. *-lowering-*.f6498.1

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

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

      \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(6 \cdot x\right) \cdot z} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\left(x \cdot 6\right)} \cdot z \]
      3. associate-*r*N/A

        \[\leadsto \color{blue}{x \cdot \left(6 \cdot z\right)} \]
      4. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(6 \cdot z\right)} \]
      5. *-lowering-*.f6450.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{2}{3} - z \leq -20000000:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;\frac{2}{3} - z \leq 1:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 75.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{3} - z\\ t_1 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;t\_0 \leq -20000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* 6.0 (* x z))))
   (if (<= t_0 -20000000.0) t_1 (if (<= t_0 1.0) (fma 4.0 (- y x) x) t_1))))
double code(double x, double y, double z) {
	double t_0 = (2.0 / 3.0) - z;
	double t_1 = 6.0 * (x * z);
	double tmp;
	if (t_0 <= -20000000.0) {
		tmp = t_1;
	} else if (t_0 <= 1.0) {
		tmp = fma(4.0, (y - x), x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(2.0 / 3.0) - z)
	t_1 = Float64(6.0 * Float64(x * z))
	tmp = 0.0
	if (t_0 <= -20000000.0)
		tmp = t_1;
	elseif (t_0 <= 1.0)
		tmp = fma(4.0, Float64(y - x), x);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -20000000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{2}{3} - z\\
t_1 := 6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;t\_0 \leq -20000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -2e7 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z)

    1. Initial program 99.6%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-6 \cdot \left(y - x\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(y - x\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      9. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right)\right) \]
      10. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\left(y + \color{blue}{-1 \cdot x}\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + y\right)}\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      13. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. remove-double-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(x - y\right)}\right) \]
      16. --lowering--.f6498.4

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

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

      \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
      2. *-commutativeN/A

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

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

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

    if -2e7 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 1

    1. Initial program 99.3%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6497.8

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified97.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{2}{3} - z \leq -20000000:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;\frac{2}{3} - z \leq 1:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.6% accurate, 0.9× speedup?

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

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

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

      \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} \]
    2. *-commutativeN/A

      \[\leadsto x + \color{blue}{\left(6 \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(y - x\right)} \]
    3. flip--N/A

      \[\leadsto x + \left(6 \cdot \left(\frac{2}{3} - z\right)\right) \cdot \color{blue}{\frac{y \cdot y - x \cdot x}{y + x}} \]
    4. clear-numN/A

      \[\leadsto x + \left(6 \cdot \left(\frac{2}{3} - z\right)\right) \cdot \color{blue}{\frac{1}{\frac{y + x}{y \cdot y - x \cdot x}}} \]
    5. un-div-invN/A

      \[\leadsto x + \color{blue}{\frac{6 \cdot \left(\frac{2}{3} - z\right)}{\frac{y + x}{y \cdot y - x \cdot x}}} \]
    6. /-lowering-/.f64N/A

      \[\leadsto x + \color{blue}{\frac{6 \cdot \left(\frac{2}{3} - z\right)}{\frac{y + x}{y \cdot y - x \cdot x}}} \]
    7. sub-negN/A

      \[\leadsto x + \frac{6 \cdot \color{blue}{\left(\frac{2}{3} + \left(\mathsf{neg}\left(z\right)\right)\right)}}{\frac{y + x}{y \cdot y - x \cdot x}} \]
    8. +-commutativeN/A

      \[\leadsto x + \frac{6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(z\right)\right) + \frac{2}{3}\right)}}{\frac{y + x}{y \cdot y - x \cdot x}} \]
    9. distribute-lft-inN/A

      \[\leadsto x + \frac{\color{blue}{6 \cdot \left(\mathsf{neg}\left(z\right)\right) + 6 \cdot \frac{2}{3}}}{\frac{y + x}{y \cdot y - x \cdot x}} \]
    10. neg-mul-1N/A

      \[\leadsto x + \frac{6 \cdot \color{blue}{\left(-1 \cdot z\right)} + 6 \cdot \frac{2}{3}}{\frac{y + x}{y \cdot y - x \cdot x}} \]
    11. associate-*r*N/A

      \[\leadsto x + \frac{\color{blue}{\left(6 \cdot -1\right) \cdot z} + 6 \cdot \frac{2}{3}}{\frac{y + x}{y \cdot y - x \cdot x}} \]
    12. metadata-evalN/A

      \[\leadsto x + \frac{\color{blue}{-6} \cdot z + 6 \cdot \frac{2}{3}}{\frac{y + x}{y \cdot y - x \cdot x}} \]
    13. metadata-evalN/A

      \[\leadsto x + \frac{\color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot z + 6 \cdot \frac{2}{3}}{\frac{y + x}{y \cdot y - x \cdot x}} \]
    14. accelerator-lowering-fma.f64N/A

      \[\leadsto x + \frac{\color{blue}{\mathsf{fma}\left(\mathsf{neg}\left(6\right), z, 6 \cdot \frac{2}{3}\right)}}{\frac{y + x}{y \cdot y - x \cdot x}} \]
    15. metadata-evalN/A

      \[\leadsto x + \frac{\mathsf{fma}\left(\color{blue}{-6}, z, 6 \cdot \frac{2}{3}\right)}{\frac{y + x}{y \cdot y - x \cdot x}} \]
    16. metadata-evalN/A

      \[\leadsto x + \frac{\mathsf{fma}\left(-6, z, 6 \cdot \color{blue}{\frac{2}{3}}\right)}{\frac{y + x}{y \cdot y - x \cdot x}} \]
    17. metadata-evalN/A

      \[\leadsto x + \frac{\mathsf{fma}\left(-6, z, \color{blue}{4}\right)}{\frac{y + x}{y \cdot y - x \cdot x}} \]
    18. clear-numN/A

      \[\leadsto x + \frac{\mathsf{fma}\left(-6, z, 4\right)}{\color{blue}{\frac{1}{\frac{y \cdot y - x \cdot x}{y + x}}}} \]
    19. flip--N/A

      \[\leadsto x + \frac{\mathsf{fma}\left(-6, z, 4\right)}{\frac{1}{\color{blue}{y - x}}} \]
    20. /-lowering-/.f64N/A

      \[\leadsto x + \frac{\mathsf{fma}\left(-6, z, 4\right)}{\color{blue}{\frac{1}{y - x}}} \]
    21. --lowering--.f6499.7

      \[\leadsto x + \frac{\mathsf{fma}\left(-6, z, 4\right)}{\frac{1}{\color{blue}{y - x}}} \]
  4. Applied egg-rr99.7%

    \[\leadsto x + \color{blue}{\frac{\mathsf{fma}\left(-6, z, 4\right)}{\frac{1}{y - x}}} \]
  5. Add Preprocessing

Alternative 6: 75.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \mathsf{fma}\left(6, z, -3\right)\\ \mathbf{if}\;z \leq -9 \cdot 10^{+71}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -2.9 \cdot 10^{-9}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-27}:\\ \;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (fma 6.0 z -3.0))))
   (if (<= z -9e+71)
     (* -6.0 (* y z))
     (if (<= z -2.9e-9) t_0 (if (<= z 1.1e-27) (fma x -3.0 (* y 4.0)) t_0)))))
double code(double x, double y, double z) {
	double t_0 = x * fma(6.0, z, -3.0);
	double tmp;
	if (z <= -9e+71) {
		tmp = -6.0 * (y * z);
	} else if (z <= -2.9e-9) {
		tmp = t_0;
	} else if (z <= 1.1e-27) {
		tmp = fma(x, -3.0, (y * 4.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(x * fma(6.0, z, -3.0))
	tmp = 0.0
	if (z <= -9e+71)
		tmp = Float64(-6.0 * Float64(y * z));
	elseif (z <= -2.9e-9)
		tmp = t_0;
	elseif (z <= 1.1e-27)
		tmp = fma(x, -3.0, Float64(y * 4.0));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(6.0 * z + -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9e+71], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -2.9e-9], t$95$0, If[LessEqual[z, 1.1e-27], N[(x * -3.0 + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \mathsf{fma}\left(6, z, -3\right)\\
\mathbf{if}\;z \leq -9 \cdot 10^{+71}:\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\

\mathbf{elif}\;z \leq -2.9 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 99.7%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-6 \cdot \left(y - x\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(y - x\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      9. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right)\right) \]
      10. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\left(y + \color{blue}{-1 \cdot x}\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + y\right)}\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      13. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. remove-double-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(x - y\right)}\right) \]
      16. --lowering--.f6499.7

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

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

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

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

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

      \[\leadsto z \cdot \color{blue}{\left(y \cdot -6\right)} \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(z \cdot y\right) \cdot -6} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(z \cdot y\right) \cdot -6} \]
      3. *-lowering-*.f6463.8

        \[\leadsto \color{blue}{\left(z \cdot y\right)} \cdot -6 \]
    10. Applied egg-rr63.8%

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

    if -9.00000000000000087e71 < z < -2.89999999999999991e-9 or 1.09999999999999993e-27 < z

    1. Initial program 99.6%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(\frac{2}{3} - z\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(\frac{2}{3} - z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(-6 \cdot \left(\frac{2}{3} - z\right) + 1\right)} \]
      3. sub-negN/A

        \[\leadsto x \cdot \left(-6 \cdot \color{blue}{\left(\frac{2}{3} + \left(\mathsf{neg}\left(z\right)\right)\right)} + 1\right) \]
      4. mul-1-negN/A

        \[\leadsto x \cdot \left(-6 \cdot \left(\frac{2}{3} + \color{blue}{-1 \cdot z}\right) + 1\right) \]
      5. +-commutativeN/A

        \[\leadsto x \cdot \left(-6 \cdot \color{blue}{\left(-1 \cdot z + \frac{2}{3}\right)} + 1\right) \]
      6. distribute-lft-inN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(-6 \cdot \left(-1 \cdot z\right) + -6 \cdot \frac{2}{3}\right)} + 1\right) \]
      7. metadata-evalN/A

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

        \[\leadsto x \cdot \color{blue}{\left(-6 \cdot \left(-1 \cdot z\right) + \left(-4 + 1\right)\right)} \]
      9. associate-*r*N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(-6 \cdot -1\right) \cdot z} + \left(-4 + 1\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto x \cdot \left(\color{blue}{6} \cdot z + \left(-4 + 1\right)\right) \]
      11. metadata-evalN/A

        \[\leadsto x \cdot \left(6 \cdot z + \color{blue}{-3}\right) \]
      12. metadata-evalN/A

        \[\leadsto x \cdot \left(6 \cdot z + \color{blue}{\left(1 + -4\right)}\right) \]
      13. accelerator-lowering-fma.f64N/A

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

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

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

    if -2.89999999999999991e-9 < z < 1.09999999999999993e-27

    1. Initial program 99.2%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6499.5

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

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

      \[\leadsto \color{blue}{x + \left(-4 \cdot x + 4 \cdot y\right)} \]
    7. Step-by-step derivation
      1. associate-+r+N/A

        \[\leadsto \color{blue}{\left(x + -4 \cdot x\right) + 4 \cdot y} \]
      2. distribute-rgt1-inN/A

        \[\leadsto \color{blue}{\left(-4 + 1\right) \cdot x} + 4 \cdot y \]
      3. metadata-evalN/A

        \[\leadsto \color{blue}{-3} \cdot x + 4 \cdot y \]
      4. *-commutativeN/A

        \[\leadsto \color{blue}{x \cdot -3} + 4 \cdot y \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, -3, 4 \cdot y\right)} \]
      6. *-lowering-*.f6499.5

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, -3, 4 \cdot y\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification82.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+71}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -2.9 \cdot 10^{-9}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(6, z, -3\right)\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-27}:\\ \;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(6, z, -3\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 75.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \mathsf{fma}\left(6, z, -3\right)\\ \mathbf{if}\;z \leq -8 \cdot 10^{+71}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-8}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-28}:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (fma 6.0 z -3.0))))
   (if (<= z -8e+71)
     (* -6.0 (* y z))
     (if (<= z -5e-8) t_0 (if (<= z 1.35e-28) (fma 4.0 (- y x) x) t_0)))))
double code(double x, double y, double z) {
	double t_0 = x * fma(6.0, z, -3.0);
	double tmp;
	if (z <= -8e+71) {
		tmp = -6.0 * (y * z);
	} else if (z <= -5e-8) {
		tmp = t_0;
	} else if (z <= 1.35e-28) {
		tmp = fma(4.0, (y - x), x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(x * fma(6.0, z, -3.0))
	tmp = 0.0
	if (z <= -8e+71)
		tmp = Float64(-6.0 * Float64(y * z));
	elseif (z <= -5e-8)
		tmp = t_0;
	elseif (z <= 1.35e-28)
		tmp = fma(4.0, Float64(y - x), x);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(6.0 * z + -3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8e+71], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -5e-8], t$95$0, If[LessEqual[z, 1.35e-28], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \mathsf{fma}\left(6, z, -3\right)\\
\mathbf{if}\;z \leq -8 \cdot 10^{+71}:\\
\;\;\;\;-6 \cdot \left(y \cdot z\right)\\

\mathbf{elif}\;z \leq -5 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 1.35 \cdot 10^{-28}:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 99.7%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-6 \cdot \left(y - x\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(y - x\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      9. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right)\right) \]
      10. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\left(y + \color{blue}{-1 \cdot x}\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + y\right)}\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      13. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. remove-double-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(x - y\right)}\right) \]
      16. --lowering--.f6499.7

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

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

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

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

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

      \[\leadsto z \cdot \color{blue}{\left(y \cdot -6\right)} \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(z \cdot y\right) \cdot -6} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(z \cdot y\right) \cdot -6} \]
      3. *-lowering-*.f6463.8

        \[\leadsto \color{blue}{\left(z \cdot y\right)} \cdot -6 \]
    10. Applied egg-rr63.8%

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

    if -8.0000000000000003e71 < z < -4.9999999999999998e-8 or 1.3499999999999999e-28 < z

    1. Initial program 99.6%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(\frac{2}{3} - z\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{x \cdot \left(1 + -6 \cdot \left(\frac{2}{3} - z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto x \cdot \color{blue}{\left(-6 \cdot \left(\frac{2}{3} - z\right) + 1\right)} \]
      3. sub-negN/A

        \[\leadsto x \cdot \left(-6 \cdot \color{blue}{\left(\frac{2}{3} + \left(\mathsf{neg}\left(z\right)\right)\right)} + 1\right) \]
      4. mul-1-negN/A

        \[\leadsto x \cdot \left(-6 \cdot \left(\frac{2}{3} + \color{blue}{-1 \cdot z}\right) + 1\right) \]
      5. +-commutativeN/A

        \[\leadsto x \cdot \left(-6 \cdot \color{blue}{\left(-1 \cdot z + \frac{2}{3}\right)} + 1\right) \]
      6. distribute-lft-inN/A

        \[\leadsto x \cdot \left(\color{blue}{\left(-6 \cdot \left(-1 \cdot z\right) + -6 \cdot \frac{2}{3}\right)} + 1\right) \]
      7. metadata-evalN/A

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

        \[\leadsto x \cdot \color{blue}{\left(-6 \cdot \left(-1 \cdot z\right) + \left(-4 + 1\right)\right)} \]
      9. associate-*r*N/A

        \[\leadsto x \cdot \left(\color{blue}{\left(-6 \cdot -1\right) \cdot z} + \left(-4 + 1\right)\right) \]
      10. metadata-evalN/A

        \[\leadsto x \cdot \left(\color{blue}{6} \cdot z + \left(-4 + 1\right)\right) \]
      11. metadata-evalN/A

        \[\leadsto x \cdot \left(6 \cdot z + \color{blue}{-3}\right) \]
      12. metadata-evalN/A

        \[\leadsto x \cdot \left(6 \cdot z + \color{blue}{\left(1 + -4\right)}\right) \]
      13. accelerator-lowering-fma.f64N/A

        \[\leadsto x \cdot \color{blue}{\mathsf{fma}\left(6, z, 1 + -4\right)} \]
      14. metadata-eval67.6

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

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

    if -4.9999999999999998e-8 < z < 1.3499999999999999e-28

    1. Initial program 99.2%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6499.5

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification82.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{+71}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -5 \cdot 10^{-8}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(6, z, -3\right)\\ \mathbf{elif}\;z \leq 1.35 \cdot 10^{-28}:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(6, z, -3\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 75.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -1 \cdot 10^{+72}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -14.6:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* x z))))
   (if (<= z -1e+72)
     (* -6.0 (* y z))
     (if (<= z -14.6) t_0 (if (<= z 0.5) (fma 4.0 (- y x) x) t_0)))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (x * z);
	double tmp;
	if (z <= -1e+72) {
		tmp = -6.0 * (y * z);
	} else if (z <= -14.6) {
		tmp = t_0;
	} else if (z <= 0.5) {
		tmp = fma(4.0, (y - x), x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(6.0 * Float64(x * z))
	tmp = 0.0
	if (z <= -1e+72)
		tmp = Float64(-6.0 * Float64(y * z));
	elseif (z <= -14.6)
		tmp = t_0;
	elseif (z <= 0.5)
		tmp = fma(4.0, Float64(y - x), x);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1e+72], N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -14.6], t$95$0, If[LessEqual[z, 0.5], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -14.6:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 99.7%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-6 \cdot \left(y - x\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(y - x\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      9. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right)\right) \]
      10. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\left(y + \color{blue}{-1 \cdot x}\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + y\right)}\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      13. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. remove-double-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(x - y\right)}\right) \]
      16. --lowering--.f6499.7

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

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

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

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

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

      \[\leadsto z \cdot \color{blue}{\left(y \cdot -6\right)} \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(z \cdot y\right) \cdot -6} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(z \cdot y\right) \cdot -6} \]
      3. *-lowering-*.f6463.8

        \[\leadsto \color{blue}{\left(z \cdot y\right)} \cdot -6 \]
    10. Applied egg-rr63.8%

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

    if -9.99999999999999944e71 < z < -14.5999999999999996 or 0.5 < z

    1. Initial program 99.6%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-6 \cdot \left(y - x\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(y - x\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      9. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right)\right) \]
      10. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\left(y + \color{blue}{-1 \cdot x}\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + y\right)}\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      13. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. remove-double-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(x - y\right)}\right) \]
      16. --lowering--.f6497.7

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

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

      \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
      2. *-commutativeN/A

        \[\leadsto 6 \cdot \color{blue}{\left(z \cdot x\right)} \]
      3. *-lowering-*.f6464.5

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

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

    if -14.5999999999999996 < z < 0.5

    1. Initial program 99.3%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6497.8

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified97.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification81.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+72}:\\ \;\;\;\;-6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;z \leq -14.6:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 75.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -4.2 \cdot 10^{+71}:\\ \;\;\;\;y \cdot \left(-6 \cdot z\right)\\ \mathbf{elif}\;z \leq -3.4:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 0.58:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* x z))))
   (if (<= z -4.2e+71)
     (* y (* -6.0 z))
     (if (<= z -3.4) t_0 (if (<= z 0.58) (fma 4.0 (- y x) x) t_0)))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (x * z);
	double tmp;
	if (z <= -4.2e+71) {
		tmp = y * (-6.0 * z);
	} else if (z <= -3.4) {
		tmp = t_0;
	} else if (z <= 0.58) {
		tmp = fma(4.0, (y - x), x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(6.0 * Float64(x * z))
	tmp = 0.0
	if (z <= -4.2e+71)
		tmp = Float64(y * Float64(-6.0 * z));
	elseif (z <= -3.4)
		tmp = t_0;
	elseif (z <= 0.58)
		tmp = fma(4.0, Float64(y - x), x);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e+71], N[(y * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -3.4], t$95$0, If[LessEqual[z, 0.58], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -3.4:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 0.58:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 99.7%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip3-+N/A

        \[\leadsto \color{blue}{\frac{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}}} \]
      4. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}}}} \]
      5. flip3-+N/A

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

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

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

        \[\leadsto \color{blue}{\left(4 + -6 \cdot z\right) \cdot y} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{\left(4 + -6 \cdot z\right) \cdot y} \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{\left(-6 \cdot z + 4\right)} \cdot y \]
      4. accelerator-lowering-fma.f6463.7

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

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

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

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

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

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

    if -4.19999999999999978e71 < z < -3.39999999999999991 or 0.57999999999999996 < z

    1. Initial program 99.6%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-6 \cdot \left(y - x\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(y - x\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      9. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right)\right) \]
      10. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\left(y + \color{blue}{-1 \cdot x}\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + y\right)}\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      13. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. remove-double-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(x - y\right)}\right) \]
      16. --lowering--.f6497.7

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

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

      \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
      2. *-commutativeN/A

        \[\leadsto 6 \cdot \color{blue}{\left(z \cdot x\right)} \]
      3. *-lowering-*.f6464.5

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

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

    if -3.39999999999999991 < z < 0.57999999999999996

    1. Initial program 99.3%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6497.8

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified97.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification81.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+71}:\\ \;\;\;\;y \cdot \left(-6 \cdot z\right)\\ \mathbf{elif}\;z \leq -3.4:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq 0.58:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 75.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -9.5 \cdot 10^{+71}:\\ \;\;\;\;z \cdot \left(y \cdot -6\right)\\ \mathbf{elif}\;z \leq -232:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* 6.0 (* x z))))
   (if (<= z -9.5e+71)
     (* z (* y -6.0))
     (if (<= z -232.0) t_0 (if (<= z 0.5) (fma 4.0 (- y x) x) t_0)))))
double code(double x, double y, double z) {
	double t_0 = 6.0 * (x * z);
	double tmp;
	if (z <= -9.5e+71) {
		tmp = z * (y * -6.0);
	} else if (z <= -232.0) {
		tmp = t_0;
	} else if (z <= 0.5) {
		tmp = fma(4.0, (y - x), x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(6.0 * Float64(x * z))
	tmp = 0.0
	if (z <= -9.5e+71)
		tmp = Float64(z * Float64(y * -6.0));
	elseif (z <= -232.0)
		tmp = t_0;
	elseif (z <= 0.5)
		tmp = fma(4.0, Float64(y - x), x);
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9.5e+71], N[(z * N[(y * -6.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -232.0], t$95$0, If[LessEqual[z, 0.5], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -232:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 99.7%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-6 \cdot \left(y - x\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(y - x\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      9. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right)\right) \]
      10. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\left(y + \color{blue}{-1 \cdot x}\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + y\right)}\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      13. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. remove-double-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(x - y\right)}\right) \]
      16. --lowering--.f6499.7

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

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

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

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

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

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

    if -9.50000000000000015e71 < z < -232 or 0.5 < z

    1. Initial program 99.6%

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

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

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

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

        \[\leadsto \color{blue}{z \cdot \left(-6 \cdot \left(y - x\right)\right)} \]
      4. metadata-evalN/A

        \[\leadsto z \cdot \left(\color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(y - x\right)\right) \]
      5. distribute-lft-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(6 \cdot \left(y - x\right)\right)\right)} \]
      7. distribute-rgt-neg-inN/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      8. *-lowering-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(6 \cdot \left(\mathsf{neg}\left(\left(y - x\right)\right)\right)\right)} \]
      9. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(x\right)\right)\right)}\right)\right)\right) \]
      10. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\left(y + \color{blue}{-1 \cdot x}\right)\right)\right)\right) \]
      11. +-commutativeN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\mathsf{neg}\left(\color{blue}{\left(-1 \cdot x + y\right)}\right)\right)\right) \]
      12. distribute-neg-inN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(\left(\mathsf{neg}\left(-1 \cdot x\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)}\right) \]
      13. mul-1-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)\right) + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      14. remove-double-negN/A

        \[\leadsto z \cdot \left(6 \cdot \left(\color{blue}{x} + \left(\mathsf{neg}\left(y\right)\right)\right)\right) \]
      15. sub-negN/A

        \[\leadsto z \cdot \left(6 \cdot \color{blue}{\left(x - y\right)}\right) \]
      16. --lowering--.f6497.7

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

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

      \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
    7. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{6 \cdot \left(x \cdot z\right)} \]
      2. *-commutativeN/A

        \[\leadsto 6 \cdot \color{blue}{\left(z \cdot x\right)} \]
      3. *-lowering-*.f6464.5

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

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

    if -232 < z < 0.5

    1. Initial program 99.3%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6497.8

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified97.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification81.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -9.5 \cdot 10^{+71}:\\ \;\;\;\;z \cdot \left(y \cdot -6\right)\\ \mathbf{elif}\;z \leq -232:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 97.7% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{if}\;z \leq -0.58:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* -6.0 (* (- y x) z))))
   (if (<= z -0.58) t_0 (if (<= z 0.5) (fma x -3.0 (* y 4.0)) t_0))))
double code(double x, double y, double z) {
	double t_0 = -6.0 * ((y - x) * z);
	double tmp;
	if (z <= -0.58) {
		tmp = t_0;
	} else if (z <= 0.5) {
		tmp = fma(x, -3.0, (y * 4.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(-6.0 * Float64(Float64(y - x) * z))
	tmp = 0.0
	if (z <= -0.58)
		tmp = t_0;
	elseif (z <= 0.5)
		tmp = fma(x, -3.0, Float64(y * 4.0));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -0.58], t$95$0, If[LessEqual[z, 0.5], N[(x * -3.0 + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq 0.5:\\
\;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


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

    1. Initial program 99.6%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip3-+N/A

        \[\leadsto \color{blue}{\frac{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}} \]
      2. clear-numN/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\frac{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}}} \]
      4. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{{x}^{3} + {\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)}^{3}}{x \cdot x + \left(\left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right) - x \cdot \left(\left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\right)\right)}}}} \]
      5. flip3-+N/A

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

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

      \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
      2. *-lowering-*.f64N/A

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

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

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

    if -0.57999999999999996 < z < 0.5

    1. Initial program 99.3%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6497.8

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified97.8%

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

      \[\leadsto \color{blue}{x + \left(-4 \cdot x + 4 \cdot y\right)} \]
    7. Step-by-step derivation
      1. associate-+r+N/A

        \[\leadsto \color{blue}{\left(x + -4 \cdot x\right) + 4 \cdot y} \]
      2. distribute-rgt1-inN/A

        \[\leadsto \color{blue}{\left(-4 + 1\right) \cdot x} + 4 \cdot y \]
      3. metadata-evalN/A

        \[\leadsto \color{blue}{-3} \cdot x + 4 \cdot y \]
      4. *-commutativeN/A

        \[\leadsto \color{blue}{x \cdot -3} + 4 \cdot y \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, -3, 4 \cdot y\right)} \]
      6. *-lowering-*.f6497.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.58:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 99.5% accurate, 1.6× speedup?

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

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

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

      \[\leadsto x + \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} \]
    2. *-commutativeN/A

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

      \[\leadsto x + \color{blue}{\left(\left(y - x\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot 6} \]
    4. *-lowering-*.f64N/A

      \[\leadsto x + \color{blue}{\left(\left(y - x\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot 6} \]
    5. *-lowering-*.f64N/A

      \[\leadsto x + \color{blue}{\left(\left(y - x\right) \cdot \left(\frac{2}{3} - z\right)\right)} \cdot 6 \]
    6. --lowering--.f64N/A

      \[\leadsto x + \left(\color{blue}{\left(y - x\right)} \cdot \left(\frac{2}{3} - z\right)\right) \cdot 6 \]
    7. --lowering--.f64N/A

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

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

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

Alternative 13: 36.9% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -7.2 \cdot 10^{-83}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+157}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4, y, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (if (<= y -7.2e-83) (* y 4.0) (if (<= y 1.35e+157) (* x -3.0) (fma 4.0 y x))))
double code(double x, double y, double z) {
	double tmp;
	if (y <= -7.2e-83) {
		tmp = y * 4.0;
	} else if (y <= 1.35e+157) {
		tmp = x * -3.0;
	} else {
		tmp = fma(4.0, y, x);
	}
	return tmp;
}
function code(x, y, z)
	tmp = 0.0
	if (y <= -7.2e-83)
		tmp = Float64(y * 4.0);
	elseif (y <= 1.35e+157)
		tmp = Float64(x * -3.0);
	else
		tmp = fma(4.0, y, x);
	end
	return tmp
end
code[x_, y_, z_] := If[LessEqual[y, -7.2e-83], N[(y * 4.0), $MachinePrecision], If[LessEqual[y, 1.35e+157], N[(x * -3.0), $MachinePrecision], N[(4.0 * y + x), $MachinePrecision]]]
\begin{array}{l}

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4, y, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -7.20000000000000025e-83

    1. Initial program 99.5%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6457.7

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified57.7%

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    7. Step-by-step derivation
      1. *-lowering-*.f6447.1

        \[\leadsto \color{blue}{4 \cdot y} \]
    8. Simplified47.1%

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

    if -7.20000000000000025e-83 < y < 1.35e157

    1. Initial program 99.3%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6451.8

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified51.8%

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

      \[\leadsto \color{blue}{x + -4 \cdot x} \]
    7. Step-by-step derivation
      1. distribute-rgt1-inN/A

        \[\leadsto \color{blue}{\left(-4 + 1\right) \cdot x} \]
      2. metadata-evalN/A

        \[\leadsto \color{blue}{-3} \cdot x \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{x \cdot -3} \]
      4. *-lowering-*.f6444.9

        \[\leadsto \color{blue}{x \cdot -3} \]
    8. Simplified44.9%

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

    if 1.35e157 < y

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6449.0

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified49.0%

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

      \[\leadsto \mathsf{fma}\left(4, \color{blue}{y}, x\right) \]
    7. Step-by-step derivation
      1. Simplified43.5%

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y}, x\right) \]
    8. Recombined 3 regimes into one program.
    9. Final simplification45.5%

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.2 \cdot 10^{-83}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+157}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4, y, x\right)\\ \end{array} \]
    10. Add Preprocessing

    Alternative 14: 36.9% accurate, 1.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{-83}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+157}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (if (<= y -4.2e-83) (* y 4.0) (if (<= y 1.25e+157) (* x -3.0) (* y 4.0))))
    double code(double x, double y, double z) {
    	double tmp;
    	if (y <= -4.2e-83) {
    		tmp = y * 4.0;
    	} else if (y <= 1.25e+157) {
    		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 <= (-4.2d-83)) then
            tmp = y * 4.0d0
        else if (y <= 1.25d+157) 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 <= -4.2e-83) {
    		tmp = y * 4.0;
    	} else if (y <= 1.25e+157) {
    		tmp = x * -3.0;
    	} else {
    		tmp = y * 4.0;
    	}
    	return tmp;
    }
    
    def code(x, y, z):
    	tmp = 0
    	if y <= -4.2e-83:
    		tmp = y * 4.0
    	elif y <= 1.25e+157:
    		tmp = x * -3.0
    	else:
    		tmp = y * 4.0
    	return tmp
    
    function code(x, y, z)
    	tmp = 0.0
    	if (y <= -4.2e-83)
    		tmp = Float64(y * 4.0);
    	elseif (y <= 1.25e+157)
    		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 <= -4.2e-83)
    		tmp = y * 4.0;
    	elseif (y <= 1.25e+157)
    		tmp = x * -3.0;
    	else
    		tmp = y * 4.0;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, y_, z_] := If[LessEqual[y, -4.2e-83], N[(y * 4.0), $MachinePrecision], If[LessEqual[y, 1.25e+157], N[(x * -3.0), $MachinePrecision], N[(y * 4.0), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;y \leq -4.2 \cdot 10^{-83}:\\
    \;\;\;\;y \cdot 4\\
    
    \mathbf{elif}\;y \leq 1.25 \cdot 10^{+157}:\\
    \;\;\;\;x \cdot -3\\
    
    \mathbf{else}:\\
    \;\;\;\;y \cdot 4\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if y < -4.1999999999999998e-83 or 1.24999999999999994e157 < y

      1. Initial program 99.5%

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

        \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
        2. accelerator-lowering-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
        3. --lowering--.f6455.3

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

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

        \[\leadsto \color{blue}{4 \cdot y} \]
      7. Step-by-step derivation
        1. *-lowering-*.f6446.0

          \[\leadsto \color{blue}{4 \cdot y} \]
      8. Simplified46.0%

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

      if -4.1999999999999998e-83 < y < 1.24999999999999994e157

      1. Initial program 99.3%

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

        \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
      4. Step-by-step derivation
        1. +-commutativeN/A

          \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
        2. accelerator-lowering-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
        3. --lowering--.f6451.8

          \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
      5. Simplified51.8%

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

        \[\leadsto \color{blue}{x + -4 \cdot x} \]
      7. Step-by-step derivation
        1. distribute-rgt1-inN/A

          \[\leadsto \color{blue}{\left(-4 + 1\right) \cdot x} \]
        2. metadata-evalN/A

          \[\leadsto \color{blue}{-3} \cdot x \]
        3. *-commutativeN/A

          \[\leadsto \color{blue}{x \cdot -3} \]
        4. *-lowering-*.f6444.9

          \[\leadsto \color{blue}{x \cdot -3} \]
      8. Simplified44.9%

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{-83}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+157}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4\\ \end{array} \]
    5. Add Preprocessing

    Alternative 15: 99.5% accurate, 1.7× speedup?

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

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{\left(y - x\right) \cdot \left(6 \cdot \left(\frac{2}{3} - z\right)\right)} + x \]
      3. *-commutativeN/A

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

        \[\leadsto \color{blue}{\left(\left(y - x\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot 6} + x \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(y - x\right) \cdot \left(\frac{2}{3} - z\right), 6, x\right)} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y - x\right) \cdot \left(\frac{2}{3} - z\right)}, 6, x\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(y - x\right)} \cdot \left(\frac{2}{3} - z\right), 6, x\right) \]
      8. --lowering--.f64N/A

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

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

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

    Alternative 16: 51.2% accurate, 3.1× speedup?

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

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6453.4

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified53.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
    6. Add Preprocessing

    Alternative 17: 26.3% accurate, 5.2× speedup?

    \[\begin{array}{l} \\ y \cdot 4 \end{array} \]
    (FPCore (x y z) :precision binary64 (* y 4.0))
    double code(double x, double y, double z) {
    	return y * 4.0;
    }
    
    real(8) function code(x, y, z)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        real(8), intent (in) :: z
        code = y * 4.0d0
    end function
    
    public static double code(double x, double y, double z) {
    	return y * 4.0;
    }
    
    def code(x, y, z):
    	return y * 4.0
    
    function code(x, y, z)
    	return Float64(y * 4.0)
    end
    
    function tmp = code(x, y, z)
    	tmp = y * 4.0;
    end
    
    code[x_, y_, z_] := N[(y * 4.0), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    y \cdot 4
    \end{array}
    
    Derivation
    1. Initial program 99.4%

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

      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{4 \cdot \left(y - x\right) + x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
      3. --lowering--.f6453.4

        \[\leadsto \mathsf{fma}\left(4, \color{blue}{y - x}, x\right) \]
    5. Simplified53.4%

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    7. Step-by-step derivation
      1. *-lowering-*.f6425.7

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

      \[\leadsto \color{blue}{4 \cdot y} \]
    9. Final simplification25.7%

      \[\leadsto y \cdot 4 \]
    10. Add Preprocessing

    Reproduce

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