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

Percentage Accurate: 99.5% → 99.8%
Time: 8.8s
Alternatives: 14
Speedup: 1.0×

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}

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 14 alternatives:

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

Initial Program: 99.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = x + (((y - x) * 6.0d0) * ((2.0d0 / 3.0d0) - z))
end function
public static double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
def code(x, y, z):
	return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z))
function code(x, y, z)
	return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z)))
end
function tmp = code(x, y, z)
	tmp = x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.8% accurate, 1.0× speedup?

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

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

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

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

Alternative 2: 99.5% accurate, 1.0× speedup?

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

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

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Applied rewrites99.5%

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

Alternative 3: 97.8% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Applied rewrites99.5%

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

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

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

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

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

    if -0.619999999999999996 < z < 0.55000000000000004

    1. Initial program 99.5%

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

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

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

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

    if 0.55000000000000004 < z

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Applied rewrites99.5%

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

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

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

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

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

Alternative 4: 97.7% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Applied rewrites99.5%

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

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

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

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

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

    if -0.619999999999999996 < z < 0.55000000000000004

    1. Initial program 99.5%

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

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

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

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

    if 0.55000000000000004 < z

    1. Initial program 99.5%

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

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

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

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

Alternative 5: 97.7% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 99.5%

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

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

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

    if -0.619999999999999996 < z < 0.55000000000000004

    1. Initial program 99.5%

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

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

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

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

    if 0.55000000000000004 < z

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Applied rewrites99.5%

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

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

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

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

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

Alternative 6: 97.7% accurate, 1.1× speedup?

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

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

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

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


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

    1. Initial program 99.5%

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

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

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

    if -0.619999999999999996 < z < 0.55000000000000004

    1. Initial program 99.5%

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

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

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

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

Alternative 7: 74.9% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;z \leq -21:\\
\;\;\;\;\mathsf{fma}\left(x \cdot z, 6, x\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.75000000000000008e254 or 0.55000000000000004 < z

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

    if -1.75000000000000008e254 < z < -21

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Applied rewrites99.5%

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

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

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

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

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

    if -21 < z < 0.55000000000000004

    1. Initial program 99.5%

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

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

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

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

Alternative 8: 74.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := -6 \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -1.75 \cdot 10^{+254}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq -21:\\
\;\;\;\;\mathsf{fma}\left(x \cdot z, 6, x\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.75000000000000008e254 or 0.660000000000000031 < z

    1. Initial program 99.5%

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

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

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

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

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

    if -1.75000000000000008e254 < z < -21

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Applied rewrites99.5%

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

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

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

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

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

    if -21 < z < 0.660000000000000031

    1. Initial program 99.5%

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

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

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

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

Alternative 9: 74.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := -6 \cdot \left(y \cdot z\right)\\
\mathbf{if}\;z \leq -1.75 \cdot 10^{+254}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;z \leq -11:\\
\;\;\;\;6 \cdot \left(x \cdot z\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.75000000000000008e254 or 0.660000000000000031 < z

    1. Initial program 99.5%

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

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

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

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

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

    if -1.75000000000000008e254 < z < -11

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Applied rewrites99.5%

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

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

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

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

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

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

    if -11 < z < 0.660000000000000031

    1. Initial program 99.5%

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

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

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

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

Alternative 10: 50.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{3} - z\\ t_1 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;t\_0 \leq -20000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 0.667:\\ \;\;\;\;6 \cdot \left(0.6666666666666666 \cdot y\right)\\ \mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+247}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* -6.0 (* y z))))
   (if (<= t_0 -20000.0)
     t_1
     (if (<= t_0 0.667)
       (* 6.0 (* 0.6666666666666666 y))
       (if (<= t_0 4e+247) (* 6.0 (* x z)) t_1)))))
