Data.Metrics.Snapshot:quantile from metrics-0.3.0.2

Percentage Accurate: 100.0% → 100.0%
Time: 6.0s
Alternatives: 11
Speedup: 1.0×

Specification

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

\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

\\
x + \left(y - z\right) \cdot \left(t - x\right)
\end{array}

Alternative 1: 100.0% accurate, 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: 52.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + z \cdot x\\ \mathbf{if}\;z \leq -3.4 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-87}:\\ \;\;\;\;x + y \cdot t\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{+22} \lor \neg \left(z \leq 6.5 \cdot 10^{+43}\right) \land z \leq 6.6 \cdot 10^{+150}:\\ \;\;\;\;x - z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (* z x))))
   (if (<= z -3.4e-11)
     t_1
     (if (<= z 1.55e-87)
       (+ x (* y t))
       (if (or (<= z 1.6e+22) (and (not (<= z 6.5e+43)) (<= z 6.6e+150)))
         (- x (* z t))
         t_1)))))
double code(double x, double y, double z, double t) {
	double t_1 = x + (z * x);
	double tmp;
	if (z <= -3.4e-11) {
		tmp = t_1;
	} else if (z <= 1.55e-87) {
		tmp = x + (y * t);
	} else if ((z <= 1.6e+22) || (!(z <= 6.5e+43) && (z <= 6.6e+150))) {
		tmp = x - (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 * x)
    if (z <= (-3.4d-11)) then
        tmp = t_1
    else if (z <= 1.55d-87) then
        tmp = x + (y * t)
    else if ((z <= 1.6d+22) .or. (.not. (z <= 6.5d+43)) .and. (z <= 6.6d+150)) then
        tmp = x - (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 * x);
	double tmp;
	if (z <= -3.4e-11) {
		tmp = t_1;
	} else if (z <= 1.55e-87) {
		tmp = x + (y * t);
	} else if ((z <= 1.6e+22) || (!(z <= 6.5e+43) && (z <= 6.6e+150))) {
		tmp = x - (z * t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x + (z * x)
	tmp = 0
	if z <= -3.4e-11:
		tmp = t_1
	elif z <= 1.55e-87:
		tmp = x + (y * t)
	elif (z <= 1.6e+22) or (not (z <= 6.5e+43) and (z <= 6.6e+150)):
		tmp = x - (z * t)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x + Float64(z * x))
	tmp = 0.0
	if (z <= -3.4e-11)
		tmp = t_1;
	elseif (z <= 1.55e-87)
		tmp = Float64(x + Float64(y * t));
	elseif ((z <= 1.6e+22) || (!(z <= 6.5e+43) && (z <= 6.6e+150)))
		tmp = Float64(x - Float64(z * t));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + (z * x);
	tmp = 0.0;
	if (z <= -3.4e-11)
		tmp = t_1;
	elseif (z <= 1.55e-87)
		tmp = x + (y * t);
	elseif ((z <= 1.6e+22) || (~((z <= 6.5e+43)) && (z <= 6.6e+150)))
		tmp = x - (z * t);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.4e-11], t$95$1, If[LessEqual[z, 1.55e-87], N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 1.6e+22], And[N[Not[LessEqual[z, 6.5e+43]], $MachinePrecision], LessEqual[z, 6.6e+150]]], N[(x - N[(z * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + z \cdot x\\
\mathbf{if}\;z \leq -3.4 \cdot 10^{-11}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 1.55 \cdot 10^{-87}:\\
\;\;\;\;x + y \cdot t\\

\mathbf{elif}\;z \leq 1.6 \cdot 10^{+22} \lor \neg \left(z \leq 6.5 \cdot 10^{+43}\right) \land z \leq 6.6 \cdot 10^{+150}:\\
\;\;\;\;x - z \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -3.3999999999999999e-11 or 1.6e22 < z < 6.4999999999999998e43 or 6.59999999999999962e150 < z

    1. Initial program 100.0%

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

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

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

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

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

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

    if -3.3999999999999999e-11 < z < 1.54999999999999999e-87

    1. Initial program 99.9%

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

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

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

    if 1.54999999999999999e-87 < z < 1.6e22 or 6.4999999999999998e43 < z < 6.59999999999999962e150

    1. Initial program 99.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{-11}:\\ \;\;\;\;x + z \cdot x\\ \mathbf{elif}\;z \leq 1.55 \cdot 10^{-87}:\\ \;\;\;\;x + y \cdot t\\ \mathbf{elif}\;z \leq 1.6 \cdot 10^{+22} \lor \neg \left(z \leq 6.5 \cdot 10^{+43}\right) \land z \leq 6.6 \cdot 10^{+150}:\\ \;\;\;\;x - z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot x\\ \end{array} \]

Alternative 3: 54.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + z \cdot x\\ t_2 := x - z \cdot t\\ \mathbf{if}\;y \leq -2.8 \cdot 10^{-28}:\\ \;\;\;\;x + y \cdot t\\ \mathbf{elif}\;y \leq -1.55 \cdot 10^{-257}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -3 \cdot 10^{-287}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-62}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 32:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (* z x))) (t_2 (- x (* z t))))
   (if (<= y -2.8e-28)
     (+ x (* y t))
     (if (<= y -1.55e-257)
       t_2
       (if (<= y -3e-287)
         t_1
         (if (<= y 1.4e-62) t_2 (if (<= y 32.0) t_1 (- x (* y x)))))))))
