Data.Metrics.Snapshot:quantile from metrics-0.3.0.2

Percentage Accurate: 100.0% → 100.0%
Time: 8.4s
Alternatives: 13
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 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, 0.1× 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. Step-by-step derivation
    1. +-commutative100.0%

      \[\leadsto \color{blue}{\left(y - z\right) \cdot \left(t - x\right) + x} \]
    2. fma-def100.0%

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

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

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

Alternative 2: 63.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + y \cdot t\\ t_2 := x \cdot \left(\left(z + 1\right) - y\right)\\ \mathbf{if}\;t \leq -5 \cdot 10^{+232}:\\ \;\;\;\;y \cdot \left(t + x\right)\\ \mathbf{elif}\;t \leq -1.65 \cdot 10^{+208}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;t \leq -2.85 \cdot 10^{+150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -3.2 \cdot 10^{+22}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -2.65 \cdot 10^{-39}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{elif}\;t \leq 3 \cdot 10^{+42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{+112} \lor \neg \left(t \leq 5.3 \cdot 10^{+190}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (* y t))) (t_2 (* x (- (+ z 1.0) y))))
   (if (<= t -5e+232)
     (* y (+ t x))
     (if (<= t -1.65e+208)
       (* z (- t))
       (if (<= t -2.85e+150)
         t_1
         (if (<= t -3.2e+22)
           t_2
           (if (<= t -2.65e-39)
             (* y (- t x))
             (if (<= t 3e+42)
               t_2
               (if (or (<= t 3.8e+112) (not (<= t 5.3e+190)))
                 t_1
                 (- x (* z t)))))))))))