double code(double x, double y, double z) {
	double t_0 = (2.0 / 3.0) - z;
	double t_1 = -6.0 * (y * z);
	double tmp;
	if (t_0 <= -20000.0) {
		tmp = t_1;
	} else if (t_0 <= 0.667) {
		tmp = 6.0 * (0.6666666666666666 * y);
	} else if (t_0 <= 4e+247) {
		tmp = 6.0 * (x * z);
	} else {
		tmp = t_1;
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (2.0d0 / 3.0d0) - z
    t_1 = (-6.0d0) * (y * z)
    if (t_0 <= (-20000.0d0)) then
        tmp = t_1
    else if (t_0 <= 0.667d0) then
        tmp = 6.0d0 * (0.6666666666666666d0 * y)
    else if (t_0 <= 4d+247) then
        tmp = 6.0d0 * (x * z)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (2.0 / 3.0) - z;
	double t_1 = -6.0 * (y * z);
	double tmp;
	if (t_0 <= -20000.0) {
		tmp = t_1;
	} else if (t_0 <= 0.667) {
		tmp = 6.0 * (0.6666666666666666 * y);
	} else if (t_0 <= 4e+247) {
		tmp = 6.0 * (x * z);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (2.0 / 3.0) - z
	t_1 = -6.0 * (y * z)
	tmp = 0
	if t_0 <= -20000.0:
		tmp = t_1
	elif t_0 <= 0.667:
		tmp = 6.0 * (0.6666666666666666 * y)
	elif t_0 <= 4e+247:
		tmp = 6.0 * (x * z)
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(2.0 / 3.0) - z)
	t_1 = Float64(-6.0 * Float64(y * z))
	tmp = 0.0
	if (t_0 <= -20000.0)
		tmp = t_1;
	elseif (t_0 <= 0.667)
		tmp = Float64(6.0 * Float64(0.6666666666666666 * y));
	elseif (t_0 <= 4e+247)
		tmp = Float64(6.0 * Float64(x * z));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (2.0 / 3.0) - z;
	t_1 = -6.0 * (y * z);
	tmp = 0.0;
	if (t_0 <= -20000.0)
		tmp = t_1;
	elseif (t_0 <= 0.667)
		tmp = 6.0 * (0.6666666666666666 * y);
	elseif (t_0 <= 4e+247)
		tmp = 6.0 * (x * z);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -20000.0], t$95$1, If[LessEqual[t$95$0, 0.667], N[(6.0 * N[(0.6666666666666666 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+247], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_0 \leq 0.667:\\
\;\;\;\;6 \cdot \left(0.6666666666666666 \cdot y\right)\\

\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{+247}:\\
\;\;\;\;6 \cdot \left(x \cdot z\right)\\

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

    1. Initial program 99.5%

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

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

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

      \[\leadsto 6 \cdot \left(\frac{2}{3} \cdot \color{blue}{y}\right) \]
    5. Applied rewrites26.0%

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

    if 0.66700000000000004 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 3.99999999999999981e247

    1. Initial program 99.5%

      \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
    2. Applied rewrites99.5%

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

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

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

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

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

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

Alternative 11: 50.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{2}{3} - z\\ t_1 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;t\_0 \leq -20000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 40:\\ \;\;\;\;6 \cdot \left(0.6666666666666666 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (- (/ 2.0 3.0) z)) (t_1 (* -6.0 (* y z))))
   (if (<= t_0 -20000.0)
     t_1
     (if (<= t_0 40.0) (* 6.0 (* 0.6666666666666666 y)) t_1))))
double code(double x, double y, double z) {
	double t_0 = (2.0 / 3.0) - z;
	double t_1 = -6.0 * (y * z);
	double tmp;
	if (t_0 <= -20000.0) {
		tmp = t_1;
	} else if (t_0 <= 40.0) {
		tmp = 6.0 * (0.6666666666666666 * y);
	} else {
		tmp = t_1;
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (2.0d0 / 3.0d0) - z
    t_1 = (-6.0d0) * (y * z)
    if (t_0 <= (-20000.0d0)) then
        tmp = t_1
    else if (t_0 <= 40.0d0) then
        tmp = 6.0d0 * (0.6666666666666666d0 * y)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	double t_0 = (2.0 / 3.0) - z;
	double t_1 = -6.0 * (y * z);
	double tmp;
	if (t_0 <= -20000.0) {
		tmp = t_1;
	} else if (t_0 <= 40.0) {
		tmp = 6.0 * (0.6666666666666666 * y);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z):
	t_0 = (2.0 / 3.0) - z
	t_1 = -6.0 * (y * z)
	tmp = 0
	if t_0 <= -20000.0:
		tmp = t_1
	elif t_0 <= 40.0:
		tmp = 6.0 * (0.6666666666666666 * y)
	else:
		tmp = t_1
	return tmp
function code(x, y, z)
	t_0 = Float64(Float64(2.0 / 3.0) - z)
	t_1 = Float64(-6.0 * Float64(y * z))
	tmp = 0.0
	if (t_0 <= -20000.0)
		tmp = t_1;
	elseif (t_0 <= 40.0)
		tmp = Float64(6.0 * Float64(0.6666666666666666 * y));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z)
	t_0 = (2.0 / 3.0) - z;
	t_1 = -6.0 * (y * z);
	tmp = 0.0;
	if (t_0 <= -20000.0)
		tmp = t_1;
	elseif (t_0 <= 40.0)
		tmp = 6.0 * (0.6666666666666666 * y);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$1 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -20000.0], t$95$1, If[LessEqual[t$95$0, 40.0], N[(6.0 * N[(0.6666666666666666 * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_0 \leq 40:\\
\;\;\;\;6 \cdot \left(0.6666666666666666 \cdot y\right)\\

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

    1. Initial program 99.5%

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

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

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

      \[\leadsto 6 \cdot \left(\frac{2}{3} \cdot \color{blue}{y}\right) \]
    5. Applied rewrites26.0%

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

Alternative 12: 49.7% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

    1. Initial program 99.5%

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

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

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

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

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

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

Alternative 13: 36.7% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.8 \cdot 10^{-62}:\\
\;\;\;\;\mathsf{fma}\left(y, 4, x\right)\\

\mathbf{elif}\;y \leq 4.9 \cdot 10^{+87}:\\
\;\;\;\;x + -4 \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.79999999999999975e-62 or 4.89999999999999971e87 < y

    1. Initial program 99.5%

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

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

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

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

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

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

    if -6.79999999999999975e-62 < y < 4.89999999999999971e87

    1. Initial program 99.5%

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

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

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

      \[\leadsto x + -4 \cdot \color{blue}{x} \]
    5. Applied rewrites26.1%

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

Alternative 14: 25.9% accurate, 3.1× speedup?

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

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

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

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

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

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

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

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

Reproduce

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