double code(double x, double y, double z, double t) {
	double t_1 = x + (z * x);
	double t_2 = x - (z * t);
	double tmp;
	if (y <= -2.8e-28) {
		tmp = x + (y * t);
	} else if (y <= -1.55e-257) {
		tmp = t_2;
	} else if (y <= -3e-287) {
		tmp = t_1;
	} else if (y <= 1.4e-62) {
		tmp = t_2;
	} else if (y <= 32.0) {
		tmp = t_1;
	} else {
		tmp = x - (y * 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) :: t_2
    real(8) :: tmp
    t_1 = x + (z * x)
    t_2 = x - (z * t)
    if (y <= (-2.8d-28)) then
        tmp = x + (y * t)
    else if (y <= (-1.55d-257)) then
        tmp = t_2
    else if (y <= (-3d-287)) then
        tmp = t_1
    else if (y <= 1.4d-62) then
        tmp = t_2
    else if (y <= 32.0d0) then
        tmp = t_1
    else
        tmp = x - (y * x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x + (z * x);
	double t_2 = x - (z * t);
	double tmp;
	if (y <= -2.8e-28) {
		tmp = x + (y * t);
	} else if (y <= -1.55e-257) {
		tmp = t_2;
	} else if (y <= -3e-287) {
		tmp = t_1;
	} else if (y <= 1.4e-62) {
		tmp = t_2;
	} else if (y <= 32.0) {
		tmp = t_1;
	} else {
		tmp = x - (y * x);
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x + (z * x)
	t_2 = x - (z * t)
	tmp = 0
	if y <= -2.8e-28:
		tmp = x + (y * t)
	elif y <= -1.55e-257:
		tmp = t_2
	elif y <= -3e-287:
		tmp = t_1
	elif y <= 1.4e-62:
		tmp = t_2
	elif y <= 32.0:
		tmp = t_1
	else:
		tmp = x - (y * x)
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x + Float64(z * x))
	t_2 = Float64(x - Float64(z * t))
	tmp = 0.0
	if (y <= -2.8e-28)
		tmp = Float64(x + Float64(y * t));
	elseif (y <= -1.55e-257)
		tmp = t_2;
	elseif (y <= -3e-287)
		tmp = t_1;
	elseif (y <= 1.4e-62)
		tmp = t_2;
	elseif (y <= 32.0)
		tmp = t_1;
	else
		tmp = Float64(x - Float64(y * x));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + (z * x);
	t_2 = x - (z * t);
	tmp = 0.0;
	if (y <= -2.8e-28)
		tmp = x + (y * t);
	elseif (y <= -1.55e-257)
		tmp = t_2;
	elseif (y <= -3e-287)
		tmp = t_1;
	elseif (y <= 1.4e-62)
		tmp = t_2;
	elseif (y <= 32.0)
		tmp = t_1;
	else
		tmp = x - (y * x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.8e-28], N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.55e-257], t$95$2, If[LessEqual[y, -3e-287], t$95$1, If[LessEqual[y, 1.4e-62], t$95$2, If[LessEqual[y, 32.0], t$95$1, N[(x - N[(y * x), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + z \cdot x\\
t_2 := x - z \cdot t\\
\mathbf{if}\;y \leq -2.8 \cdot 10^{-28}:\\
\;\;\;\;x + y \cdot t\\

\mathbf{elif}\;y \leq -1.55 \cdot 10^{-257}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y \leq -3 \cdot 10^{-287}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 1.4 \cdot 10^{-62}:\\
\;\;\;\;t_2\\

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

\mathbf{else}:\\
\;\;\;\;x - y \cdot x\\


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

    1. Initial program 100.0%

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

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

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

    if -2.7999999999999998e-28 < y < -1.55000000000000004e-257 or -2.99999999999999992e-287 < y < 1.40000000000000001e-62

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -1.55000000000000004e-257 < y < -2.99999999999999992e-287 or 1.40000000000000001e-62 < y < 32

    1. Initial program 99.9%

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

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

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

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

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

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

    if 32 < y

    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. Taylor expanded in t around 0 64.0%

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

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

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

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

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

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

      \[\leadsto x - \color{blue}{y \cdot x} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification63.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.8 \cdot 10^{-28}:\\ \;\;\;\;x + y \cdot t\\ \mathbf{elif}\;y \leq -1.55 \cdot 10^{-257}:\\ \;\;\;\;x - z \cdot t\\ \mathbf{elif}\;y \leq -3 \cdot 10^{-287}:\\ \;\;\;\;x + z \cdot x\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-62}:\\ \;\;\;\;x - z \cdot t\\ \mathbf{elif}\;y \leq 32:\\ \;\;\;\;x + z \cdot x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot x\\ \end{array} \]

Alternative 4: 69.9% accurate, 0.8× speedup?

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

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

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

\mathbf{elif}\;x \leq 4.5 \cdot 10^{+257}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;x - y \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.10000000000000004e145 or 6.40000000000000032e118 < x < 4.4999999999999999e257

    1. Initial program 100.0%

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

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

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

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

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

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

    if -1.10000000000000004e145 < x < 6.40000000000000032e118

    1. Initial program 99.9%

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

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

    if 4.4999999999999999e257 < x

    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. Taylor expanded in t around 0 100.0%

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

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

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

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

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

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

      \[\leadsto x - \color{blue}{y \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification75.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+145}:\\ \;\;\;\;x + z \cdot x\\ \mathbf{elif}\;x \leq 6.4 \cdot 10^{+118}:\\ \;\;\;\;x - t \cdot \left(z - y\right)\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{+257}:\\ \;\;\;\;x + z \cdot x\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot x\\ \end{array} \]

Alternative 5: 77.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.028 \lor \neg \left(z \leq 190\right):\\
\;\;\;\;x + z \cdot \left(x - t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.0280000000000000006 or 190 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0280000000000000006 < z < 190

    1. Initial program 99.9%

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

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

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

Alternative 6: 84.9% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+39} \lor \neg \left(y \leq 2.6 \cdot 10^{+15}\right):\\
\;\;\;\;x - y \cdot \left(x - t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.2000000000000005e39 or 2.6e15 < y

    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. Taylor expanded in z around 0 81.6%

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

    if -6.2000000000000005e39 < y < 2.6e15

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 81.3% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.4 \cdot 10^{-65} \lor \neg \left(t \leq 2.95 \cdot 10^{+16}\right):\\
\;\;\;\;x - t \cdot \left(z - y\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -3.39999999999999987e-65 or 2.95e16 < t

    1. Initial program 100.0%

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

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

    if -3.39999999999999987e-65 < t < 2.95e16

    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. Taylor expanded in t around 0 88.2%

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

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

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

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

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

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

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

Alternative 8: 53.5% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.60000000000000003e-11 or 5.3e6 < z

    1. Initial program 100.0%

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

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

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

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

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

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

    if -8.60000000000000003e-11 < z < 5.3e6

    1. Initial program 99.9%

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

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

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

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

Alternative 9: 100.0% accurate, 1.0× speedup?

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

\\
x - \left(y - z\right) \cdot \left(x - t\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(x - t\right) \]

Alternative 10: 41.8% accurate, 1.8× speedup?

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

\\
x + y \cdot t
\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 60.4%

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

    \[\leadsto \color{blue}{y \cdot t + x} \]
  4. Final simplification38.8%

    \[\leadsto x + y \cdot t \]

Alternative 11: 17.5% 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 60.4%

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

    \[\leadsto \color{blue}{x} \]
  4. Final simplification16.5%

    \[\leadsto x \]

Developer target: 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 2023182 
(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))))