Data.Metrics.Snapshot:quantile from metrics-0.3.0.2

Percentage Accurate: 100.0% → 100.0%
Time: 7.3s
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: 37.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := t \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -1.05 \cdot 10^{-17}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-252}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-113}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-51}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+117} \lor \neg \left(z \leq 2.4 \cdot 10^{+275}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* t (- z))))
   (if (<= z -1.05e-17)
     t_1
     (if (<= z 3.6e-252)
       x
       (if (<= z 4.9e-113)
         (* y t)
         (if (<= z 3.8e-51)
           x
           (if (or (<= z 1.25e+117) (not (<= z 2.4e+275))) t_1 (* z x))))))))
double code(double x, double y, double z, double t) {
	double t_1 = t * -z;
	double tmp;
	if (z <= -1.05e-17) {
		tmp = t_1;
	} else if (z <= 3.6e-252) {
		tmp = x;
	} else if (z <= 4.9e-113) {
		tmp = y * t;
	} else if (z <= 3.8e-51) {
		tmp = x;
	} else if ((z <= 1.25e+117) || !(z <= 2.4e+275)) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = t * -z
    if (z <= (-1.05d-17)) then
        tmp = t_1
    else if (z <= 3.6d-252) then
        tmp = x
    else if (z <= 4.9d-113) then
        tmp = y * t
    else if (z <= 3.8d-51) then
        tmp = x
    else if ((z <= 1.25d+117) .or. (.not. (z <= 2.4d+275))) then
        tmp = t_1
    else
        tmp = z * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = t * -z;
	double tmp;
	if (z <= -1.05e-17) {
		tmp = t_1;
	} else if (z <= 3.6e-252) {
		tmp = x;
	} else if (z <= 4.9e-113) {
		tmp = y * t;
	} else if (z <= 3.8e-51) {
		tmp = x;
	} else if ((z <= 1.25e+117) || !(z <= 2.4e+275)) {
		tmp = t_1;
	} else {
		tmp = z * x;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = t * -z
	tmp = 0
	if z <= -1.05e-17:
		tmp = t_1
	elif z <= 3.6e-252:
		tmp = x
	elif z <= 4.9e-113:
		tmp = y * t
	elif z <= 3.8e-51:
		tmp = x
	elif (z <= 1.25e+117) or not (z <= 2.4e+275):
		tmp = t_1
	else:
		tmp = z * x
	return tmp
function code(x, y, z, t)
	t_1 = Float64(t * Float64(-z))
	tmp = 0.0
	if (z <= -1.05e-17)
		tmp = t_1;
	elseif (z <= 3.6e-252)
		tmp = x;
	elseif (z <= 4.9e-113)
		tmp = Float64(y * t);
	elseif (z <= 3.8e-51)
		tmp = x;
	elseif ((z <= 1.25e+117) || !(z <= 2.4e+275))
		tmp = t_1;
	else
		tmp = Float64(z * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = t * -z;
	tmp = 0.0;
	if (z <= -1.05e-17)
		tmp = t_1;
	elseif (z <= 3.6e-252)
		tmp = x;
	elseif (z <= 4.9e-113)
		tmp = y * t;
	elseif (z <= 3.8e-51)
		tmp = x;
	elseif ((z <= 1.25e+117) || ~((z <= 2.4e+275)))
		tmp = t_1;
	else
		tmp = z * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * (-z)), $MachinePrecision]}, If[LessEqual[z, -1.05e-17], t$95$1, If[LessEqual[z, 3.6e-252], x, If[LessEqual[z, 4.9e-113], N[(y * t), $MachinePrecision], If[LessEqual[z, 3.8e-51], x, If[Or[LessEqual[z, 1.25e+117], N[Not[LessEqual[z, 2.4e+275]], $MachinePrecision]], t$95$1, N[(z * x), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := t \cdot \left(-z\right)\\
\mathbf{if}\;z \leq -1.05 \cdot 10^{-17}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 3.6 \cdot 10^{-252}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 4.9 \cdot 10^{-113}:\\
\;\;\;\;y \cdot t\\

\mathbf{elif}\;z \leq 3.8 \cdot 10^{-51}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 1.25 \cdot 10^{+117} \lor \neg \left(z \leq 2.4 \cdot 10^{+275}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.04999999999999996e-17 or 3.80000000000000003e-51 < z < 1.24999999999999996e117 or 2.39999999999999997e275 < z

    1. Initial program 100.0%

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

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

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

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

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

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

    if -1.04999999999999996e-17 < z < 3.60000000000000023e-252 or 4.9000000000000003e-113 < z < 3.80000000000000003e-51

    1. Initial program 100.0%

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

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

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

    if 3.60000000000000023e-252 < z < 4.9000000000000003e-113

    1. Initial program 100.0%

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

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

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

    if 1.24999999999999996e117 < z < 2.39999999999999997e275

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.05 \cdot 10^{-17}:\\ \;\;\;\;t \cdot \left(-z\right)\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-252}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-113}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 3.8 \cdot 10^{-51}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+117} \lor \neg \left(z \leq 2.4 \cdot 10^{+275}\right):\\ \;\;\;\;t \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]

Alternative 3: 84.2% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + z \cdot \left(x - t\right)\\ \mathbf{if}\;z \leq -4.6 \cdot 10^{-17}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-53}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+65}:\\ \;\;\;\;x + \left(y - z\right) \cdot t\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+89}:\\ \;\;\;\;x + x \cdot \left(z - y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (* z (- x t)))))
   (if (<= z -4.6e-17)
     t_1
     (if (<= z 8e-53)
       (+ x (* y (- t x)))
       (if (<= z 1.2e+65)
         (+ x (* (- y z) t))
         (if (<= z 6.5e+89) (+ x (* x (- z y))) t_1))))))
