Data.Metrics.Snapshot:quantile from metrics-0.3.0.2

Percentage Accurate: 100.0% → 100.0%
Time: 9.5s
Alternatives: 11
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 11 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: 71.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -1.45 \cdot 10^{+43}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq -6.4 \cdot 10^{-38}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{-20}:\\ \;\;\;\;\mathsf{fma}\left(y, t, 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 -1.45e+43)
     t_1
     (if (<= z -6.4e-38) (* y (- t x)) (if (<= z 1.45e-20) (fma y t x) t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = z * (x - t);
	double tmp;
	if (z <= -1.45e+43) {
		tmp = t_1;
	} else if (z <= -6.4e-38) {
		tmp = y * (t - x);
	} else if (z <= 1.45e-20) {
		tmp = fma(y, t, 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 <= -1.45e+43)
		tmp = t_1;
	elseif (z <= -6.4e-38)
		tmp = Float64(y * Float64(t - x));
	elseif (z <= 1.45e-20)
		tmp = fma(y, t, 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, -1.45e+43], t$95$1, If[LessEqual[z, -6.4e-38], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.45e-20], N[(y * t + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.4500000000000001e43 or 1.45e-20 < 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--.f6483.1

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

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

    if -1.4500000000000001e43 < z < -6.39999999999999955e-38

    1. Initial program 99.8%

      \[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--.f6467.0

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

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

    if -6.39999999999999955e-38 < z < 1.45e-20

    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 x + \color{blue}{y \cdot \left(t - x\right)} \]
    4. Step-by-step derivation
      1. lower-*.f64N/A

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

        \[\leadsto x + y \cdot \color{blue}{\left(t - x\right)} \]
    5. Simplified95.1%

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

      \[\leadsto x + \color{blue}{t \cdot y} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto x + \color{blue}{y \cdot t} \]
      2. lower-*.f6471.3

        \[\leadsto x + \color{blue}{y \cdot t} \]
    8. Simplified71.3%

      \[\leadsto x + \color{blue}{y \cdot t} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \color{blue}{y \cdot t} + x \]
      4. lower-fma.f6471.3

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, t, x\right)} \]
    10. Applied egg-rr71.3%

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

Alternative 3: 66.7% accurate, 0.6× speedup?

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

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

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

\mathbf{elif}\;y \leq 8.6 \cdot 10^{+97}:\\
\;\;\;\;\left(y - z\right) \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -9.2e20 or 8.5999999999999996e97 < 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--.f6486.9

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

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

    if -9.2e20 < y < 6.6000000000000004e-131

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

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

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

      \[\leadsto \color{blue}{x + x \cdot z} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{x \cdot z + x} \]
      2. lower-fma.f6463.6

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, z, x\right)} \]
    8. Simplified63.6%

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

    if 6.6000000000000004e-131 < y < 8.5999999999999996e97

    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--.f6462.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{+20}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{-131}:\\ \;\;\;\;\mathsf{fma}\left(x, z, x\right)\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{+97}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 54.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+191}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq -2.5 \cdot 10^{+40}:\\
\;\;\;\;-z \cdot t\\

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

\mathbf{else}:\\
\;\;\;\;x \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -4.2000000000000001e191 or 7.5999999999999999e61 < 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--.f6492.1

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

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

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

        \[\leadsto \color{blue}{x \cdot z} \]
    8. Simplified59.5%

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

    if -4.2000000000000001e191 < z < -2.50000000000000002e40

    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--.f6463.0

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

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

      \[\leadsto \color{blue}{-1 \cdot \left(t \cdot z\right)} \]
    7. Step-by-step derivation
      1. associate-*r*N/A

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

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

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

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(t\right)\right)} \]
      5. lower-neg.f6455.9

        \[\leadsto z \cdot \color{blue}{\left(-t\right)} \]
    8. Simplified55.9%

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

    if -2.50000000000000002e40 < z < 7.5999999999999999e61

    1. Initial program 99.9%

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

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

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

        \[\leadsto x + y \cdot \color{blue}{\left(t - x\right)} \]
    5. Simplified90.0%

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

      \[\leadsto x + \color{blue}{t \cdot y} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto x + \color{blue}{y \cdot t} \]
      2. lower-*.f6464.0

        \[\leadsto x + \color{blue}{y \cdot t} \]
    8. Simplified64.0%

      \[\leadsto x + \color{blue}{y \cdot t} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \color{blue}{y \cdot t} + x \]
      4. lower-fma.f6464.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, t, x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification61.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+191}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{+40}:\\ \;\;\;\;-z \cdot t\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{+61}:\\ \;\;\;\;\mathsf{fma}\left(y, t, x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 83.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{+43}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+61}:\\ \;\;\;\;\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 -1.6e+43) t_1 (if (<= z 7.2e+61) (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 <= -1.6e+43) {
		tmp = t_1;
	} else if (z <= 7.2e+61) {
		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 <= -1.6e+43)
		tmp = t_1;
	elseif (z <= 7.2e+61)
		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, -1.6e+43], t$95$1, If[LessEqual[z, 7.2e+61], 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 -1.6 \cdot 10^{+43}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 7.2 \cdot 10^{+61}:\\
\;\;\;\;\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 < -1.60000000000000007e43 or 7.20000000000000021e61 < 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--.f6487.7

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

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

    if -1.60000000000000007e43 < z < 7.20000000000000021e61

    1. Initial program 99.9%

      \[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.0

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

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

Alternative 6: 76.5% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -6.1e10 or 2.55000000000000002e32 < t

    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--.f6486.9

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

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

    if -6.1e10 < t < 2.55000000000000002e32

    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--.f6483.8

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

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

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

Alternative 7: 62.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(y - z\right) \cdot t\\ \mathbf{if}\;t \leq -8600000000:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{-74}:\\ \;\;\;\;\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 -8600000000.0) t_1 (if (<= t 2.8e-74) (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 <= -8600000000.0) {
		tmp = t_1;
	} else if (t <= 2.8e-74) {
		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 <= -8600000000.0)
		tmp = t_1;
	elseif (t <= 2.8e-74)
		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, -8600000000.0], t$95$1, If[LessEqual[t, 2.8e-74], 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 -8600000000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 2.8 \cdot 10^{-74}:\\
\;\;\;\;\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 < -8.6e9 or 2.79999999999999988e-74 < t

    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--.f6479.6

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

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

    if -8.6e9 < t < 2.79999999999999988e-74

    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--.f6488.8

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

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

      \[\leadsto \color{blue}{x + x \cdot z} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{x \cdot z + x} \]
      2. lower-fma.f6457.3

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, z, x\right)} \]
    8. Simplified57.3%

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

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

