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

Percentage Accurate: 99.5% → 99.7%
Time: 11.4s
Alternatives: 12
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 99.5% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{3} - z\\ \mathbf{if}\;t\_0 \leq -1000:\\ \;\;\;\;\left(z \cdot -6\right) \cdot \left(y - x\right)\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(y - x\right) \cdot z\right) \cdot -6\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (/ 2.0 3.0) z)))
   (if (<= t_0 -1000.0)
     (* (* z -6.0) (- y x))
     (if (<= t_0 1.0) (fma (- y x) 4.0 x) (* (* (- y 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 <= -1000.0) {
		tmp = (z * -6.0) * (y - x);
	} else if (t_0 <= 1.0) {
		tmp = fma((y - x), 4.0, x);
	} else {
		tmp = ((y - 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 <= -1000.0)
		tmp = Float64(Float64(z * -6.0) * Float64(y - x));
	elseif (t_0 <= 1.0)
		tmp = fma(Float64(y - x), 4.0, x);
	else
		tmp = Float64(Float64(Float64(y - x) * 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, -1000.0], N[(N[(z * -6.0), $MachinePrecision] * N[(y - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision]]]]
\begin{array}{l}

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

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

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


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

    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. lift-+.f64N/A

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\frac{2}{3} - z, \color{blue}{6 \cdot \left(y - x\right)}, x\right) \]
      10. lower-*.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(6 \cdot z + \color{blue}{-3}\right) \cdot x \]
      16. lower-fma.f6454.5

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(z \cdot -6\right) \cdot \color{blue}{\left(y - x\right)} \]
    10. Applied rewrites98.3%

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

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

    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. *-commutativeN/A

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

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

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

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

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

    1. Initial program 99.8%

      \[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. *-commutativeN/A

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

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

        \[\leadsto \color{blue}{\left(z \cdot \left(y - x\right)\right)} \cdot -6 \]
      4. lower--.f6497.0

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

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

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

Alternative 3: 97.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{3} - z\\ t_1 := \left(\left(y - x\right) \cdot z\right) \cdot -6\\ \mathbf{if}\;t\_0 \leq -1000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(y - x, 4, 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 (* (* (- y x) z) -6.0)))
   (if (<= t_0 -1000.0) t_1 (if (<= t_0 1.0) (fma (- y x) 4.0 x) t_1))))
double code(double x, double y, double z) {
	double t_0 = (2.0 / 3.0) - z;
	double t_1 = ((y - x) * z) * -6.0;
	double tmp;
	if (t_0 <= -1000.0) {
		tmp = t_1;
	} else if (t_0 <= 1.0) {
		tmp = fma((y - x), 4.0, x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(2.0 / 3.0) - z)
	t_1 = Float64(Float64(Float64(y - x) * z) * -6.0)
	tmp = 0.0
	if (t_0 <= -1000.0)
		tmp = t_1;
	elseif (t_0 <= 1.0)
		tmp = fma(Float64(y - x), 4.0, 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[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision]}, If[LessEqual[t$95$0, -1000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, 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) < -1e3 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z)

    1. Initial program 99.8%

      \[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. *-commutativeN/A

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

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

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

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

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

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

    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. *-commutativeN/A

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

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

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

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

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

Alternative 4: 75.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{3} - z\\ t_1 := \left(y \cdot -6\right) \cdot z\\ \mathbf{if}\;t\_0 \leq -1000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(y - x, 4, 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 (* (* y -6.0) z)))
   (if (<= t_0 -1000.0) t_1 (if (<= t_0 1.0) (fma (- y x) 4.0 x) t_1))))
double code(double x, double y, double z) {
	double t_0 = (2.0 / 3.0) - z;
	double t_1 = (y * -6.0) * z;
	double tmp;
	if (t_0 <= -1000.0) {
		tmp = t_1;
	} else if (t_0 <= 1.0) {
		tmp = fma((y - x), 4.0, x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z)
	t_0 = Float64(Float64(2.0 / 3.0) - z)
	t_1 = Float64(Float64(y * -6.0) * z)
	tmp = 0.0
	if (t_0 <= -1000.0)
		tmp = t_1;
	elseif (t_0 <= 1.0)
		tmp = fma(Float64(y - x), 4.0, 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[(N[(y * -6.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$0, -1000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\mathsf{fma}\left(y - x, 4, 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) < -1e3 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z)

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\color{blue}{z \cdot -6} + 4\right) \cdot y \]
      12. lower-fma.f6452.3

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

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

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

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

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

      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. *-commutativeN/A

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

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

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

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

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

    Alternative 5: 75.2% accurate, 0.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(z \cdot -6\right) \cdot y\\ t_1 := \left(6 \cdot x\right) \cdot z\\ \mathbf{if}\;z \leq -128000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{+48}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{+167}:\\ \;\;\;\;\left(6 \cdot z\right) \cdot x\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+281}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (* (* z -6.0) y)) (t_1 (* (* 6.0 x) z)))
       (if (<= z -128000000.0)
         t_1
         (if (<= z 0.66)
           (fma (- y x) 4.0 x)
           (if (<= z 5.6e+48)
             t_0
             (if (<= z 9.5e+167) (* (* 6.0 z) x) (if (<= z 2.1e+281) t_0 t_1)))))))
    double code(double x, double y, double z) {
    	double t_0 = (z * -6.0) * y;
    	double t_1 = (6.0 * x) * z;
    	double tmp;
    	if (z <= -128000000.0) {
    		tmp = t_1;
    	} else if (z <= 0.66) {
    		tmp = fma((y - x), 4.0, x);
    	} else if (z <= 5.6e+48) {
    		tmp = t_0;
    	} else if (z <= 9.5e+167) {
    		tmp = (6.0 * z) * x;
    	} else if (z <= 2.1e+281) {
    		tmp = t_0;
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    function code(x, y, z)
    	t_0 = Float64(Float64(z * -6.0) * y)
    	t_1 = Float64(Float64(6.0 * x) * z)
    	tmp = 0.0
    	if (z <= -128000000.0)
    		tmp = t_1;
    	elseif (z <= 0.66)
    		tmp = fma(Float64(y - x), 4.0, x);
    	elseif (z <= 5.6e+48)
    		tmp = t_0;
    	elseif (z <= 9.5e+167)
    		tmp = Float64(Float64(6.0 * z) * x);
    	elseif (z <= 2.1e+281)
    		tmp = t_0;
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * -6.0), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -128000000.0], t$95$1, If[LessEqual[z, 0.66], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[z, 5.6e+48], t$95$0, If[LessEqual[z, 9.5e+167], N[(N[(6.0 * z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[z, 2.1e+281], t$95$0, t$95$1]]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \left(z \cdot -6\right) \cdot y\\
    t_1 := \left(6 \cdot x\right) \cdot z\\
    \mathbf{if}\;z \leq -128000000:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;z \leq 0.66:\\
    \;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
    
    \mathbf{elif}\;z \leq 5.6 \cdot 10^{+48}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;z \leq 9.5 \cdot 10^{+167}:\\
    \;\;\;\;\left(6 \cdot z\right) \cdot x\\
    
    \mathbf{elif}\;z \leq 2.1 \cdot 10^{+281}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if z < -1.28e8 or 2.10000000000000007e281 < z

      1. Initial program 99.8%

        \[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. lift-+.f64N/A

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{fma}\left(\frac{2}{3} - z, \color{blue}{6 \cdot \left(y - x\right)}, x\right) \]
        10. lower-*.f6499.8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \left(6 \cdot z + \color{blue}{-3}\right) \cdot x \]
        16. lower-fma.f6458.2

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

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

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

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

        if -1.28e8 < z < 0.660000000000000031

        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. *-commutativeN/A

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

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

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

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

        if 0.660000000000000031 < z < 5.60000000000000025e48 or 9.5000000000000006e167 < z < 2.10000000000000007e281

        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 y around inf

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(\color{blue}{z \cdot -6} + 4\right) \cdot y \]
          12. lower-fma.f6474.9

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

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

          \[\leadsto \left(-6 \cdot z\right) \cdot y \]
        7. Step-by-step derivation
          1. Applied rewrites73.2%

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

          if 5.60000000000000025e48 < z < 9.5000000000000006e167

          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. lift-+.f64N/A

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{fma}\left(\frac{2}{3} - z, \color{blue}{6 \cdot \left(y - x\right)}, x\right) \]
            10. lower-*.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \left(6 \cdot z\right) \cdot x \]
          9. Step-by-step derivation
            1. Applied rewrites69.1%

              \[\leadsto \left(z \cdot 6\right) \cdot x \]
          10. Recombined 4 regimes into one program.
          11. Final simplification79.3%

            \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -128000000:\\ \;\;\;\;\left(6 \cdot x\right) \cdot z\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{+48}:\\ \;\;\;\;\left(z \cdot -6\right) \cdot y\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{+167}:\\ \;\;\;\;\left(6 \cdot z\right) \cdot x\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+281}:\\ \;\;\;\;\left(z \cdot -6\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(6 \cdot x\right) \cdot z\\ \end{array} \]
          12. Add Preprocessing

          Alternative 6: 75.2% accurate, 0.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(z \cdot -6\right) \cdot y\\ t_1 := \left(6 \cdot x\right) \cdot z\\ \mathbf{if}\;z \leq -128000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{+48}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{+167}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+281}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (let* ((t_0 (* (* z -6.0) y)) (t_1 (* (* 6.0 x) z)))
             (if (<= z -128000000.0)
               t_1
               (if (<= z 0.66)
                 (fma (- y x) 4.0 x)
                 (if (<= z 5.6e+48)
                   t_0
                   (if (<= z 9.5e+167) t_1 (if (<= z 2.1e+281) t_0 t_1)))))))
          double code(double x, double y, double z) {
          	double t_0 = (z * -6.0) * y;
          	double t_1 = (6.0 * x) * z;
          	double tmp;
          	if (z <= -128000000.0) {
          		tmp = t_1;
          	} else if (z <= 0.66) {
          		tmp = fma((y - x), 4.0, x);
          	} else if (z <= 5.6e+48) {
          		tmp = t_0;
          	} else if (z <= 9.5e+167) {
          		tmp = t_1;
          	} else if (z <= 2.1e+281) {
          		tmp = t_0;
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	t_0 = Float64(Float64(z * -6.0) * y)
          	t_1 = Float64(Float64(6.0 * x) * z)
          	tmp = 0.0
          	if (z <= -128000000.0)
          		tmp = t_1;
          	elseif (z <= 0.66)
          		tmp = fma(Float64(y - x), 4.0, x);
          	elseif (z <= 5.6e+48)
          		tmp = t_0;
          	elseif (z <= 9.5e+167)
          		tmp = t_1;
          	elseif (z <= 2.1e+281)
          		tmp = t_0;
          	else
          		tmp = t_1;
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * -6.0), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -128000000.0], t$95$1, If[LessEqual[z, 0.66], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[z, 5.6e+48], t$95$0, If[LessEqual[z, 9.5e+167], t$95$1, If[LessEqual[z, 2.1e+281], t$95$0, t$95$1]]]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \left(z \cdot -6\right) \cdot y\\
          t_1 := \left(6 \cdot x\right) \cdot z\\
          \mathbf{if}\;z \leq -128000000:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;z \leq 0.66:\\
          \;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
          
          \mathbf{elif}\;z \leq 5.6 \cdot 10^{+48}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;z \leq 9.5 \cdot 10^{+167}:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;z \leq 2.1 \cdot 10^{+281}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if z < -1.28e8 or 5.60000000000000025e48 < z < 9.5000000000000006e167 or 2.10000000000000007e281 < z

            1. Initial program 99.8%

              \[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. lift-+.f64N/A

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{fma}\left(\frac{2}{3} - z, \color{blue}{6 \cdot \left(y - x\right)}, x\right) \]
              10. lower-*.f6499.7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              if -1.28e8 < z < 0.660000000000000031

              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. *-commutativeN/A

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

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

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

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

              if 0.660000000000000031 < z < 5.60000000000000025e48 or 9.5000000000000006e167 < z < 2.10000000000000007e281

              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 y around inf

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(\color{blue}{z \cdot -6} + 4\right) \cdot y \]
                12. lower-fma.f6474.9

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

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

                \[\leadsto \left(-6 \cdot z\right) \cdot y \]
              7. Step-by-step derivation
                1. Applied rewrites73.2%

                  \[\leadsto \left(z \cdot -6\right) \cdot y \]
              8. Recombined 3 regimes into one program.
              9. Add Preprocessing

              Alternative 7: 75.6% accurate, 0.9× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(6, z, -3\right) \cdot x\\ \mathbf{if}\;z \leq -128000000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{+167}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{+281}:\\ \;\;\;\;\left(z \cdot -6\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(6 \cdot x\right) \cdot z\\ \end{array} \end{array} \]
              (FPCore (x y z)
               :precision binary64
               (let* ((t_0 (* (fma 6.0 z -3.0) x)))
                 (if (<= z -128000000.0)
                   t_0
                   (if (<= z 1.25e-9)
                     (fma (- y x) 4.0 x)
                     (if (<= z 9.5e+167)
                       t_0
                       (if (<= z 2.1e+281) (* (* z -6.0) y) (* (* 6.0 x) z)))))))
              double code(double x, double y, double z) {
              	double t_0 = fma(6.0, z, -3.0) * x;
              	double tmp;
              	if (z <= -128000000.0) {
              		tmp = t_0;
              	} else if (z <= 1.25e-9) {
              		tmp = fma((y - x), 4.0, x);
              	} else if (z <= 9.5e+167) {
              		tmp = t_0;
              	} else if (z <= 2.1e+281) {
              		tmp = (z * -6.0) * y;
              	} else {
              		tmp = (6.0 * x) * z;
              	}
              	return tmp;
              }
              
              function code(x, y, z)
              	t_0 = Float64(fma(6.0, z, -3.0) * x)
              	tmp = 0.0
              	if (z <= -128000000.0)
              		tmp = t_0;
              	elseif (z <= 1.25e-9)
              		tmp = fma(Float64(y - x), 4.0, x);
              	elseif (z <= 9.5e+167)
              		tmp = t_0;
              	elseif (z <= 2.1e+281)
              		tmp = Float64(Float64(z * -6.0) * y);
              	else
              		tmp = Float64(Float64(6.0 * x) * z);
              	end
              	return tmp
              end
              
              code[x_, y_, z_] := Block[{t$95$0 = N[(N[(6.0 * z + -3.0), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[z, -128000000.0], t$95$0, If[LessEqual[z, 1.25e-9], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], If[LessEqual[z, 9.5e+167], t$95$0, If[LessEqual[z, 2.1e+281], N[(N[(z * -6.0), $MachinePrecision] * y), $MachinePrecision], N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              t_0 := \mathsf{fma}\left(6, z, -3\right) \cdot x\\
              \mathbf{if}\;z \leq -128000000:\\
              \;\;\;\;t\_0\\
              
              \mathbf{elif}\;z \leq 1.25 \cdot 10^{-9}:\\
              \;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
              
              \mathbf{elif}\;z \leq 9.5 \cdot 10^{+167}:\\
              \;\;\;\;t\_0\\
              
              \mathbf{elif}\;z \leq 2.1 \cdot 10^{+281}:\\
              \;\;\;\;\left(z \cdot -6\right) \cdot y\\
              
              \mathbf{else}:\\
              \;\;\;\;\left(6 \cdot x\right) \cdot z\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 4 regimes
              2. if z < -1.28e8 or 1.25e-9 < z < 9.5000000000000006e167

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

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

                    \[\leadsto x + \color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(x \cdot \left(\frac{2}{3} - z\right)\right) \]
                  2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(6 \cdot \left(\frac{2}{3} - z\right) - 1\right)\right)\right) \cdot x} \]
                  18. lower-*.f64N/A

                    \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(6 \cdot \left(\frac{2}{3} - z\right) - 1\right)\right)\right) \cdot x} \]
                5. Applied rewrites58.0%

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

                if -1.28e8 < z < 1.25e-9

                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. *-commutativeN/A

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

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

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

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

                if 9.5000000000000006e167 < z < 2.10000000000000007e281

                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 y around inf

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \left(\color{blue}{z \cdot -6} + 4\right) \cdot y \]
                  12. lower-fma.f6471.7

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

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

                  \[\leadsto \left(-6 \cdot z\right) \cdot y \]
                7. Step-by-step derivation
                  1. Applied rewrites71.8%

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

                  if 2.10000000000000007e281 < z

                  1. Initial program 100.0%

                    \[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. lift-+.f64N/A

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

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

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

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

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(\frac{2}{3} - z, \color{blue}{6 \cdot \left(y - x\right)}, x\right) \]
                    10. lower-*.f64100.0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \left(6 \cdot z + \color{blue}{-3}\right) \cdot x \]
                    16. lower-fma.f6485.5

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

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

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

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

                  Alternative 8: 74.4% accurate, 1.3× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \mathsf{fma}\left(z, -6, 4\right) \cdot y\\ \mathbf{if}\;y \leq -7.8 \cdot 10^{+20}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{-98}:\\ \;\;\;\;\mathsf{fma}\left(6, z, -3\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                  (FPCore (x y z)
                   :precision binary64
                   (let* ((t_0 (* (fma z -6.0 4.0) y)))
                     (if (<= y -7.8e+20) t_0 (if (<= y 5.4e-98) (* (fma 6.0 z -3.0) x) t_0))))
                  double code(double x, double y, double z) {
                  	double t_0 = fma(z, -6.0, 4.0) * y;
                  	double tmp;
                  	if (y <= -7.8e+20) {
                  		tmp = t_0;
                  	} else if (y <= 5.4e-98) {
                  		tmp = fma(6.0, z, -3.0) * x;
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  function code(x, y, z)
                  	t_0 = Float64(fma(z, -6.0, 4.0) * y)
                  	tmp = 0.0
                  	if (y <= -7.8e+20)
                  		tmp = t_0;
                  	elseif (y <= 5.4e-98)
                  		tmp = Float64(fma(6.0, z, -3.0) * x);
                  	else
                  		tmp = t_0;
                  	end
                  	return tmp
                  end
                  
                  code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * -6.0 + 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[y, -7.8e+20], t$95$0, If[LessEqual[y, 5.4e-98], N[(N[(6.0 * z + -3.0), $MachinePrecision] * x), $MachinePrecision], t$95$0]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \mathsf{fma}\left(z, -6, 4\right) \cdot y\\
                  \mathbf{if}\;y \leq -7.8 \cdot 10^{+20}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;y \leq 5.4 \cdot 10^{-98}:\\
                  \;\;\;\;\mathsf{fma}\left(6, z, -3\right) \cdot x\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if y < -7.8e20 or 5.3999999999999997e-98 < y

                    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 y around inf

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\color{blue}{z \cdot -6} + 4\right) \cdot y \]
                      12. lower-fma.f6479.7

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

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

                    if -7.8e20 < y < 5.3999999999999997e-98

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

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

                        \[\leadsto x + \color{blue}{\left(\mathsf{neg}\left(6\right)\right)} \cdot \left(x \cdot \left(\frac{2}{3} - z\right)\right) \]
                      2. cancel-sign-sub-invN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(6 \cdot \left(\frac{2}{3} - z\right) - 1\right)\right)\right) \cdot x} \]
                      18. lower-*.f64N/A

                        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(6 \cdot \left(\frac{2}{3} - z\right) - 1\right)\right)\right) \cdot x} \]
                    5. Applied rewrites79.8%

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

                  Alternative 9: 75.1% accurate, 1.3× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(z \cdot -6\right) \cdot y\\ \mathbf{if}\;z \leq -2.2:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 0.66:\\ \;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                  (FPCore (x y z)
                   :precision binary64
                   (let* ((t_0 (* (* z -6.0) y)))
                     (if (<= z -2.2) t_0 (if (<= z 0.66) (fma (- y x) 4.0 x) t_0))))
                  double code(double x, double y, double z) {
                  	double t_0 = (z * -6.0) * y;
                  	double tmp;
                  	if (z <= -2.2) {
                  		tmp = t_0;
                  	} else if (z <= 0.66) {
                  		tmp = fma((y - x), 4.0, x);
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  function code(x, y, z)
                  	t_0 = Float64(Float64(z * -6.0) * y)
                  	tmp = 0.0
                  	if (z <= -2.2)
                  		tmp = t_0;
                  	elseif (z <= 0.66)
                  		tmp = fma(Float64(y - x), 4.0, x);
                  	else
                  		tmp = t_0;
                  	end
                  	return tmp
                  end
                  
                  code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z * -6.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[z, -2.2], t$95$0, If[LessEqual[z, 0.66], N[(N[(y - x), $MachinePrecision] * 4.0 + x), $MachinePrecision], t$95$0]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_0 := \left(z \cdot -6\right) \cdot y\\
                  \mathbf{if}\;z \leq -2.2:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;z \leq 0.66:\\
                  \;\;\;\;\mathsf{fma}\left(y - x, 4, x\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if z < -2.2000000000000002 or 0.660000000000000031 < z

                    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \left(\color{blue}{z \cdot -6} + 4\right) \cdot y \]
                      12. lower-fma.f6452.3

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

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

                      \[\leadsto \left(-6 \cdot z\right) \cdot y \]
                    7. Step-by-step derivation
                      1. Applied rewrites50.8%

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

                      if -2.2000000000000002 < z < 0.660000000000000031

                      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. *-commutativeN/A

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

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

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

                        \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 4, x\right)} \]
                    8. Recombined 2 regimes into one program.
                    9. Add Preprocessing

                    Alternative 10: 38.0% accurate, 1.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

                          \[\leadsto \left(\color{blue}{z \cdot -6} + 4\right) \cdot y \]
                        12. lower-fma.f6482.1

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

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

                        \[\leadsto 4 \cdot y \]
                      7. Step-by-step derivation
                        1. Applied rewrites41.9%

                          \[\leadsto 4 \cdot y \]

                        if -8.5000000000000008e84 < y < 2.0499999999999999e-43

                        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 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. *-commutativeN/A

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

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

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

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

                          \[\leadsto x + \color{blue}{-4 \cdot x} \]
                        7. Step-by-step derivation
                          1. Applied rewrites33.6%

                            \[\leadsto -3 \cdot \color{blue}{x} \]
                        8. Recombined 2 regimes into one program.
                        9. Add Preprocessing

                        Alternative 11: 51.1% accurate, 3.1× speedup?

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

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

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

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

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

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

                        Alternative 12: 25.8% accurate, 5.2× speedup?

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

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

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

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

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

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

                          \[\leadsto x + \color{blue}{-4 \cdot x} \]
                        7. Step-by-step derivation
                          1. Applied rewrites22.1%

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

                          Reproduce

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