Data.Metrics.Snapshot:quantile from metrics-0.3.0.2

Percentage Accurate: 100.0% → 100.0%
Time: 9.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-define100.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. Add Preprocessing
  5. Add Preprocessing

Alternative 2: 67.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := y \cdot \left(t - x\right)\\ t_2 := z \cdot \left(x - t\right)\\ \mathbf{if}\;y \leq -1.15 \cdot 10^{+44}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq -4 \cdot 10^{-199}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-257}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+36}:\\ \;\;\;\;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 (- x t))))
   (if (<= y -1.15e+44)
     t_1
     (if (<= y -4e-199)
       t_2
       (if (<= y 4.2e-257) (* x (+ z 1.0)) (if (<= y 6.5e+36) t_2 t_1))))))
double code(double x, double y, double z, double t) {
	double t_1 = y * (t - x);
	double t_2 = z * (x - t);
	double tmp;
	if (y <= -1.15e+44) {
		tmp = t_1;
	} else if (y <= -4e-199) {
		tmp = t_2;
	} else if (y <= 4.2e-257) {
		tmp = x * (z + 1.0);
	} else if (y <= 6.5e+36) {
		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 * (x - t)
    if (y <= (-1.15d+44)) then
        tmp = t_1
    else if (y <= (-4d-199)) then
        tmp = t_2
    else if (y <= 4.2d-257) then
        tmp = x * (z + 1.0d0)
    else if (y <= 6.5d+36) 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 * (x - t);
	double tmp;
	if (y <= -1.15e+44) {
		tmp = t_1;
	} else if (y <= -4e-199) {
		tmp = t_2;
	} else if (y <= 4.2e-257) {
		tmp = x * (z + 1.0);
	} else if (y <= 6.5e+36) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = y * (t - x)
	t_2 = z * (x - t)
	tmp = 0
	if y <= -1.15e+44:
		tmp = t_1
	elif y <= -4e-199:
		tmp = t_2
	elif y <= 4.2e-257:
		tmp = x * (z + 1.0)
	elif y <= 6.5e+36:
		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(x - t))
	tmp = 0.0
	if (y <= -1.15e+44)
		tmp = t_1;
	elseif (y <= -4e-199)
		tmp = t_2;
	elseif (y <= 4.2e-257)
		tmp = Float64(x * Float64(z + 1.0));
	elseif (y <= 6.5e+36)
		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 * (x - t);
	tmp = 0.0;
	if (y <= -1.15e+44)
		tmp = t_1;
	elseif (y <= -4e-199)
		tmp = t_2;
	elseif (y <= 4.2e-257)
		tmp = x * (z + 1.0);
	elseif (y <= 6.5e+36)
		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 * N[(x - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.15e+44], t$95$1, If[LessEqual[y, -4e-199], t$95$2, If[LessEqual[y, 4.2e-257], N[(x * N[(z + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.5e+36], 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(x - t\right)\\
\mathbf{if}\;y \leq -1.15 \cdot 10^{+44}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq -4 \cdot 10^{-199}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;y \leq 4.2 \cdot 10^{-257}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\

\mathbf{elif}\;y \leq 6.5 \cdot 10^{+36}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.15000000000000002e44 or 6.4999999999999998e36 < 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 inf 85.1%

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

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

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

        \[\leadsto x + \left(-\color{blue}{\left(\left(t + -1 \cdot \frac{y \cdot \left(t - x\right)}{z}\right) - x\right) \cdot z}\right) \]
      3. distribute-rgt-neg-in76.4%

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

        \[\leadsto x + \left(\left(t + \color{blue}{\left(-\frac{y \cdot \left(t - x\right)}{z}\right)}\right) - x\right) \cdot \left(-z\right) \]
      5. unsub-neg76.4%

        \[\leadsto x + \left(\color{blue}{\left(t - \frac{y \cdot \left(t - x\right)}{z}\right)} - x\right) \cdot \left(-z\right) \]
      6. associate-/l*82.6%

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

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

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

    if -1.15000000000000002e44 < y < -3.99999999999999993e-199 or 4.2000000000000002e-257 < y < 6.4999999999999998e36

    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 80.4%

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

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

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

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

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

    if -3.99999999999999993e-199 < y < 4.2000000000000002e-257

    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 90.5%

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(z + 1\right)} \]
    8. Simplified90.5%

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

Alternative 3: 45.6% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.1 \cdot 10^{+35}:\\
\;\;\;\;y \cdot t\\

\mathbf{elif}\;t \leq 7.5 \cdot 10^{+88}:\\
\;\;\;\;x \cdot \left(z + 1\right)\\

\mathbf{elif}\;t \leq 8.2 \cdot 10^{+114} \lor \neg \left(t \leq 4.5 \cdot 10^{+235}\right):\\
\;\;\;\;y \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -6.09999999999999977e35 or 7.50000000000000031e88 < t < 8.2000000000000001e114 or 4.5e235 < t

    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 94.5%

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

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

        \[\leadsto x + \color{blue}{\left(-z \cdot \left(\left(t + -1 \cdot \frac{y \cdot \left(t - x\right)}{z}\right) - x\right)\right)} \]
      2. *-commutative80.9%

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

        \[\leadsto x + \color{blue}{\left(\left(t + -1 \cdot \frac{y \cdot \left(t - x\right)}{z}\right) - x\right) \cdot \left(-z\right)} \]
      4. mul-1-neg80.9%

        \[\leadsto x + \left(\left(t + \color{blue}{\left(-\frac{y \cdot \left(t - x\right)}{z}\right)}\right) - x\right) \cdot \left(-z\right) \]
      5. unsub-neg80.9%

        \[\leadsto x + \left(\color{blue}{\left(t - \frac{y \cdot \left(t - x\right)}{z}\right)} - x\right) \cdot \left(-z\right) \]
      6. associate-/l*78.7%

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

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

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

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

        \[\leadsto \color{blue}{y \cdot t} \]
    10. Simplified65.3%

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

    if -6.09999999999999977e35 < t < 7.50000000000000031e88

    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 77.8%

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(z + 1\right)} \]
    8. Simplified56.3%

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

    if 8.2000000000000001e114 < t < 4.5e235

    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 77.7%

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

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

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

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

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

        \[\leadsto \color{blue}{-t \cdot z} \]
      2. distribute-rgt-neg-in56.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -6.1 \cdot 10^{+35}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;t \leq 7.5 \cdot 10^{+88}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{elif}\;t \leq 8.2 \cdot 10^{+114} \lor \neg \left(t \leq 4.5 \cdot 10^{+235}\right):\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 33.8% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;x \leq -2.3 \cdot 10^{-96}:\\
\;\;\;\;y \cdot t\\

\mathbf{elif}\;x \leq -2 \cdot 10^{-304}:\\
\;\;\;\;z \cdot \left(-t\right)\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{+48}:\\
\;\;\;\;y \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.08000000000000006e145 or 2.1999999999999999e48 < 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 88.4%

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

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

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

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

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

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

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

    if -1.08000000000000006e145 < x < -2.3e-96 or -1.99999999999999994e-304 < x < 2.1999999999999999e48

    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 88.8%

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

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

        \[\leadsto x + \color{blue}{\left(-z \cdot \left(\left(t + -1 \cdot \frac{y \cdot \left(t - x\right)}{z}\right) - x\right)\right)} \]
      2. *-commutative83.5%

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

        \[\leadsto x + \color{blue}{\left(\left(t + -1 \cdot \frac{y \cdot \left(t - x\right)}{z}\right) - x\right) \cdot \left(-z\right)} \]
      4. mul-1-neg83.5%

        \[\leadsto x + \left(\left(t + \color{blue}{\left(-\frac{y \cdot \left(t - x\right)}{z}\right)}\right) - x\right) \cdot \left(-z\right) \]
      5. unsub-neg83.5%

        \[\leadsto x + \left(\color{blue}{\left(t - \frac{y \cdot \left(t - x\right)}{z}\right)} - x\right) \cdot \left(-z\right) \]
      6. associate-/l*78.8%

        \[\leadsto x + \left(\left(t - \color{blue}{y \cdot \frac{t - x}{z}}\right) - x\right) \cdot \left(-z\right) \]
    6. Simplified78.8%

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

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

      \[\leadsto \color{blue}{t \cdot y} \]
    9. Step-by-step derivation
      1. *-commutative45.8%

        \[\leadsto \color{blue}{y \cdot t} \]
    10. Simplified45.8%

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

    if -2.3e-96 < x < -1.99999999999999994e-304

    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 85.0%

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

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

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

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

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

        \[\leadsto \color{blue}{-t \cdot z} \]
      2. distribute-rgt-neg-in62.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.08 \cdot 10^{+145}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-96}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-304}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+48}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 46.6% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.85 \cdot 10^{-31}:\\
