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

Percentage Accurate: 99.5% → 99.8%
Time: 3.2s
Alternatives: 15
Speedup: 1.3×

Specification

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

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 15 alternatives:

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

Initial Program: 99.5% accurate, 1.0× speedup?

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

Alternative 1: 99.8% accurate, 0.9× speedup?

\[\mathsf{fma}\left(y - x, -6 \cdot z, \mathsf{fma}\left(-3, x, 4 \cdot y\right)\right) \]
(FPCore (x y z)
 :precision binary64
 (fma (- y x) (* -6.0 z) (fma -3.0 x (* 4.0 y))))
double code(double x, double y, double z) {
	return fma((y - x), (-6.0 * z), fma(-3.0, x, (4.0 * y)));
}
function code(x, y, z)
	return fma(Float64(y - x), Float64(-6.0 * z), fma(-3.0, x, Float64(4.0 * y)))
end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(-6.0 * z), $MachinePrecision] + N[(-3.0 * x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(y - x, -6 \cdot z, \mathsf{fma}\left(-3, x, 4 \cdot y\right)\right)
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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.7% accurate, 1.3× speedup?

\[\mathsf{fma}\left(\mathsf{fma}\left(z, 6, -4\right), x - y, x\right) \]
(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]
\mathsf{fma}\left(\mathsf{fma}\left(z, 6, -4\right), x - y, x\right)
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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(6 \cdot \left(z - \frac{2}{3}\right), x - y, 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 4: 97.6% accurate, 0.9× speedup?

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

\mathbf{elif}\;z \leq 95000:\\
\;\;\;\;\left(x + -4 \cdot x\right) + \left(-y\right) \cdot -4\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(6 \cdot \left(z - \frac{2}{3}\right), x - y, 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-*.f6450.8

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

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

    if -1.19999999999999996 < z < 95000

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(6 \cdot \left(z - \frac{2}{3}\right), x - y, 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 rewrites50.1%

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\left(x + x \cdot -4\right)} + \left(\mathsf{neg}\left(y\right)\right) \cdot -4 \]
        9. *-commutativeN/A

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

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

          \[\leadsto \left(x + -4 \cdot x\right) + \color{blue}{\left(\mathsf{neg}\left(y\right)\right) \cdot -4} \]
        12. lower-neg.f6450.1

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

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

      if 95000 < 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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
      5. 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--.f6451.3

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

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

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

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

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

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

          \[\leadsto \left(z \cdot -6\right) \cdot \left(y - \color{blue}{x}\right) \]
        6. sub-negate-revN/A

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

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

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

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

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

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

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

          \[\leadsto z \cdot \left(6 \cdot \left(x - \color{blue}{y}\right)\right) \]
        14. sub-flipN/A

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

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

          \[\leadsto z \cdot \left(x \cdot \left(\mathsf{neg}\left(-6\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot 6\right) \]
        17. distribute-rgt-neg-outN/A

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

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

          \[\leadsto z \cdot \left(\left(\mathsf{neg}\left(x \cdot -6\right)\right) + \left(\mathsf{neg}\left(6 \cdot y\right)\right)\right) \]
        20. lift-*.f64N/A

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

          \[\leadsto z \cdot \left(\mathsf{neg}\left(\left(x \cdot -6 + 6 \cdot y\right)\right)\right) \]
        22. lift-fma.f64N/A

          \[\leadsto z \cdot \left(\mathsf{neg}\left(\mathsf{fma}\left(x, -6, 6 \cdot y\right)\right)\right) \]
        23. *-commutativeN/A

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

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

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

    Alternative 5: 97.6% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(6 \cdot \left(z - \frac{2}{3}\right), x - y, 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-*.f6450.8

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

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

      if -1.19999999999999996 < z < 95000

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(6 \cdot \left(z - \frac{2}{3}\right), x - y, 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 rewrites50.1%

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

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

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

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

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

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

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

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

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

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

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

        if 95000 < 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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
        5. 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--.f6451.3

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

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

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

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

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

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

            \[\leadsto \left(z \cdot -6\right) \cdot \left(y - \color{blue}{x}\right) \]
          6. sub-negate-revN/A

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

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

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

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

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

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

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

            \[\leadsto z \cdot \left(6 \cdot \left(x - \color{blue}{y}\right)\right) \]
          14. sub-flipN/A

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

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

            \[\leadsto z \cdot \left(x \cdot \left(\mathsf{neg}\left(-6\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot 6\right) \]
          17. distribute-rgt-neg-outN/A

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

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

            \[\leadsto z \cdot \left(\left(\mathsf{neg}\left(x \cdot -6\right)\right) + \left(\mathsf{neg}\left(6 \cdot y\right)\right)\right) \]
          20. lift-*.f64N/A

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

            \[\leadsto z \cdot \left(\mathsf{neg}\left(\left(x \cdot -6 + 6 \cdot y\right)\right)\right) \]
          22. lift-fma.f64N/A

            \[\leadsto z \cdot \left(\mathsf{neg}\left(\mathsf{fma}\left(x, -6, 6 \cdot y\right)\right)\right) \]
          23. *-commutativeN/A

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

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

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

      Alternative 6: 97.6% accurate, 1.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(6 \cdot \left(z - \frac{2}{3}\right), x - y, 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-*.f6450.8

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

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

        if -1.19999999999999996 < z < 95000

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\mathsf{fma}\left(6 \cdot \left(z - \frac{2}{3}\right), x - y, 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 rewrites50.1%

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

          if 95000 < 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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
          5. 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--.f6451.3

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

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

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

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

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

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

              \[\leadsto \left(z \cdot -6\right) \cdot \left(y - \color{blue}{x}\right) \]
            6. sub-negate-revN/A

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

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

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

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

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

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

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

              \[\leadsto z \cdot \left(6 \cdot \left(x - \color{blue}{y}\right)\right) \]
            14. sub-flipN/A

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

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

              \[\leadsto z \cdot \left(x \cdot \left(\mathsf{neg}\left(-6\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot 6\right) \]
            17. distribute-rgt-neg-outN/A

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

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

              \[\leadsto z \cdot \left(\left(\mathsf{neg}\left(x \cdot -6\right)\right) + \left(\mathsf{neg}\left(6 \cdot y\right)\right)\right) \]
            20. lift-*.f64N/A

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

              \[\leadsto z \cdot \left(\mathsf{neg}\left(\left(x \cdot -6 + 6 \cdot y\right)\right)\right) \]
            22. lift-fma.f64N/A

              \[\leadsto z \cdot \left(\mathsf{neg}\left(\mathsf{fma}\left(x, -6, 6 \cdot y\right)\right)\right) \]
            23. *-commutativeN/A

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

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

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

        Alternative 7: 97.6% accurate, 1.1× speedup?

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

          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--.f6451.3

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

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

          if -1.19999999999999996 < z < 95000

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(6 \cdot \left(z - \frac{2}{3}\right), x - y, 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 rewrites50.1%

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

            if 95000 < 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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
            5. 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--.f6451.3

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

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

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

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

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

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

                \[\leadsto \left(z \cdot -6\right) \cdot \left(y - \color{blue}{x}\right) \]
              6. sub-negate-revN/A

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

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

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

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

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

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

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

                \[\leadsto z \cdot \left(6 \cdot \left(x - \color{blue}{y}\right)\right) \]
              14. sub-flipN/A

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

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

                \[\leadsto z \cdot \left(x \cdot \left(\mathsf{neg}\left(-6\right)\right) + \left(\mathsf{neg}\left(y\right)\right) \cdot 6\right) \]
              17. distribute-rgt-neg-outN/A

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

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

                \[\leadsto z \cdot \left(\left(\mathsf{neg}\left(x \cdot -6\right)\right) + \left(\mathsf{neg}\left(6 \cdot y\right)\right)\right) \]
              20. lift-*.f64N/A

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

                \[\leadsto z \cdot \left(\mathsf{neg}\left(\left(x \cdot -6 + 6 \cdot y\right)\right)\right) \]
              22. lift-fma.f64N/A

                \[\leadsto z \cdot \left(\mathsf{neg}\left(\mathsf{fma}\left(x, -6, 6 \cdot y\right)\right)\right) \]
              23. *-commutativeN/A

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

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

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

          Alternative 8: 97.6% accurate, 1.1× speedup?

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

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

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

            if -1.19999999999999996 < z < 95000

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(6 \cdot \left(z - \frac{2}{3}\right), x - y, 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 rewrites50.1%

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

            Alternative 9: 75.4% accurate, 0.5× speedup?

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

              1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \left(4 + 6 \cdot \left(\mathsf{neg}\left(z\right)\right)\right) \cdot y \]
                12. distribute-rgt-neg-outN/A

                  \[\leadsto \left(4 + \left(\mathsf{neg}\left(6 \cdot z\right)\right)\right) \cdot y \]
                13. distribute-lft-neg-outN/A

                  \[\leadsto \left(4 + \left(\mathsf{neg}\left(6\right)\right) \cdot z\right) \cdot y \]
                14. metadata-evalN/A

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

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

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

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

                  \[\leadsto \left(z \cdot -6 + 4\right) \cdot y \]
                19. lower-fma.f6451.6

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

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

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

              1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(6 \cdot \left(z - \frac{2}{3}\right), x - y, 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 rewrites50.1%

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

                if 5e228 < (-.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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                  \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
                5. 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--.f6451.3

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

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

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

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

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

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

              Alternative 10: 74.7% accurate, 0.5× speedup?

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

                1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto -6 \cdot \left(y \cdot z\right) \]
                7. Applied rewrites28.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(6 \cdot \left(z - \frac{2}{3}\right), x - y, 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 rewrites50.1%

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

                  if 5e228 < (-.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. lift-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
                  5. 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--.f6451.3

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

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

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

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

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

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

                Alternative 11: 50.8% accurate, 0.8× speedup?

                \[\begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -1.5 \cdot 10^{+233}:\\ \;\;\;\;6 \cdot \left(x \cdot z\right)\\ \mathbf{elif}\;z \leq -3.7 \cdot 10^{-18}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -1.45 \cdot 10^{-221}:\\ \;\;\;\;x + -4 \cdot x\\ \mathbf{elif}\;z \leq 95000:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                (FPCore (x y z)
                 :precision binary64
                 (let* ((t_0 (* -6.0 (* y z))))
                   (if (<= z -1.5e+233)
                     (* 6.0 (* x z))
                     (if (<= z -3.7e-18)
                       t_0
                       (if (<= z -1.45e-221)
                         (+ x (* -4.0 x))
                         (if (<= z 95000.0) (* 4.0 y) t_0))))))
                double code(double x, double y, double z) {
                	double t_0 = -6.0 * (y * z);
                	double tmp;
                	if (z <= -1.5e+233) {
                		tmp = 6.0 * (x * z);
                	} else if (z <= -3.7e-18) {
                		tmp = t_0;
                	} else if (z <= -1.45e-221) {
                		tmp = x + (-4.0 * x);
                	} else if (z <= 95000.0) {
                		tmp = 4.0 * y;
                	} 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) * (y * z)
                    if (z <= (-1.5d+233)) then
                        tmp = 6.0d0 * (x * z)
                    else if (z <= (-3.7d-18)) then
                        tmp = t_0
                    else if (z <= (-1.45d-221)) then
                        tmp = x + ((-4.0d0) * x)
                    else if (z <= 95000.0d0) then
                        tmp = 4.0d0 * y
                    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 * (y * z);
                	double tmp;
                	if (z <= -1.5e+233) {
                		tmp = 6.0 * (x * z);
                	} else if (z <= -3.7e-18) {
                		tmp = t_0;
                	} else if (z <= -1.45e-221) {
                		tmp = x + (-4.0 * x);
                	} else if (z <= 95000.0) {
                		tmp = 4.0 * y;
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                def code(x, y, z):
                	t_0 = -6.0 * (y * z)
                	tmp = 0
                	if z <= -1.5e+233:
                		tmp = 6.0 * (x * z)
                	elif z <= -3.7e-18:
                		tmp = t_0
                	elif z <= -1.45e-221:
                		tmp = x + (-4.0 * x)
                	elif z <= 95000.0:
                		tmp = 4.0 * y
                	else:
                		tmp = t_0
                	return tmp
                
                function code(x, y, z)
                	t_0 = Float64(-6.0 * Float64(y * z))
                	tmp = 0.0
                	if (z <= -1.5e+233)
                		tmp = Float64(6.0 * Float64(x * z));
                	elseif (z <= -3.7e-18)
                		tmp = t_0;
                	elseif (z <= -1.45e-221)
                		tmp = Float64(x + Float64(-4.0 * x));
                	elseif (z <= 95000.0)
                		tmp = Float64(4.0 * y);
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, y, z)
                	t_0 = -6.0 * (y * z);
                	tmp = 0.0;
                	if (z <= -1.5e+233)
                		tmp = 6.0 * (x * z);
                	elseif (z <= -3.7e-18)
                		tmp = t_0;
                	elseif (z <= -1.45e-221)
                		tmp = x + (-4.0 * x);
                	elseif (z <= 95000.0)
                		tmp = 4.0 * y;
                	else
                		tmp = t_0;
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.5e+233], N[(6.0 * N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -3.7e-18], t$95$0, If[LessEqual[z, -1.45e-221], N[(x + N[(-4.0 * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 95000.0], N[(4.0 * y), $MachinePrecision], t$95$0]]]]]
                
                \begin{array}{l}
                t_0 := -6 \cdot \left(y \cdot z\right)\\
                \mathbf{if}\;z \leq -1.5 \cdot 10^{+233}:\\
                \;\;\;\;6 \cdot \left(x \cdot z\right)\\
                
                \mathbf{elif}\;z \leq -3.7 \cdot 10^{-18}:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;z \leq -1.45 \cdot 10^{-221}:\\
                \;\;\;\;x + -4 \cdot x\\
                
                \mathbf{elif}\;z \leq 95000:\\
                \;\;\;\;4 \cdot y\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                
                Derivation
                1. Split input into 4 regimes
                2. if z < -1.50000000000000007e233

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
                  5. 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--.f6451.3

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

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

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

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

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

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

                  if -1.50000000000000007e233 < z < -3.7000000000000003e-18 or 95000 < z

                  1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto -6 \cdot \left(y \cdot z\right) \]
                  7. Applied rewrites28.4%

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

                  if -3.7000000000000003e-18 < z < -1.44999999999999997e-221

                  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--.f6450.1

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

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

                    \[\leadsto x + -4 \cdot \color{blue}{x} \]
                  6. Step-by-step derivation
                    1. lower-*.f6426.5

                      \[\leadsto x + -4 \cdot x \]
                  7. Applied rewrites26.5%

                    \[\leadsto x + -4 \cdot \color{blue}{x} \]

                  if -1.44999999999999997e-221 < z < 95000

                  1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                      \[\leadsto \left(4 + 6 \cdot \left(\mathsf{neg}\left(z\right)\right)\right) \cdot y \]
                    12. distribute-rgt-neg-outN/A

                      \[\leadsto \left(4 + \left(\mathsf{neg}\left(6 \cdot z\right)\right)\right) \cdot y \]
                    13. distribute-lft-neg-outN/A

                      \[\leadsto \left(4 + \left(\mathsf{neg}\left(6\right)\right) \cdot z\right) \cdot y \]
                    14. metadata-evalN/A

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

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

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

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

                      \[\leadsto \left(z \cdot -6 + 4\right) \cdot y \]
                    19. lower-fma.f6451.6

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

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

                    \[\leadsto 4 \cdot y \]
                  8. Step-by-step derivation
                    1. Applied rewrites25.4%

                      \[\leadsto 4 \cdot y \]
                  9. Recombined 4 regimes into one program.
                  10. Add Preprocessing

                  Alternative 12: 50.5% accurate, 1.0× speedup?

                  \[\begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -3.7 \cdot 10^{-18}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;z \leq -1.45 \cdot 10^{-221}:\\ \;\;\;\;x + -4 \cdot x\\ \mathbf{elif}\;z \leq 95000:\\ \;\;\;\;4 \cdot y\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                  (FPCore (x y z)
                   :precision binary64
                   (let* ((t_0 (* -6.0 (* y z))))
                     (if (<= z -3.7e-18)
                       t_0
                       (if (<= z -1.45e-221)
                         (+ x (* -4.0 x))
                         (if (<= z 95000.0) (* 4.0 y) t_0)))))
                  double code(double x, double y, double z) {
                  	double t_0 = -6.0 * (y * z);
                  	double tmp;
                  	if (z <= -3.7e-18) {
                  		tmp = t_0;
                  	} else if (z <= -1.45e-221) {
                  		tmp = x + (-4.0 * x);
                  	} else if (z <= 95000.0) {
                  		tmp = 4.0 * y;
                  	} 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) * (y * z)
                      if (z <= (-3.7d-18)) then
                          tmp = t_0
                      else if (z <= (-1.45d-221)) then
                          tmp = x + ((-4.0d0) * x)
                      else if (z <= 95000.0d0) then
                          tmp = 4.0d0 * y
                      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 * (y * z);
                  	double tmp;
                  	if (z <= -3.7e-18) {
                  		tmp = t_0;
                  	} else if (z <= -1.45e-221) {
                  		tmp = x + (-4.0 * x);
                  	} else if (z <= 95000.0) {
                  		tmp = 4.0 * y;
                  	} else {
                  		tmp = t_0;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, y, z):
                  	t_0 = -6.0 * (y * z)
                  	tmp = 0
                  	if z <= -3.7e-18:
                  		tmp = t_0
                  	elif z <= -1.45e-221:
                  		tmp = x + (-4.0 * x)
                  	elif z <= 95000.0:
                  		tmp = 4.0 * y
                  	else:
                  		tmp = t_0
                  	return tmp
                  
                  function code(x, y, z)
                  	t_0 = Float64(-6.0 * Float64(y * z))
                  	tmp = 0.0
                  	if (z <= -3.7e-18)
                  		tmp = t_0;
                  	elseif (z <= -1.45e-221)
                  		tmp = Float64(x + Float64(-4.0 * x));
                  	elseif (z <= 95000.0)
                  		tmp = Float64(4.0 * y);
                  	else
                  		tmp = t_0;
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, y, z)
                  	t_0 = -6.0 * (y * z);
                  	tmp = 0.0;
                  	if (z <= -3.7e-18)
                  		tmp = t_0;
                  	elseif (z <= -1.45e-221)
                  		tmp = x + (-4.0 * x);
                  	elseif (z <= 95000.0)
                  		tmp = 4.0 * y;
                  	else
                  		tmp = t_0;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, y_, z_] := Block[{t$95$0 = N[(-6.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.7e-18], t$95$0, If[LessEqual[z, -1.45e-221], N[(x + N[(-4.0 * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 95000.0], N[(4.0 * y), $MachinePrecision], t$95$0]]]]
                  
                  \begin{array}{l}
                  t_0 := -6 \cdot \left(y \cdot z\right)\\
                  \mathbf{if}\;z \leq -3.7 \cdot 10^{-18}:\\
                  \;\;\;\;t\_0\\
                  
                  \mathbf{elif}\;z \leq -1.45 \cdot 10^{-221}:\\
                  \;\;\;\;x + -4 \cdot x\\
                  
                  \mathbf{elif}\;z \leq 95000:\\
                  \;\;\;\;4 \cdot y\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_0\\
                  
                  
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if z < -3.7000000000000003e-18 or 95000 < z

                    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto -6 \cdot \left(y \cdot z\right) \]
                    7. Applied rewrites28.4%

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

                    if -3.7000000000000003e-18 < z < -1.44999999999999997e-221

                    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--.f6450.1

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

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

                      \[\leadsto x + -4 \cdot \color{blue}{x} \]
                    6. Step-by-step derivation
                      1. lower-*.f6426.5

                        \[\leadsto x + -4 \cdot x \]
                    7. Applied rewrites26.5%

                      \[\leadsto x + -4 \cdot \color{blue}{x} \]

                    if -1.44999999999999997e-221 < z < 95000

                    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                        \[\leadsto \left(4 + 6 \cdot \left(\mathsf{neg}\left(z\right)\right)\right) \cdot y \]
                      12. distribute-rgt-neg-outN/A

                        \[\leadsto \left(4 + \left(\mathsf{neg}\left(6 \cdot z\right)\right)\right) \cdot y \]
                      13. distribute-lft-neg-outN/A

                        \[\leadsto \left(4 + \left(\mathsf{neg}\left(6\right)\right) \cdot z\right) \cdot y \]
                      14. metadata-evalN/A

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

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

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

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

                        \[\leadsto \left(z \cdot -6 + 4\right) \cdot y \]
                      19. lower-fma.f6451.6

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

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

                      \[\leadsto 4 \cdot y \]
                    8. Step-by-step derivation
                      1. Applied rewrites25.4%

                        \[\leadsto 4 \cdot y \]
                    9. Recombined 3 regimes into one program.
                    10. Add Preprocessing

                    Alternative 13: 34.9% accurate, 1.3× speedup?

                    \[\begin{array}{l} t_0 := x + 4 \cdot y\\ \mathbf{if}\;y \leq -5.5 \cdot 10^{-166}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{+117}:\\ \;\;\;\;x + -4 \cdot x\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \]
                    (FPCore (x y z)
                     :precision binary64
                     (let* ((t_0 (+ x (* 4.0 y))))
                       (if (<= y -5.5e-166) t_0 (if (<= y 9.8e+117) (+ x (* -4.0 x)) t_0))))
                    double code(double x, double y, double z) {
                    	double t_0 = x + (4.0 * y);
                    	double tmp;
                    	if (y <= -5.5e-166) {
                    		tmp = t_0;
                    	} else if (y <= 9.8e+117) {
                    		tmp = x + (-4.0 * x);
                    	} 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 = x + (4.0d0 * y)
                        if (y <= (-5.5d-166)) then
                            tmp = t_0
                        else if (y <= 9.8d+117) then
                            tmp = x + ((-4.0d0) * x)
                        else
                            tmp = t_0
                        end if
                        code = tmp
                    end function
                    
                    public static double code(double x, double y, double z) {
                    	double t_0 = x + (4.0 * y);
                    	double tmp;
                    	if (y <= -5.5e-166) {
                    		tmp = t_0;
                    	} else if (y <= 9.8e+117) {
                    		tmp = x + (-4.0 * x);
                    	} else {
                    		tmp = t_0;
                    	}
                    	return tmp;
                    }
                    
                    def code(x, y, z):
                    	t_0 = x + (4.0 * y)
                    	tmp = 0
                    	if y <= -5.5e-166:
                    		tmp = t_0
                    	elif y <= 9.8e+117:
                    		tmp = x + (-4.0 * x)
                    	else:
                    		tmp = t_0
                    	return tmp
                    
                    function code(x, y, z)
                    	t_0 = Float64(x + Float64(4.0 * y))
                    	tmp = 0.0
                    	if (y <= -5.5e-166)
                    		tmp = t_0;
                    	elseif (y <= 9.8e+117)
                    		tmp = Float64(x + Float64(-4.0 * x));
                    	else
                    		tmp = t_0;
                    	end
                    	return tmp
                    end
                    
                    function tmp_2 = code(x, y, z)
                    	t_0 = x + (4.0 * y);
                    	tmp = 0.0;
                    	if (y <= -5.5e-166)
                    		tmp = t_0;
                    	elseif (y <= 9.8e+117)
                    		tmp = x + (-4.0 * x);
                    	else
                    		tmp = t_0;
                    	end
                    	tmp_2 = tmp;
                    end
                    
                    code[x_, y_, z_] := Block[{t$95$0 = N[(x + N[(4.0 * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.5e-166], t$95$0, If[LessEqual[y, 9.8e+117], N[(x + N[(-4.0 * x), $MachinePrecision]), $MachinePrecision], t$95$0]]]
                    
                    \begin{array}{l}
                    t_0 := x + 4 \cdot y\\
                    \mathbf{if}\;y \leq -5.5 \cdot 10^{-166}:\\
                    \;\;\;\;t\_0\\
                    
                    \mathbf{elif}\;y \leq 9.8 \cdot 10^{+117}:\\
                    \;\;\;\;x + -4 \cdot x\\
                    
                    \mathbf{else}:\\
                    \;\;\;\;t\_0\\
                    
                    
                    \end{array}
                    
                    Derivation
                    1. Split input into 2 regimes
                    2. if y < -5.4999999999999997e-166 or 9.8000000000000002e117 < y

                      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--.f6450.1

                          \[\leadsto x + 4 \cdot \left(y - \color{blue}{x}\right) \]
                      4. Applied rewrites50.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 rewrites25.1%

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

                        if -5.4999999999999997e-166 < y < 9.8000000000000002e117

                        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--.f6450.1

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

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

                          \[\leadsto x + -4 \cdot \color{blue}{x} \]
                        6. Step-by-step derivation
                          1. lower-*.f6426.5

                            \[\leadsto x + -4 \cdot x \]
                        7. Applied rewrites26.5%

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

                      Alternative 14: 34.7% accurate, 1.3× speedup?

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

                        1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \left(4 + 6 \cdot \left(\mathsf{neg}\left(z\right)\right)\right) \cdot y \]
                          12. distribute-rgt-neg-outN/A

                            \[\leadsto \left(4 + \left(\mathsf{neg}\left(6 \cdot z\right)\right)\right) \cdot y \]
                          13. distribute-lft-neg-outN/A

                            \[\leadsto \left(4 + \left(\mathsf{neg}\left(6\right)\right) \cdot z\right) \cdot y \]
                          14. metadata-evalN/A

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

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

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

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

                            \[\leadsto \left(z \cdot -6 + 4\right) \cdot y \]
                          19. lower-fma.f6451.6

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

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

                          \[\leadsto 4 \cdot y \]
                        8. Step-by-step derivation
                          1. Applied rewrites25.4%

                            \[\leadsto 4 \cdot y \]

                          if -5.4999999999999997e-166 < y < 9.8000000000000002e117

                          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--.f6450.1

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

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

                            \[\leadsto x + -4 \cdot \color{blue}{x} \]
                          6. Step-by-step derivation
                            1. lower-*.f6426.5

                              \[\leadsto x + -4 \cdot x \]
                          7. Applied rewrites26.5%

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

                        Alternative 15: 25.4% accurate, 4.6× speedup?

                        \[4 \cdot y \]
                        (FPCore (x y z) :precision binary64 (* 4.0 y))
                        double code(double x, double y, double z) {
                        	return 4.0 * y;
                        }
                        
                        module fmin_fmax_functions
                            implicit none
                            private
                            public fmax
                            public fmin
                        
                            interface fmax
                                module procedure fmax88
                                module procedure fmax44
                                module procedure fmax84
                                module procedure fmax48
                            end interface
                            interface fmin
                                module procedure fmin88
                                module procedure fmin44
                                module procedure fmin84
                                module procedure fmin48
                            end interface
                        contains
                            real(8) function fmax88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmax44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmax84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmax48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                            end function
                            real(8) function fmin88(x, y) result (res)
                                real(8), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(4) function fmin44(x, y) result (res)
                                real(4), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                            end function
                            real(8) function fmin84(x, y) result(res)
                                real(8), intent (in) :: x
                                real(4), intent (in) :: y
                                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                            end function
                            real(8) function fmin48(x, y) result(res)
                                real(4), intent (in) :: x
                                real(8), intent (in) :: y
                                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                            end function
                        end module
                        
                        real(8) function code(x, y, z)
                        use fmin_fmax_functions
                            real(8), intent (in) :: x
                            real(8), intent (in) :: y
                            real(8), intent (in) :: z
                            code = 4.0d0 * y
                        end function
                        
                        public static double code(double x, double y, double z) {
                        	return 4.0 * y;
                        }
                        
                        def code(x, y, z):
                        	return 4.0 * y
                        
                        function code(x, y, z)
                        	return Float64(4.0 * y)
                        end
                        
                        function tmp = code(x, y, z)
                        	tmp = 4.0 * y;
                        end
                        
                        code[x_, y_, z_] := N[(4.0 * y), $MachinePrecision]
                        
                        4 \cdot y
                        
                        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 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                            \[\leadsto \left(4 + 6 \cdot \left(\mathsf{neg}\left(z\right)\right)\right) \cdot y \]
                          12. distribute-rgt-neg-outN/A

                            \[\leadsto \left(4 + \left(\mathsf{neg}\left(6 \cdot z\right)\right)\right) \cdot y \]
                          13. distribute-lft-neg-outN/A

                            \[\leadsto \left(4 + \left(\mathsf{neg}\left(6\right)\right) \cdot z\right) \cdot y \]
                          14. metadata-evalN/A

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

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

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

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

                            \[\leadsto \left(z \cdot -6 + 4\right) \cdot y \]
                          19. lower-fma.f6451.6

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

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

                          \[\leadsto 4 \cdot y \]
                        8. Step-by-step derivation
                          1. Applied rewrites25.4%

                            \[\leadsto 4 \cdot y \]
                          2. Add Preprocessing

                          Reproduce

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