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

Percentage Accurate: 99.5% → 99.8%
Time: 3.6s
Alternatives: 13
Speedup: 1.3×

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 13 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.3× speedup?

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

\\
\mathsf{fma}\left(\mathsf{fma}\left(z, 6, -4\right), x - y, 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. 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. add-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.0% accurate, 1.0× speedup?

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

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

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

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


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

    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. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

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

    if -0.57999999999999996 < z < 0.52000000000000002

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-3, \color{blue}{x}, 4 \cdot y\right) \]
      2. lower-*.f6451.1

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

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

    if 0.52000000000000002 < z

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.0% accurate, 1.0× speedup?

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

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

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

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


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

    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. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

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

    if -0.57999999999999996 < z < 0.52000000000000002

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-3, \color{blue}{x}, 4 \cdot y\right) \]
      2. lower-*.f6451.1

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

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

    if 0.52000000000000002 < z

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.0% 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.58:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq 0.52:\\ \;\;\;\;\mathsf{fma}\left(-3, x, 4 \cdot y\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.58) t_0 (if (<= z 0.52) (fma -3.0 x (* 4.0 y)) t_0))))
double code(double x, double y, double z) {
	double t_0 = -6.0 * (z * (y - x));
	double tmp;
	if (z <= -0.58) {
		tmp = t_0;
	} else if (z <= 0.52) {
		tmp = fma(-3.0, x, (4.0 * y));
	} 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.58)
		tmp = t_0;
	elseif (z <= 0.52)
		tmp = fma(-3.0, x, Float64(4.0 * y));
	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.58], t$95$0, If[LessEqual[z, 0.52], N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $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.58:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.57999999999999996 or 0.52000000000000002 < 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. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

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

    if -0.57999999999999996 < z < 0.52000000000000002

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-3, \color{blue}{x}, 4 \cdot y\right) \]
      2. lower-*.f6451.1

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

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

