Data.Metrics.Snapshot:quantile from metrics-0.3.0.2

Percentage Accurate: 100.0% → 100.0%
Time: 2.2s
Alternatives: 9
Speedup: 1.1×

Specification

?
\[x + \left(y - z\right) \cdot \left(t - x\right) \]
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
	return x + ((y - z) * (t - x));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y - z) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
	return x + ((y - z) * (t - x));
}
def code(x, y, z, t):
	return x + ((y - z) * (t - x))
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y - z) * Float64(t - x)))
end
function tmp = code(x, y, z, t)
	tmp = x + ((y - z) * (t - x));
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(y - z\right) \cdot \left(t - x\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 9 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: 100.0% accurate, 1.0× speedup?

\[x + \left(y - z\right) \cdot \left(t - x\right) \]
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
	return x + ((y - z) * (t - x));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, y, z, t)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y - z) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
	return x + ((y - z) * (t - x));
}
def code(x, y, z, t):
	return x + ((y - z) * (t - x))
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y - z) * Float64(t - x)))
end
function tmp = code(x, y, z, t)
	tmp = x + ((y - z) * (t - x));
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \left(y - z\right) \cdot \left(t - x\right)

Alternative 1: 100.0% accurate, 1.1× speedup?

\[\mathsf{fma}\left(z - y, x - t, x\right) \]
(FPCore (x y z t) :precision binary64 (fma (- z y) (- x t) x))
double code(double x, double y, double z, double t) {
	return fma((z - y), (x - t), x);
}
function code(x, y, z, t)
	return fma(Float64(z - y), Float64(x - t), x)
end
code[x_, y_, z_, t_] := N[(N[(z - y), $MachinePrecision] * N[(x - t), $MachinePrecision] + x), $MachinePrecision]
\mathsf{fma}\left(z - y, x - t, x\right)
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \left(z - y\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(t - x\right)}\right)\right) + x \]
    9. sub-negate-revN/A

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z - y, x - t, x\right)} \]
    11. lower--.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{z - y}, x - t, x\right) \]
    12. lower--.f64100.0%

      \[\leadsto \mathsf{fma}\left(z - y, \color{blue}{x - t}, x\right) \]
  3. Applied rewrites100.0%

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

Alternative 2: 83.9% accurate, 0.7× speedup?

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

