Data.Metrics.Snapshot:quantile from metrics-0.3.0.2

Percentage Accurate: 100.0% → 100.0%
Time: 9.7s
Alternatives: 13
Speedup: 1.2×

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 13 alternatives:

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

Initial Program: 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.2× speedup?

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

\\
\mathsf{fma}\left(y - z, t - x, x\right)
\end{array}
Derivation
  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 x + \color{blue}{\left(y - z\right)} \cdot \left(t - x\right) \]
    2. lift--.f64N/A

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

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

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

      \[\leadsto \color{blue}{\left(y - z\right) \cdot \left(t - x\right)} + x \]
    6. lower-fma.f64100.0

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

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

Alternative 2: 66.3% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;y \leq 1.45 \cdot 10^{-292}:\\
\;\;\;\;\left(y - z\right) \cdot t\\

\mathbf{elif}\;y \leq 0.012:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.6e-36 or 0.012 < y

    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 \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--.f6479.3

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

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

    if -2.6e-36 < y < -1.12e-212 or 1.44999999999999996e-292 < y < 0.012

    1. Initial program 100.0%

      \[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--.f6493.4

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

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

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

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

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

        \[\leadsto x \cdot z + \color{blue}{x} \]
      4. lower-fma.f6465.9

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

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

    if -1.12e-212 < y < 1.44999999999999996e-292

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-36}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq -1.12 \cdot 10^{-212}:\\ \;\;\;\;\mathsf{fma}\left(x, z, x\right)\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-292}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{elif}\;y \leq 0.012:\\ \;\;\;\;\mathsf{fma}\left(x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 47.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-36}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq -1.12 \cdot 10^{-212}:\\ \;\;\;\;\mathsf{fma}\left(x, z, x\right)\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-292}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+20}:\\ \;\;\;\;\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 -2.6e-36)
   (* y t)
   (if (<= y -1.12e-212)
     (fma x z x)
     (if (<= y 1.45e-292)
       (* z (- t))
       (if (<= y 1.95e+20) (fma x z x) (* y (- x)))))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -2.6e-36) {
		tmp = y * t;
	} else if (y <= -1.12e-212) {
		tmp = fma(x, z, x);
	} else if (y <= 1.45e-292) {
		tmp = z * -t;
	} else if (y <= 1.95e+20) {
		tmp = fma(x, z, x);
	} else {
		tmp = y * -x;
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (y <= -2.6e-36)
		tmp = Float64(y * t);
	elseif (y <= -1.12e-212)
		tmp = fma(x, z, x);
	elseif (y <= 1.45e-292)
		tmp = Float64(z * Float64(-t));
	elseif (y <= 1.95e+20)
		tmp = fma(x, z, x);
	else
		tmp = Float64(y * Float64(-x));
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.6e-36], N[(y * t), $MachinePrecision], If[LessEqual[y, -1.12e-212], N[(x * z + x), $MachinePrecision], If[LessEqual[y, 1.45e-292], N[(z * (-t)), $MachinePrecision], If[LessEqual[y, 1.95e+20], N[(x * z + x), $MachinePrecision], N[(y * (-x)), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{-36}:\\
\;\;\;\;y \cdot t\\

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

\mathbf{elif}\;y \leq 1.45 \cdot 10^{-292}:\\
\;\;\;\;z \cdot \left(-t\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if y < -2.6e-36

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

        \[\leadsto t \cdot \color{blue}{\left(y - z\right)} \]
    5. Applied rewrites57.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. lower-*.f6446.2

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

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

    if -2.6e-36 < y < -1.12e-212 or 1.44999999999999996e-292 < y < 1.95e20

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -1.12e-212 < y < 1.44999999999999996e-292

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

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

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

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

        \[\leadsto z \cdot \color{blue}{\left(\mathsf{neg}\left(t\right)\right)} \]
      2. lower-neg.f6471.3

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

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

    if 1.95e20 < 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--.f6478.8

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{-1 \cdot x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(x\right)}, x\right) \]
      2. lower-neg.f6457.5

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

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

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

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

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

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

        \[\leadsto y \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
      5. lower-neg.f6457.5

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

      \[\leadsto \color{blue}{y \cdot \left(-x\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification58.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-36}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq -1.12 \cdot 10^{-212}:\\ \;\;\;\;\mathsf{fma}\left(x, z, x\right)\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-292}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+20}:\\ \;\;\;\;\mathsf{fma}\left(x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 68.3% accurate, 0.6× speedup?

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

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

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

\mathbf{elif}\;y \leq 3500000000000:\\
\;\;\;\;z \cdot \left(x - t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.6e-36 or 3.5e12 < y

    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 \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--.f6479.9

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

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

    if -2.6e-36 < y < -2.1e-212

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto x \cdot z + \color{blue}{x} \]
      4. lower-fma.f6470.5

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

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

    if -2.1e-212 < y < 3.5e12

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

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

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

Alternative 5: 62.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.3 \cdot 10^{+158}:\\
\;\;\;\;\mathsf{fma}\left(x, z, x\right)\\

\mathbf{elif}\;x \leq -2 \cdot 10^{+100}:\\
\;\;\;\;y \cdot \left(-x\right)\\

\mathbf{elif}\;x \leq 47:\\
\;\;\;\;\left(y - z\right) \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.29999999999999986e158 or 47 < x

    1. Initial program 100.0%

      \[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--.f6462.1

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

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

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

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

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

        \[\leadsto x \cdot z + \color{blue}{x} \]
      4. lower-fma.f6455.0

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

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

    if -2.29999999999999986e158 < x < -2.00000000000000003e100

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

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{-1 \cdot x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(x\right)}, x\right) \]
      2. lower-neg.f6474.0

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{-x}, x\right) \]
    8. Applied rewrites74.0%

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

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

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

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

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

        \[\leadsto y \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
      5. lower-neg.f6467.4

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

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

    if -2.00000000000000003e100 < x < 47

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

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

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

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

Alternative 6: 84.0% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{-36}:\\
\;\;\;\;\mathsf{fma}\left(y, t - x, x\right)\\

\mathbf{elif}\;y \leq 3500000000000:\\
\;\;\;\;\mathsf{fma}\left(z, x - t, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.6e-36

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

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

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

    if -2.6e-36 < y < 3.5e12

    1. Initial program 100.0%

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

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

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

    if 3.5e12 < 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--.f6479.1

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

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

Alternative 7: 84.4% accurate, 0.7× speedup?

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

\mathbf{elif}\;z \leq 7.8 \cdot 10^{+24}:\\
\;\;\;\;\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 < -23500 or 7.7999999999999995e24 < z

    1. Initial program 99.9%

      \[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--.f6480.5

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

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

    if -23500 < z < 7.7999999999999995e24

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

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

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

Alternative 8: 74.5% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(x, z - y, x\right)\\ \mathbf{if}\;x \leq -4.25 \cdot 10^{+99}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-50}:\\ \;\;\;\;\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 -4.25e+99) t_1 (if (<= x 1.8e-50) (* (- 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 <= -4.25e+99) {
		tmp = t_1;
	} else if (x <= 1.8e-50) {
		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 <= -4.25e+99)
		tmp = t_1;
	elseif (x <= 1.8e-50)
		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, -4.25e+99], t$95$1, If[LessEqual[x, 1.8e-50], 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 -4.25 \cdot 10^{+99}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.24999999999999992e99 or 1.7999999999999999e-50 < 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--.f6483.6

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

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

    if -4.24999999999999992e99 < x < 1.7999999999999999e-50

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

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

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

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

Alternative 9: 71.9% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -2.8e-40 or 1.44999999999999996 < y

    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 \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--.f6479.3

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

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

    if -2.8e-40 < y < 1.44999999999999996

    1. Initial program 100.0%

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

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

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

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

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

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

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

Alternative 10: 49.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-36}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{+20}:\\ \;\;\;\;\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 -2.6e-36) (* y t) (if (<= y 1.95e+20) (fma x z x) (* y (- x)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -2.6e-36) {
		tmp = y * t;
	} else if (y <= 1.95e+20) {
		tmp = fma(x, z, x);
	} else {
		tmp = y * -x;
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (y <= -2.6e-36)
		tmp = Float64(y * t);
	elseif (y <= 1.95e+20)
		tmp = fma(x, z, x);
	else
		tmp = Float64(y * Float64(-x));
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.6e-36], N[(y * t), $MachinePrecision], If[LessEqual[y, 1.95e+20], N[(x * z + x), $MachinePrecision], N[(y * (-x)), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{-36}:\\
\;\;\;\;y \cdot t\\

\mathbf{elif}\;y \leq 1.95 \cdot 10^{+20}:\\
\;\;\;\;\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 < -2.6e-36

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

        \[\leadsto t \cdot \color{blue}{\left(y - z\right)} \]
    5. Applied rewrites57.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. lower-*.f6446.2

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

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

    if -2.6e-36 < y < 1.95e20

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if 1.95e20 < 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--.f6478.8

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{-1 \cdot x}, x\right) \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{fma}\left(y, \color{blue}{\mathsf{neg}\left(x\right)}, x\right) \]
      2. lower-neg.f6457.5

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

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

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

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

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

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

        \[\leadsto y \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
      5. lower-neg.f6457.5

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

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

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

Alternative 11: 49.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{-36}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 0.012:\\ \;\;\;\;\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 -2.6e-36) (* y t) (if (<= y 0.012) (fma x z x) (* y t))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -2.6e-36) {
		tmp = y * t;
	} else if (y <= 0.012) {
		tmp = fma(x, z, x);
	} else {
		tmp = y * t;
	}
	return tmp;
}
function code(x, y, z, t)
	tmp = 0.0
	if (y <= -2.6e-36)
		tmp = Float64(y * t);
	elseif (y <= 0.012)
		tmp = fma(x, z, x);
	else
		tmp = Float64(y * t);
	end
	return tmp
end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.6e-36], N[(y * t), $MachinePrecision], If[LessEqual[y, 0.012], N[(x * z + x), $MachinePrecision], N[(y * t), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{-36}:\\
\;\;\;\;y \cdot t\\

\mathbf{elif}\;y \leq 0.012:\\
\;\;\;\;\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 < -2.6e-36 or 0.012 < y

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

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

      \[\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. lower-*.f6438.6

        \[\leadsto \color{blue}{t \cdot y} \]
    8. Applied rewrites38.6%

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

    if -2.6e-36 < y < 0.012

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

Alternative 12: 38.5% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -600000:\\
\;\;\;\;z \cdot x\\

\mathbf{elif}\;z \leq 3.4 \cdot 10^{+63}:\\
\;\;\;\;y \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -6e5 or 3.3999999999999999e63 < z

    1. Initial program 99.9%

      \[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--.f6482.2

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

      \[\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-*.f6442.3

        \[\leadsto \color{blue}{x \cdot z} \]
    8. Applied rewrites42.3%

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

    if -6e5 < z < 3.3999999999999999e63

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

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

      \[\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. lower-*.f6431.6

        \[\leadsto \color{blue}{t \cdot y} \]
    8. Applied rewrites31.6%

      \[\leadsto \color{blue}{t \cdot y} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -600000:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+63}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 26.8% accurate, 2.5× speedup?

\[\begin{array}{l} \\ y \cdot t \end{array} \]
(FPCore (x y z t) :precision binary64 (* y t))
double code(double x, double y, double z, double t) {
	return y * t;
}
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 = y * t
end function
public static double code(double x, double y, double z, double t) {
	return y * t;
}
def code(x, y, z, t):
	return y * t
function code(x, y, z, t)
	return Float64(y * t)
end
function tmp = code(x, y, z, t)
	tmp = y * t;
end
code[x_, y_, z_, t_] := N[(y * t), $MachinePrecision]
\begin{array}{l}

\\
y \cdot t
\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 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--.f6448.6

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

    \[\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. lower-*.f6423.2

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

    \[\leadsto \color{blue}{t \cdot y} \]
  9. Final simplification23.2%

    \[\leadsto y \cdot t \]
  10. Add Preprocessing

Developer Target 1: 96.7% 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 2024219 
(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))))