Alternative 5: 76.1% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-6, z, 4\right) \cdot y\\
t_1 := \frac{2}{3} - z\\
t_2 := \mathsf{fma}\left(x \cdot z, 6, x\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+85}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 0.666666665:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+40}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+188}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e85 or 2.00000000000000006e40 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 5.0000000000000001e188

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x \cdot \color{blue}{z}, 6, x\right) \]
    8. Step-by-step derivation
      1. lower-*.f6427.2

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

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

    if -1e85 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 0.666666665000000047 or 0.680000000000000049 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2.00000000000000006e40

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
      5. metadata-eval51.5

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

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

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

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

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

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

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

        \[\leadsto \left(-6 \cdot \left(z - \frac{2}{3}\right)\right) \cdot y \]
      7. sub-negate-revN/A

        \[\leadsto \left(-6 \cdot \left(\mathsf{neg}\left(\left(\frac{2}{3} - z\right)\right)\right)\right) \cdot y \]
      8. distribute-rgt-neg-inN/A

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

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

        \[\leadsto \left(6 \cdot \left(\frac{2}{3} - z\right)\right) \cdot y \]
      11. distribute-lft-out--N/A

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

        \[\leadsto \left(6 \cdot \frac{2}{3} - 6 \cdot z\right) \cdot y \]
      13. metadata-evalN/A

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

        \[\leadsto \left(4 - 6 \cdot z\right) \cdot y \]
      15. metadata-evalN/A

        \[\leadsto \left(6 \cdot \frac{2}{3} - 6 \cdot z\right) \cdot y \]
      16. metadata-evalN/A

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

        \[\leadsto \left(6 \cdot \frac{2}{3} - 6 \cdot z\right) \cdot y \]
      18. distribute-lft-out--N/A

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

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

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

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

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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-3, \color{blue}{x}, 4 \cdot y\right) \]
      2. lower-*.f6451.1

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

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

    if 5.0000000000000001e188 < (-.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. 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. add-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
      5. metadata-eval51.5

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

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

      \[\leadsto -6 \cdot \left(y \cdot \color{blue}{z}\right) \]
    8. Step-by-step derivation
      1. lower-*.f6427.1

        \[\leadsto -6 \cdot \left(y \cdot z\right) \]
    9. Applied rewrites27.1%

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

Alternative 6: 76.1% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-6, z, 4\right) \cdot y\\
t_1 := \frac{2}{3} - z\\
t_2 := 6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+85}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 0.666666665:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+40}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+188}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e85 or 2.00000000000000006e40 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 5.0000000000000001e188

    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 inf

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

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

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

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

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

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

        \[\leadsto x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right) \]
    4. Applied rewrites51.6%

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

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

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

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

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

    if -1e85 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 0.666666665000000047 or 0.680000000000000049 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2.00000000000000006e40

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
      5. metadata-eval51.5

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

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

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

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

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

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

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

        \[\leadsto \left(-6 \cdot \left(z - \frac{2}{3}\right)\right) \cdot y \]
      7. sub-negate-revN/A

        \[\leadsto \left(-6 \cdot \left(\mathsf{neg}\left(\left(\frac{2}{3} - z\right)\right)\right)\right) \cdot y \]
      8. distribute-rgt-neg-inN/A

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

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

        \[\leadsto \left(6 \cdot \left(\frac{2}{3} - z\right)\right) \cdot y \]
      11. distribute-lft-out--N/A

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

        \[\leadsto \left(6 \cdot \frac{2}{3} - 6 \cdot z\right) \cdot y \]
      13. metadata-evalN/A

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

        \[\leadsto \left(4 - 6 \cdot z\right) \cdot y \]
      15. metadata-evalN/A

        \[\leadsto \left(6 \cdot \frac{2}{3} - 6 \cdot z\right) \cdot y \]
      16. metadata-evalN/A

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

        \[\leadsto \left(6 \cdot \frac{2}{3} - 6 \cdot z\right) \cdot y \]
      18. distribute-lft-out--N/A

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

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

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

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

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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(-3, \color{blue}{x}, 4 \cdot y\right) \]
      2. lower-*.f6451.1

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

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

    if 5.0000000000000001e188 < (-.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. 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. add-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
      5. metadata-eval51.5

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

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

      \[\leadsto -6 \cdot \left(y \cdot \color{blue}{z}\right) \]
    8. Step-by-step derivation
      1. lower-*.f6427.1

        \[\leadsto -6 \cdot \left(y \cdot z\right) \]
    9. Applied rewrites27.1%

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

Alternative 7: 76.1% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(-6, z, 4\right) \cdot y\\
t_1 := \frac{2}{3} - z\\
t_2 := 6 \cdot \left(x \cdot z\right)\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+85}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;t\_1 \leq 0.666666665:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+40}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+188}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e85 or 2.00000000000000006e40 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 5.0000000000000001e188

    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 inf

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

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

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

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

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

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

        \[\leadsto x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right) \]
    4. Applied rewrites51.6%

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

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

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

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

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

    if -1e85 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 0.666666665000000047 or 0.680000000000000049 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 2.00000000000000006e40

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
      5. metadata-eval51.5

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

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

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

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

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

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

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

        \[\leadsto \left(-6 \cdot \left(z - \frac{2}{3}\right)\right) \cdot y \]
      7. sub-negate-revN/A

        \[\leadsto \left(-6 \cdot \left(\mathsf{neg}\left(\left(\frac{2}{3} - z\right)\right)\right)\right) \cdot y \]
      8. distribute-rgt-neg-inN/A

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

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

        \[\leadsto \left(6 \cdot \left(\frac{2}{3} - z\right)\right) \cdot y \]
      11. distribute-lft-out--N/A

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

        \[\leadsto \left(6 \cdot \frac{2}{3} - 6 \cdot z\right) \cdot y \]
      13. metadata-evalN/A

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

        \[\leadsto \left(4 - 6 \cdot z\right) \cdot y \]
      15. metadata-evalN/A

        \[\leadsto \left(6 \cdot \frac{2}{3} - 6 \cdot z\right) \cdot y \]
      16. metadata-evalN/A

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

        \[\leadsto \left(6 \cdot \frac{2}{3} - 6 \cdot z\right) \cdot y \]
      18. distribute-lft-out--N/A

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

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

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

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

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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 5.0000000000000001e188 < (-.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. 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. add-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
        5. metadata-eval51.5

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

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

        \[\leadsto -6 \cdot \left(y \cdot \color{blue}{z}\right) \]
      8. Step-by-step derivation
        1. lower-*.f6427.1

          \[\leadsto -6 \cdot \left(y \cdot z\right) \]
      9. Applied rewrites27.1%

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

    Alternative 8: 75.6% accurate, 0.4× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ t_1 := \frac{2}{3} - z\\ t_2 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+85}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;t\_1 \leq -2:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_1 \leq 1:\\ \;\;\;\;\mathsf{fma}\left(-4, x - y, x\right)\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+188}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (x y z)
     :precision binary64
     (let* ((t_0 (* -6.0 (* y z))) (t_1 (- (/ 2.0 3.0) z)) (t_2 (* 6.0 (* x z))))
       (if (<= t_1 -1e+85)
         t_2
         (if (<= t_1 -2.0)
           t_0
           (if (<= t_1 1.0) (fma -4.0 (- x y) x) (if (<= t_1 5e+188) t_2 t_0))))))
    double code(double x, double y, double z) {
    	double t_0 = -6.0 * (y * z);
    	double t_1 = (2.0 / 3.0) - z;
    	double t_2 = 6.0 * (x * z);
    	double tmp;
    	if (t_1 <= -1e+85) {
    		tmp = t_2;
    	} else if (t_1 <= -2.0) {
    		tmp = t_0;
    	} else if (t_1 <= 1.0) {
    		tmp = fma(-4.0, (x - y), x);
    	} else if (t_1 <= 5e+188) {
    		tmp = t_2;
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    function code(x, y, z)
    	t_0 = Float64(-6.0 * Float64(y * z))
    	t_1 = Float64(Float64(2.0 / 3.0) - z)
    	t_2 = Float64(6.0 * Float64(x * z))
    	tmp = 0.0
    	if (t_1 <= -1e+85)
    		tmp = t_2;
    	elseif (t_1 <= -2.0)
    		tmp = t_0;
    	elseif (t_1 <= 1.0)
    		tmp = fma(-4.0, Float64(x - y), x);
    	elseif (t_1 <= 5e+188)
    		tmp = t_2;
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]}, Block[{t$95$2 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+85], t$95$2, If[LessEqual[t$95$1, -2.0], t$95$0, If[LessEqual[t$95$1, 1.0], N[(-4.0 * N[(x - y), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$1, 5e+188], t$95$2, t$95$0]]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := -6 \cdot \left(y \cdot z\right)\\
    t_1 := \frac{2}{3} - z\\
    t_2 := 6 \cdot \left(x \cdot z\right)\\
    \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+85}:\\
    \;\;\;\;t\_2\\
    
    \mathbf{elif}\;t\_1 \leq -2:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;t\_1 \leq 1:\\
    \;\;\;\;\mathsf{fma}\left(-4, x - y, x\right)\\
    
    \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+188}:\\
    \;\;\;\;t\_2\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -1e85 or 1 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < 5.0000000000000001e188

      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 inf

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

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

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

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

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

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

          \[\leadsto x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right) \]
      4. Applied rewrites51.6%

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

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

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

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

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

      if -1e85 < (-.f64 (/.f64 #s(literal 2 binary64) #s(literal 3 binary64)) z) < -2 or 5.0000000000000001e188 < (-.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. 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. add-flipN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
        5. metadata-eval51.5

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

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

        \[\leadsto -6 \cdot \left(y \cdot \color{blue}{z}\right) \]
      8. Step-by-step derivation
        1. lower-*.f6427.1

          \[\leadsto -6 \cdot \left(y \cdot z\right) \]
      9. Applied rewrites27.1%

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

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

      1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 9: 50.4% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ t_1 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -5.6 \cdot 10^{+189}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -2.35 \cdot 10^{-33}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -1.06 \cdot 10^{-169}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-225}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 0.52:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+79}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
      (FPCore (x y z)
       :precision binary64
       (let* ((t_0 (* -6.0 (* y z))) (t_1 (* 6.0 (* x z))))
         (if (<= z -5.6e+189)
           t_0
           (if (<= z -2.35e-33)
             t_1
             (if (<= z -1.06e-169)
               (* x -3.0)
               (if (<= z -1.2e-225)
                 (* 4.0 y)
                 (if (<= z 0.52) (* x -3.0) (if (<= z 3.4e+79) t_0 t_1))))))))
      double code(double x, double y, double z) {
      	double t_0 = -6.0 * (y * z);
      	double t_1 = 6.0 * (x * z);
      	double tmp;
      	if (z <= -5.6e+189) {
      		tmp = t_0;
      	} else if (z <= -2.35e-33) {
      		tmp = t_1;
      	} else if (z <= -1.06e-169) {
      		tmp = x * -3.0;
      	} else if (z <= -1.2e-225) {
      		tmp = 4.0 * y;
      	} else if (z <= 0.52) {
      		tmp = x * -3.0;
      	} else if (z <= 3.4e+79) {
      		tmp = t_0;
      	} 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 = (-6.0d0) * (y * z)
          t_1 = 6.0d0 * (x * z)
          if (z <= (-5.6d+189)) then
              tmp = t_0
          else if (z <= (-2.35d-33)) then
              tmp = t_1
          else if (z <= (-1.06d-169)) then
              tmp = x * (-3.0d0)
          else if (z <= (-1.2d-225)) then
              tmp = 4.0d0 * y
          else if (z <= 0.52d0) then
              tmp = x * (-3.0d0)
          else if (z <= 3.4d+79) then
              tmp = t_0
          else
              tmp = t_1
          end if
          code = tmp
      end function
      
      public static double code(double x, double y, double z) {
      	double t_0 = -6.0 * (y * z);
      	double t_1 = 6.0 * (x * z);
      	double tmp;
      	if (z <= -5.6e+189) {
      		tmp = t_0;
      	} else if (z <= -2.35e-33) {
      		tmp = t_1;
      	} else if (z <= -1.06e-169) {
      		tmp = x * -3.0;
      	} else if (z <= -1.2e-225) {
      		tmp = 4.0 * y;
      	} else if (z <= 0.52) {
      		tmp = x * -3.0;
      	} else if (z <= 3.4e+79) {
      		tmp = t_0;
      	} else {
      		tmp = t_1;
      	}
      	return tmp;
      }
      
      def code(x, y, z):
      	t_0 = -6.0 * (y * z)
      	t_1 = 6.0 * (x * z)
      	tmp = 0
      	if z <= -5.6e+189:
      		tmp = t_0
      	elif z <= -2.35e-33:
      		tmp = t_1
      	elif z <= -1.06e-169:
      		tmp = x * -3.0
      	elif z <= -1.2e-225:
      		tmp = 4.0 * y
      	elif z <= 0.52:
      		tmp = x * -3.0
      	elif z <= 3.4e+79:
      		tmp = t_0
      	else:
      		tmp = t_1
      	return tmp
      
      function code(x, y, z)
      	t_0 = Float64(-6.0 * Float64(y * z))
      	t_1 = Float64(6.0 * Float64(x * z))
      	tmp = 0.0
      	if (z <= -5.6e+189)
      		tmp = t_0;
      	elseif (z <= -2.35e-33)
      		tmp = t_1;
      	elseif (z <= -1.06e-169)
      		tmp = Float64(x * -3.0);
      	elseif (z <= -1.2e-225)
      		tmp = Float64(4.0 * y);
      	elseif (z <= 0.52)
      		tmp = Float64(x * -3.0);
      	elseif (z <= 3.4e+79)
      		tmp = t_0;
      	else
      		tmp = t_1;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, y, z)
      	t_0 = -6.0 * (y * z);
      	t_1 = 6.0 * (x * z);
      	tmp = 0.0;
      	if (z <= -5.6e+189)
      		tmp = t_0;
      	elseif (z <= -2.35e-33)
      		tmp = t_1;
      	elseif (z <= -1.06e-169)
      		tmp = x * -3.0;
      	elseif (z <= -1.2e-225)
      		tmp = 4.0 * y;
      	elseif (z <= 0.52)
      		tmp = x * -3.0;
      	elseif (z <= 3.4e+79)
      		tmp = t_0;
      	else
      		tmp = t_1;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.6e+189], t$95$0, If[LessEqual[z, -2.35e-33], t$95$1, If[LessEqual[z, -1.06e-169], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -1.2e-225], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 0.52], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, 3.4e+79], t$95$0, t$95$1]]]]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := -6 \cdot \left(y \cdot z\right)\\
      t_1 := 6 \cdot \left(x \cdot z\right)\\
      \mathbf{if}\;z \leq -5.6 \cdot 10^{+189}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;z \leq -2.35 \cdot 10^{-33}:\\
      \;\;\;\;t\_1\\
      
      \mathbf{elif}\;z \leq -1.06 \cdot 10^{-169}:\\
      \;\;\;\;x \cdot -3\\
      
      \mathbf{elif}\;z \leq -1.2 \cdot 10^{-225}:\\
      \;\;\;\;4 \cdot y\\
      
      \mathbf{elif}\;z \leq 0.52:\\
      \;\;\;\;x \cdot -3\\
      
      \mathbf{elif}\;z \leq 3.4 \cdot 10^{+79}:\\
      \;\;\;\;t\_0\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 4 regimes
      2. if z < -5.60000000000000013e189 or 0.52000000000000002 < z < 3.40000000000000032e79

        1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
          5. metadata-eval51.5

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

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

          \[\leadsto -6 \cdot \left(y \cdot \color{blue}{z}\right) \]
        8. Step-by-step derivation
          1. lower-*.f6427.1

            \[\leadsto -6 \cdot \left(y \cdot z\right) \]
        9. Applied rewrites27.1%

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

        if -5.60000000000000013e189 < z < -2.3500000000000001e-33 or 3.40000000000000032e79 < 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 inf

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

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

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

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

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

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

            \[\leadsto x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right) \]
        4. Applied rewrites51.6%

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

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

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

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

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

        if -2.3500000000000001e-33 < z < -1.06e-169 or -1.19999999999999998e-225 < z < 0.52000000000000002

        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 inf

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

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

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

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

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

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

            \[\leadsto x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right) \]
        4. Applied rewrites51.6%

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

          \[\leadsto x \cdot -3 \]
        6. Step-by-step derivation
          1. Applied rewrites26.3%

            \[\leadsto x \cdot -3 \]

          if -1.06e-169 < z < -1.19999999999999998e-225

          1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
            5. metadata-eval51.5

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

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

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

              \[\leadsto 4 \cdot y \]
          9. Applied rewrites26.7%

            \[\leadsto 4 \cdot \color{blue}{y} \]
        7. Recombined 4 regimes into one program.
        8. Add Preprocessing

        Alternative 10: 50.0% accurate, 0.8× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -2.35 \cdot 10^{-33}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -1.06 \cdot 10^{-169}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-225}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;z \leq 3.1:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (x y z)
         :precision binary64
         (let* ((t_0 (* 6.0 (* x z))))
           (if (<= z -2.35e-33)
             t_0
             (if (<= z -1.06e-169)
               (* x -3.0)
               (if (<= z -1.2e-225) (* 4.0 y) (if (<= z 3.1) (* x -3.0) t_0))))))
        double code(double x, double y, double z) {
        	double t_0 = 6.0 * (x * z);
        	double tmp;
        	if (z <= -2.35e-33) {
        		tmp = t_0;
        	} else if (z <= -1.06e-169) {
        		tmp = x * -3.0;
        	} else if (z <= -1.2e-225) {
        		tmp = 4.0 * y;
        	} else if (z <= 3.1) {
        		tmp = x * -3.0;
        	} else {
        		tmp = t_0;
        	}
        	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) :: tmp
            t_0 = 6.0d0 * (x * z)
            if (z <= (-2.35d-33)) then
                tmp = t_0
            else if (z <= (-1.06d-169)) then
                tmp = x * (-3.0d0)
            else if (z <= (-1.2d-225)) then
                tmp = 4.0d0 * y
            else if (z <= 3.1d0) then
                tmp = x * (-3.0d0)
            else
                tmp = t_0
            end if
            code = tmp
        end function
        
        public static double code(double x, double y, double z) {
        	double t_0 = 6.0 * (x * z);
        	double tmp;
        	if (z <= -2.35e-33) {
        		tmp = t_0;
        	} else if (z <= -1.06e-169) {
        		tmp = x * -3.0;
        	} else if (z <= -1.2e-225) {
        		tmp = 4.0 * y;
        	} else if (z <= 3.1) {
        		tmp = x * -3.0;
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(x, y, z):
        	t_0 = 6.0 * (x * z)
        	tmp = 0
        	if z <= -2.35e-33:
        		tmp = t_0
        	elif z <= -1.06e-169:
        		tmp = x * -3.0
        	elif z <= -1.2e-225:
        		tmp = 4.0 * y
        	elif z <= 3.1:
        		tmp = x * -3.0
        	else:
        		tmp = t_0
        	return tmp
        
        function code(x, y, z)
        	t_0 = Float64(6.0 * Float64(x * z))
        	tmp = 0.0
        	if (z <= -2.35e-33)
        		tmp = t_0;
        	elseif (z <= -1.06e-169)
        		tmp = Float64(x * -3.0);
        	elseif (z <= -1.2e-225)
        		tmp = Float64(4.0 * y);
        	elseif (z <= 3.1)
        		tmp = Float64(x * -3.0);
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, y, z)
        	t_0 = 6.0 * (x * z);
        	tmp = 0.0;
        	if (z <= -2.35e-33)
        		tmp = t_0;
        	elseif (z <= -1.06e-169)
        		tmp = x * -3.0;
        	elseif (z <= -1.2e-225)
        		tmp = 4.0 * y;
        	elseif (z <= 3.1)
        		tmp = x * -3.0;
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, y_, z_] := Block[{t$95$0 = N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.35e-33], t$95$0, If[LessEqual[z, -1.06e-169], N[(x * -3.0), $MachinePrecision], If[LessEqual[z, -1.2e-225], N[(4.0 * y), $MachinePrecision], If[LessEqual[z, 3.1], N[(x * -3.0), $MachinePrecision], t$95$0]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := 6 \cdot \left(x \cdot z\right)\\
        \mathbf{if}\;z \leq -2.35 \cdot 10^{-33}:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;z \leq -1.06 \cdot 10^{-169}:\\
        \;\;\;\;x \cdot -3\\
        
        \mathbf{elif}\;z \leq -1.2 \cdot 10^{-225}:\\
        \;\;\;\;4 \cdot y\\
        
        \mathbf{elif}\;z \leq 3.1:\\
        \;\;\;\;x \cdot -3\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if z < -2.3500000000000001e-33 or 3.10000000000000009 < 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 inf

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

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

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

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

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

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

              \[\leadsto x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right) \]
          4. Applied rewrites51.6%

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

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

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

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

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

          if -2.3500000000000001e-33 < z < -1.06e-169 or -1.19999999999999998e-225 < z < 3.10000000000000009

          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 inf

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

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

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

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

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

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

              \[\leadsto x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right) \]
          4. Applied rewrites51.6%

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

            \[\leadsto x \cdot -3 \]
          6. Step-by-step derivation
            1. Applied rewrites26.3%

              \[\leadsto x \cdot -3 \]

            if -1.06e-169 < z < -1.19999999999999998e-225

            1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
              5. metadata-eval51.5

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

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

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

                \[\leadsto 4 \cdot y \]
            9. Applied rewrites26.7%

              \[\leadsto 4 \cdot \color{blue}{y} \]
          7. Recombined 3 regimes into one program.
          8. Add Preprocessing

          Alternative 11: 36.8% accurate, 1.6× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{+36}:\\ \;\;\;\;x + 4 \cdot y\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+161}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;4 \cdot y\\ \end{array} \end{array} \]
          (FPCore (x y z)
           :precision binary64
           (if (<= y -3.7e+36) (+ x (* 4.0 y)) (if (<= y 6e+161) (* x -3.0) (* 4.0 y))))
          double code(double x, double y, double z) {
          	double tmp;
          	if (y <= -3.7e+36) {
          		tmp = x + (4.0 * y);
          	} else if (y <= 6e+161) {
          		tmp = x * -3.0;
          	} else {
          		tmp = 4.0 * y;
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(x, y, z)
          use fmin_fmax_functions
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              real(8), intent (in) :: z
              real(8) :: tmp
              if (y <= (-3.7d+36)) then
                  tmp = x + (4.0d0 * y)
              else if (y <= 6d+161) then
                  tmp = x * (-3.0d0)
              else
                  tmp = 4.0d0 * y
              end if
              code = tmp
          end function
          
          public static double code(double x, double y, double z) {
          	double tmp;
          	if (y <= -3.7e+36) {
          		tmp = x + (4.0 * y);
          	} else if (y <= 6e+161) {
          		tmp = x * -3.0;
          	} else {
          		tmp = 4.0 * y;
          	}
          	return tmp;
          }
          
          def code(x, y, z):
          	tmp = 0
          	if y <= -3.7e+36:
          		tmp = x + (4.0 * y)
          	elif y <= 6e+161:
          		tmp = x * -3.0
          	else:
          		tmp = 4.0 * y
          	return tmp
          
          function code(x, y, z)
          	tmp = 0.0
          	if (y <= -3.7e+36)
          		tmp = Float64(x + Float64(4.0 * y));
          	elseif (y <= 6e+161)
          		tmp = Float64(x * -3.0);
          	else
          		tmp = Float64(4.0 * y);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, y, z)
          	tmp = 0.0;
          	if (y <= -3.7e+36)
          		tmp = x + (4.0 * y);
          	elseif (y <= 6e+161)
          		tmp = x * -3.0;
          	else
          		tmp = 4.0 * y;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_] := If[LessEqual[y, -3.7e+36], N[(x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e+161], N[(x * -3.0), $MachinePrecision], N[(4.0 * y), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;y \leq -3.7 \cdot 10^{+36}:\\
          \;\;\;\;x + 4 \cdot y\\
          
          \mathbf{elif}\;y \leq 6 \cdot 10^{+161}:\\
          \;\;\;\;x \cdot -3\\
          
          \mathbf{else}:\\
          \;\;\;\;4 \cdot y\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if y < -3.70000000000000029e36

            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. Step-by-step derivation
              1. lower-*.f64N/A

                \[\leadsto x + 4 \cdot \color{blue}{\left(y - x\right)} \]
              2. lower--.f6451.1

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

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

              \[\leadsto x + 4 \cdot y \]
            6. Step-by-step derivation
              1. Applied rewrites26.4%

                \[\leadsto x + 4 \cdot y \]

              if -3.70000000000000029e36 < y < 6.00000000000000023e161

              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 inf

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

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

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

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

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

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

                  \[\leadsto x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right) \]
              4. Applied rewrites51.6%

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

                \[\leadsto x \cdot -3 \]
              6. Step-by-step derivation
                1. Applied rewrites26.3%

                  \[\leadsto x \cdot -3 \]

                if 6.00000000000000023e161 < y

                1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
                  5. metadata-eval51.5

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

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

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

                    \[\leadsto 4 \cdot y \]
                9. Applied rewrites26.7%

                  \[\leadsto 4 \cdot \color{blue}{y} \]
              7. Recombined 3 regimes into one program.
              8. Add Preprocessing

              Alternative 12: 36.8% accurate, 1.6× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{+36}:\\ \;\;\;\;4 \cdot y\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+161}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;4 \cdot y\\ \end{array} \end{array} \]
              (FPCore (x y z)
               :precision binary64
               (if (<= y -3.7e+36) (* 4.0 y) (if (<= y 6e+161) (* x -3.0) (* 4.0 y))))
              double code(double x, double y, double z) {
              	double tmp;
              	if (y <= -3.7e+36) {
              		tmp = 4.0 * y;
              	} else if (y <= 6e+161) {
              		tmp = x * -3.0;
              	} else {
              		tmp = 4.0 * y;
              	}
              	return tmp;
              }
              
              module fmin_fmax_functions
                  implicit none
                  private
                  public fmax
                  public fmin
              
                  interface fmax
                      module procedure fmax88
                      module procedure fmax44
                      module procedure fmax84
                      module procedure fmax48
                  end interface
                  interface fmin
                      module procedure fmin88
                      module procedure fmin44
                      module procedure fmin84
                      module procedure fmin48
                  end interface
              contains
                  real(8) function fmax88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmax44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmax84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmax48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                  end function
                  real(8) function fmin88(x, y) result (res)
                      real(8), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(4) function fmin44(x, y) result (res)
                      real(4), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                  end function
                  real(8) function fmin84(x, y) result(res)
                      real(8), intent (in) :: x
                      real(4), intent (in) :: y
                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                  end function
                  real(8) function fmin48(x, y) result(res)
                      real(4), intent (in) :: x
                      real(8), intent (in) :: y
                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                  end function
              end module
              
              real(8) function code(x, y, z)
              use fmin_fmax_functions
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  real(8), intent (in) :: z
                  real(8) :: tmp
                  if (y <= (-3.7d+36)) then
                      tmp = 4.0d0 * y
                  else if (y <= 6d+161) then
                      tmp = x * (-3.0d0)
                  else
                      tmp = 4.0d0 * y
                  end if
                  code = tmp
              end function
              
              public static double code(double x, double y, double z) {
              	double tmp;
              	if (y <= -3.7e+36) {
              		tmp = 4.0 * y;
              	} else if (y <= 6e+161) {
              		tmp = x * -3.0;
              	} else {
              		tmp = 4.0 * y;
              	}
              	return tmp;
              }
              
              def code(x, y, z):
              	tmp = 0
              	if y <= -3.7e+36:
              		tmp = 4.0 * y
              	elif y <= 6e+161:
              		tmp = x * -3.0
              	else:
              		tmp = 4.0 * y
              	return tmp
              
              function code(x, y, z)
              	tmp = 0.0
              	if (y <= -3.7e+36)
              		tmp = Float64(4.0 * y);
              	elseif (y <= 6e+161)
              		tmp = Float64(x * -3.0);
              	else
              		tmp = Float64(4.0 * y);
              	end
              	return tmp
              end
              
              function tmp_2 = code(x, y, z)
              	tmp = 0.0;
              	if (y <= -3.7e+36)
              		tmp = 4.0 * y;
              	elseif (y <= 6e+161)
              		tmp = x * -3.0;
              	else
              		tmp = 4.0 * y;
              	end
              	tmp_2 = tmp;
              end
              
              code[x_, y_, z_] := If[LessEqual[y, -3.7e+36], N[(4.0 * y), $MachinePrecision], If[LessEqual[y, 6e+161], N[(x * -3.0), $MachinePrecision], N[(4.0 * y), $MachinePrecision]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;y \leq -3.7 \cdot 10^{+36}:\\
              \;\;\;\;4 \cdot y\\
              
              \mathbf{elif}\;y \leq 6 \cdot 10^{+161}:\\
              \;\;\;\;x \cdot -3\\
              
              \mathbf{else}:\\
              \;\;\;\;4 \cdot y\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 2 regimes
              2. if y < -3.70000000000000029e36 or 6.00000000000000023e161 < y

                1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto -6 \cdot \left(y \cdot \left(z - \color{blue}{\frac{2}{3}}\right)\right) \]
                  5. metadata-eval51.5

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

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

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

                    \[\leadsto 4 \cdot y \]
                9. Applied rewrites26.7%

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

                if -3.70000000000000029e36 < y < 6.00000000000000023e161

                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 inf

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

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

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

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

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

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

                    \[\leadsto x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right) \]
                4. Applied rewrites51.6%

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

                  \[\leadsto x \cdot -3 \]
                6. Step-by-step derivation
                  1. Applied rewrites26.3%

                    \[\leadsto x \cdot -3 \]
                7. Recombined 2 regimes into one program.
                8. Add Preprocessing

                Alternative 13: 26.3% accurate, 4.6× speedup?

                \[\begin{array}{l} \\ x \cdot -3 \end{array} \]
                (FPCore (x y z) :precision binary64 (* x -3.0))
                double code(double x, double y, double z) {
                	return x * -3.0;
                }
                
                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 * (-3.0d0)
                end function
                
                public static double code(double x, double y, double z) {
                	return x * -3.0;
                }
                
                def code(x, y, z):
                	return x * -3.0
                
                function code(x, y, z)
                	return Float64(x * -3.0)
                end
                
                function tmp = code(x, y, z)
                	tmp = x * -3.0;
                end
                
                code[x_, y_, z_] := N[(x * -3.0), $MachinePrecision]
                
                \begin{array}{l}
                
                \\
                x \cdot -3
                \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. Taylor expanded in x around inf

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

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

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

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

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

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

                    \[\leadsto x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right) \]
                4. Applied rewrites51.6%

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

                  \[\leadsto x \cdot -3 \]
                6. Step-by-step derivation
                  1. Applied rewrites26.3%

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

                  Reproduce

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