double code(double x, double y, double z, double t) {
	double t_1 = x + (y * t);
	double t_2 = x * ((z + 1.0) - y);
	double tmp;
	if (t <= -5e+232) {
		tmp = y * (t + x);
	} else if (t <= -1.65e+208) {
		tmp = z * -t;
	} else if (t <= -2.85e+150) {
		tmp = t_1;
	} else if (t <= -3.2e+22) {
		tmp = t_2;
	} else if (t <= -2.65e-39) {
		tmp = y * (t - x);
	} else if (t <= 3e+42) {
		tmp = t_2;
	} else if ((t <= 3.8e+112) || !(t <= 5.3e+190)) {
		tmp = t_1;
	} else {
		tmp = x - (z * t);
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x + (y * t)
    t_2 = x * ((z + 1.0d0) - y)
    if (t <= (-5d+232)) then
        tmp = y * (t + x)
    else if (t <= (-1.65d+208)) then
        tmp = z * -t
    else if (t <= (-2.85d+150)) then
        tmp = t_1
    else if (t <= (-3.2d+22)) then
        tmp = t_2
    else if (t <= (-2.65d-39)) then
        tmp = y * (t - x)
    else if (t <= 3d+42) then
        tmp = t_2
    else if ((t <= 3.8d+112) .or. (.not. (t <= 5.3d+190))) then
        tmp = t_1
    else
        tmp = x - (z * t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x + (y * t);
	double t_2 = x * ((z + 1.0) - y);
	double tmp;
	if (t <= -5e+232) {
		tmp = y * (t + x);
	} else if (t <= -1.65e+208) {
		tmp = z * -t;
	} else if (t <= -2.85e+150) {
		tmp = t_1;
	} else if (t <= -3.2e+22) {
		tmp = t_2;
	} else if (t <= -2.65e-39) {
		tmp = y * (t - x);
	} else if (t <= 3e+42) {
		tmp = t_2;
	} else if ((t <= 3.8e+112) || !(t <= 5.3e+190)) {
		tmp = t_1;
	} else {
		tmp = x - (z * t);
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x + (y * t)
	t_2 = x * ((z + 1.0) - y)
	tmp = 0
	if t <= -5e+232:
		tmp = y * (t + x)
	elif t <= -1.65e+208:
		tmp = z * -t
	elif t <= -2.85e+150:
		tmp = t_1
	elif t <= -3.2e+22:
		tmp = t_2
	elif t <= -2.65e-39:
		tmp = y * (t - x)
	elif t <= 3e+42:
		tmp = t_2
	elif (t <= 3.8e+112) or not (t <= 5.3e+190):
		tmp = t_1
	else:
		tmp = x - (z * t)
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x + Float64(y * t))
	t_2 = Float64(x * Float64(Float64(z + 1.0) - y))
	tmp = 0.0
	if (t <= -5e+232)
		tmp = Float64(y * Float64(t + x));
	elseif (t <= -1.65e+208)
		tmp = Float64(z * Float64(-t));
	elseif (t <= -2.85e+150)
		tmp = t_1;
	elseif (t <= -3.2e+22)
		tmp = t_2;
	elseif (t <= -2.65e-39)
		tmp = Float64(y * Float64(t - x));
	elseif (t <= 3e+42)
		tmp = t_2;
	elseif ((t <= 3.8e+112) || !(t <= 5.3e+190))
		tmp = t_1;
	else
		tmp = Float64(x - Float64(z * t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + (y * t);
	t_2 = x * ((z + 1.0) - y);
	tmp = 0.0;
	if (t <= -5e+232)
		tmp = y * (t + x);
	elseif (t <= -1.65e+208)
		tmp = z * -t;
	elseif (t <= -2.85e+150)
		tmp = t_1;
	elseif (t <= -3.2e+22)
		tmp = t_2;
	elseif (t <= -2.65e-39)
		tmp = y * (t - x);
	elseif (t <= 3e+42)
		tmp = t_2;
	elseif ((t <= 3.8e+112) || ~((t <= 5.3e+190)))
		tmp = t_1;
	else
		tmp = x - (z * t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(N[(z + 1.0), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -5e+232], N[(y * N[(t + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, -1.65e+208], N[(z * (-t)), $MachinePrecision], If[LessEqual[t, -2.85e+150], t$95$1, If[LessEqual[t, -3.2e+22], t$95$2, If[LessEqual[t, -2.65e-39], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 3e+42], t$95$2, If[Or[LessEqual[t, 3.8e+112], N[Not[LessEqual[t, 5.3e+190]], $MachinePrecision]], t$95$1, N[(x - N[(z * t), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + y \cdot t\\
t_2 := x \cdot \left(\left(z + 1\right) - y\right)\\
\mathbf{if}\;t \leq -5 \cdot 10^{+232}:\\
\;\;\;\;y \cdot \left(t + x\right)\\

\mathbf{elif}\;t \leq -1.65 \cdot 10^{+208}:\\
\;\;\;\;z \cdot \left(-t\right)\\

\mathbf{elif}\;t \leq -2.85 \cdot 10^{+150}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t \leq -3.2 \cdot 10^{+22}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t \leq -2.65 \cdot 10^{-39}:\\
\;\;\;\;y \cdot \left(t - x\right)\\

\mathbf{elif}\;t \leq 3 \cdot 10^{+42}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t \leq 3.8 \cdot 10^{+112} \lor \neg \left(t \leq 5.3 \cdot 10^{+190}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if t < -4.99999999999999987e232

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{y \cdot \left(t - x\right)} \]
    4. Step-by-step derivation
      1. sub-neg82.6%

        \[\leadsto y \cdot \color{blue}{\left(t + \left(-x\right)\right)} \]
      2. distribute-lft-in82.6%

        \[\leadsto \color{blue}{y \cdot t + y \cdot \left(-x\right)} \]
      3. add-sqr-sqrt63.6%

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

        \[\leadsto y \cdot t + y \cdot \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}} \]
      5. sqr-neg73.6%

        \[\leadsto y \cdot t + y \cdot \sqrt{\color{blue}{x \cdot x}} \]
      6. sqrt-unprod9.9%

        \[\leadsto y \cdot t + y \cdot \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \]
      7. add-sqr-sqrt73.6%

        \[\leadsto y \cdot t + y \cdot \color{blue}{x} \]
    5. Applied egg-rr73.6%

      \[\leadsto \color{blue}{y \cdot t + y \cdot x} \]
    6. Step-by-step derivation
      1. distribute-lft-in82.6%

        \[\leadsto \color{blue}{y \cdot \left(t + x\right)} \]
    7. Simplified82.6%

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

    if -4.99999999999999987e232 < t < -1.65e208

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{t \cdot \left(y - z\right)} \]
    3. Taylor expanded in y around 0 100.0%

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

        \[\leadsto \color{blue}{x + -1 \cdot \left(t \cdot z\right)} \]
      2. mul-1-neg100.0%

        \[\leadsto x + \color{blue}{\left(-t \cdot z\right)} \]
      3. unsub-neg100.0%

        \[\leadsto \color{blue}{x - t \cdot z} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{x - t \cdot z} \]
    6. Taylor expanded in x around 0 100.0%

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

        \[\leadsto \color{blue}{\left(-1 \cdot t\right) \cdot z} \]
      2. neg-mul-1100.0%

        \[\leadsto \color{blue}{\left(-t\right)} \cdot z \]
      3. *-commutative100.0%

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

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

    if -1.65e208 < t < -2.8500000000000001e150 or 3.00000000000000029e42 < t < 3.80000000000000008e112 or 5.30000000000000015e190 < t

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{t \cdot \left(y - z\right)} \]
    3. Taylor expanded in z around 0 72.1%

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

    if -2.8500000000000001e150 < t < -3.2e22 or -2.65000000000000002e-39 < t < 3.00000000000000029e42

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \left(y - z\right)\right) \cdot x} \]
    3. Step-by-step derivation
      1. *-commutative79.7%

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(y - z\right)\right)} \]
      2. mul-1-neg79.7%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-\left(y - z\right)\right)}\right) \]
      3. unsub-neg79.7%

        \[\leadsto x \cdot \color{blue}{\left(1 - \left(y - z\right)\right)} \]
      4. distribute-lft-out--79.7%

        \[\leadsto \color{blue}{x \cdot 1 - x \cdot \left(y - z\right)} \]
      5. *-rgt-identity79.7%

        \[\leadsto \color{blue}{x} - x \cdot \left(y - z\right) \]
    4. Simplified79.7%

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

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

    if -3.2e22 < t < -2.65000000000000002e-39

    1. Initial program 100.0%

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

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

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

    if 3.80000000000000008e112 < t < 5.30000000000000015e190

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{t \cdot \left(y - z\right)} \]
    3. Taylor expanded in y around 0 90.4%

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

        \[\leadsto \color{blue}{x + -1 \cdot \left(t \cdot z\right)} \]
      2. mul-1-neg90.4%

        \[\leadsto x + \color{blue}{\left(-t \cdot z\right)} \]
      3. unsub-neg90.4%

        \[\leadsto \color{blue}{x - t \cdot z} \]
    5. Simplified90.4%

      \[\leadsto \color{blue}{x - t \cdot z} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification79.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -5 \cdot 10^{+232}:\\ \;\;\;\;y \cdot \left(t + x\right)\\ \mathbf{elif}\;t \leq -1.65 \cdot 10^{+208}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;t \leq -2.85 \cdot 10^{+150}:\\ \;\;\;\;x + y \cdot t\\ \mathbf{elif}\;t \leq -3.2 \cdot 10^{+22}:\\ \;\;\;\;x \cdot \left(\left(z + 1\right) - y\right)\\ \mathbf{elif}\;t \leq -2.65 \cdot 10^{-39}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{elif}\;t \leq 3 \cdot 10^{+42}:\\ \;\;\;\;x \cdot \left(\left(z + 1\right) - y\right)\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{+112} \lor \neg \left(t \leq 5.3 \cdot 10^{+190}\right):\\ \;\;\;\;x + y \cdot t\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot t\\ \end{array} \]

Alternative 3: 37.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(t + x\right)\\ t_2 := z \cdot \left(-t\right)\\ \mathbf{if}\;y \leq -2.7 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-43}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -1.42 \cdot 10^{-105}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-237}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{-275}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{-196}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-106}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{-64}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* y (+ t x))) (t_2 (* z (- t))))
   (if (<= y -2.7e+39)
     t_1
     (if (<= y -1.35e-43)
       t_2
       (if (<= y -1.42e-105)
         x
         (if (<= y -1.35e-237)
           t_2
           (if (<= y 4.1e-275)
             x
             (if (<= y 2.05e-196)
               t_2
               (if (<= y 2e-106) x (if (<= y 3.8e-64) t_2 t_1))))))))))
