Data.Metrics.Snapshot:quantile from metrics-0.3.0.2

Percentage Accurate: 100.0% → 100.0%
Time: 10.4s
Alternatives: 10
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ x + \left(y - z\right) \cdot \left(t - x\right) \end{array} \]
(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));
}
real(8) function code(x, y, z, t)
    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]
\begin{array}{l}

\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 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?

\[\begin{array}{l} \\ x + \left(y - z\right) \cdot \left(t - x\right) \end{array} \]
(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));
}
real(8) function code(x, y, z, t)
    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]
\begin{array}{l}

\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}

Alternative 1: 100.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ x + \left(y - z\right) \cdot \left(t - x\right) \end{array} \]
(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));
}
real(8) function code(x, y, z, t)
    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]
\begin{array}{l}

\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}
Derivation
  1. Initial program 100.0%

    \[x + \left(y - z\right) \cdot \left(t - x\right) \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 83.7% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -15800000000:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.58e10 or 6.6e15 < y

    1. Initial program 100.0%

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

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

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

        \[\leadsto y \cdot \color{blue}{\left(t - x\right)} \]
    5. Applied rewrites85.2%

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

    if -1.58e10 < y < 6.6e15

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{x + -1 \cdot \left(z \cdot \left(t - x\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

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

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(\left(t - x\right)\right)\right)} + x \]
      4. mul-1-negN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, -1 \cdot \left(t - x\right), x\right)} \]
      6. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\mathsf{neg}\left(\left(t - x\right)\right)}, x\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{fma}\left(z, \mathsf{neg}\left(\color{blue}{\left(t + \left(\mathsf{neg}\left(x\right)\right)\right)}\right), x\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, \mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(x\right)\right) + t\right)}\right), x\right) \]
      9. distribute-neg-inN/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) + \left(\mathsf{neg}\left(t\right)\right)}, x\right) \]
      10. unsub-negN/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) - t}, x\right) \]
      11. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{x} - t, x\right) \]
      12. lower--.f6492.3

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

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

Alternative 3: 83.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -4.2 \cdot 10^{+14}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{+51}:\\ \;\;\;\;\mathsf{fma}\left(y, t - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* z (- x t))))
   (if (<= z -4.2e+14) t_1 (if (<= z 8.2e+51) (fma y (- t x) x) t_1))))
double code(double x, double y, double z, double t) {
	double t_1 = z * (x - t);
	double tmp;
	if (z <= -4.2e+14) {
		tmp = t_1;
	} else if (z <= 8.2e+51) {
		tmp = fma(y, (t - x), 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 <= -4.2e+14)
		tmp = t_1;
	elseif (z <= 8.2e+51)
		tmp = fma(y, Float64(t - x), 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, -4.2e+14], t$95$1, If[LessEqual[z, 8.2e+51], N[(y * N[(t - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := z \cdot \left(x - t\right)\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+14}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.2e14 or 8.20000000000000021e51 < z

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(t - x\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

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

        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(\left(t - x\right)\right)\right)} \]
      3. mul-1-negN/A

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

        \[\leadsto \color{blue}{z \cdot \left(-1 \cdot \left(t - x\right)\right)} \]
      5. mul-1-negN/A

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(t - x\right)\right)\right)} \]
      6. sub-negN/A

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

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

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

        \[\leadsto z \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) - t\right)} \]
      10. remove-double-negN/A

        \[\leadsto z \cdot \left(\color{blue}{x} - t\right) \]
      11. lower--.f6486.5

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

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

    if -4.2e14 < z < 8.20000000000000021e51

    1. Initial program 100.0%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, t - x, x\right)} \]
      3. lower--.f6489.9

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{t - x}, x\right) \]
    5. Applied rewrites89.9%

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

