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

Percentage Accurate: 99.5% → 99.8%
Time: 4.1s
Alternatives: 15
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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    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 15 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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z)
use fmin_fmax_functions
    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.8% accurate, 1.9× speedup?

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

\\
\mathsf{fma}\left(y - x, \mathsf{fma}\left(-6, z, 4\right), 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 + \left(-6 \cdot \left(z \cdot \left(y - x\right)\right) + 4 \cdot \left(y - x\right)\right)} \]
  4. Step-by-step derivation
    1. +-commutativeN/A

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

      \[\leadsto \left(\left(-6 \cdot z\right) \cdot \left(y - x\right) + 4 \cdot \left(y - x\right)\right) + x \]
    3. distribute-rgt-outN/A

      \[\leadsto \left(y - x\right) \cdot \left(-6 \cdot z + 4\right) + x \]
    4. lower-fma.f64N/A

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

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

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

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

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

Alternative 2: 75.0% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+140}:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 99.7%

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

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

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

        \[\leadsto \left(\left(-6 \cdot z\right) \cdot \left(y - x\right) + 4 \cdot \left(y - x\right)\right) + x \]
      3. distribute-rgt-outN/A

        \[\leadsto \left(y - x\right) \cdot \left(-6 \cdot z + 4\right) + x \]
      4. lower-fma.f64N/A

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

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

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

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

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

        \[\leadsto \left(4 + -6 \cdot z\right) \cdot y \]
      2. lower-*.f64N/A

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

        \[\leadsto \left(-6 \cdot z + 4\right) \cdot y \]
      4. lift-fma.f6458.5

        \[\leadsto \mathsf{fma}\left(-6, z, 4\right) \cdot y \]
    8. Applied rewrites58.5%

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

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

    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 4 \cdot \left(y - x\right) + \color{blue}{x} \]
      2. lower-fma.f64N/A

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

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

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

      \[\leadsto -3 \cdot x + \color{blue}{4 \cdot y} \]
    7. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(-3, x, 4 \cdot y\right) \]
      2. lower-*.f6499.6

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

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

    if 5.00000000000000008e140 < (-.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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
      2. lower-*.f64N/A

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

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      4. lower-*.f64N/A

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      5. lift--.f6499.7

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
    5. Applied rewrites99.7%

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

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

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      3. lift-*.f64N/A

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      4. associate-*l*N/A

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

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

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

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

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

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

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

        \[\leadsto \left(\mathsf{neg}\left(x\right)\right) \cdot \left(-6 \cdot z\right) \]
      2. lower-neg.f6472.2

        \[\leadsto \left(-x\right) \cdot \left(-6 \cdot z\right) \]
    10. Applied rewrites72.2%

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

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

Alternative 3: 75.0% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+140}:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 99.7%

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

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

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

        \[\leadsto \left(\left(-6 \cdot z\right) \cdot \left(y - x\right) + 4 \cdot \left(y - x\right)\right) + x \]
      3. distribute-rgt-outN/A

        \[\leadsto \left(y - x\right) \cdot \left(-6 \cdot z + 4\right) + x \]
      4. lower-fma.f64N/A

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

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

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

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

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

        \[\leadsto \left(4 + -6 \cdot z\right) \cdot y \]
      2. lower-*.f64N/A

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

        \[\leadsto \left(-6 \cdot z + 4\right) \cdot y \]
      4. lift-fma.f6458.5

        \[\leadsto \mathsf{fma}\left(-6, z, 4\right) \cdot y \]
    8. Applied rewrites58.5%

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

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

    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 4 \cdot \left(y - x\right) + \color{blue}{x} \]
      2. lower-fma.f64N/A

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

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

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

      \[\leadsto -3 \cdot x + \color{blue}{4 \cdot y} \]
    7. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(-3, x, 4 \cdot y\right) \]
      2. lower-*.f6499.6

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

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

    if 5.00000000000000008e140 < (-.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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
      2. lower-*.f64N/A

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

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      4. lower-*.f64N/A

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      5. lift--.f6499.7

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
    5. Applied rewrites99.7%

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

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

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

        \[\leadsto \left(x \cdot z\right) \cdot 6 \]
      3. *-commutativeN/A

        \[\leadsto \left(z \cdot x\right) \cdot 6 \]
      4. lower-*.f6472.0

        \[\leadsto \left(z \cdot x\right) \cdot 6 \]
    8. Applied rewrites72.0%

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

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

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

        \[\leadsto 6 \cdot \left(z \cdot x\right) \]
      4. *-commutativeN/A

        \[\leadsto 6 \cdot \left(x \cdot z\right) \]
      5. associate-*r*N/A

        \[\leadsto \left(6 \cdot x\right) \cdot z \]
      6. lower-*.f64N/A

        \[\leadsto \left(6 \cdot x\right) \cdot z \]
      7. lower-*.f6472.0

        \[\leadsto \left(6 \cdot x\right) \cdot z \]
    10. Applied rewrites72.0%

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

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

Alternative 4: 74.4% accurate, 0.4× 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 -2000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+140}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\left(6 \cdot x\right) \cdot z\\ \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 -2000000.0)
     t_1
     (if (<= t_0 1.0)
       (fma -3.0 x (* 4.0 y))
       (if (<= t_0 5e+140) t_1 (* (* 6.0 x) z))))))
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 <= -2000000.0) {
		tmp = t_1;
	} else if (t_0 <= 1.0) {
		tmp = fma(-3.0, x, (4.0 * y));
	} else if (t_0 <= 5e+140) {
		tmp = t_1;
	} else {
		tmp = (6.0 * x) * z;
	}
	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 <= -2000000.0)
		tmp = t_1;
	elseif (t_0 <= 1.0)
		tmp = fma(-3.0, x, Float64(4.0 * y));
	elseif (t_0 <= 5e+140)
		tmp = t_1;
	else
		tmp = Float64(Float64(6.0 * x) * z);
	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, -2000000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+140], t$95$1, N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]]]