double code(double x, double y, double z, double t) {
	double t_1 = y * (t + x);
	double t_2 = z * -t;
	double tmp;
	if (y <= -2.7e+39) {
		tmp = t_1;
	} else if (y <= -1.35e-43) {
		tmp = t_2;
	} else if (y <= -1.42e-105) {
		tmp = x;
	} else if (y <= -1.35e-237) {
		tmp = t_2;
	} else if (y <= 4.1e-275) {
		tmp = x;
	} else if (y <= 2.05e-196) {
		tmp = t_2;
	} else if (y <= 2e-106) {
		tmp = x;
	} else if (y <= 3.8e-64) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = y * (t + x)
    t_2 = z * -t
    if (y <= (-2.7d+39)) then
        tmp = t_1
    else if (y <= (-1.35d-43)) then
        tmp = t_2
    else if (y <= (-1.42d-105)) then
        tmp = x
    else if (y <= (-1.35d-237)) then
        tmp = t_2
    else if (y <= 4.1d-275) then
        tmp = x
    else if (y <= 2.05d-196) then
        tmp = t_2
    else if (y <= 2d-106) then
        tmp = x
    else if (y <= 3.8d-64) then
        tmp = t_2
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = y * (t + x);
	double t_2 = z * -t;
	double tmp;
	if (y <= -2.7e+39) {
		tmp = t_1;
	} else if (y <= -1.35e-43) {
		tmp = t_2;
	} else if (y <= -1.42e-105) {
		tmp = x;
	} else if (y <= -1.35e-237) {
		tmp = t_2;
	} else if (y <= 4.1e-275) {
		tmp = x;
	} else if (y <= 2.05e-196) {
		tmp = t_2;
	} else if (y <= 2e-106) {
		tmp = x;
	} else if (y <= 3.8e-64) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = y * (t + x)
	t_2 = z * -t
	tmp = 0
	if y <= -2.7e+39:
		tmp = t_1
	elif y <= -1.35e-43:
		tmp = t_2
	elif y <= -1.42e-105:
		tmp = x
	elif y <= -1.35e-237:
		tmp = t_2
	elif y <= 4.1e-275:
		tmp = x
	elif y <= 2.05e-196:
		tmp = t_2
	elif y <= 2e-106:
		tmp = x
	elif y <= 3.8e-64:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(y * Float64(t + x))
	t_2 = Float64(z * Float64(-t))
	tmp = 0.0
	if (y <= -2.7e+39)
		tmp = t_1;
	elseif (y <= -1.35e-43)
		tmp = t_2;
	elseif (y <= -1.42e-105)
		tmp = x;
	elseif (y <= -1.35e-237)
		tmp = t_2;
	elseif (y <= 4.1e-275)
		tmp = x;
	elseif (y <= 2.05e-196)
		tmp = t_2;
	elseif (y <= 2e-106)
		tmp = x;
	elseif (y <= 3.8e-64)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = y * (t + x);
	t_2 = z * -t;
	tmp = 0.0;
	if (y <= -2.7e+39)
		tmp = t_1;
	elseif (y <= -1.35e-43)
		tmp = t_2;
	elseif (y <= -1.42e-105)
		tmp = x;
	elseif (y <= -1.35e-237)
		tmp = t_2;
	elseif (y <= 4.1e-275)
		tmp = x;
	elseif (y <= 2.05e-196)
		tmp = t_2;
	elseif (y <= 2e-106)
		tmp = x;
	elseif (y <= 3.8e-64)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * (-t)), $MachinePrecision]}, If[LessEqual[y, -2.7e+39], t$95$1, If[LessEqual[y, -1.35e-43], t$95$2, If[LessEqual[y, -1.42e-105], x, If[LessEqual[y, -1.35e-237], t$95$2, If[LessEqual[y, 4.1e-275], x, If[LessEqual[y, 2.05e-196], t$95$2, If[LessEqual[y, 2e-106], x, If[LessEqual[y, 3.8e-64], t$95$2, t$95$1]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := y \cdot \left(t + x\right)\\
t_2 := z \cdot \left(-t\right)\\
\mathbf{if}\;y \leq -2.7 \cdot 10^{+39}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq -1.35 \cdot 10^{-43}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y \leq -1.42 \cdot 10^{-105}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq -1.35 \cdot 10^{-237}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y \leq 4.1 \cdot 10^{-275}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 2.05 \cdot 10^{-196}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y \leq 2 \cdot 10^{-106}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 3.8 \cdot 10^{-64}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -2.70000000000000003e39 or 3.8000000000000002e-64 < y

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{y \cdot \left(t - x\right)} \]
    4. Step-by-step derivation
      1. sub-neg73.8%

        \[\leadsto y \cdot \color{blue}{\left(t + \left(-x\right)\right)} \]
      2. distribute-lft-in72.9%

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

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

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

        \[\leadsto y \cdot t + y \cdot \sqrt{\color{blue}{x \cdot x}} \]
      6. sqrt-unprod17.6%

        \[\leadsto y \cdot t + y \cdot \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)} \]
      7. add-sqr-sqrt43.7%

        \[\leadsto y \cdot t + y \cdot \color{blue}{x} \]
    5. Applied egg-rr43.7%

      \[\leadsto \color{blue}{y \cdot t + y \cdot x} \]
    6. Step-by-step derivation
      1. distribute-lft-in45.4%

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

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

    if -2.70000000000000003e39 < y < -1.34999999999999996e-43 or -1.4199999999999999e-105 < y < -1.34999999999999992e-237 or 4.09999999999999975e-275 < y < 2.05000000000000011e-196 or 1.99999999999999988e-106 < y < 3.8000000000000002e-64

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{t \cdot \left(y - z\right)} \]
    3. Taylor expanded in y around 0 59.7%

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

        \[\leadsto \color{blue}{x + -1 \cdot \left(t \cdot z\right)} \]
      2. mul-1-neg59.7%

        \[\leadsto x + \color{blue}{\left(-t \cdot z\right)} \]
      3. unsub-neg59.7%

        \[\leadsto \color{blue}{x - t \cdot z} \]
    5. Simplified59.7%

      \[\leadsto \color{blue}{x - t \cdot z} \]
    6. Taylor expanded in x around 0 50.1%

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

        \[\leadsto \color{blue}{\left(-1 \cdot t\right) \cdot z} \]
      2. neg-mul-150.1%

        \[\leadsto \color{blue}{\left(-t\right)} \cdot z \]
      3. *-commutative50.1%

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

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

    if -1.34999999999999996e-43 < y < -1.4199999999999999e-105 or -1.34999999999999992e-237 < y < 4.09999999999999975e-275 or 2.05000000000000011e-196 < y < 1.99999999999999988e-106

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification49.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.7 \cdot 10^{+39}:\\ \;\;\;\;y \cdot \left(t + x\right)\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-43}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;y \leq -1.42 \cdot 10^{-105}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.35 \cdot 10^{-237}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{-275}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{-196}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-106}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{-64}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t + x\right)\\ \end{array} \]

Alternative 4: 71.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + z \cdot x\\ t_2 := y \cdot \left(t - x\right)\\ t_3 := x - z \cdot t\\ \mathbf{if}\;y \leq -4.2 \cdot 10^{+19}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -2.7 \cdot 10^{-150}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -3.4 \cdot 10^{-192}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{-214}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{-102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-21}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 23000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (* z x))) (t_2 (* y (- t x))) (t_3 (- x (* z t))))
   (if (<= y -4.2e+19)
     t_2
     (if (<= y -2.7e-150)
       t_3
       (if (<= y -3.4e-192)
         t_1
         (if (<= y 4.8e-214)
           t_3
           (if (<= y 3.7e-102)
             t_1
             (if (<= y 3.5e-21) t_3 (if (<= y 23000.0) t_1 t_2)))))))))