Alternative 8: 53.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{+42}:\\
\;\;\;\;x \cdot z\\

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

\mathbf{else}:\\
\;\;\;\;x \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.50000000000000003e42 or 1.02000000000000002e62 < 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.9

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

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

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

        \[\leadsto \color{blue}{x \cdot z} \]
    8. Simplified47.0%

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

    if -2.50000000000000003e42 < z < 1.02000000000000002e62

    1. Initial program 99.9%

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

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

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

        \[\leadsto x + y \cdot \color{blue}{\left(t - x\right)} \]
    5. Simplified90.0%

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

      \[\leadsto x + \color{blue}{t \cdot y} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto x + \color{blue}{y \cdot t} \]
      2. lower-*.f6464.0

        \[\leadsto x + \color{blue}{y \cdot t} \]
    8. Simplified64.0%

      \[\leadsto x + \color{blue}{y \cdot t} \]
    9. Step-by-step derivation
      1. lift-*.f64N/A

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

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

        \[\leadsto \color{blue}{y \cdot t} + x \]
      4. lower-fma.f6464.1

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

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

Alternative 9: 45.6% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -25000:\\
\;\;\;\;y \cdot t\\

\mathbf{elif}\;t \leq 7 \cdot 10^{+35}:\\
\;\;\;\;\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 t < -25000 or 7.0000000000000001e35 < t

    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--.f6486.2

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

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

      \[\leadsto \color{blue}{t \cdot y} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot t} \]
      2. lower-*.f6452.4

        \[\leadsto \color{blue}{y \cdot t} \]
    8. Simplified52.4%

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

    if -25000 < t < 7.0000000000000001e35

    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--.f6483.8

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

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

      \[\leadsto \color{blue}{x + x \cdot z} \]
    7. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{x \cdot z + x} \]
      2. lower-fma.f6453.7

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, z, x\right)} \]
    8. Simplified53.7%

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

Alternative 10: 38.9% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -7.4 \cdot 10^{+40}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{+62}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -7.4e+40) (* x z) (if (<= z 1.85e+62) (* y t) (* x z))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -7.4e+40) {
		tmp = x * z;
	} else if (z <= 1.85e+62) {
		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 <= (-7.4d+40)) then
        tmp = x * z
    else if (z <= 1.85d+62) 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 <= -7.4e+40) {
		tmp = x * z;
	} else if (z <= 1.85e+62) {
		tmp = y * t;
	} else {
		tmp = x * z;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -7.4e+40:
		tmp = x * z
	elif z <= 1.85e+62:
		tmp = y * t
	else:
		tmp = x * z
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -7.4e+40)
		tmp = Float64(x * z);
	elseif (z <= 1.85e+62)
		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 <= -7.4e+40)
		tmp = x * z;
	elseif (z <= 1.85e+62)
		tmp = y * t;
	else
		tmp = x * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.4e+40], N[(x * z), $MachinePrecision], If[LessEqual[z, 1.85e+62], N[(y * t), $MachinePrecision], N[(x * z), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.4 \cdot 10^{+40}:\\
\;\;\;\;x \cdot z\\

\mathbf{elif}\;z \leq 1.85 \cdot 10^{+62}:\\
\;\;\;\;y \cdot t\\

\mathbf{else}:\\
\;\;\;\;x \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.4e40 or 1.85000000000000007e62 < 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.9

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

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

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

        \[\leadsto \color{blue}{x \cdot z} \]
    8. Simplified47.0%

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

    if -7.4e40 < z < 1.85000000000000007e62

    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--.f6445.4

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

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

      \[\leadsto \color{blue}{t \cdot y} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot t} \]
      2. lower-*.f6437.2

        \[\leadsto \color{blue}{y \cdot t} \]
    8. Simplified37.2%

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

Alternative 11: 23.0% 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--.f6442.9

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

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

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

      \[\leadsto \color{blue}{x \cdot z} \]
  8. Simplified21.9%

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

Developer Target 1: 96.8% 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 2024207 
(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))))