double code(double x, double y, double z, double t) {
	double t_1 = x + (z * (x - t));
	double tmp;
	if (z <= -4.6e-17) {
		tmp = t_1;
	} else if (z <= 8e-53) {
		tmp = x + (y * (t - x));
	} else if (z <= 1.2e+65) {
		tmp = x + ((y - z) * t);
	} else if (z <= 6.5e+89) {
		tmp = x + (x * (z - y));
	} 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) :: tmp
    t_1 = x + (z * (x - t))
    if (z <= (-4.6d-17)) then
        tmp = t_1
    else if (z <= 8d-53) then
        tmp = x + (y * (t - x))
    else if (z <= 1.2d+65) then
        tmp = x + ((y - z) * t)
    else if (z <= 6.5d+89) then
        tmp = x + (x * (z - y))
    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 = x + (z * (x - t));
	double tmp;
	if (z <= -4.6e-17) {
		tmp = t_1;
	} else if (z <= 8e-53) {
		tmp = x + (y * (t - x));
	} else if (z <= 1.2e+65) {
		tmp = x + ((y - z) * t);
	} else if (z <= 6.5e+89) {
		tmp = x + (x * (z - y));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x + (z * (x - t))
	tmp = 0
	if z <= -4.6e-17:
		tmp = t_1
	elif z <= 8e-53:
		tmp = x + (y * (t - x))
	elif z <= 1.2e+65:
		tmp = x + ((y - z) * t)
	elif z <= 6.5e+89:
		tmp = x + (x * (z - y))
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x + Float64(z * Float64(x - t)))
	tmp = 0.0
	if (z <= -4.6e-17)
		tmp = t_1;
	elseif (z <= 8e-53)
		tmp = Float64(x + Float64(y * Float64(t - x)));
	elseif (z <= 1.2e+65)
		tmp = Float64(x + Float64(Float64(y - z) * t));
	elseif (z <= 6.5e+89)
		tmp = Float64(x + Float64(x * Float64(z - y)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + (z * (x - t));
	tmp = 0.0;
	if (z <= -4.6e-17)
		tmp = t_1;
	elseif (z <= 8e-53)
		tmp = x + (y * (t - x));
	elseif (z <= 1.2e+65)
		tmp = x + ((y - z) * t);
	elseif (z <= 6.5e+89)
		tmp = x + (x * (z - y));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.6e-17], t$95$1, If[LessEqual[z, 8e-53], N[(x + N[(y * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.2e+65], N[(x + N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.5e+89], N[(x + N[(x * N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -4.60000000000000018e-17 or 6.4999999999999996e89 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -4.60000000000000018e-17 < z < 8.00000000000000025e-53

    1. Initial program 100.0%

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

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

    if 8.00000000000000025e-53 < z < 1.2000000000000001e65

    1. Initial program 100.0%

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

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

    if 1.2000000000000001e65 < z < 6.4999999999999996e89

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.6 \cdot 10^{-17}:\\ \;\;\;\;x + z \cdot \left(x - t\right)\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-53}:\\ \;\;\;\;x + y \cdot \left(t - x\right)\\ \mathbf{elif}\;z \leq 1.2 \cdot 10^{+65}:\\ \;\;\;\;x + \left(y - z\right) \cdot t\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+89}:\\ \;\;\;\;x + x \cdot \left(z - y\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(x - t\right)\\ \end{array} \]

Alternative 4: 55.5% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y - z \leq -1 \cdot 10^{-35} \lor \neg \left(y - z \leq 4 \cdot 10^{-22}\right):\\
\;\;\;\;\left(y - z\right) \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 y z) < -1.00000000000000001e-35 or 4.0000000000000002e-22 < (-.f64 y z)

    1. Initial program 100.0%

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

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

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

    if -1.00000000000000001e-35 < (-.f64 y z) < 4.0000000000000002e-22

    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 x around inf 76.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y - z \leq -1 \cdot 10^{-35} \lor \neg \left(y - z \leq 4 \cdot 10^{-22}\right):\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 5: 37.0% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{-16}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-251}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-112}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 27000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= z -1.7e-16)
   (* z x)
   (if (<= z 8.2e-251)
     x
     (if (<= z 9.5e-112) (* y t) (if (<= z 27000000.0) x (* z x))))))
double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.7e-16) {
		tmp = z * x;
	} else if (z <= 8.2e-251) {
		tmp = x;
	} else if (z <= 9.5e-112) {
		tmp = y * t;
	} else if (z <= 27000000.0) {
		tmp = x;
	} else {
		tmp = z * x;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= (-1.7d-16)) then
        tmp = z * x
    else if (z <= 8.2d-251) then
        tmp = x
    else if (z <= 9.5d-112) then
        tmp = y * t
    else if (z <= 27000000.0d0) then
        tmp = x
    else
        tmp = z * x
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (z <= -1.7e-16) {
		tmp = z * x;
	} else if (z <= 8.2e-251) {
		tmp = x;
	} else if (z <= 9.5e-112) {
		tmp = y * t;
	} else if (z <= 27000000.0) {
		tmp = x;
	} else {
		tmp = z * x;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if z <= -1.7e-16:
		tmp = z * x
	elif z <= 8.2e-251:
		tmp = x
	elif z <= 9.5e-112:
		tmp = y * t
	elif z <= 27000000.0:
		tmp = x
	else:
		tmp = z * x
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (z <= -1.7e-16)
		tmp = Float64(z * x);
	elseif (z <= 8.2e-251)
		tmp = x;
	elseif (z <= 9.5e-112)
		tmp = Float64(y * t);
	elseif (z <= 27000000.0)
		tmp = x;
	else
		tmp = Float64(z * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (z <= -1.7e-16)
		tmp = z * x;
	elseif (z <= 8.2e-251)
		tmp = x;
	elseif (z <= 9.5e-112)
		tmp = y * t;
	elseif (z <= 27000000.0)
		tmp = x;
	else
		tmp = z * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.7e-16], N[(z * x), $MachinePrecision], If[LessEqual[z, 8.2e-251], x, If[LessEqual[z, 9.5e-112], N[(y * t), $MachinePrecision], If[LessEqual[z, 27000000.0], x, N[(z * x), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{-16}:\\
\;\;\;\;z \cdot x\\

\mathbf{elif}\;z \leq 8.2 \cdot 10^{-251}:\\
\;\;\;\;x\\

\mathbf{elif}\;z \leq 9.5 \cdot 10^{-112}:\\
\;\;\;\;y \cdot t\\

\mathbf{elif}\;z \leq 27000000:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.7e-16 or 2.7e7 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

    if -1.7e-16 < z < 8.1999999999999997e-251 or 9.50000000000000056e-112 < z < 2.7e7

    1. Initial program 100.0%

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

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

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

    if 8.1999999999999997e-251 < z < 9.50000000000000056e-112

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.7 \cdot 10^{-16}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-251}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-112}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;z \leq 27000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]

Alternative 6: 61.7% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot \left(z + 1\right)\\
\mathbf{if}\;x \leq -7.8 \cdot 10^{+163}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -1.66 \cdot 10^{-40}:\\
\;\;\;\;x - y \cdot x\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -7.80000000000000047e163 or 1.10000000000000005e-31 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -7.80000000000000047e163 < x < -1.6600000000000001e-40

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x - y \cdot x} \]

    if -1.6600000000000001e-40 < x < 1.10000000000000005e-31

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.8 \cdot 10^{+163}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{elif}\;x \leq -1.66 \cdot 10^{-40}:\\ \;\;\;\;x - y \cdot x\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-31}:\\ \;\;\;\;\left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \end{array} \]