\mathbf{elif}\;z \leq 1.5 \cdot 10^{+24}:\\
\;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \left(z - y\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(t - x\right)}\right)\right) + x \]
      9. sub-negate-revN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z - y, x - t, x\right)} \]
      11. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{z - y}, x - t, x\right) \]
      12. lower--.f64100.0%

        \[\leadsto \mathsf{fma}\left(z - y, \color{blue}{x - t}, x\right) \]
    3. Applied rewrites100.0%

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

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

        \[\leadsto z \cdot \color{blue}{\left(x - t\right)} \]
      2. lower--.f6444.8%

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

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

    if -5.9000000000000002e74 < z < 1.49999999999999997e24

    1. Initial program 100.0%

      \[x + \left(y - z\right) \cdot \left(t - x\right) \]
    2. Taylor expanded in z around 0

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

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

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

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

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

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

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

        \[\leadsto y \cdot \left(t - x\right) + x \]
      4. lift-*.f64N/A

        \[\leadsto y \cdot \left(t - x\right) + x \]
      5. *-commutativeN/A

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

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

        \[\leadsto \mathsf{fma}\left(t - x, y, x\right) \]
    6. Applied rewrites60.4%

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

    if 1.49999999999999997e24 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

        \[\leadsto \left(z - y\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(t - x\right)}\right)\right) + x \]
      9. sub-negate-revN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z - y, x - t, x\right)} \]
      11. lower--.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{z - y}, x - t, x\right) \]
      12. lower--.f64100.0%

        \[\leadsto \mathsf{fma}\left(z - y, \color{blue}{x - t}, x\right) \]
    3. Applied rewrites100.0%

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

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

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

    Alternative 3: 83.9% accurate, 0.7× speedup?

    \[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -5.9 \cdot 10^{+74}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+24}:\\ \;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (let* ((t_1 (* z (- x t))))
       (if (<= z -5.9e+74) t_1 (if (<= z 1.5e+24) (fma (- t x) y x) t_1))))
    double code(double x, double y, double z, double t) {
    	double t_1 = z * (x - t);
    	double tmp;
    	if (z <= -5.9e+74) {
    		tmp = t_1;
    	} else if (z <= 1.5e+24) {
    		tmp = fma((t - x), y, x);
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    function code(x, y, z, t)
    	t_1 = Float64(z * Float64(x - t))
    	tmp = 0.0
    	if (z <= -5.9e+74)
    		tmp = t_1;
    	elseif (z <= 1.5e+24)
    		tmp = fma(Float64(t - x), y, x);
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.9e+74], t$95$1, If[LessEqual[z, 1.5e+24], N[(N[(t - x), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
    
    \begin{array}{l}
    t_1 := z \cdot \left(x - t\right)\\
    \mathbf{if}\;z \leq -5.9 \cdot 10^{+74}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;z \leq 1.5 \cdot 10^{+24}:\\
    \;\;\;\;\mathsf{fma}\left(t - x, y, x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if z < -5.9000000000000002e74 or 1.49999999999999997e24 < z

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

          \[\leadsto \left(z - y\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(t - x\right)}\right)\right) + x \]
        9. sub-negate-revN/A

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(z - y, x - t, x\right)} \]
        11. lower--.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{z - y}, x - t, x\right) \]
        12. lower--.f64100.0%

          \[\leadsto \mathsf{fma}\left(z - y, \color{blue}{x - t}, x\right) \]
      3. Applied rewrites100.0%

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

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

          \[\leadsto z \cdot \color{blue}{\left(x - t\right)} \]
        2. lower--.f6444.8%

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

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

      if -5.9000000000000002e74 < z < 1.49999999999999997e24

      1. Initial program 100.0%

        \[x + \left(y - z\right) \cdot \left(t - x\right) \]
      2. Taylor expanded in z around 0

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

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

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

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

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

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

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

          \[\leadsto y \cdot \left(t - x\right) + x \]
        4. lift-*.f64N/A

          \[\leadsto y \cdot \left(t - x\right) + x \]
        5. *-commutativeN/A

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

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

          \[\leadsto \mathsf{fma}\left(t - x, y, x\right) \]
      6. Applied rewrites60.4%

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

    Alternative 4: 71.0% accurate, 0.7× speedup?

    \[\begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -5.9 \cdot 10^{+74}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -9.2 \cdot 10^{-100}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+24}:\\ \;\;\;\;\mathsf{fma}\left(t, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (let* ((t_1 (* z (- x t))))
       (if (<= z -5.9e+74)
         t_1
         (if (<= z -9.2e-100) (* y (- t x)) (if (<= z 1.5e+24) (fma t y x) t_1)))))
    double code(double x, double y, double z, double t) {
    	double t_1 = z * (x - t);
    	double tmp;
    	if (z <= -5.9e+74) {
    		tmp = t_1;
    	} else if (z <= -9.2e-100) {
    		tmp = y * (t - x);
    	} else if (z <= 1.5e+24) {
    		tmp = fma(t, y, x);
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    function code(x, y, z, t)
    	t_1 = Float64(z * Float64(x - t))
    	tmp = 0.0
    	if (z <= -5.9e+74)
    		tmp = t_1;
    	elseif (z <= -9.2e-100)
    		tmp = Float64(y * Float64(t - x));
    	elseif (z <= 1.5e+24)
    		tmp = fma(t, y, x);
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5.9e+74], t$95$1, If[LessEqual[z, -9.2e-100], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.5e+24], N[(t * y + x), $MachinePrecision], t$95$1]]]]
    
    \begin{array}{l}
    t_1 := z \cdot \left(x - t\right)\\
    \mathbf{if}\;z \leq -5.9 \cdot 10^{+74}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;z \leq -9.2 \cdot 10^{-100}:\\
    \;\;\;\;y \cdot \left(t - x\right)\\
    
    \mathbf{elif}\;z \leq 1.5 \cdot 10^{+24}:\\
    \;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if z < -5.9000000000000002e74 or 1.49999999999999997e24 < z

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

          \[\leadsto \left(z - y\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(t - x\right)}\right)\right) + x \]
        9. sub-negate-revN/A

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(z - y, x - t, x\right)} \]
        11. lower--.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{z - y}, x - t, x\right) \]
        12. lower--.f64100.0%

          \[\leadsto \mathsf{fma}\left(z - y, \color{blue}{x - t}, x\right) \]
      3. Applied rewrites100.0%

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

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

          \[\leadsto z \cdot \color{blue}{\left(x - t\right)} \]
        2. lower--.f6444.8%

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

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

      if -5.9000000000000002e74 < z < -9.19999999999999978e-100

      1. Initial program 100.0%

        \[x + \left(y - z\right) \cdot \left(t - x\right) \]
      2. Taylor expanded in y around inf

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

          \[\leadsto y \cdot \color{blue}{\left(t - x\right)} \]
        2. lower--.f6444.8%

          \[\leadsto y \cdot \left(t - \color{blue}{x}\right) \]
      4. Applied rewrites44.8%

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

      if -9.19999999999999978e-100 < z < 1.49999999999999997e24

      1. Initial program 100.0%

        \[x + \left(y - z\right) \cdot \left(t - x\right) \]
      2. Taylor expanded in z around 0

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

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

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

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

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

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

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

          \[\leadsto y \cdot \left(t - x\right) + x \]
        4. lift-*.f64N/A

          \[\leadsto y \cdot \left(t - x\right) + x \]
        5. *-commutativeN/A

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

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

          \[\leadsto \mathsf{fma}\left(t - x, y, x\right) \]
      6. Applied rewrites60.4%

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

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

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

      Alternative 5: 60.1% accurate, 0.5× speedup?

      \[\begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ t_2 := t \cdot \left(y - z\right)\\ \mathbf{if}\;y \leq -1.45 \cdot 10^{+51}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq -1.55 \cdot 10^{-72}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{-233}:\\ \;\;\;\;\mathsf{fma}\left(t, y, x\right)\\ \mathbf{elif}\;y \leq 59000:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
      (FPCore (x y z t)
       :precision binary64
       (let* ((t_1 (* y (- t x))) (t_2 (* t (- y z))))
         (if (<= y -1.45e+51)
           t_1
           (if (<= y -1.55e-72)
             t_2
             (if (<= y 6.6e-233) (fma t y x) (if (<= y 59000.0) t_2 t_1))))))
      double code(double x, double y, double z, double t) {
      	double t_1 = y * (t - x);
      	double t_2 = t * (y - z);
      	double tmp;
      	if (y <= -1.45e+51) {
      		tmp = t_1;
      	} else if (y <= -1.55e-72) {
      		tmp = t_2;
      	} else if (y <= 6.6e-233) {
      		tmp = fma(t, y, x);
      	} else if (y <= 59000.0) {
      		tmp = t_2;
      	} else {
      		tmp = t_1;
      	}
      	return tmp;
      }
      
      function code(x, y, z, t)
      	t_1 = Float64(y * Float64(t - x))
      	t_2 = Float64(t * Float64(y - z))
      	tmp = 0.0
      	if (y <= -1.45e+51)
      		tmp = t_1;
      	elseif (y <= -1.55e-72)
      		tmp = t_2;
      	elseif (y <= 6.6e-233)
      		tmp = fma(t, y, x);
      	elseif (y <= 59000.0)
      		tmp = t_2;
      	else
      		tmp = t_1;
      	end
      	return tmp
      end
      
      code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.45e+51], t$95$1, If[LessEqual[y, -1.55e-72], t$95$2, If[LessEqual[y, 6.6e-233], N[(t * y + x), $MachinePrecision], If[LessEqual[y, 59000.0], t$95$2, t$95$1]]]]]]
      
      \begin{array}{l}
      t_1 := y \cdot \left(t - x\right)\\
      t_2 := t \cdot \left(y - z\right)\\
      \mathbf{if}\;y \leq -1.45 \cdot 10^{+51}:\\
      \;\;\;\;t\_1\\
      
      \mathbf{elif}\;y \leq -1.55 \cdot 10^{-72}:\\
      \;\;\;\;t\_2\\
      
      \mathbf{elif}\;y \leq 6.6 \cdot 10^{-233}:\\
      \;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
      
      \mathbf{elif}\;y \leq 59000:\\
      \;\;\;\;t\_2\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_1\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if y < -1.4499999999999999e51 or 59000 < y

        1. Initial program 100.0%

          \[x + \left(y - z\right) \cdot \left(t - x\right) \]
        2. Taylor expanded in y around inf

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

            \[\leadsto y \cdot \color{blue}{\left(t - x\right)} \]
          2. lower--.f6444.8%

            \[\leadsto y \cdot \left(t - \color{blue}{x}\right) \]
        4. Applied rewrites44.8%

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

        if -1.4499999999999999e51 < y < -1.5499999999999999e-72 or 6.6000000000000001e-233 < y < 59000

        1. Initial program 100.0%

          \[x + \left(y - z\right) \cdot \left(t - x\right) \]
        2. Taylor expanded in x around 0

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

            \[\leadsto t \cdot \color{blue}{\left(y - z\right)} \]
          2. lower--.f6448.6%

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

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

        if -1.5499999999999999e-72 < y < 6.6000000000000001e-233

        1. Initial program 100.0%

          \[x + \left(y - z\right) \cdot \left(t - x\right) \]
        2. Taylor expanded in z around 0

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

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

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

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

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

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

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

            \[\leadsto y \cdot \left(t - x\right) + x \]
          4. lift-*.f64N/A

            \[\leadsto y \cdot \left(t - x\right) + x \]
          5. *-commutativeN/A

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

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

            \[\leadsto \mathsf{fma}\left(t - x, y, x\right) \]
        6. Applied rewrites60.4%

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

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

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

        Alternative 6: 59.4% accurate, 0.7× speedup?

        \[\begin{array}{l} t_1 := t \cdot \left(y - z\right)\\ \mathbf{if}\;z \leq -1.2 \cdot 10^{+196}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -10.5:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{-5}:\\ \;\;\;\;\mathsf{fma}\left(t, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \]
        (FPCore (x y z t)
         :precision binary64
         (let* ((t_1 (* t (- y z))))
           (if (<= z -1.2e+196)
             (* x z)
             (if (<= z -10.5) t_1 (if (<= z 7.5e-5) (fma t y x) t_1)))))
        double code(double x, double y, double z, double t) {
        	double t_1 = t * (y - z);
        	double tmp;
        	if (z <= -1.2e+196) {
        		tmp = x * z;
        	} else if (z <= -10.5) {
        		tmp = t_1;
        	} else if (z <= 7.5e-5) {
        		tmp = fma(t, y, x);
        	} else {
        		tmp = t_1;
        	}
        	return tmp;
        }
        
        function code(x, y, z, t)
        	t_1 = Float64(t * Float64(y - z))
        	tmp = 0.0
        	if (z <= -1.2e+196)
        		tmp = Float64(x * z);
        	elseif (z <= -10.5)
        		tmp = t_1;
        	elseif (z <= 7.5e-5)
        		tmp = fma(t, y, x);
        	else
        		tmp = t_1;
        	end
        	return tmp
        end
        
        code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.2e+196], N[(x * z), $MachinePrecision], If[LessEqual[z, -10.5], t$95$1, If[LessEqual[z, 7.5e-5], N[(t * y + x), $MachinePrecision], t$95$1]]]]
        
        \begin{array}{l}
        t_1 := t \cdot \left(y - z\right)\\
        \mathbf{if}\;z \leq -1.2 \cdot 10^{+196}:\\
        \;\;\;\;x \cdot z\\
        
        \mathbf{elif}\;z \leq -10.5:\\
        \;\;\;\;t\_1\\
        
        \mathbf{elif}\;z \leq 7.5 \cdot 10^{-5}:\\
        \;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_1\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if z < -1.2e196

          1. Initial program 100.0%

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

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

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

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

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

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

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

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

              \[\leadsto \left(z - y\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(t - x\right)}\right)\right) + x \]
            9. sub-negate-revN/A

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(z - y, x - t, x\right)} \]
            11. lower--.f64N/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{z - y}, x - t, x\right) \]
            12. lower--.f64100.0%

              \[\leadsto \mathsf{fma}\left(z - y, \color{blue}{x - t}, x\right) \]
          3. Applied rewrites100.0%

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

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

              \[\leadsto z \cdot \color{blue}{\left(x - t\right)} \]
            2. lower--.f6444.8%

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

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

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

              \[\leadsto x \cdot z \]
          9. Applied rewrites22.7%

            \[\leadsto x \cdot \color{blue}{z} \]

          if -1.2e196 < z < -10.5 or 7.49999999999999934e-5 < z

          1. Initial program 100.0%

            \[x + \left(y - z\right) \cdot \left(t - x\right) \]
          2. Taylor expanded in x around 0

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

              \[\leadsto t \cdot \color{blue}{\left(y - z\right)} \]
            2. lower--.f6448.6%

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

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

          if -10.5 < z < 7.49999999999999934e-5

          1. Initial program 100.0%

            \[x + \left(y - z\right) \cdot \left(t - x\right) \]
          2. Taylor expanded in z around 0

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

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

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

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

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

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

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

              \[\leadsto y \cdot \left(t - x\right) + x \]
            4. lift-*.f64N/A

              \[\leadsto y \cdot \left(t - x\right) + x \]
            5. *-commutativeN/A

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

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

              \[\leadsto \mathsf{fma}\left(t - x, y, x\right) \]
          6. Applied rewrites60.4%

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

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

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

          Alternative 7: 51.9% accurate, 0.9× speedup?

          \[\begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{+163}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 2.45 \cdot 10^{+64}:\\ \;\;\;\;\mathsf{fma}\left(t, y, x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]
          (FPCore (x y z t)
           :precision binary64
           (if (<= z -1.4e+163) (* x z) (if (<= z 2.45e+64) (fma t y x) (* x z))))
          double code(double x, double y, double z, double t) {
          	double tmp;
          	if (z <= -1.4e+163) {
          		tmp = x * z;
          	} else if (z <= 2.45e+64) {
          		tmp = fma(t, y, x);
          	} else {
          		tmp = x * z;
          	}
          	return tmp;
          }
          
          function code(x, y, z, t)
          	tmp = 0.0
          	if (z <= -1.4e+163)
          		tmp = Float64(x * z);
          	elseif (z <= 2.45e+64)
          		tmp = fma(t, y, x);
          	else
          		tmp = Float64(x * z);
          	end
          	return tmp
          end
          
          code[x_, y_, z_, t_] := If[LessEqual[z, -1.4e+163], N[(x * z), $MachinePrecision], If[LessEqual[z, 2.45e+64], N[(t * y + x), $MachinePrecision], N[(x * z), $MachinePrecision]]]
          
          \begin{array}{l}
          \mathbf{if}\;z \leq -1.4 \cdot 10^{+163}:\\
          \;\;\;\;x \cdot z\\
          
          \mathbf{elif}\;z \leq 2.45 \cdot 10^{+64}:\\
          \;\;\;\;\mathsf{fma}\left(t, y, x\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;x \cdot z\\
          
          
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if z < -1.40000000000000007e163 or 2.4500000000000001e64 < z

            1. Initial program 100.0%

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

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

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

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

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

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

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

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

                \[\leadsto \left(z - y\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(t - x\right)}\right)\right) + x \]
              9. sub-negate-revN/A

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(z - y, x - t, x\right)} \]
              11. lower--.f64N/A

                \[\leadsto \mathsf{fma}\left(\color{blue}{z - y}, x - t, x\right) \]
              12. lower--.f64100.0%

                \[\leadsto \mathsf{fma}\left(z - y, \color{blue}{x - t}, x\right) \]
            3. Applied rewrites100.0%

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

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

                \[\leadsto z \cdot \color{blue}{\left(x - t\right)} \]
              2. lower--.f6444.8%

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

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

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

                \[\leadsto x \cdot z \]
            9. Applied rewrites22.7%

              \[\leadsto x \cdot \color{blue}{z} \]

            if -1.40000000000000007e163 < z < 2.4500000000000001e64

            1. Initial program 100.0%

              \[x + \left(y - z\right) \cdot \left(t - x\right) \]
            2. Taylor expanded in z around 0

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

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

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

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

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

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

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

                \[\leadsto y \cdot \left(t - x\right) + x \]
              4. lift-*.f64N/A

                \[\leadsto y \cdot \left(t - x\right) + x \]
              5. *-commutativeN/A

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

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

                \[\leadsto \mathsf{fma}\left(t - x, y, x\right) \]
            6. Applied rewrites60.4%

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

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

                \[\leadsto \mathsf{fma}\left(t, y, x\right) \]
            9. Recombined 2 regimes into one program.
            10. Add Preprocessing

            Alternative 8: 37.1% accurate, 1.0× speedup?

            \[\begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{+154}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+24}:\\ \;\;\;\;t \cdot y\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]
            (FPCore (x y z t)
             :precision binary64
             (if (<= z -1.05e+154) (* x z) (if (<= z 6.2e+24) (* t y) (* x z))))
            double code(double x, double y, double z, double t) {
            	double tmp;
            	if (z <= -1.05e+154) {
            		tmp = x * z;
            	} else if (z <= 6.2e+24) {
            		tmp = t * y;
            	} else {
            		tmp = x * z;
            	}
            	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, t)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8), intent (in) :: t
                real(8) :: tmp
                if (z <= (-1.05d+154)) then
                    tmp = x * z
                else if (z <= 6.2d+24) then
                    tmp = t * y
                else
                    tmp = x * z
                end if
                code = tmp
            end function
            
            public static double code(double x, double y, double z, double t) {
            	double tmp;
            	if (z <= -1.05e+154) {
            		tmp = x * z;
            	} else if (z <= 6.2e+24) {
            		tmp = t * y;
            	} else {
            		tmp = x * z;
            	}
            	return tmp;
            }
            
            def code(x, y, z, t):
            	tmp = 0
            	if z <= -1.05e+154:
            		tmp = x * z
            	elif z <= 6.2e+24:
            		tmp = t * y
            	else:
            		tmp = x * z
            	return tmp
            
            function code(x, y, z, t)
            	tmp = 0.0
            	if (z <= -1.05e+154)
            		tmp = Float64(x * z);
            	elseif (z <= 6.2e+24)
            		tmp = Float64(t * y);
            	else
            		tmp = Float64(x * z);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x, y, z, t)
            	tmp = 0.0;
            	if (z <= -1.05e+154)
            		tmp = x * z;
            	elseif (z <= 6.2e+24)
            		tmp = t * y;
            	else
            		tmp = x * z;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_, y_, z_, t_] := If[LessEqual[z, -1.05e+154], N[(x * z), $MachinePrecision], If[LessEqual[z, 6.2e+24], N[(t * y), $MachinePrecision], N[(x * z), $MachinePrecision]]]
            
            \begin{array}{l}
            \mathbf{if}\;z \leq -1.05 \cdot 10^{+154}:\\
            \;\;\;\;x \cdot z\\
            
            \mathbf{elif}\;z \leq 6.2 \cdot 10^{+24}:\\
            \;\;\;\;t \cdot y\\
            
            \mathbf{else}:\\
            \;\;\;\;x \cdot z\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if z < -1.04999999999999997e154 or 6.20000000000000022e24 < z

              1. Initial program 100.0%

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

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

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

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

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

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

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

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

                  \[\leadsto \left(z - y\right) \cdot \left(\mathsf{neg}\left(\color{blue}{\left(t - x\right)}\right)\right) + x \]
                9. sub-negate-revN/A

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(z - y, x - t, x\right)} \]
                11. lower--.f64N/A

                  \[\leadsto \mathsf{fma}\left(\color{blue}{z - y}, x - t, x\right) \]
                12. lower--.f64100.0%

                  \[\leadsto \mathsf{fma}\left(z - y, \color{blue}{x - t}, x\right) \]
              3. Applied rewrites100.0%

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

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

                  \[\leadsto z \cdot \color{blue}{\left(x - t\right)} \]
                2. lower--.f6444.8%

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

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

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

                  \[\leadsto x \cdot z \]
              9. Applied rewrites22.7%

                \[\leadsto x \cdot \color{blue}{z} \]

              if -1.04999999999999997e154 < z < 6.20000000000000022e24

              1. Initial program 100.0%

                \[x + \left(y - z\right) \cdot \left(t - x\right) \]
              2. Taylor expanded in y around inf

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

                  \[\leadsto y \cdot \color{blue}{\left(t - x\right)} \]
                2. lower--.f6444.8%

                  \[\leadsto y \cdot \left(t - \color{blue}{x}\right) \]
              4. Applied rewrites44.8%

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

                \[\leadsto t \cdot \color{blue}{y} \]
              6. Step-by-step derivation
                1. lower-*.f6426.3%

                  \[\leadsto t \cdot y \]
              7. Applied rewrites26.3%

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

            Alternative 9: 26.3% accurate, 3.0× speedup?

            \[t \cdot y \]
            (FPCore (x y z t) :precision binary64 (* t y))
            double code(double x, double y, double z, double t) {
            	return t * 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, t)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                real(8), intent (in) :: z
                real(8), intent (in) :: t
                code = t * y
            end function
            
            public static double code(double x, double y, double z, double t) {
            	return t * y;
            }
            
            def code(x, y, z, t):
            	return t * y
            
            function code(x, y, z, t)
            	return Float64(t * y)
            end
            
            function tmp = code(x, y, z, t)
            	tmp = t * y;
            end
            
            code[x_, y_, z_, t_] := N[(t * y), $MachinePrecision]
            
            t \cdot y
            
            Derivation
            1. Initial program 100.0%

              \[x + \left(y - z\right) \cdot \left(t - x\right) \]
            2. Taylor expanded in y around inf

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

                \[\leadsto y \cdot \color{blue}{\left(t - x\right)} \]
              2. lower--.f6444.8%

                \[\leadsto y \cdot \left(t - \color{blue}{x}\right) \]
            4. Applied rewrites44.8%

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

              \[\leadsto t \cdot \color{blue}{y} \]
            6. Step-by-step derivation
              1. lower-*.f6426.3%

                \[\leadsto t \cdot y \]
            7. Applied rewrites26.3%

              \[\leadsto t \cdot \color{blue}{y} \]
            8. Add Preprocessing

            Reproduce

            ?
            herbie shell --seed 2025183 
            (FPCore (x y z t)
              :name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
              :precision binary64
              (+ x (* (- y z) (- t x))))