double code(double x, double y, double z, double t) {
	double t_1 = x + (z * x);
	double t_2 = y * (t - x);
	double t_3 = x - (z * t);
	double tmp;
	if (y <= -4.2e+19) {
		tmp = t_2;
	} else if (y <= -2.7e-150) {
		tmp = t_3;
	} else if (y <= -3.4e-192) {
		tmp = t_1;
	} else if (y <= 4.8e-214) {
		tmp = t_3;
	} else if (y <= 3.7e-102) {
		tmp = t_1;
	} else if (y <= 3.5e-21) {
		tmp = t_3;
	} else if (y <= 23000.0) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_1 = x + (z * x)
    t_2 = y * (t - x)
    t_3 = x - (z * t)
    if (y <= (-4.2d+19)) then
        tmp = t_2
    else if (y <= (-2.7d-150)) then
        tmp = t_3
    else if (y <= (-3.4d-192)) then
        tmp = t_1
    else if (y <= 4.8d-214) then
        tmp = t_3
    else if (y <= 3.7d-102) then
        tmp = t_1
    else if (y <= 3.5d-21) then
        tmp = t_3
    else if (y <= 23000.0d0) then
        tmp = t_1
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x + (z * x);
	double t_2 = y * (t - x);
	double t_3 = x - (z * t);
	double tmp;
	if (y <= -4.2e+19) {
		tmp = t_2;
	} else if (y <= -2.7e-150) {
		tmp = t_3;
	} else if (y <= -3.4e-192) {
		tmp = t_1;
	} else if (y <= 4.8e-214) {
		tmp = t_3;
	} else if (y <= 3.7e-102) {
		tmp = t_1;
	} else if (y <= 3.5e-21) {
		tmp = t_3;
	} else if (y <= 23000.0) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x + (z * x)
	t_2 = y * (t - x)
	t_3 = x - (z * t)
	tmp = 0
	if y <= -4.2e+19:
		tmp = t_2
	elif y <= -2.7e-150:
		tmp = t_3
	elif y <= -3.4e-192:
		tmp = t_1
	elif y <= 4.8e-214:
		tmp = t_3
	elif y <= 3.7e-102:
		tmp = t_1
	elif y <= 3.5e-21:
		tmp = t_3
	elif y <= 23000.0:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x + Float64(z * x))
	t_2 = Float64(y * Float64(t - x))
	t_3 = Float64(x - Float64(z * t))
	tmp = 0.0
	if (y <= -4.2e+19)
		tmp = t_2;
	elseif (y <= -2.7e-150)
		tmp = t_3;
	elseif (y <= -3.4e-192)
		tmp = t_1;
	elseif (y <= 4.8e-214)
		tmp = t_3;
	elseif (y <= 3.7e-102)
		tmp = t_1;
	elseif (y <= 3.5e-21)
		tmp = t_3;
	elseif (y <= 23000.0)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + (z * x);
	t_2 = y * (t - x);
	t_3 = x - (z * t);
	tmp = 0.0;
	if (y <= -4.2e+19)
		tmp = t_2;
	elseif (y <= -2.7e-150)
		tmp = t_3;
	elseif (y <= -3.4e-192)
		tmp = t_1;
	elseif (y <= 4.8e-214)
		tmp = t_3;
	elseif (y <= 3.7e-102)
		tmp = t_1;
	elseif (y <= 3.5e-21)
		tmp = t_3;
	elseif (y <= 23000.0)
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.2e+19], t$95$2, If[LessEqual[y, -2.7e-150], t$95$3, If[LessEqual[y, -3.4e-192], t$95$1, If[LessEqual[y, 4.8e-214], t$95$3, If[LessEqual[y, 3.7e-102], t$95$1, If[LessEqual[y, 3.5e-21], t$95$3, If[LessEqual[y, 23000.0], t$95$1, t$95$2]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -2.7 \cdot 10^{-150}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;y \leq -3.4 \cdot 10^{-192}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 4.8 \cdot 10^{-214}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;y \leq 3.7 \cdot 10^{-102}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 3.5 \cdot 10^{-21}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;y \leq 23000:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.2e19 or 23000 < y

    1. Initial program 100.0%

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

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

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

    if -4.2e19 < y < -2.7000000000000001e-150 or -3.40000000000000002e-192 < y < 4.80000000000000041e-214 or 3.6999999999999997e-102 < y < 3.5000000000000003e-21

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{t \cdot \left(y - z\right)} \]
    3. Taylor expanded in y around 0 72.4%

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

        \[\leadsto \color{blue}{x + -1 \cdot \left(t \cdot z\right)} \]
      2. mul-1-neg72.4%

        \[\leadsto x + \color{blue}{\left(-t \cdot z\right)} \]
      3. unsub-neg72.4%

        \[\leadsto \color{blue}{x - t \cdot z} \]
    5. Simplified72.4%

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

    if -2.7000000000000001e-150 < y < -3.40000000000000002e-192 or 4.80000000000000041e-214 < y < 3.6999999999999997e-102 or 3.5000000000000003e-21 < y < 23000

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \left(y - z\right)\right) \cdot x} \]
    3. Step-by-step derivation
      1. *-commutative82.1%

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(y - z\right)\right)} \]
      2. mul-1-neg82.1%

        \[\leadsto x \cdot \left(1 + \color{blue}{\left(-\left(y - z\right)\right)}\right) \]
      3. unsub-neg82.1%

        \[\leadsto x \cdot \color{blue}{\left(1 - \left(y - z\right)\right)} \]
      4. distribute-lft-out--82.1%

        \[\leadsto \color{blue}{x \cdot 1 - x \cdot \left(y - z\right)} \]
      5. *-rgt-identity82.1%

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

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

      \[\leadsto x - \color{blue}{-1 \cdot \left(z \cdot x\right)} \]
    6. Step-by-step derivation
      1. mul-1-neg80.7%

        \[\leadsto x - \color{blue}{\left(-z \cdot x\right)} \]
      2. distribute-rgt-neg-in80.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{+19}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq -2.7 \cdot 10^{-150}:\\ \;\;\;\;x - z \cdot t\\ \mathbf{elif}\;y \leq -3.4 \cdot 10^{-192}:\\ \;\;\;\;x + z \cdot x\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{-214}:\\ \;\;\;\;x - z \cdot t\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{-102}:\\ \;\;\;\;x + z \cdot x\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-21}:\\ \;\;\;\;x - z \cdot t\\ \mathbf{elif}\;y \leq 23000:\\ \;\;\;\;x + z \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \end{array} \]