\;\;\;\;x \cdot \left(1 - y\right)\\

\mathbf{elif}\;x \leq -1.1 \cdot 10^{-305}:\\
\;\;\;\;z \cdot \left(-t\right)\\

\mathbf{elif}\;x \leq 1.1 \cdot 10^{-32}:\\
\;\;\;\;y \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -1.8499999999999999e-31

    1. Initial program 99.9%

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

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

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

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

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

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

    if -1.8499999999999999e-31 < x < -1.09999999999999998e-305

    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 82.3%

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

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

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

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

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

        \[\leadsto \color{blue}{-t \cdot z} \]
      2. distribute-rgt-neg-in60.2%

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

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

    if -1.09999999999999998e-305 < x < 1.1e-32

    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 81.9%

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

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

        \[\leadsto x + \color{blue}{\left(-z \cdot \left(\left(t + -1 \cdot \frac{y \cdot \left(t - x\right)}{z}\right) - x\right)\right)} \]
      2. *-commutative70.2%

        \[\leadsto x + \left(-\color{blue}{\left(\left(t + -1 \cdot \frac{y \cdot \left(t - x\right)}{z}\right) - x\right) \cdot z}\right) \]
      3. distribute-rgt-neg-in70.2%

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

        \[\leadsto x + \left(\left(t + \color{blue}{\left(-\frac{y \cdot \left(t - x\right)}{z}\right)}\right) - x\right) \cdot \left(-z\right) \]
      5. unsub-neg70.2%

        \[\leadsto x + \left(\color{blue}{\left(t - \frac{y \cdot \left(t - x\right)}{z}\right)} - x\right) \cdot \left(-z\right) \]
      6. associate-/l*70.3%

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

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

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

      \[\leadsto \color{blue}{t \cdot y} \]
    9. Step-by-step derivation
      1. *-commutative57.9%

        \[\leadsto \color{blue}{y \cdot t} \]
    10. Simplified57.9%

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

    if 1.1e-32 < 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 79.0%

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(z + 1\right)} \]
    8. Simplified58.7%

      \[\leadsto x \cdot \color{blue}{\left(z + 1\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification58.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.85 \cdot 10^{-31}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{elif}\;x \leq -1.1 \cdot 10^{-305}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-32}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 35.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-35}:\\
\;\;\;\;x \cdot \left(-y\right)\\

\mathbf{elif}\;x \leq -4.8 \cdot 10^{-306}:\\
\;\;\;\;z \cdot \left(-t\right)\\

\mathbf{elif}\;x \leq 8 \cdot 10^{+46}:\\
\;\;\;\;y \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -2.00000000000000002e-35

    1. Initial program 99.9%

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

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

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

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

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

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

        \[\leadsto \color{blue}{-x \cdot y} \]
      2. distribute-lft-neg-out39.2%

        \[\leadsto \color{blue}{\left(-x\right) \cdot y} \]
      3. *-commutative39.2%

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

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

    if -2.00000000000000002e-35 < x < -4.7999999999999999e-306

    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 82.3%

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

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

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

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

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

        \[\leadsto \color{blue}{-t \cdot z} \]
      2. distribute-rgt-neg-in60.2%

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

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

    if -4.7999999999999999e-306 < x < 7.9999999999999999e46

    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 85.2%

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

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

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

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

        \[\leadsto x + \color{blue}{\left(\left(t + -1 \cdot \frac{y \cdot \left(t - x\right)}{z}\right) - x\right) \cdot \left(-z\right)} \]
      4. mul-1-neg76.3%

        \[\leadsto x + \left(\left(t + \color{blue}{\left(-\frac{y \cdot \left(t - x\right)}{z}\right)}\right) - x\right) \cdot \left(-z\right) \]
      5. unsub-neg76.3%

        \[\leadsto x + \left(\color{blue}{\left(t - \frac{y \cdot \left(t - x\right)}{z}\right)} - x\right) \cdot \left(-z\right) \]
      6. associate-/l*73.8%

        \[\leadsto x + \left(\left(t - \color{blue}{y \cdot \frac{t - x}{z}}\right) - x\right) \cdot \left(-z\right) \]
    6. Simplified73.8%

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

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

      \[\leadsto \color{blue}{t \cdot y} \]
    9. Step-by-step derivation
      1. *-commutative49.7%

        \[\leadsto \color{blue}{y \cdot t} \]
    10. Simplified49.7%

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

    if 7.9999999999999999e46 < 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 84.3%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-35}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{elif}\;x \leq -4.8 \cdot 10^{-306}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+46}:\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 84.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{+24} \lor \neg \left(z \leq 1.05 \cdot 10^{+56}\right):\\
