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

Percentage Accurate: 99.5% → 99.5%
Time: 6.8s
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.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}
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. Add Preprocessing

Alternative 2: 73.9% accurate, 0.6× speedup?

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

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

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


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

    1. Initial program 99.8%

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

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

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

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

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

      if -5e6 < (-.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. Applied rewrites97.6%

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

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

      Alternative 3: 74.7% accurate, 1.1× speedup?

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

        1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{6 \cdot \left(y \cdot \left(\frac{2}{3} - z\right)\right)} \]
        6. Applied rewrites64.2%

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

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

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

          if -6.1e7 < z < 0.619999999999999996

          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. Applied rewrites96.8%

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

              \[\leadsto x \cdot \color{blue}{\left(4 \cdot \frac{y}{x} - 3\right)} \]
            3. Applied rewrites88.9%

              \[\leadsto \mathsf{fma}\left(\frac{4}{x}, y, -3\right) \cdot \color{blue}{x} \]
            4. Step-by-step derivation
              1. Applied rewrites88.9%

                \[\leadsto \mathsf{fma}\left(x, -3, x \cdot \left(\frac{4}{x} \cdot y\right)\right) \]
              2. Taylor expanded in x around 0

                \[\leadsto \mathsf{fma}\left(x, -3, 4 \cdot y\right) \]
              3. Step-by-step derivation
                1. Applied rewrites96.9%

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

                if 0.619999999999999996 < z < 5.00000000000000019e200

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

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

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

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

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

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

                Alternative 4: 74.6% accurate, 1.1× speedup?

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

                  1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{6 \cdot \left(y \cdot \left(\frac{2}{3} - z\right)\right)} \]
                  6. Applied rewrites64.2%

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

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

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

                    if -6.1e7 < z < 0.619999999999999996

                    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. Applied rewrites96.8%

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

                      if 0.619999999999999996 < z < 5.00000000000000019e200

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

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

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

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

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

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

                      Alternative 5: 97.7% accurate, 1.2× speedup?

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

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

                          if -0.599999999999999978 < z < 0.619999999999999996

                          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. Applied rewrites97.6%

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

                              \[\leadsto x \cdot \color{blue}{\left(4 \cdot \frac{y}{x} - 3\right)} \]
                            3. Applied rewrites89.5%

                              \[\leadsto \mathsf{fma}\left(\frac{4}{x}, y, -3\right) \cdot \color{blue}{x} \]
                            4. Step-by-step derivation
                              1. Applied rewrites89.6%

                                \[\leadsto \mathsf{fma}\left(x, -3, x \cdot \left(\frac{4}{x} \cdot y\right)\right) \]
                              2. Taylor expanded in x around 0

                                \[\leadsto \mathsf{fma}\left(x, -3, 4 \cdot y\right) \]
                              3. Step-by-step derivation
                                1. Applied rewrites97.6%

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

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

                              Alternative 6: 97.7% accurate, 1.2× speedup?

                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.68:\\ \;\;\;\;\mathsf{fma}\left(-6 \cdot z, y - x, x\right)\\ \mathbf{elif}\;z \leq 0.62:\\ \;\;\;\;\mathsf{fma}\left(x, -3, 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.68)
                                 (fma (* -6.0 z) (- y x) x)
                                 (if (<= z 0.62) (fma x -3.0 (* 4.0 y)) (* (* (- y x) z) -6.0))))
                              double code(double x, double y, double z) {
                              	double tmp;
                              	if (z <= -0.68) {
                              		tmp = fma((-6.0 * z), (y - x), x);
                              	} else if (z <= 0.62) {
                              		tmp = fma(x, -3.0, (4.0 * y));
                              	} else {
                              		tmp = ((y - x) * z) * -6.0;
                              	}
                              	return tmp;
                              }
                              
                              function code(x, y, z)
                              	tmp = 0.0
                              	if (z <= -0.68)
                              		tmp = fma(Float64(-6.0 * z), Float64(y - x), x);
                              	elseif (z <= 0.62)
                              		tmp = fma(x, -3.0, 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.68], N[(N[(-6.0 * z), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[z, 0.62], N[(x * -3.0 + 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.68:\\
                              \;\;\;\;\mathsf{fma}\left(-6 \cdot z, y - x, x\right)\\
                              
                              \mathbf{elif}\;z \leq 0.62:\\
                              \;\;\;\;\mathsf{fma}\left(x, -3, 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.680000000000000049

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

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

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

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

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

                                  if -0.680000000000000049 < z < 0.619999999999999996

                                  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. Applied rewrites97.6%

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

                                      \[\leadsto x \cdot \color{blue}{\left(4 \cdot \frac{y}{x} - 3\right)} \]
                                    3. Applied rewrites89.5%

                                      \[\leadsto \mathsf{fma}\left(\frac{4}{x}, y, -3\right) \cdot \color{blue}{x} \]
                                    4. Step-by-step derivation
                                      1. Applied rewrites89.6%

                                        \[\leadsto \mathsf{fma}\left(x, -3, x \cdot \left(\frac{4}{x} \cdot y\right)\right) \]
                                      2. Taylor expanded in x around 0

                                        \[\leadsto \mathsf{fma}\left(x, -3, 4 \cdot y\right) \]
                                      3. Step-by-step derivation
                                        1. Applied rewrites97.6%

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

                                        if 0.619999999999999996 < 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. Applied rewrites98.3%

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

                                        Alternative 7: 75.7% accurate, 1.3× speedup?

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

                                          1. Initial program 99.6%

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

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

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

                                            if -2.5e11 < y < 1.3500000000000001e-9

                                            1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                          Alternative 8: 75.9% accurate, 1.3× speedup?

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

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

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

                                              if -5.8999999999999999e-8 < z < 4.00000000000000019e-4

                                              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. Applied rewrites99.3%

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

                                                  \[\leadsto x \cdot \color{blue}{\left(4 \cdot \frac{y}{x} - 3\right)} \]
                                                3. Applied rewrites91.1%

                                                  \[\leadsto \mathsf{fma}\left(\frac{4}{x}, y, -3\right) \cdot \color{blue}{x} \]
                                                4. Step-by-step derivation
                                                  1. Applied rewrites91.1%

                                                    \[\leadsto \mathsf{fma}\left(x, -3, x \cdot \left(\frac{4}{x} \cdot y\right)\right) \]
                                                  2. Taylor expanded in x around 0

                                                    \[\leadsto \mathsf{fma}\left(x, -3, 4 \cdot y\right) \]
                                                  3. Step-by-step derivation
                                                    1. Applied rewrites99.4%

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

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

                                                  Alternative 9: 38.0% accurate, 1.6× speedup?

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

                                                    1. Initial program 99.7%

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

                                                      \[\leadsto \color{blue}{x + 4 \cdot \left(y - x\right)} \]
                                                    4. Step-by-step derivation
                                                      1. Applied rewrites47.2%

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

                                                        \[\leadsto 4 \cdot \color{blue}{y} \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites31.9%

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

                                                        if -2800 < y < 2.60000000000000013e-19

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

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

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

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

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

                                                          if 2.60000000000000013e-19 < y

                                                          1. Initial program 99.6%

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

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

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

                                                              \[\leadsto \mathsf{fma}\left(4, y, x\right) \]
                                                            3. Step-by-step derivation
                                                              1. Applied rewrites39.7%

                                                                \[\leadsto \mathsf{fma}\left(4, y, x\right) \]
                                                            4. Recombined 3 regimes into one program.
                                                            5. Add Preprocessing

                                                            Alternative 10: 38.1% accurate, 1.7× speedup?

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

                                                              1. Initial program 99.6%

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

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

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

                                                                  \[\leadsto 4 \cdot \color{blue}{y} \]
                                                                3. Step-by-step derivation
                                                                  1. Applied rewrites35.9%

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

                                                                  if -2800 < y < 2.60000000000000013e-19

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

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

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

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

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

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

                                                                  Alternative 11: 99.5% accurate, 1.7× speedup?

                                                                  \[\begin{array}{l} \\ \mathsf{fma}\left(0.6666666666666666 - z, 6 \cdot \left(y - x\right), x\right) \end{array} \]
                                                                  (FPCore (x y z)
                                                                   :precision binary64
                                                                   (fma (- 0.6666666666666666 z) (* 6.0 (- y x)) x))
                                                                  double code(double x, double y, double z) {
                                                                  	return fma((0.6666666666666666 - z), (6.0 * (y - x)), x);
                                                                  }
                                                                  
                                                                  function code(x, y, z)
                                                                  	return fma(Float64(0.6666666666666666 - z), Float64(6.0 * Float64(y - x)), x)
                                                                  end
                                                                  
                                                                  code[x_, y_, z_] := N[(N[(0.6666666666666666 - z), $MachinePrecision] * N[(6.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
                                                                  
                                                                  \begin{array}{l}
                                                                  
                                                                  \\
                                                                  \mathsf{fma}\left(0.6666666666666666 - z, 6 \cdot \left(y - x\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. Step-by-step derivation
                                                                    1. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

                                                                  Alternative 12: 99.5% accurate, 1.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                                  Alternative 13: 99.8% accurate, 1.9× speedup?

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

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

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

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

                                                                  Alternative 14: 50.4% 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. Applied rewrites47.0%

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

                                                                    Alternative 15: 26.2% accurate, 5.2× speedup?

                                                                    \[\begin{array}{l} \\ 4 \cdot y \end{array} \]
                                                                    (FPCore (x y z) :precision binary64 (* 4.0 y))
                                                                    double code(double x, double y, double z) {
                                                                    	return 4.0 * y;
                                                                    }
                                                                    
                                                                    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 = 4.0d0 * y
                                                                    end function
                                                                    
                                                                    public static double code(double x, double y, double z) {
                                                                    	return 4.0 * y;
                                                                    }
                                                                    
                                                                    def code(x, y, z):
                                                                    	return 4.0 * y
                                                                    
                                                                    function code(x, y, z)
                                                                    	return Float64(4.0 * y)
                                                                    end
                                                                    
                                                                    function tmp = code(x, y, z)
                                                                    	tmp = 4.0 * y;
                                                                    end
                                                                    
                                                                    code[x_, y_, z_] := N[(4.0 * y), $MachinePrecision]
                                                                    
                                                                    \begin{array}{l}
                                                                    
                                                                    \\
                                                                    4 \cdot y
                                                                    \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. Applied rewrites47.0%

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

                                                                        \[\leadsto 4 \cdot \color{blue}{y} \]
                                                                      3. Step-by-step derivation
                                                                        1. Applied rewrites23.6%

                                                                          \[\leadsto 4 \cdot \color{blue}{y} \]
                                                                        2. Add Preprocessing

                                                                        Reproduce

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