Alternative 5: 56.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ t_2 := z \cdot \left(-t\right)\\ \mathbf{if}\;y \leq -4.2 \cdot 10^{+19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -8.2 \cdot 10^{-233}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-276}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-196}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-106}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{-63}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* y (- t x))) (t_2 (* z (- t))))
   (if (<= y -4.2e+19)
     t_1
     (if (<= y -8.2e-233)
       t_2
       (if (<= y 4.9e-276)
         x
         (if (<= y 1.2e-196)
           t_2
           (if (<= y 1.45e-106) x (if (<= y 8.6e-63) t_2 t_1))))))))
double code(double x, double y, double z, double t) {
	double t_1 = y * (t - x);
	double t_2 = z * -t;
	double tmp;
	if (y <= -4.2e+19) {
		tmp = t_1;
	} else if (y <= -8.2e-233) {
		tmp = t_2;
	} else if (y <= 4.9e-276) {
		tmp = x;
	} else if (y <= 1.2e-196) {
		tmp = t_2;
	} else if (y <= 1.45e-106) {
		tmp = x;
	} else if (y <= 8.6e-63) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = y * (t - x)
    t_2 = z * -t
    if (y <= (-4.2d+19)) then
        tmp = t_1
    else if (y <= (-8.2d-233)) then
        tmp = t_2
    else if (y <= 4.9d-276) then
        tmp = x
    else if (y <= 1.2d-196) then
        tmp = t_2
    else if (y <= 1.45d-106) then
        tmp = x
    else if (y <= 8.6d-63) then
        tmp = t_2
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = y * (t - x);
	double t_2 = z * -t;
	double tmp;
	if (y <= -4.2e+19) {
		tmp = t_1;
	} else if (y <= -8.2e-233) {
		tmp = t_2;
	} else if (y <= 4.9e-276) {
		tmp = x;
	} else if (y <= 1.2e-196) {
		tmp = t_2;
	} else if (y <= 1.45e-106) {
		tmp = x;
	} else if (y <= 8.6e-63) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = y * (t - x)
	t_2 = z * -t
	tmp = 0
	if y <= -4.2e+19:
		tmp = t_1
	elif y <= -8.2e-233:
		tmp = t_2
	elif y <= 4.9e-276:
		tmp = x
	elif y <= 1.2e-196:
		tmp = t_2
	elif y <= 1.45e-106:
		tmp = x
	elif y <= 8.6e-63:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(y * Float64(t - x))
	t_2 = Float64(z * Float64(-t))
	tmp = 0.0
	if (y <= -4.2e+19)
		tmp = t_1;
	elseif (y <= -8.2e-233)
		tmp = t_2;
	elseif (y <= 4.9e-276)
		tmp = x;
	elseif (y <= 1.2e-196)
		tmp = t_2;
	elseif (y <= 1.45e-106)
		tmp = x;
	elseif (y <= 8.6e-63)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = y * (t - x);
	t_2 = z * -t;
	tmp = 0.0;
	if (y <= -4.2e+19)
		tmp = t_1;
	elseif (y <= -8.2e-233)
		tmp = t_2;
	elseif (y <= 4.9e-276)
		tmp = x;
	elseif (y <= 1.2e-196)
		tmp = t_2;
	elseif (y <= 1.45e-106)
		tmp = x;
	elseif (y <= 8.6e-63)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * (-t)), $MachinePrecision]}, If[LessEqual[y, -4.2e+19], t$95$1, If[LessEqual[y, -8.2e-233], t$95$2, If[LessEqual[y, 4.9e-276], x, If[LessEqual[y, 1.2e-196], t$95$2, If[LessEqual[y, 1.45e-106], x, If[LessEqual[y, 8.6e-63], t$95$2, t$95$1]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq -8.2 \cdot 10^{-233}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y \leq 4.9 \cdot 10^{-276}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 1.2 \cdot 10^{-196}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y \leq 1.45 \cdot 10^{-106}:\\
\;\;\;\;x\\

\mathbf{elif}\;y \leq 8.6 \cdot 10^{-63}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.2e19 or 8.5999999999999997e-63 < y

    1. Initial program 100.0%

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

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

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

    if -4.2e19 < y < -8.2000000000000009e-233 or 4.89999999999999966e-276 < y < 1.2000000000000001e-196 or 1.45e-106 < y < 8.5999999999999997e-63

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{t \cdot \left(y - z\right)} \]
    3. Taylor expanded in y around 0 63.7%

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

        \[\leadsto \color{blue}{x + -1 \cdot \left(t \cdot z\right)} \]
      2. mul-1-neg63.7%

        \[\leadsto x + \color{blue}{\left(-t \cdot z\right)} \]
      3. unsub-neg63.7%

        \[\leadsto \color{blue}{x - t \cdot z} \]
    5. Simplified63.7%

      \[\leadsto \color{blue}{x - t \cdot z} \]
    6. Taylor expanded in x around 0 46.4%

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

        \[\leadsto \color{blue}{\left(-1 \cdot t\right) \cdot z} \]
      2. neg-mul-146.4%

        \[\leadsto \color{blue}{\left(-t\right)} \cdot z \]
      3. *-commutative46.4%

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

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

    if -8.2000000000000009e-233 < y < 4.89999999999999966e-276 or 1.2000000000000001e-196 < y < 1.45e-106

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification61.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{+19}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq -8.2 \cdot 10^{-233}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{-276}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-196}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-106}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{-63}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(t - x\right)\\ \end{array} \]

Alternative 6: 81.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -2.8 \cdot 10^{-41} \lor \neg \left(t \leq 2.5 \cdot 10^{-56}\right):\\ \;\;\;\;x + \left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\left(z + 1\right) - y\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= t -2.8e-41) (not (<= t 2.5e-56)))
   (+ x (* (- y z) t))
   (* x (- (+ z 1.0) y))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -2.8e-41) || !(t <= 2.5e-56)) {
		tmp = x + ((y - z) * t);
	} else {
		tmp = x * ((z + 1.0) - y);
	}
	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 ((t <= (-2.8d-41)) .or. (.not. (t <= 2.5d-56))) then
        tmp = x + ((y - z) * t)
    else
        tmp = x * ((z + 1.0d0) - y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -2.8e-41) || !(t <= 2.5e-56)) {
		tmp = x + ((y - z) * t);
	} else {
		tmp = x * ((z + 1.0) - y);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (t <= -2.8e-41) or not (t <= 2.5e-56):
		tmp = x + ((y - z) * t)
	else:
		tmp = x * ((z + 1.0) - y)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((t <= -2.8e-41) || !(t <= 2.5e-56))
		tmp = Float64(x + Float64(Float64(y - z) * t));
	else
		tmp = Float64(x * Float64(Float64(z + 1.0) - y));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((t <= -2.8e-41) || ~((t <= 2.5e-56)))
		tmp = x + ((y - z) * t);
	else
		tmp = x * ((z + 1.0) - y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -2.8e-41], N[Not[LessEqual[t, 2.5e-56]], $MachinePrecision]], N[(x + N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(z + 1.0), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.8 \cdot 10^{-41} \lor \neg \left(t \leq 2.5 \cdot 10^{-56}\right):\\
\;\;\;\;x + \left(y - z\right) \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -2.8000000000000002e-41 or 2.49999999999999999e-56 < t

    1. Initial program 100.0%

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

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

    if -2.8000000000000002e-41 < t < 2.49999999999999999e-56

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(1 + -1 \cdot \left(y - z\right)\right) \cdot x} \]
    3. Step-by-step derivation
      1. *-commutative91.4%

        \[\leadsto \color{blue}{x \cdot \left(1 + -1 \cdot \left(y - z\right)\right)} \]
      2. mul-1-neg91.4%

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

        \[\leadsto x \cdot \color{blue}{\left(1 - \left(y - z\right)\right)} \]
      4. distribute-lft-out--91.4%

        \[\leadsto \color{blue}{x \cdot 1 - x \cdot \left(y - z\right)} \]
      5. *-rgt-identity91.4%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -2.8 \cdot 10^{-41} \lor \neg \left(t \leq 2.5 \cdot 10^{-56}\right):\\ \;\;\;\;x + \left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\left(z + 1\right) - y\right)\\ \end{array} \]