Alternative 4: 77.0% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, z - y, x\right)\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{-47}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.25 \cdot 10^{-80}:\\
\;\;\;\;\left(y - z\right) \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.3499999999999999e-47 or 2.2500000000000001e-80 < x

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(y - z\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

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

        \[\leadsto \color{blue}{x \cdot \left(-1 \cdot \left(y - z\right)\right) + x \cdot 1} \]
      3. *-rgt-identityN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, -1 \cdot \left(y - z\right), x\right)} \]
      5. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\mathsf{neg}\left(\left(y - z\right)\right)}, x\right) \]
      6. sub-negN/A

        \[\leadsto \mathsf{fma}\left(x, \mathsf{neg}\left(\color{blue}{\left(y + \left(\mathsf{neg}\left(z\right)\right)\right)}\right), x\right) \]
      7. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(x, \mathsf{neg}\left(\color{blue}{\left(\left(\mathsf{neg}\left(z\right)\right) + y\right)}\right), x\right) \]
      8. distribute-neg-inN/A

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)\right) + \left(\mathsf{neg}\left(y\right)\right)}, x\right) \]
      9. unsub-negN/A

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(z\right)\right)\right)\right) - y}, x\right) \]
      10. remove-double-negN/A

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

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

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

    if -1.3499999999999999e-47 < x < 2.2500000000000001e-80

    1. Initial program 100.0%

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

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

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

        \[\leadsto t \cdot \color{blue}{\left(y - z\right)} \]
    5. Applied rewrites81.9%

      \[\leadsto \color{blue}{t \cdot \left(y - z\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{-47}:\\ \;\;\;\;\mathsf{fma}\left(x, z - y, x\right)\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-80}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, z - y, x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 66.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_1 := y \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq -0.00065:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 9.8 \cdot 10^{+14}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.4999999999999997e-4 or 9.8e14 < y

    1. Initial program 100.0%

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

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

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

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

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

    if -6.4999999999999997e-4 < y < 9.8e14

    1. Initial program 99.9%

      \[x + \left(y - z\right) \cdot \left(t - x\right) \]
    2. Add Preprocessing
    3. 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 \left(y - z\right) \cdot \color{blue}{\left(t - x\right)} + x \]
      5. sub-negN/A

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, t, \left(\mathsf{neg}\left(x\right)\right) \cdot \left(y - z\right) + x\right)} \]
      10. *-commutativeN/A

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

        \[\leadsto \mathsf{fma}\left(y - z, t, \color{blue}{\mathsf{fma}\left(y - z, \mathsf{neg}\left(x\right), x\right)}\right) \]
      12. lower-neg.f6498.3

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

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

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

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

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

        \[\leadsto \left(x \cdot z + \color{blue}{\left(-1 \cdot t\right) \cdot z}\right) + x \]
      4. distribute-rgt-inN/A

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, x + -1 \cdot t, x\right)} \]
      6. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(z, x + \color{blue}{\left(\mathsf{neg}\left(t\right)\right)}, x\right) \]
      7. sub-negN/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{x - t}, x\right) \]
      8. lower--.f6492.2

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{x - t}, x\right) \]
    7. Applied rewrites92.2%

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

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

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

    Alternative 6: 62.7% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(y - z\right) \cdot t\\ \mathbf{if}\;t \leq -13400:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 6000000000:\\ \;\;\;\;\mathsf{fma}\left(x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (x y z t)
     :precision binary64
     (let* ((t_1 (* (- y z) t)))
       (if (<= t -13400.0) t_1 (if (<= t 6000000000.0) (fma x z x) t_1))))
    double code(double x, double y, double z, double t) {
    	double t_1 = (y - z) * t;
    	double tmp;
    	if (t <= -13400.0) {
    		tmp = t_1;
    	} else if (t <= 6000000000.0) {
    		tmp = fma(x, z, x);
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    function code(x, y, z, t)
    	t_1 = Float64(Float64(y - z) * t)
    	tmp = 0.0
    	if (t <= -13400.0)
    		tmp = t_1;
    	elseif (t <= 6000000000.0)
    		tmp = fma(x, z, x);
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]}, If[LessEqual[t, -13400.0], t$95$1, If[LessEqual[t, 6000000000.0], N[(x * z + x), $MachinePrecision], t$95$1]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \left(y - z\right) \cdot t\\
    \mathbf{if}\;t \leq -13400:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;t \leq 6000000000:\\
    \;\;\;\;\mathsf{fma}\left(x, z, x\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if t < -13400 or 6e9 < t

      1. Initial program 99.9%

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

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

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

          \[\leadsto t \cdot \color{blue}{\left(y - z\right)} \]
      5. Applied rewrites77.1%

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

      if -13400 < t < 6e9

      1. Initial program 100.0%

        \[x + \left(y - z\right) \cdot \left(t - x\right) \]
      2. Add Preprocessing
      3. 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 \left(y - z\right) \cdot \color{blue}{\left(t - x\right)} + x \]
        5. sub-negN/A

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, t, \left(\mathsf{neg}\left(x\right)\right) \cdot \left(y - z\right) + x\right)} \]
        10. *-commutativeN/A

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

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

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

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

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

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

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

          \[\leadsto \left(x \cdot z + \color{blue}{\left(-1 \cdot t\right) \cdot z}\right) + x \]
        4. distribute-rgt-inN/A

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(z, x + -1 \cdot t, x\right)} \]
        6. mul-1-negN/A

          \[\leadsto \mathsf{fma}\left(z, x + \color{blue}{\left(\mathsf{neg}\left(t\right)\right)}, x\right) \]
        7. sub-negN/A

          \[\leadsto \mathsf{fma}\left(z, \color{blue}{x - t}, x\right) \]
        8. lower--.f6467.0

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

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

        \[\leadsto x \cdot \color{blue}{\left(1 + z\right)} \]
      9. Step-by-step derivation
        1. Applied rewrites57.7%

          \[\leadsto \mathsf{fma}\left(x, \color{blue}{z}, x\right) \]
      10. Recombined 2 regimes into one program.
      11. Final simplification66.6%

        \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -13400:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{elif}\;t \leq 6000000000:\\ \;\;\;\;\mathsf{fma}\left(x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \end{array} \]
      12. Add Preprocessing

      Alternative 7: 49.6% accurate, 0.7× speedup?

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

        1. Initial program 100.0%

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

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

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

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

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

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

          \[\leadsto t \cdot \color{blue}{y} \]
        7. Step-by-step derivation
          1. Applied rewrites56.5%

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

          if -5.8000000000000003e57 < y < 7e59

          1. Initial program 100.0%

            \[x + \left(y - z\right) \cdot \left(t - x\right) \]
          2. Add Preprocessing
          3. 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 \left(y - z\right) \cdot \color{blue}{\left(t - x\right)} + x \]
            5. sub-negN/A

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

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

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

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, t, \left(\mathsf{neg}\left(x\right)\right) \cdot \left(y - z\right) + x\right)} \]
            10. *-commutativeN/A

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

              \[\leadsto \mathsf{fma}\left(y - z, t, \color{blue}{\mathsf{fma}\left(y - z, \mathsf{neg}\left(x\right), x\right)}\right) \]
            12. lower-neg.f6498.5

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

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

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

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

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

              \[\leadsto \left(x \cdot z + \color{blue}{\left(-1 \cdot t\right) \cdot z}\right) + x \]
            4. distribute-rgt-inN/A

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(z, x + -1 \cdot t, x\right)} \]
            6. mul-1-negN/A

              \[\leadsto \mathsf{fma}\left(z, x + \color{blue}{\left(\mathsf{neg}\left(t\right)\right)}, x\right) \]
            7. sub-negN/A

              \[\leadsto \mathsf{fma}\left(z, \color{blue}{x - t}, x\right) \]
            8. lower--.f6486.2

              \[\leadsto \mathsf{fma}\left(z, \color{blue}{x - t}, x\right) \]
          7. Applied rewrites86.2%

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

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

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

            if 7e59 < y

            1. Initial program 100.0%

              \[x + \left(y - z\right) \cdot \left(t - x\right) \]
            2. Add Preprocessing
            3. 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 \left(y - z\right) \cdot \color{blue}{\left(t - x\right)} + x \]
              5. sub-negN/A

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

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

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

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, t, \left(\mathsf{neg}\left(x\right)\right) \cdot \left(y - z\right) + x\right)} \]
              10. *-commutativeN/A

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

                \[\leadsto \mathsf{fma}\left(y - z, t, \color{blue}{\mathsf{fma}\left(y - z, \mathsf{neg}\left(x\right), x\right)}\right) \]
              12. lower-neg.f6493.9

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

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

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

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

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

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

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

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

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

                \[\leadsto y \cdot \left(-x\right) \]
            10. Recombined 3 regimes into one program.
            11. Final simplification57.1%

              \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{+57}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+59}:\\ \;\;\;\;\mathsf{fma}\left(x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \end{array} \]
            12. Add Preprocessing

            Alternative 8: 49.3% accurate, 0.8× speedup?

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

              1. Initial program 100.0%

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

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

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(y, t - x, x\right)} \]
                3. lower--.f6487.1

                  \[\leadsto \mathsf{fma}\left(y, \color{blue}{t - x}, x\right) \]
              5. Applied rewrites87.1%

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

                \[\leadsto t \cdot \color{blue}{y} \]
              7. Step-by-step derivation
                1. Applied rewrites51.3%

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

                if -5.8000000000000003e57 < y < 8.2e17

                1. Initial program 100.0%

                  \[x + \left(y - z\right) \cdot \left(t - x\right) \]
                2. Add Preprocessing
                3. 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 \left(y - z\right) \cdot \color{blue}{\left(t - x\right)} + x \]
                  5. sub-negN/A

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

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

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

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, t, \left(\mathsf{neg}\left(x\right)\right) \cdot \left(y - z\right) + x\right)} \]
                  10. *-commutativeN/A

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

                    \[\leadsto \mathsf{fma}\left(y - z, t, \color{blue}{\mathsf{fma}\left(y - z, \mathsf{neg}\left(x\right), x\right)}\right) \]
                  12. lower-neg.f6498.5

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

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

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

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

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

                    \[\leadsto \left(x \cdot z + \color{blue}{\left(-1 \cdot t\right) \cdot z}\right) + x \]
                  4. distribute-rgt-inN/A

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

                    \[\leadsto \color{blue}{\mathsf{fma}\left(z, x + -1 \cdot t, x\right)} \]
                  6. mul-1-negN/A

                    \[\leadsto \mathsf{fma}\left(z, x + \color{blue}{\left(\mathsf{neg}\left(t\right)\right)}, x\right) \]
                  7. sub-negN/A

                    \[\leadsto \mathsf{fma}\left(z, \color{blue}{x - t}, x\right) \]
                  8. lower--.f6488.0

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

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

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

                    \[\leadsto \mathsf{fma}\left(x, \color{blue}{z}, x\right) \]
                10. Recombined 2 regimes into one program.
                11. Final simplification56.3%

                  \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -5.8 \cdot 10^{+57}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+17}:\\ \;\;\;\;\mathsf{fma}\left(x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot t\\ \end{array} \]
                12. Add Preprocessing

                Alternative 9: 39.0% accurate, 0.8× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+14}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+36}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \end{array} \]
                (FPCore (x y z t)
                 :precision binary64
                 (if (<= z -4.2e+14) (* x z) (if (<= z 2e+36) (* y t) (* x z))))
                double code(double x, double y, double z, double t) {
                	double tmp;
                	if (z <= -4.2e+14) {
                		tmp = x * z;
                	} else if (z <= 2e+36) {
                		tmp = y * t;
                	} else {
                		tmp = x * z;
                	}
                	return tmp;
                }
                
                real(8) function code(x, y, z, t)
                    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 <= (-4.2d+14)) then
                        tmp = x * z
                    else if (z <= 2d+36) then
                        tmp = y * t
                    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 <= -4.2e+14) {
                		tmp = x * z;
                	} else if (z <= 2e+36) {
                		tmp = y * t;
                	} else {
                		tmp = x * z;
                	}
                	return tmp;
                }
                
                def code(x, y, z, t):
                	tmp = 0
                	if z <= -4.2e+14:
                		tmp = x * z
                	elif z <= 2e+36:
                		tmp = y * t
                	else:
                		tmp = x * z
                	return tmp
                
                function code(x, y, z, t)
                	tmp = 0.0
                	if (z <= -4.2e+14)
                		tmp = Float64(x * z);
                	elseif (z <= 2e+36)
                		tmp = Float64(y * t);
                	else
                		tmp = Float64(x * z);
                	end
                	return tmp
                end
                
                function tmp_2 = code(x, y, z, t)
                	tmp = 0.0;
                	if (z <= -4.2e+14)
                		tmp = x * z;
                	elseif (z <= 2e+36)
                		tmp = y * t;
                	else
                		tmp = x * z;
                	end
                	tmp_2 = tmp;
                end
                
                code[x_, y_, z_, t_] := If[LessEqual[z, -4.2e+14], N[(x * z), $MachinePrecision], If[LessEqual[z, 2e+36], N[(y * t), $MachinePrecision], N[(x * z), $MachinePrecision]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                \mathbf{if}\;z \leq -4.2 \cdot 10^{+14}:\\
                \;\;\;\;x \cdot z\\
                
                \mathbf{elif}\;z \leq 2 \cdot 10^{+36}:\\
                \;\;\;\;y \cdot t\\
                
                \mathbf{else}:\\
                \;\;\;\;x \cdot z\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if z < -4.2e14 or 2.00000000000000008e36 < z

                  1. Initial program 100.0%

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

                    \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(t - x\right)\right)} \]
                  4. Step-by-step derivation
                    1. mul-1-negN/A

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

                      \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(\left(t - x\right)\right)\right)} \]
                    3. mul-1-negN/A

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

                      \[\leadsto \color{blue}{z \cdot \left(-1 \cdot \left(t - x\right)\right)} \]
                    5. mul-1-negN/A

                      \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(t - x\right)\right)\right)} \]
                    6. sub-negN/A

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

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

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

                      \[\leadsto z \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) - t\right)} \]
                    10. remove-double-negN/A

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

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

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

                    \[\leadsto x \cdot \color{blue}{z} \]
                  7. Step-by-step derivation
                    1. Applied rewrites50.2%

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

                    if -4.2e14 < z < 2.00000000000000008e36

                    1. Initial program 100.0%

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

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

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

                        \[\leadsto \color{blue}{\mathsf{fma}\left(y, t - x, x\right)} \]
                      3. lower--.f6490.5

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

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

                      \[\leadsto t \cdot \color{blue}{y} \]
                    7. Step-by-step derivation
                      1. Applied rewrites39.8%

                        \[\leadsto t \cdot \color{blue}{y} \]
                    8. Recombined 2 regimes into one program.
                    9. Final simplification44.1%

                      \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+14}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+36}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]
                    10. Add Preprocessing

                    Alternative 10: 23.1% accurate, 2.5× speedup?

                    \[\begin{array}{l} \\ x \cdot z \end{array} \]
                    (FPCore (x y z t) :precision binary64 (* x z))
                    double code(double x, double y, double z, double t) {
                    	return x * z;
                    }
                    
                    real(8) function code(x, y, z, t)
                        real(8), intent (in) :: x
                        real(8), intent (in) :: y
                        real(8), intent (in) :: z
                        real(8), intent (in) :: t
                        code = x * z
                    end function
                    
                    public static double code(double x, double y, double z, double t) {
                    	return x * z;
                    }
                    
                    def code(x, y, z, t):
                    	return x * z
                    
                    function code(x, y, z, t)
                    	return Float64(x * z)
                    end
                    
                    function tmp = code(x, y, z, t)
                    	tmp = x * z;
                    end
                    
                    code[x_, y_, z_, t_] := N[(x * z), $MachinePrecision]
                    
                    \begin{array}{l}
                    
                    \\
                    x \cdot z
                    \end{array}
                    
                    Derivation
                    1. Initial program 100.0%

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

                      \[\leadsto \color{blue}{-1 \cdot \left(z \cdot \left(t - x\right)\right)} \]
                    4. Step-by-step derivation
                      1. mul-1-negN/A

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

                        \[\leadsto \color{blue}{z \cdot \left(\mathsf{neg}\left(\left(t - x\right)\right)\right)} \]
                      3. mul-1-negN/A

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

                        \[\leadsto \color{blue}{z \cdot \left(-1 \cdot \left(t - x\right)\right)} \]
                      5. mul-1-negN/A

                        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(\left(t - x\right)\right)\right)} \]
                      6. sub-negN/A

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

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

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

                        \[\leadsto z \cdot \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) - t\right)} \]
                      10. remove-double-negN/A

                        \[\leadsto z \cdot \left(\color{blue}{x} - t\right) \]
                      11. lower--.f6441.5

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

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

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

                        \[\leadsto x \cdot \color{blue}{z} \]
                      2. Add Preprocessing

                      Developer Target 1: 96.0% accurate, 0.6× speedup?

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

                      Reproduce

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