Alternative 7: 69.9% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{+120} \lor \neg \left(x \leq 5.9 \cdot 10^{+184}\right):\\
\;\;\;\;x \cdot \left(z + 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -8.50000000000000026e120 or 5.9000000000000001e184 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -8.50000000000000026e120 < x < 5.9000000000000001e184

    1. Initial program 100.0%

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

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

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

Alternative 8: 77.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.46 \lor \neg \left(y \leq 7200000000\right):\\
\;\;\;\;x + y \cdot \left(t - x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -0.46000000000000002 or 7.2e9 < y

    1. Initial program 100.0%

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

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

    if -0.46000000000000002 < y < 7.2e9

    1. Initial program 100.0%

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

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

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

Alternative 9: 80.0% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{+97} \lor \neg \left(x \leq 2.3 \cdot 10^{-60}\right):\\
\;\;\;\;x + x \cdot \left(z - y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.4000000000000002e97 or 2.3000000000000001e-60 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -4.4000000000000002e97 < x < 2.3000000000000001e-60

    1. Initial program 100.0%

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

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

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

Alternative 10: 62.5% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+70} \lor \neg \left(x \leq 2.9 \cdot 10^{-31}\right):\\
\;\;\;\;x \cdot \left(z + 1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.7e70 or 2.9000000000000001e-31 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -1.7e70 < x < 2.9000000000000001e-31

    1. Initial program 100.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{+70} \lor \neg \left(x \leq 2.9 \cdot 10^{-31}\right):\\ \;\;\;\;x \cdot \left(z + 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \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.2% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;y \leq 2.4 \cdot 10^{-19}:\\
\;\;\;\;x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -1.7500000000000001e-37 or 2.40000000000000023e-19 < y

    1. Initial program 100.0%

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

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

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

    if -1.7500000000000001e-37 < y < 2.40000000000000023e-19

    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 x around inf 37.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{-37}:\\ \;\;\;\;y \cdot t\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot t\\ \end{array} \]

Alternative 13: 17.7% 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 64.4%

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification19.7%

    \[\leadsto x \]

Developer target: 96.2% 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 2023238 
(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))))