Alternative 7: 81.2% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -2.9 \cdot 10^{-42} \lor \neg \left(t \leq 1.3 \cdot 10^{-56}\right):\\ \;\;\;\;x + \left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \left(z - y\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= t -2.9e-42) (not (<= t 1.3e-56)))
   (+ x (* (- y z) t))
   (+ x (* x (- z y)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -2.9e-42) || !(t <= 1.3e-56)) {
		tmp = x + ((y - z) * t);
	} else {
		tmp = x + (x * (z - y));
	}
	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 ((t <= (-2.9d-42)) .or. (.not. (t <= 1.3d-56))) then
        tmp = x + ((y - z) * t)
    else
        tmp = x + (x * (z - y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((t <= -2.9e-42) || !(t <= 1.3e-56)) {
		tmp = x + ((y - z) * t);
	} else {
		tmp = x + (x * (z - y));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (t <= -2.9e-42) or not (t <= 1.3e-56):
		tmp = x + ((y - z) * t)
	else:
		tmp = x + (x * (z - y))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((t <= -2.9e-42) || !(t <= 1.3e-56))
		tmp = Float64(x + Float64(Float64(y - z) * t));
	else
		tmp = Float64(x + Float64(x * Float64(z - y)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((t <= -2.9e-42) || ~((t <= 1.3e-56)))
		tmp = x + ((y - z) * t);
	else
		tmp = x + (x * (z - y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -2.9e-42], N[Not[LessEqual[t, 1.3e-56]], $MachinePrecision]], N[(x + N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.9 \cdot 10^{-42} \lor \neg \left(t \leq 1.3 \cdot 10^{-56}\right):\\
\;\;\;\;x + \left(y - z\right) \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -2.9000000000000003e-42 or 1.29999999999999998e-56 < t

    1. Initial program 100.0%

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

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

    if -2.9000000000000003e-42 < t < 1.29999999999999998e-56

    1. Initial program 100.0%

      \[x + \left(y - z\right) \cdot \left(t - x\right) \]
    2. Step-by-step derivation
      1. sub-neg100.0%

        \[\leadsto x + \left(y - z\right) \cdot \color{blue}{\left(t + \left(-x\right)\right)} \]
      2. distribute-lft-in100.0%

        \[\leadsto x + \color{blue}{\left(\left(y - z\right) \cdot t + \left(y - z\right) \cdot \left(-x\right)\right)} \]
    3. Applied egg-rr100.0%

      \[\leadsto x + \color{blue}{\left(\left(y - z\right) \cdot t + \left(y - z\right) \cdot \left(-x\right)\right)} \]
    4. Taylor expanded in y around 0 96.0%

      \[\leadsto x + \color{blue}{\left(-1 \cdot \left(t \cdot z\right) + \left(\left(t + -1 \cdot x\right) \cdot y + z \cdot x\right)\right)} \]
    5. Step-by-step derivation
      1. +-commutative96.0%

        \[\leadsto x + \left(-1 \cdot \left(t \cdot z\right) + \color{blue}{\left(z \cdot x + \left(t + -1 \cdot x\right) \cdot y\right)}\right) \]
      2. associate-+r+96.0%

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

        \[\leadsto x + \left(\left(\color{blue}{\left(-1 \cdot t\right) \cdot z} + z \cdot x\right) + \left(t + -1 \cdot x\right) \cdot y\right) \]
      4. *-commutative96.0%

        \[\leadsto x + \left(\left(\left(-1 \cdot t\right) \cdot z + \color{blue}{x \cdot z}\right) + \left(t + -1 \cdot x\right) \cdot y\right) \]
      5. distribute-rgt-in96.0%

        \[\leadsto x + \left(\color{blue}{z \cdot \left(-1 \cdot t + x\right)} + \left(t + -1 \cdot x\right) \cdot y\right) \]
      6. *-commutative96.0%

        \[\leadsto x + \left(z \cdot \left(-1 \cdot t + x\right) + \color{blue}{y \cdot \left(t + -1 \cdot x\right)}\right) \]
      7. mul-1-neg96.0%

        \[\leadsto x + \left(z \cdot \left(-1 \cdot t + x\right) + y \cdot \left(t + \color{blue}{\left(-x\right)}\right)\right) \]
      8. distribute-lft-in96.0%

        \[\leadsto x + \left(z \cdot \left(-1 \cdot t + x\right) + \color{blue}{\left(y \cdot t + y \cdot \left(-x\right)\right)}\right) \]
      9. distribute-rgt-neg-in96.0%

        \[\leadsto x + \left(z \cdot \left(-1 \cdot t + x\right) + \left(y \cdot t + \color{blue}{\left(-y \cdot x\right)}\right)\right) \]
      10. mul-1-neg96.0%

        \[\leadsto x + \left(z \cdot \left(-1 \cdot t + x\right) + \left(y \cdot t + \color{blue}{-1 \cdot \left(y \cdot x\right)}\right)\right) \]
      11. fma-def97.0%

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

        \[\leadsto x + \mathsf{fma}\left(z, \color{blue}{x + -1 \cdot t}, y \cdot t + -1 \cdot \left(y \cdot x\right)\right) \]
      13. mul-1-neg97.0%

        \[\leadsto x + \mathsf{fma}\left(z, x + \color{blue}{\left(-t\right)}, y \cdot t + -1 \cdot \left(y \cdot x\right)\right) \]
      14. sub-neg97.0%

        \[\leadsto x + \mathsf{fma}\left(z, \color{blue}{x - t}, y \cdot t + -1 \cdot \left(y \cdot x\right)\right) \]
      15. mul-1-neg97.0%

        \[\leadsto x + \mathsf{fma}\left(z, x - t, y \cdot t + \color{blue}{\left(-y \cdot x\right)}\right) \]
      16. distribute-rgt-neg-in97.0%

        \[\leadsto x + \mathsf{fma}\left(z, x - t, y \cdot t + \color{blue}{y \cdot \left(-x\right)}\right) \]
      17. distribute-lft-in97.0%

        \[\leadsto x + \mathsf{fma}\left(z, x - t, \color{blue}{y \cdot \left(t + \left(-x\right)\right)}\right) \]
      18. sub-neg97.0%

        \[\leadsto x + \mathsf{fma}\left(z, x - t, y \cdot \color{blue}{\left(t - x\right)}\right) \]
      19. *-commutative97.0%

        \[\leadsto x + \mathsf{fma}\left(z, x - t, \color{blue}{\left(t - x\right) \cdot y}\right) \]
    6. Simplified97.0%

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

      \[\leadsto x + \mathsf{fma}\left(z, x - t, \color{blue}{-1 \cdot \left(y \cdot x\right)}\right) \]
    8. Step-by-step derivation
      1. associate-*r*91.2%

        \[\leadsto x + \mathsf{fma}\left(z, x - t, \color{blue}{\left(-1 \cdot y\right) \cdot x}\right) \]
      2. neg-mul-191.2%

        \[\leadsto x + \mathsf{fma}\left(z, x - t, \color{blue}{\left(-y\right)} \cdot x\right) \]
    9. Simplified91.2%

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

      \[\leadsto x + \color{blue}{\left(z + -1 \cdot y\right) \cdot x} \]
    11. Step-by-step derivation
      1. *-commutative91.4%

        \[\leadsto x + \color{blue}{x \cdot \left(z + -1 \cdot y\right)} \]
      2. mul-1-neg91.4%

        \[\leadsto x + x \cdot \left(z + \color{blue}{\left(-y\right)}\right) \]
      3. unsub-neg91.4%

        \[\leadsto x + x \cdot \color{blue}{\left(z - y\right)} \]
    12. Simplified91.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -2.9 \cdot 10^{-42} \lor \neg \left(t \leq 1.3 \cdot 10^{-56}\right):\\ \;\;\;\;x + \left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \left(z - y\right)\\ \end{array} \]

Alternative 8: 84.1% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.066 \lor \neg \left(z \leq 5.8 \cdot 10^{-8}\right):\\ \;\;\;\;x - z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= z -0.066) (not (<= z 5.8e-8)))
   (- x (* z (- t x)))
   (+ x (* y (- t x)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -0.066) || !(z <= 5.8e-8)) {
		tmp = x - (z * (t - x));
	} else {
		tmp = x + (y * (t - 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 <= (-0.066d0)) .or. (.not. (z <= 5.8d-8))) then
        tmp = x - (z * (t - x))
    else
        tmp = x + (y * (t - x))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -0.066) || !(z <= 5.8e-8)) {
		tmp = x - (z * (t - x));
	} else {
		tmp = x + (y * (t - x));
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (z <= -0.066) or not (z <= 5.8e-8):
		tmp = x - (z * (t - x))
	else:
		tmp = x + (y * (t - x))
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -0.066) || !(z <= 5.8e-8))
		tmp = Float64(x - Float64(z * Float64(t - x)));
	else
		tmp = Float64(x + Float64(y * Float64(t - x)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z <= -0.066) || ~((z <= 5.8e-8)))
		tmp = x - (z * (t - x));
	else
		tmp = x + (y * (t - x));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -0.066], N[Not[LessEqual[z, 5.8e-8]], $MachinePrecision]], N[(x - N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.066 \lor \neg \left(z \leq 5.8 \cdot 10^{-8}\right):\\
\;\;\;\;x - z \cdot \left(t - x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.066000000000000003 or 5.8000000000000003e-8 < z

    1. Initial program 100.0%

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

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

        \[\leadsto \color{blue}{x + -1 \cdot \left(\left(t - x\right) \cdot z\right)} \]
      2. mul-1-neg86.6%

        \[\leadsto x + \color{blue}{\left(-\left(t - x\right) \cdot z\right)} \]
      3. unsub-neg86.6%

        \[\leadsto \color{blue}{x - \left(t - x\right) \cdot z} \]
      4. *-commutative86.6%

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

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

    if -0.066000000000000003 < z < 5.8000000000000003e-8

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.066 \lor \neg \left(z \leq 5.8 \cdot 10^{-8}\right):\\ \;\;\;\;x - z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \end{array} \]

Alternative 9: 52.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{+65} \lor \neg \left(z \leq 1.7 \cdot 10^{+43}\right):\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= z -5.5e+65) (not (<= z 1.7e+43))) (* z (- t)) (+ x (* y t))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -5.5e+65) || !(z <= 1.7e+43)) {
		tmp = z * -t;
	} else {
		tmp = x + (y * t);
	}
	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 <= (-5.5d+65)) .or. (.not. (z <= 1.7d+43))) then
        tmp = z * -t
    else
        tmp = x + (y * t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -5.5e+65) || !(z <= 1.7e+43)) {
		tmp = z * -t;
	} else {
		tmp = x + (y * t);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (z <= -5.5e+65) or not (z <= 1.7e+43):
		tmp = z * -t
	else:
		tmp = x + (y * t)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -5.5e+65) || !(z <= 1.7e+43))
		tmp = Float64(z * Float64(-t));
	else
		tmp = Float64(x + Float64(y * t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z <= -5.5e+65) || ~((z <= 1.7e+43)))
		tmp = z * -t;
	else
		tmp = x + (y * t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -5.5e+65], N[Not[LessEqual[z, 1.7e+43]], $MachinePrecision]], N[(z * (-t)), $MachinePrecision], N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+65} \lor \neg \left(z \leq 1.7 \cdot 10^{+43}\right):\\