\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 -2000000:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+140}:\\
\;\;\;\;t\_1\\

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


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

    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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
      2. lower-*.f64N/A

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

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      4. lower-*.f64N/A

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      5. lift--.f6498.7

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
    5. Applied rewrites98.7%

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

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

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      3. lift-*.f64N/A

        \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      4. associate-*l*N/A

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(\color{blue}{-6} \cdot z\right) \]
      2. Step-by-step derivation
        1. metadata-eval56.3

          \[\leadsto y \cdot \left(-6 \cdot z\right) \]
        2. associate-*l*56.3

          \[\leadsto y \cdot \left(-6 \cdot z\right) \]
        3. *-commutative56.3

          \[\leadsto y \cdot \left(-6 \cdot z\right) \]
        4. associate-*l*56.3

          \[\leadsto y \cdot \left(-6 \cdot z\right) \]
        5. +-commutative56.3

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

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

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

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

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

          \[\leadsto \left(y \cdot -6\right) \cdot z \]
      3. Applied rewrites56.3%

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

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

      1. Initial program 99.4%

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

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

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

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

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

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

        \[\leadsto -3 \cdot x + \color{blue}{4 \cdot y} \]
      7. Step-by-step derivation
        1. lower-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(-3, x, 4 \cdot y\right) \]
        2. lower-*.f6498.7

          \[\leadsto \mathsf{fma}\left(-3, x, 4 \cdot y\right) \]
      8. Applied rewrites98.7%

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

      if 5.00000000000000008e140 < (-.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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
        2. lower-*.f64N/A

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

          \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
        4. lower-*.f64N/A

          \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
        5. lift--.f6499.7

          \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      5. Applied rewrites99.7%

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

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

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

          \[\leadsto \left(x \cdot z\right) \cdot 6 \]
        3. *-commutativeN/A

          \[\leadsto \left(z \cdot x\right) \cdot 6 \]
        4. lower-*.f6472.0

          \[\leadsto \left(z \cdot x\right) \cdot 6 \]
      8. Applied rewrites72.0%

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

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

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

          \[\leadsto 6 \cdot \left(z \cdot x\right) \]
        4. *-commutativeN/A

          \[\leadsto 6 \cdot \left(x \cdot z\right) \]
        5. associate-*r*N/A

          \[\leadsto \left(6 \cdot x\right) \cdot z \]
        6. lower-*.f64N/A

          \[\leadsto \left(6 \cdot x\right) \cdot z \]
        7. lower-*.f6472.0

          \[\leadsto \left(6 \cdot x\right) \cdot z \]
      10. Applied rewrites72.0%

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

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

    Alternative 5: 74.4% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{3} - z\\ \mathbf{if}\;t\_0 \leq -2000000:\\ \;\;\;\;\left(y \cdot z\right) \cdot -6\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+140}:\\ \;\;\;\;y \cdot \left(-6 \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(6 \cdot x\right) \cdot z\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (- (/ 2.0 3.0) z)))
       (if (<= t_0 -2000000.0)
         (* (* y z) -6.0)
         (if (<= t_0 1.0)
           (fma 4.0 (- y x) x)
           (if (<= t_0 5e+140) (* y (* -6.0 z)) (* (* 6.0 x) z))))))
    double code(double x, double y, double z) {
    	double t_0 = (2.0 / 3.0) - z;
    	double tmp;
    	if (t_0 <= -2000000.0) {
    		tmp = (y * z) * -6.0;
    	} else if (t_0 <= 1.0) {
    		tmp = fma(4.0, (y - x), x);
    	} else if (t_0 <= 5e+140) {
    		tmp = y * (-6.0 * z);
    	} else {
    		tmp = (6.0 * x) * z;
    	}
    	return tmp;
    }
    
    function code(x, y, z)
    	t_0 = Float64(Float64(2.0 / 3.0) - z)
    	tmp = 0.0
    	if (t_0 <= -2000000.0)
    		tmp = Float64(Float64(y * z) * -6.0);
    	elseif (t_0 <= 1.0)
    		tmp = fma(4.0, Float64(y - x), x);
    	elseif (t_0 <= 5e+140)
    		tmp = Float64(y * Float64(-6.0 * z));
    	else
    		tmp = Float64(Float64(6.0 * x) * z);
    	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, -2000000.0], N[(N[(y * z), $MachinePrecision] * -6.0), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$0, 5e+140], N[(y * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision], N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{2}{3} - z\\
    \mathbf{if}\;t\_0 \leq -2000000:\\
    \;\;\;\;\left(y \cdot z\right) \cdot -6\\
    
    \mathbf{elif}\;t\_0 \leq 1:\\
    \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
    
    \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+140}:\\
    \;\;\;\;y \cdot \left(-6 \cdot z\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(6 \cdot x\right) \cdot z\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -2e6

      1. Initial program 99.7%

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

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

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

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

          \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
        4. lower-*.f64N/A

          \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
        5. lift--.f6498.4

          \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
      5. Applied rewrites98.4%

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

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

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

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

        1. Initial program 99.4%

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

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

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

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

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

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

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

        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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
          2. lower-*.f64N/A

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

            \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
          4. lower-*.f64N/A

            \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
          5. lift--.f6499.6

            \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
        5. Applied rewrites99.6%

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

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

            \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
          3. lift-*.f64N/A

            \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
          4. associate-*l*N/A

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

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

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

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

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

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

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

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

          if 5.00000000000000008e140 < (-.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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
            2. lower-*.f64N/A

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

              \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
            4. lower-*.f64N/A

              \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
            5. lift--.f6499.7

              \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
          5. Applied rewrites99.7%

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

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

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

              \[\leadsto \left(x \cdot z\right) \cdot 6 \]
            3. *-commutativeN/A

              \[\leadsto \left(z \cdot x\right) \cdot 6 \]
            4. lower-*.f6472.0

              \[\leadsto \left(z \cdot x\right) \cdot 6 \]
          8. Applied rewrites72.0%

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

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

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

              \[\leadsto 6 \cdot \left(z \cdot x\right) \]
            4. *-commutativeN/A

              \[\leadsto 6 \cdot \left(x \cdot z\right) \]
            5. associate-*r*N/A

              \[\leadsto \left(6 \cdot x\right) \cdot z \]
            6. lower-*.f64N/A

              \[\leadsto \left(6 \cdot x\right) \cdot z \]
            7. lower-*.f6472.0

              \[\leadsto \left(6 \cdot x\right) \cdot z \]
          10. Applied rewrites72.0%

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

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

        Alternative 6: 74.4% accurate, 0.4× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{3} - z\\ t_1 := y \cdot \left(-6 \cdot z\right)\\ \mathbf{if}\;t\_0 \leq -2000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+140}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\left(6 \cdot x\right) \cdot z\\ \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 -2000000.0)
             t_1
             (if (<= t_0 1.0)
               (fma 4.0 (- y x) x)
               (if (<= t_0 5e+140) t_1 (* (* 6.0 x) z))))))
        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 <= -2000000.0) {
        		tmp = t_1;
        	} else if (t_0 <= 1.0) {
        		tmp = fma(4.0, (y - x), x);
        	} else if (t_0 <= 5e+140) {
        		tmp = t_1;
        	} else {
        		tmp = (6.0 * x) * z;
        	}
        	return tmp;
        }
        
        function code(x, y, z)
        	t_0 = Float64(Float64(2.0 / 3.0) - z)
        	t_1 = Float64(y * Float64(-6.0 * z))
        	tmp = 0.0
        	if (t_0 <= -2000000.0)
        		tmp = t_1;
        	elseif (t_0 <= 1.0)
        		tmp = fma(4.0, Float64(y - x), x);
        	elseif (t_0 <= 5e+140)
        		tmp = t_1;
        	else
        		tmp = Float64(Float64(6.0 * x) * z);
        	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[(y * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2000000.0], t$95$1, If[LessEqual[t$95$0, 1.0], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$0, 5e+140], t$95$1, N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision]]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := \frac{2}{3} - z\\
        t_1 := y \cdot \left(-6 \cdot z\right)\\
        \mathbf{if}\;t\_0 \leq -2000000:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;t\_0 \leq 1:\\
        \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
        
        \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+140}:\\
        \;\;\;\;t\_1\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(6 \cdot x\right) \cdot z\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -2e6 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 5.00000000000000008e140

          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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
            2. lower-*.f64N/A

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

              \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
            4. lower-*.f64N/A

              \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
            5. lift--.f6498.7

              \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
          5. Applied rewrites98.7%

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

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

              \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
            3. lift-*.f64N/A

              \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
            4. associate-*l*N/A

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

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

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

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

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

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

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

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

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

            1. Initial program 99.4%

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

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

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

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

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

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

            if 5.00000000000000008e140 < (-.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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
              2. lower-*.f64N/A

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

                \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              4. lower-*.f64N/A

                \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              5. lift--.f6499.7

                \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
            5. Applied rewrites99.7%

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

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

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

                \[\leadsto \left(x \cdot z\right) \cdot 6 \]
              3. *-commutativeN/A

                \[\leadsto \left(z \cdot x\right) \cdot 6 \]
              4. lower-*.f6472.0

                \[\leadsto \left(z \cdot x\right) \cdot 6 \]
            8. Applied rewrites72.0%

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

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

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

                \[\leadsto 6 \cdot \left(z \cdot x\right) \]
              4. *-commutativeN/A

                \[\leadsto 6 \cdot \left(x \cdot z\right) \]
              5. associate-*r*N/A

                \[\leadsto \left(6 \cdot x\right) \cdot z \]
              6. lower-*.f64N/A

                \[\leadsto \left(6 \cdot x\right) \cdot z \]
              7. lower-*.f6472.0

                \[\leadsto \left(6 \cdot x\right) \cdot z \]
            10. Applied rewrites72.0%

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

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

          Alternative 7: 74.5% accurate, 1.1× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.55 \cdot 10^{+142}:\\ \;\;\;\;\left(6 \cdot x\right) \cdot z\\ \mathbf{elif}\;z \leq -65 \lor \neg \left(z \leq 0.65\right):\\ \;\;\;\;\left(y \cdot -6\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (<= z -1.55e+142)
             (* (* 6.0 x) z)
             (if (or (<= z -65.0) (not (<= z 0.65)))
               (* (* y -6.0) z)
               (fma 4.0 (- y x) x))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (z <= -1.55e+142) {
          		tmp = (6.0 * x) * z;
          	} else if ((z <= -65.0) || !(z <= 0.65)) {
          		tmp = (y * -6.0) * z;
          	} else {
          		tmp = fma(4.0, (y - x), x);
          	}
          	return tmp;
          }
          
          function code(x, y, z)
          	tmp = 0.0
          	if (z <= -1.55e+142)
          		tmp = Float64(Float64(6.0 * x) * z);
          	elseif ((z <= -65.0) || !(z <= 0.65))
          		tmp = Float64(Float64(y * -6.0) * z);
          	else
          		tmp = fma(4.0, Float64(y - x), x);
          	end
          	return tmp
          end
          
          code[x_, y_, z_] := If[LessEqual[z, -1.55e+142], N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision], If[Or[LessEqual[z, -65.0], N[Not[LessEqual[z, 0.65]], $MachinePrecision]], N[(N[(y * -6.0), $MachinePrecision] * z), $MachinePrecision], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;z \leq -1.55 \cdot 10^{+142}:\\
          \;\;\;\;\left(6 \cdot x\right) \cdot z\\
          
          \mathbf{elif}\;z \leq -65 \lor \neg \left(z \leq 0.65\right):\\
          \;\;\;\;\left(y \cdot -6\right) \cdot z\\
          
          \mathbf{else}:\\
          \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if z < -1.55e142

            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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
              2. lower-*.f64N/A

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

                \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              4. lower-*.f64N/A

                \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              5. lift--.f6499.7

                \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
            5. Applied rewrites99.7%

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

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

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

                \[\leadsto \left(x \cdot z\right) \cdot 6 \]
              3. *-commutativeN/A

                \[\leadsto \left(z \cdot x\right) \cdot 6 \]
              4. lower-*.f6472.0

                \[\leadsto \left(z \cdot x\right) \cdot 6 \]
            8. Applied rewrites72.0%

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

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

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

                \[\leadsto 6 \cdot \left(z \cdot x\right) \]
              4. *-commutativeN/A

                \[\leadsto 6 \cdot \left(x \cdot z\right) \]
              5. associate-*r*N/A

                \[\leadsto \left(6 \cdot x\right) \cdot z \]
              6. lower-*.f64N/A

                \[\leadsto \left(6 \cdot x\right) \cdot z \]
              7. lower-*.f6472.0

                \[\leadsto \left(6 \cdot x\right) \cdot z \]
            10. Applied rewrites72.0%

              \[\leadsto \left(6 \cdot x\right) \cdot z \]

            if -1.55e142 < z < -65 or 0.650000000000000022 < 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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
              2. lower-*.f64N/A

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

                \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              4. lower-*.f64N/A

                \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              5. lift--.f6498.7

                \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
            5. Applied rewrites98.7%

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

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

                \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              3. lift-*.f64N/A

                \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              4. associate-*l*N/A

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

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

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

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

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

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

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

                \[\leadsto y \cdot \left(\color{blue}{-6} \cdot z\right) \]
              2. Step-by-step derivation
                1. metadata-eval56.3

                  \[\leadsto y \cdot \left(-6 \cdot z\right) \]
                2. associate-*l*56.3

                  \[\leadsto y \cdot \left(-6 \cdot z\right) \]
                3. *-commutative56.3

                  \[\leadsto y \cdot \left(-6 \cdot z\right) \]
                4. associate-*l*56.3

                  \[\leadsto y \cdot \left(-6 \cdot z\right) \]
                5. +-commutative56.3

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

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

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

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

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

                  \[\leadsto \left(y \cdot -6\right) \cdot z \]
              3. Applied rewrites56.3%

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

              if -65 < z < 0.650000000000000022

              1. Initial program 99.4%

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

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

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

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

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

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.55 \cdot 10^{+142}:\\ \;\;\;\;\left(6 \cdot x\right) \cdot z\\ \mathbf{elif}\;z \leq -65 \lor \neg \left(z \leq 0.65\right):\\ \;\;\;\;\left(y \cdot -6\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \end{array} \]
            12. Add Preprocessing

            Alternative 8: 97.7% accurate, 1.2× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.52 \lor \neg \left(z \leq 0.5\right):\\ \;\;\;\;\left(\left(y - x\right) \cdot z\right) \cdot -6\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (or (<= z -0.52) (not (<= z 0.5)))
               (* (* (- y x) z) -6.0)
               (fma -3.0 x (* 4.0 y))))
            double code(double x, double y, double z) {
            	double tmp;
            	if ((z <= -0.52) || !(z <= 0.5)) {
            		tmp = ((y - x) * z) * -6.0;
            	} else {
            		tmp = fma(-3.0, x, (4.0 * y));
            	}
            	return tmp;
            }
            
            function code(x, y, z)
            	tmp = 0.0
            	if ((z <= -0.52) || !(z <= 0.5))
            		tmp = Float64(Float64(Float64(y - x) * z) * -6.0);
            	else
            		tmp = fma(-3.0, x, Float64(4.0 * y));
            	end
            	return tmp
            end
            
            code[x_, y_, z_] := If[Or[LessEqual[z, -0.52], N[Not[LessEqual[z, 0.5]], $MachinePrecision]], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;z \leq -0.52 \lor \neg \left(z \leq 0.5\right):\\
            \;\;\;\;\left(\left(y - x\right) \cdot z\right) \cdot -6\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if z < -0.52000000000000002 or 0.5 < 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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
                2. lower-*.f64N/A

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

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
                4. lower-*.f64N/A

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
                5. lift--.f6499.0

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              5. Applied rewrites99.0%

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

              if -0.52000000000000002 < z < 0.5

              1. Initial program 99.4%

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

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

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

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

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

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

                \[\leadsto -3 \cdot x + \color{blue}{4 \cdot y} \]
              7. Step-by-step derivation
                1. lower-fma.f64N/A

                  \[\leadsto \mathsf{fma}\left(-3, x, 4 \cdot y\right) \]
                2. lower-*.f6498.7

                  \[\leadsto \mathsf{fma}\left(-3, x, 4 \cdot y\right) \]
              8. Applied rewrites98.7%

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

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

            Alternative 9: 74.8% accurate, 1.2× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{-101} \lor \neg \left(x \leq 10^{-9}\right):\\ \;\;\;\;\left(-x\right) \cdot \mathsf{fma}\left(-6, z, 3\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (or (<= x -1.9e-101) (not (<= x 1e-9)))
               (* (- x) (fma -6.0 z 3.0))
               (* (fma -6.0 z 4.0) y)))
            double code(double x, double y, double z) {
            	double tmp;
            	if ((x <= -1.9e-101) || !(x <= 1e-9)) {
            		tmp = -x * fma(-6.0, z, 3.0);
            	} else {
            		tmp = fma(-6.0, z, 4.0) * y;
            	}
            	return tmp;
            }
            
            function code(x, y, z)
            	tmp = 0.0
            	if ((x <= -1.9e-101) || !(x <= 1e-9))
            		tmp = Float64(Float64(-x) * fma(-6.0, z, 3.0));
            	else
            		tmp = Float64(fma(-6.0, z, 4.0) * y);
            	end
            	return tmp
            end
            
            code[x_, y_, z_] := If[Or[LessEqual[x, -1.9e-101], N[Not[LessEqual[x, 1e-9]], $MachinePrecision]], N[((-x) * N[(-6.0 * z + 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq -1.9 \cdot 10^{-101} \lor \neg \left(x \leq 10^{-9}\right):\\
            \;\;\;\;\left(-x\right) \cdot \mathsf{fma}\left(-6, z, 3\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -1.90000000000000005e-101 or 1.00000000000000006e-9 < x

              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 + \left(-6 \cdot \left(z \cdot \left(y - x\right)\right) + 4 \cdot \left(y - x\right)\right)} \]
              4. Step-by-step derivation
                1. +-commutativeN/A

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

                  \[\leadsto \left(\left(-6 \cdot z\right) \cdot \left(y - x\right) + 4 \cdot \left(y - x\right)\right) + x \]
                3. distribute-rgt-outN/A

                  \[\leadsto \left(y - x\right) \cdot \left(-6 \cdot z + 4\right) + x \]
                4. lower-fma.f64N/A

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(-x\right) \cdot \left(-6 \cdot z + 3\right) \]
                6. lower-fma.f6478.6

                  \[\leadsto \left(-x\right) \cdot \mathsf{fma}\left(-6, z, 3\right) \]
              8. Applied rewrites78.6%

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

              if -1.90000000000000005e-101 < x < 1.00000000000000006e-9

              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 + \left(-6 \cdot \left(z \cdot \left(y - x\right)\right) + 4 \cdot \left(y - x\right)\right)} \]
              4. Step-by-step derivation
                1. +-commutativeN/A

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

                  \[\leadsto \left(\left(-6 \cdot z\right) \cdot \left(y - x\right) + 4 \cdot \left(y - x\right)\right) + x \]
                3. distribute-rgt-outN/A

                  \[\leadsto \left(y - x\right) \cdot \left(-6 \cdot z + 4\right) + x \]
                4. lower-fma.f64N/A

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

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

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

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

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

                  \[\leadsto \left(4 + -6 \cdot z\right) \cdot y \]
                2. lower-*.f64N/A

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

                  \[\leadsto \left(-6 \cdot z + 4\right) \cdot y \]
                4. lift-fma.f6481.2

                  \[\leadsto \mathsf{fma}\left(-6, z, 4\right) \cdot y \]
              8. Applied rewrites81.2%

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

              \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{-101} \lor \neg \left(x \leq 10^{-9}\right):\\ \;\;\;\;\left(-x\right) \cdot \mathsf{fma}\left(-6, z, 3\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\ \end{array} \]
            5. Add Preprocessing

            Alternative 10: 97.7% accurate, 1.2× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.52:\\ \;\;\;\;\left(y - x\right) \cdot \left(-6 \cdot z\right)\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(y - x\right) \cdot z\right) \cdot -6\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (<= z -0.52)
               (* (- y x) (* -6.0 z))
               (if (<= z 0.5) (fma -3.0 x (* 4.0 y)) (* (* (- y x) z) -6.0))))
            double code(double x, double y, double z) {
            	double tmp;
            	if (z <= -0.52) {
            		tmp = (y - x) * (-6.0 * z);
            	} else if (z <= 0.5) {
            		tmp = fma(-3.0, x, (4.0 * y));
            	} else {
            		tmp = ((y - x) * z) * -6.0;
            	}
            	return tmp;
            }
            
            function code(x, y, z)
            	tmp = 0.0
            	if (z <= -0.52)
            		tmp = Float64(Float64(y - x) * Float64(-6.0 * z));
            	elseif (z <= 0.5)
            		tmp = fma(-3.0, x, Float64(4.0 * y));
            	else
            		tmp = Float64(Float64(Float64(y - x) * z) * -6.0);
            	end
            	return tmp
            end
            
            code[x_, y_, z_] := If[LessEqual[z, -0.52], N[(N[(y - x), $MachinePrecision] * N[(-6.0 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 0.5], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision] * -6.0), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;z \leq -0.52:\\
            \;\;\;\;\left(y - x\right) \cdot \left(-6 \cdot z\right)\\
            
            \mathbf{elif}\;z \leq 0.5:\\
            \;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\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 z < -0.52000000000000002

              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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
                2. lower-*.f64N/A

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

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
                4. lower-*.f64N/A

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
                5. lift--.f6499.7

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              5. Applied rewrites99.7%

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

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

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
                3. lift-*.f64N/A

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
                4. associate-*l*N/A

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

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

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

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

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

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

              if -0.52000000000000002 < z < 0.5

              1. Initial program 99.4%

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

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

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

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

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

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

                \[\leadsto -3 \cdot x + \color{blue}{4 \cdot y} \]
              7. Step-by-step derivation
                1. lower-fma.f64N/A

                  \[\leadsto \mathsf{fma}\left(-3, x, 4 \cdot y\right) \]
                2. lower-*.f6498.7

                  \[\leadsto \mathsf{fma}\left(-3, x, 4 \cdot y\right) \]
              8. Applied rewrites98.7%

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

              if 0.5 < z

              1. Initial program 99.7%

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

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

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
                4. lower-*.f64N/A

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
                5. lift--.f6498.4

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              5. Applied rewrites98.4%

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

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

            Alternative 11: 74.8% accurate, 1.2× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.9 \cdot 10^{-101}:\\ \;\;\;\;\left(z \cdot 6 - 3\right) \cdot x\\ \mathbf{elif}\;x \leq 10^{-9}:\\ \;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;\left(-x\right) \cdot \mathsf{fma}\left(-6, z, 3\right)\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (<= x -1.9e-101)
               (* (- (* z 6.0) 3.0) x)
               (if (<= x 1e-9) (* (fma -6.0 z 4.0) y) (* (- x) (fma -6.0 z 3.0)))))
            double code(double x, double y, double z) {
            	double tmp;
            	if (x <= -1.9e-101) {
            		tmp = ((z * 6.0) - 3.0) * x;
            	} else if (x <= 1e-9) {
            		tmp = fma(-6.0, z, 4.0) * y;
            	} else {
            		tmp = -x * fma(-6.0, z, 3.0);
            	}
            	return tmp;
            }
            
            function code(x, y, z)
            	tmp = 0.0
            	if (x <= -1.9e-101)
            		tmp = Float64(Float64(Float64(z * 6.0) - 3.0) * x);
            	elseif (x <= 1e-9)
            		tmp = Float64(fma(-6.0, z, 4.0) * y);
            	else
            		tmp = Float64(Float64(-x) * fma(-6.0, z, 3.0));
            	end
            	return tmp
            end
            
            code[x_, y_, z_] := If[LessEqual[x, -1.9e-101], N[(N[(N[(z * 6.0), $MachinePrecision] - 3.0), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[x, 1e-9], N[(N[(-6.0 * z + 4.0), $MachinePrecision] * y), $MachinePrecision], N[((-x) * N[(-6.0 * z + 3.0), $MachinePrecision]), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq -1.9 \cdot 10^{-101}:\\
            \;\;\;\;\left(z \cdot 6 - 3\right) \cdot x\\
            
            \mathbf{elif}\;x \leq 10^{-9}:\\
            \;\;\;\;\mathsf{fma}\left(-6, z, 4\right) \cdot y\\
            
            \mathbf{else}:\\
            \;\;\;\;\left(-x\right) \cdot \mathsf{fma}\left(-6, z, 3\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if x < -1.90000000000000005e-101

              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 + \left(-6 \cdot \left(z \cdot \left(y - x\right)\right) + 4 \cdot \left(y - x\right)\right)} \]
              4. Step-by-step derivation
                1. +-commutativeN/A

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

                  \[\leadsto \left(\left(-6 \cdot z\right) \cdot \left(y - x\right) + 4 \cdot \left(y - x\right)\right) + x \]
                3. distribute-rgt-outN/A

                  \[\leadsto \left(y - x\right) \cdot \left(-6 \cdot z + 4\right) + x \]
                4. lower-fma.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(x + \left(\left(y - x\right) \cdot z\right) \cdot -6\right) + 4 \cdot \left(y - x\right) \]
                12. lower-*.f64N/A

                  \[\leadsto \left(x + \left(\left(y - x\right) \cdot z\right) \cdot -6\right) + 4 \cdot \left(y - x\right) \]
                13. *-commutativeN/A

                  \[\leadsto \left(x + \left(z \cdot \left(y - x\right)\right) \cdot -6\right) + 4 \cdot \left(y - x\right) \]
                14. lower-*.f64N/A

                  \[\leadsto \left(x + \left(z \cdot \left(y - x\right)\right) \cdot -6\right) + 4 \cdot \left(y - x\right) \]
                15. lift--.f64N/A

                  \[\leadsto \left(x + \left(z \cdot \left(y - x\right)\right) \cdot -6\right) + 4 \cdot \left(y - x\right) \]
                16. lower-*.f64N/A

                  \[\leadsto \left(x + \left(z \cdot \left(y - x\right)\right) \cdot -6\right) + 4 \cdot \color{blue}{\left(y - x\right)} \]
                17. lift--.f6499.8

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

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

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

                  \[\leadsto \left(6 \cdot z - 3\right) \cdot x \]
                2. lower-*.f64N/A

                  \[\leadsto \left(6 \cdot z - 3\right) \cdot x \]
                3. lower--.f64N/A

                  \[\leadsto \left(6 \cdot z - 3\right) \cdot x \]
                4. *-commutativeN/A

                  \[\leadsto \left(z \cdot 6 - 3\right) \cdot x \]
                5. lower-*.f6473.5

                  \[\leadsto \left(z \cdot 6 - 3\right) \cdot x \]
              10. Applied rewrites73.5%

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

              if -1.90000000000000005e-101 < x < 1.00000000000000006e-9

              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 + \left(-6 \cdot \left(z \cdot \left(y - x\right)\right) + 4 \cdot \left(y - x\right)\right)} \]
              4. Step-by-step derivation
                1. +-commutativeN/A

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

                  \[\leadsto \left(\left(-6 \cdot z\right) \cdot \left(y - x\right) + 4 \cdot \left(y - x\right)\right) + x \]
                3. distribute-rgt-outN/A

                  \[\leadsto \left(y - x\right) \cdot \left(-6 \cdot z + 4\right) + x \]
                4. lower-fma.f64N/A

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

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

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

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

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

                  \[\leadsto \left(4 + -6 \cdot z\right) \cdot y \]
                2. lower-*.f64N/A

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

                  \[\leadsto \left(-6 \cdot z + 4\right) \cdot y \]
                4. lift-fma.f6481.2

                  \[\leadsto \mathsf{fma}\left(-6, z, 4\right) \cdot y \]
              8. Applied rewrites81.2%

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

              if 1.00000000000000006e-9 < x

              1. Initial program 99.7%

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

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

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

                  \[\leadsto \left(\left(-6 \cdot z\right) \cdot \left(y - x\right) + 4 \cdot \left(y - x\right)\right) + x \]
                3. distribute-rgt-outN/A

                  \[\leadsto \left(y - x\right) \cdot \left(-6 \cdot z + 4\right) + x \]
                4. lower-fma.f64N/A

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(-x\right) \cdot \left(-6 \cdot z + 3\right) \]
                6. lower-fma.f6484.9

                  \[\leadsto \left(-x\right) \cdot \mathsf{fma}\left(-6, z, 3\right) \]
              8. Applied rewrites84.9%

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

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

            Alternative 12: 73.5% accurate, 1.3× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{+29} \lor \neg \left(z \leq 0.5\right):\\ \;\;\;\;\left(6 \cdot x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (or (<= z -2.6e+29) (not (<= z 0.5)))
               (* (* 6.0 x) z)
               (fma 4.0 (- y x) x)))
            double code(double x, double y, double z) {
            	double tmp;
            	if ((z <= -2.6e+29) || !(z <= 0.5)) {
            		tmp = (6.0 * x) * z;
            	} else {
            		tmp = fma(4.0, (y - x), x);
            	}
            	return tmp;
            }
            
            function code(x, y, z)
            	tmp = 0.0
            	if ((z <= -2.6e+29) || !(z <= 0.5))
            		tmp = Float64(Float64(6.0 * x) * z);
            	else
            		tmp = fma(4.0, Float64(y - x), x);
            	end
            	return tmp
            end
            
            code[x_, y_, z_] := If[Or[LessEqual[z, -2.6e+29], N[Not[LessEqual[z, 0.5]], $MachinePrecision]], N[(N[(6.0 * x), $MachinePrecision] * z), $MachinePrecision], N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;z \leq -2.6 \cdot 10^{+29} \lor \neg \left(z \leq 0.5\right):\\
            \;\;\;\;\left(6 \cdot x\right) \cdot z\\
            
            \mathbf{else}:\\
            \;\;\;\;\mathsf{fma}\left(4, y - x, x\right)\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if z < -2.6e29 or 0.5 < 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 \left(z \cdot \left(y - x\right)\right) \cdot \color{blue}{-6} \]
                2. lower-*.f64N/A

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

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
                4. lower-*.f64N/A

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
                5. lift--.f6499.0

                  \[\leadsto \left(\left(y - x\right) \cdot z\right) \cdot -6 \]
              5. Applied rewrites99.0%

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

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

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

                  \[\leadsto \left(x \cdot z\right) \cdot 6 \]
                3. *-commutativeN/A

                  \[\leadsto \left(z \cdot x\right) \cdot 6 \]
                4. lower-*.f6455.5

                  \[\leadsto \left(z \cdot x\right) \cdot 6 \]
              8. Applied rewrites55.5%

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

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

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

                  \[\leadsto 6 \cdot \left(z \cdot x\right) \]
                4. *-commutativeN/A

                  \[\leadsto 6 \cdot \left(x \cdot z\right) \]
                5. associate-*r*N/A

                  \[\leadsto \left(6 \cdot x\right) \cdot z \]
                6. lower-*.f64N/A

                  \[\leadsto \left(6 \cdot x\right) \cdot z \]
                7. lower-*.f6455.6

                  \[\leadsto \left(6 \cdot x\right) \cdot z \]
              10. Applied rewrites55.6%

                \[\leadsto \left(6 \cdot x\right) \cdot z \]

              if -2.6e29 < z < 0.5

              1. Initial program 99.4%

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

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

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

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

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

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

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

            Alternative 13: 38.3% accurate, 1.7× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{-5} \lor \neg \left(x \leq 10^{-9}\right):\\ \;\;\;\;-3 \cdot x\\ \mathbf{else}:\\ \;\;\;\;4 \cdot y\\ \end{array} \end{array} \]
            (FPCore (x y z)
             :precision binary64
             (if (or (<= x -1.1e-5) (not (<= x 1e-9))) (* -3.0 x) (* 4.0 y)))
            double code(double x, double y, double z) {
            	double tmp;
            	if ((x <= -1.1e-5) || !(x <= 1e-9)) {
            		tmp = -3.0 * x;
            	} else {
            		tmp = 4.0 * y;
            	}
            	return tmp;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(x, y, z)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8) :: tmp
                if ((x <= (-1.1d-5)) .or. (.not. (x <= 1d-9))) 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 ((x <= -1.1e-5) || !(x <= 1e-9)) {
            		tmp = -3.0 * x;
            	} else {
            		tmp = 4.0 * y;
            	}
            	return tmp;
            }
            
            def code(x, y, z):
            	tmp = 0
            	if (x <= -1.1e-5) or not (x <= 1e-9):
            		tmp = -3.0 * x
            	else:
            		tmp = 4.0 * y
            	return tmp
            
            function code(x, y, z)
            	tmp = 0.0
            	if ((x <= -1.1e-5) || !(x <= 1e-9))
            		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 ((x <= -1.1e-5) || ~((x <= 1e-9)))
            		tmp = -3.0 * x;
            	else
            		tmp = 4.0 * y;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_] := If[Or[LessEqual[x, -1.1e-5], N[Not[LessEqual[x, 1e-9]], $MachinePrecision]], N[(-3.0 * x), $MachinePrecision], N[(4.0 * y), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq -1.1 \cdot 10^{-5} \lor \neg \left(x \leq 10^{-9}\right):\\
            \;\;\;\;-3 \cdot x\\
            
            \mathbf{else}:\\
            \;\;\;\;4 \cdot y\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < -1.1e-5 or 1.00000000000000006e-9 < x

              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 4 \cdot \left(y - x\right) + \color{blue}{x} \]
                2. lower-fma.f64N/A

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

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

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

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

                  \[\leadsto -3 \cdot x \]
              8. Applied rewrites41.7%

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

              if -1.1e-5 < x < 1.00000000000000006e-9

              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 4 \cdot \left(y - x\right) + \color{blue}{x} \]
                2. lower-fma.f64N/A

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

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

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

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

                  \[\leadsto 4 \cdot y \]
              8. Applied rewrites42.4%

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

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

            Alternative 14: 50.6% accurate, 3.1× speedup?

            \[\begin{array}{l} \\ \mathsf{fma}\left(4, y - x, x\right) \end{array} \]
            (FPCore (x y z) :precision binary64 (fma 4.0 (- y x) x))
            double code(double x, double y, double z) {
            	return fma(4.0, (y - x), x);
            }
            
            function code(x, y, z)
            	return fma(4.0, Float64(y - x), x)
            end
            
            code[x_, y_, z_] := N[(4.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \mathsf{fma}\left(4, y - x, x\right)
            \end{array}
            
            Derivation
            1. Initial program 99.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 4 \cdot \left(y - x\right) + \color{blue}{x} \]
              2. lower-fma.f64N/A

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(4, y - x, x\right)} \]
            6. Final simplification50.9%

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

            Alternative 15: 25.6% 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;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(x, y, z)
            use fmin_fmax_functions
                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 4 \cdot \left(y - x\right) + \color{blue}{x} \]
              2. lower-fma.f64N/A

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

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

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

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

                \[\leadsto -3 \cdot x \]
            8. Applied rewrites26.8%

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

              \[\leadsto -3 \cdot x \]
            10. Add Preprocessing

            Reproduce

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