\;\;\;\;z \cdot \left(x - t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -7.50000000000000014e24 or 1.05000000000000009e56 < z

    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 86.5%

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

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

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

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

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

    if -7.50000000000000014e24 < z < 1.05000000000000009e56

    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 88.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{+24} \lor \neg \left(z \leq 1.05 \cdot 10^{+56}\right):\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 71.3% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.5000000000000002e24 or 5.3e10 < z

    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 83.6%

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

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

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

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

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

    if -5.5000000000000002e24 < z < 5.3e10

    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 90.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.5 \cdot 10^{+24} \lor \neg \left(z \leq 53000000000\right):\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 68.2% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{-9} \lor \neg \left(y \leq 80000\right):\\
\;\;\;\;y \cdot \left(t - x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -7.2e-9 or 8e4 < 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 inf 87.4%

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

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

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

        \[\leadsto x + \left(-\color{blue}{\left(\left(t + -1 \cdot \frac{y \cdot \left(t - x\right)}{z}\right) - x\right) \cdot z}\right) \]
      3. distribute-rgt-neg-in79.4%

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

        \[\leadsto x + \left(\left(t + \color{blue}{\left(-\frac{y \cdot \left(t - x\right)}{z}\right)}\right) - x\right) \cdot \left(-z\right) \]
      5. unsub-neg79.4%

        \[\leadsto x + \left(\color{blue}{\left(t - \frac{y \cdot \left(t - x\right)}{z}\right)} - x\right) \cdot \left(-z\right) \]
      6. associate-/l*84.6%

        \[\leadsto x + \left(\left(t - \color{blue}{y \cdot \frac{t - x}{z}}\right) - x\right) \cdot \left(-z\right) \]
    6. Simplified84.6%

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

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

    if -7.2e-9 < y < 8e4

    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 57.9%

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(z + 1\right)} \]
    8. Simplified57.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -7.2 \cdot 10^{-9} \lor \neg \left(y \leq 80000\right):\\ \;\;\;\;y \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 37.6% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+37} \lor \neg \left(z \leq 46000000000\right):\\