\;\;\;\;z \cdot \left(-t\right)\\

\mathbf{else}:\\
\;\;\;\;x + y \cdot t\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.4999999999999996e65 or 1.70000000000000006e43 < z

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{t \cdot \left(y - z\right)} \]
    3. Taylor expanded in y around 0 50.7%

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

        \[\leadsto \color{blue}{x + -1 \cdot \left(t \cdot z\right)} \]
      2. mul-1-neg50.7%

        \[\leadsto x + \color{blue}{\left(-t \cdot z\right)} \]
      3. unsub-neg50.7%

        \[\leadsto \color{blue}{x - t \cdot z} \]
    5. Simplified50.7%

      \[\leadsto \color{blue}{x - t \cdot z} \]
    6. Taylor expanded in x around 0 50.2%

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

        \[\leadsto \color{blue}{\left(-1 \cdot t\right) \cdot z} \]
      2. neg-mul-150.2%

        \[\leadsto \color{blue}{\left(-t\right)} \cdot z \]
      3. *-commutative50.2%

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

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

    if -5.4999999999999996e65 < z < 1.70000000000000006e43

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{t \cdot \left(y - z\right)} \]
    3. Taylor expanded in z around 0 65.4%

      \[\leadsto \color{blue}{y \cdot t + x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification59.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{+65} \lor \neg \left(z \leq 1.7 \cdot 10^{+43}\right):\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot t\\ \end{array} \]

Alternative 10: 72.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{+19} \lor \neg \left(y \leq 10500000000\right):\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot t\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= y -4.2e+19) (not (<= y 10500000000.0)))
   (* y (- t x))
   (- x (* z t))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -4.2e+19) || !(y <= 10500000000.0)) {
		tmp = y * (t - x);
	} else {
		tmp = x - (z * t);
	}
	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 ((y <= (-4.2d+19)) .or. (.not. (y <= 10500000000.0d0))) then
        tmp = y * (t - x)
    else
        tmp = x - (z * t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((y <= -4.2e+19) || !(y <= 10500000000.0)) {
		tmp = y * (t - x);
	} else {
		tmp = x - (z * t);
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (y <= -4.2e+19) or not (y <= 10500000000.0):
		tmp = y * (t - x)
	else:
		tmp = x - (z * t)
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((y <= -4.2e+19) || !(y <= 10500000000.0))
		tmp = Float64(y * Float64(t - x));
	else
		tmp = Float64(x - Float64(z * t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((y <= -4.2e+19) || ~((y <= 10500000000.0)))
		tmp = y * (t - x);
	else
		tmp = x - (z * t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -4.2e+19], N[Not[LessEqual[y, 10500000000.0]], $MachinePrecision]], N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+19} \lor \neg \left(y \leq 10500000000\right):\\
\;\;\;\;y \cdot \left(t - x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -4.2e19 or 1.05e10 < y

    1. Initial program 100.0%

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

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

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

    if -4.2e19 < y < 1.05e10

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{t \cdot \left(y - z\right)} \]
    3. Taylor expanded in y around 0 64.4%

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

        \[\leadsto \color{blue}{x + -1 \cdot \left(t \cdot z\right)} \]
      2. mul-1-neg64.4%

        \[\leadsto x + \color{blue}{\left(-t \cdot z\right)} \]
      3. unsub-neg64.4%

        \[\leadsto \color{blue}{x - t \cdot z} \]
    5. Simplified64.4%

      \[\leadsto \color{blue}{x - t \cdot z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification71.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{+19} \lor \neg \left(y \leq 10500000000\right):\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot t\\ \end{array} \]

Alternative 11: 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. Final simplification100.0%

    \[\leadsto x + \left(y - z\right) \cdot \left(t - x\right) \]

Alternative 12: 37.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -0.0029 \lor \neg \left(z \leq 2.5 \cdot 10^{-17}\right):\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (or (<= z -0.0029) (not (<= z 2.5e-17))) (* z (- t)) x))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -0.0029) || !(z <= 2.5e-17)) {
		tmp = z * -t;
	} else {
		tmp = 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 <= (-0.0029d0)) .or. (.not. (z <= 2.5d-17))) then
        tmp = z * -t
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((z <= -0.0029) || !(z <= 2.5e-17)) {
		tmp = z * -t;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (z <= -0.0029) or not (z <= 2.5e-17):
		tmp = z * -t
	else:
		tmp = x
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if ((z <= -0.0029) || !(z <= 2.5e-17))
		tmp = Float64(z * Float64(-t));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((z <= -0.0029) || ~((z <= 2.5e-17)))
		tmp = z * -t;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -0.0029], N[Not[LessEqual[z, 2.5e-17]], $MachinePrecision]], N[(z * (-t)), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0029 \lor \neg \left(z \leq 2.5 \cdot 10^{-17}\right):\\
\;\;\;\;z \cdot \left(-t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.0029 or 2.4999999999999999e-17 < z

    1. Initial program 100.0%

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

      \[\leadsto x + \color{blue}{t \cdot \left(y - z\right)} \]
    3. Taylor expanded in y around 0 44.9%

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

        \[\leadsto \color{blue}{x + -1 \cdot \left(t \cdot z\right)} \]
      2. mul-1-neg44.9%

        \[\leadsto x + \color{blue}{\left(-t \cdot z\right)} \]
      3. unsub-neg44.9%

        \[\leadsto \color{blue}{x - t \cdot z} \]
    5. Simplified44.9%

      \[\leadsto \color{blue}{x - t \cdot z} \]
    6. Taylor expanded in x around 0 44.2%

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

        \[\leadsto \color{blue}{\left(-1 \cdot t\right) \cdot z} \]
      2. neg-mul-144.2%

        \[\leadsto \color{blue}{\left(-t\right)} \cdot z \]
      3. *-commutative44.2%

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

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

    if -0.0029 < z < 2.4999999999999999e-17

    1. Initial program 100.0%

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

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

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification39.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.0029 \lor \neg \left(z \leq 2.5 \cdot 10^{-17}\right):\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 13: 18.1% accurate, 9.0× speedup?

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

\\
x
\end{array}
Derivation
  1. Initial program 100.0%

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

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification20.1%

    \[\leadsto x \]

Developer target: 96.4% 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 2023230 
(FPCore (x y z t)
  :name "Data.Metrics.Snapshot:quantile from metrics-0.3.0.2"
  :precision binary64

  :herbie-target
  (+ x (+ (* t (- y z)) (* (- x) (- y z))))

  (+ x (* (- y z) (- t x))))