\;\;\;\;z \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.1e37 or 4.6e10 < z

    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 55.5%

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

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

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

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

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

        \[\leadsto \color{blue}{z \cdot x} \]
    8. Simplified45.2%

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

    if -1.1e37 < z < 4.6e10

    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 87.6%

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

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

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

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

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

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

        \[\leadsto x + \left(\color{blue}{\left(t - \frac{y \cdot \left(t - x\right)}{z}\right)} - x\right) \cdot \left(-z\right) \]
      6. associate-/l*67.9%

        \[\leadsto x + \left(\left(t - \color{blue}{y \cdot \frac{t - x}{z}}\right) - x\right) \cdot \left(-z\right) \]
    6. Simplified67.9%

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

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

      \[\leadsto \color{blue}{t \cdot y} \]
    9. Step-by-step derivation
      1. *-commutative43.2%

        \[\leadsto \color{blue}{y \cdot t} \]
    10. Simplified43.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.1 \cdot 10^{+37} \lor \neg \left(z \leq 46000000000\right):\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 36.7% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{-10} \lor \neg \left(y \leq 5.6 \cdot 10^{-101}\right):\\
\;\;\;\;y \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -3.4999999999999998e-10 or 5.59999999999999978e-101 < 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 inf 89.3%

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

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

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

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

        \[\leadsto x + \color{blue}{\left(\left(t + -1 \cdot \frac{y \cdot \left(t - x\right)}{z}\right) - x\right) \cdot \left(-z\right)} \]
      4. mul-1-neg81.3%

        \[\leadsto x + \left(\left(t + \color{blue}{\left(-\frac{y \cdot \left(t - x\right)}{z}\right)}\right) - x\right) \cdot \left(-z\right) \]
      5. unsub-neg81.3%

        \[\leadsto x + \left(\color{blue}{\left(t - \frac{y \cdot \left(t - x\right)}{z}\right)} - x\right) \cdot \left(-z\right) \]
      6. associate-/l*84.5%

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

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

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

      \[\leadsto \color{blue}{t \cdot y} \]
    9. Step-by-step derivation
      1. *-commutative44.5%

        \[\leadsto \color{blue}{y \cdot t} \]
    10. Simplified44.5%

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

    if -3.4999999999999998e-10 < y < 5.59999999999999978e-101

    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 44.3%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{-10} \lor \neg \left(y \leq 5.6 \cdot 10^{-101}\right):\\ \;\;\;\;y \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 100.0% accurate, 1.0× speedup?

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

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

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

Alternative 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. Add Preprocessing
  3. Taylor expanded in y around inf 61.6%

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

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

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

    \[\leadsto \color{blue}{x} \]
  7. Add Preprocessing

Developer Target 1: 96.3% 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 2024170 
(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))))