Data.Metrics.Snapshot:quantile from metrics-0.3.0.2

Percentage Accurate: 100.0% → 100.0%
Time: 9.4s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 100.0% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 1.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 2: 71.2% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x - x \cdot y\\ t_2 := z \cdot \left(x - t\right)\\ t_3 := x + y \cdot t\\ \mathbf{if}\;z \leq -1.55 \cdot 10^{-9}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.45 \cdot 10^{-199}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{-226}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-131}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6200000000:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- x (* x y))) (t_2 (* z (- x t))) (t_3 (+ x (* y t))))
   (if (<= z -1.55e-9)
     t_2
     (if (<= z -2.45e-199)
       t_3
       (if (<= z -1.5e-226)
         t_1
         (if (<= z 2.4e-131)
           t_3
           (if (<= z 9.5e-24) t_1 (if (<= z 6200000000.0) t_3 t_2))))))))
double code(double x, double y, double z, double t) {
	double t_1 = x - (x * y);
	double t_2 = z * (x - t);
	double t_3 = x + (y * t);
	double tmp;
	if (z <= -1.55e-9) {
		tmp = t_2;
	} else if (z <= -2.45e-199) {
		tmp = t_3;
	} else if (z <= -1.5e-226) {
		tmp = t_1;
	} else if (z <= 2.4e-131) {
		tmp = t_3;
	} else if (z <= 9.5e-24) {
		tmp = t_1;
	} else if (z <= 6200000000.0) {
		tmp = t_3;
	} else {
		tmp = t_2;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_1 = x - (x * y)
    t_2 = z * (x - t)
    t_3 = x + (y * t)
    if (z <= (-1.55d-9)) then
        tmp = t_2
    else if (z <= (-2.45d-199)) then
        tmp = t_3
    else if (z <= (-1.5d-226)) then
        tmp = t_1
    else if (z <= 2.4d-131) then
        tmp = t_3
    else if (z <= 9.5d-24) then
        tmp = t_1
    else if (z <= 6200000000.0d0) then
        tmp = t_3
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = x - (x * y);
	double t_2 = z * (x - t);
	double t_3 = x + (y * t);
	double tmp;
	if (z <= -1.55e-9) {
		tmp = t_2;
	} else if (z <= -2.45e-199) {
		tmp = t_3;
	} else if (z <= -1.5e-226) {
		tmp = t_1;
	} else if (z <= 2.4e-131) {
		tmp = t_3;
	} else if (z <= 9.5e-24) {
		tmp = t_1;
	} else if (z <= 6200000000.0) {
		tmp = t_3;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = x - (x * y)
	t_2 = z * (x - t)
	t_3 = x + (y * t)
	tmp = 0
	if z <= -1.55e-9:
		tmp = t_2
	elif z <= -2.45e-199:
		tmp = t_3
	elif z <= -1.5e-226:
		tmp = t_1
	elif z <= 2.4e-131:
		tmp = t_3
	elif z <= 9.5e-24:
		tmp = t_1
	elif z <= 6200000000.0:
		tmp = t_3
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t)
	t_1 = Float64(x - Float64(x * y))
	t_2 = Float64(z * Float64(x - t))
	t_3 = Float64(x + Float64(y * t))
	tmp = 0.0
	if (z <= -1.55e-9)
		tmp = t_2;
	elseif (z <= -2.45e-199)
		tmp = t_3;
	elseif (z <= -1.5e-226)
		tmp = t_1;
	elseif (z <= 2.4e-131)
		tmp = t_3;
	elseif (z <= 9.5e-24)
		tmp = t_1;
	elseif (z <= 6200000000.0)
		tmp = t_3;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = x - (x * y);
	t_2 = z * (x - t);
	t_3 = x + (y * t);
	tmp = 0.0;
	if (z <= -1.55e-9)
		tmp = t_2;
	elseif (z <= -2.45e-199)
		tmp = t_3;
	elseif (z <= -1.5e-226)
		tmp = t_1;
	elseif (z <= 2.4e-131)
		tmp = t_3;
	elseif (z <= 9.5e-24)
		tmp = t_1;
	elseif (z <= 6200000000.0)
		tmp = t_3;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x + N[(y * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.55e-9], t$95$2, If[LessEqual[z, -2.45e-199], t$95$3, If[LessEqual[z, -1.5e-226], t$95$1, If[LessEqual[z, 2.4e-131], t$95$3, If[LessEqual[z, 9.5e-24], t$95$1, If[LessEqual[z, 6200000000.0], t$95$3, t$95$2]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.45 \cdot 10^{-199}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;z \leq -1.5 \cdot 10^{-226}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 2.4 \cdot 10^{-131}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;z \leq 9.5 \cdot 10^{-24}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \leq 6200000000:\\
\;\;\;\;t_3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.55000000000000002e-9 or 6.2e9 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55000000000000002e-9 < z < -2.45e-199 or -1.49999999999999998e-226 < z < 2.4e-131 or 9.50000000000000029e-24 < z < 6.2e9

    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-in98.9%

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

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

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

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

    if -2.45e-199 < z < -1.49999999999999998e-226 or 2.4e-131 < z < 9.50000000000000029e-24

    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 z around 0 79.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.55 \cdot 10^{-9}:\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{elif}\;z \leq -2.45 \cdot 10^{-199}:\\ \;\;\;\;x + y \cdot t\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{-226}:\\ \;\;\;\;x - x \cdot y\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-131}:\\ \;\;\;\;x + y \cdot t\\ \mathbf{elif}\;z \leq 9.5 \cdot 10^{-24}:\\ \;\;\;\;x - x \cdot y\\ \mathbf{elif}\;z \leq 6200000000:\\ \;\;\;\;x + y \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x - t\right)\\ \end{array} \]

Alternative 3: 37.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := z \cdot \left(-t\right)\\ \mathbf{if}\;z \leq -1.12 \cdot 10^{+72}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-16}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.5:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+108} \lor \neg \left(z \leq 1.65 \cdot 10^{+184}\right) \land z \leq 4.4 \cdot 10^{+229}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* z (- t))))
   (if (<= z -1.12e+72)
     (* x z)
     (if (<= z -2.6e-16)
       t_1
       (if (<= z 7.5)
         x
         (if (or (<= z 2.2e+108) (and (not (<= z 1.65e+184)) (<= z 4.4e+229)))
           t_1
           (* x z)))))))
double code(double x, double y, double z, double t) {
	double t_1 = z * -t;
	double tmp;
	if (z <= -1.12e+72) {
		tmp = x * z;
	} else if (z <= -2.6e-16) {
		tmp = t_1;
	} else if (z <= 7.5) {
		tmp = x;
	} else if ((z <= 2.2e+108) || (!(z <= 1.65e+184) && (z <= 4.4e+229))) {
		tmp = t_1;
	} else {
		tmp = x * z;
	}
	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 = z * -t
    if (z <= (-1.12d+72)) then
        tmp = x * z
    else if (z <= (-2.6d-16)) then
        tmp = t_1
    else if (z <= 7.5d0) then
        tmp = x
    else if ((z <= 2.2d+108) .or. (.not. (z <= 1.65d+184)) .and. (z <= 4.4d+229)) then
        tmp = t_1
    else
        tmp = x * z
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = z * -t;
	double tmp;
	if (z <= -1.12e+72) {
		tmp = x * z;
	} else if (z <= -2.6e-16) {
		tmp = t_1;
	} else if (z <= 7.5) {
		tmp = x;
	} else if ((z <= 2.2e+108) || (!(z <= 1.65e+184) && (z <= 4.4e+229))) {
		tmp = t_1;
	} else {
		tmp = x * z;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = z * -t
	tmp = 0
	if z <= -1.12e+72:
		tmp = x * z
	elif z <= -2.6e-16:
		tmp = t_1
	elif z <= 7.5:
		tmp = x
	elif (z <= 2.2e+108) or (not (z <= 1.65e+184) and (z <= 4.4e+229)):
		tmp = t_1
	else:
		tmp = x * z
	return tmp
function code(x, y, z, t)
	t_1 = Float64(z * Float64(-t))
	tmp = 0.0
	if (z <= -1.12e+72)
		tmp = Float64(x * z);
	elseif (z <= -2.6e-16)
		tmp = t_1;
	elseif (z <= 7.5)
		tmp = x;
	elseif ((z <= 2.2e+108) || (!(z <= 1.65e+184) && (z <= 4.4e+229)))
		tmp = t_1;
	else
		tmp = Float64(x * z);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = z * -t;
	tmp = 0.0;
	if (z <= -1.12e+72)
		tmp = x * z;
	elseif (z <= -2.6e-16)
		tmp = t_1;
	elseif (z <= 7.5)
		tmp = x;
	elseif ((z <= 2.2e+108) || (~((z <= 1.65e+184)) && (z <= 4.4e+229)))
		tmp = t_1;
	else
		tmp = x * z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * (-t)), $MachinePrecision]}, If[LessEqual[z, -1.12e+72], N[(x * z), $MachinePrecision], If[LessEqual[z, -2.6e-16], t$95$1, If[LessEqual[z, 7.5], x, If[Or[LessEqual[z, 2.2e+108], And[N[Not[LessEqual[z, 1.65e+184]], $MachinePrecision], LessEqual[z, 4.4e+229]]], t$95$1, N[(x * z), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -2.6 \cdot 10^{-16}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;z \leq 2.2 \cdot 10^{+108} \lor \neg \left(z \leq 1.65 \cdot 10^{+184}\right) \land z \leq 4.4 \cdot 10^{+229}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.12000000000000001e72 or 2.2000000000000001e108 < z < 1.6499999999999999e184 or 4.40000000000000007e229 < z

    1. Initial program 100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{z \cdot x + x} \]
    6. Taylor expanded in z around inf 60.6%

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

    if -1.12000000000000001e72 < z < -2.5999999999999998e-16 or 7.5 < z < 2.2000000000000001e108 or 1.6499999999999999e184 < z < 4.40000000000000007e229

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.5999999999999998e-16 < z < 7.5

    1. Initial program 100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.12 \cdot 10^{+72}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-16}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{elif}\;z \leq 7.5:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+108} \lor \neg \left(z \leq 1.65 \cdot 10^{+184}\right) \land z \leq 4.4 \cdot 10^{+229}:\\ \;\;\;\;z \cdot \left(-t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]

Alternative 4: 75.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := z \cdot \left(x - t\right)\\ t_2 := x + \left(y - z\right) \cdot t\\ \mathbf{if}\;z \leq -4.4 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-199}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-214}:\\ \;\;\;\;x - x \cdot y\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+25}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* z (- x t))) (t_2 (+ x (* (- y z) t))))
   (if (<= z -4.4e+69)
     t_1
     (if (<= z -3.2e-199)
       t_2
       (if (<= z -8.5e-214) (- x (* x y)) (if (<= z 5e+25) t_2 t_1))))))
double code(double x, double y, double z, double t) {
	double t_1 = z * (x - t);
	double t_2 = x + ((y - z) * t);
	double tmp;
	if (z <= -4.4e+69) {
		tmp = t_1;
	} else if (z <= -3.2e-199) {
		tmp = t_2;
	} else if (z <= -8.5e-214) {
		tmp = x - (x * y);
	} else if (z <= 5e+25) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = z * (x - t)
    t_2 = x + ((y - z) * t)
    if (z <= (-4.4d+69)) then
        tmp = t_1
    else if (z <= (-3.2d-199)) then
        tmp = t_2
    else if (z <= (-8.5d-214)) then
        tmp = x - (x * y)
    else if (z <= 5d+25) then
        tmp = t_2
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = z * (x - t);
	double t_2 = x + ((y - z) * t);
	double tmp;
	if (z <= -4.4e+69) {
		tmp = t_1;
	} else if (z <= -3.2e-199) {
		tmp = t_2;
	} else if (z <= -8.5e-214) {
		tmp = x - (x * y);
	} else if (z <= 5e+25) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = z * (x - t)
	t_2 = x + ((y - z) * t)
	tmp = 0
	if z <= -4.4e+69:
		tmp = t_1
	elif z <= -3.2e-199:
		tmp = t_2
	elif z <= -8.5e-214:
		tmp = x - (x * y)
	elif z <= 5e+25:
		tmp = t_2
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(z * Float64(x - t))
	t_2 = Float64(x + Float64(Float64(y - z) * t))
	tmp = 0.0
	if (z <= -4.4e+69)
		tmp = t_1;
	elseif (z <= -3.2e-199)
		tmp = t_2;
	elseif (z <= -8.5e-214)
		tmp = Float64(x - Float64(x * y));
	elseif (z <= 5e+25)
		tmp = t_2;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = z * (x - t);
	t_2 = x + ((y - z) * t);
	tmp = 0.0;
	if (z <= -4.4e+69)
		tmp = t_1;
	elseif (z <= -3.2e-199)
		tmp = t_2;
	elseif (z <= -8.5e-214)
		tmp = x - (x * y);
	elseif (z <= 5e+25)
		tmp = t_2;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(x - t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.4e+69], t$95$1, If[LessEqual[z, -3.2e-199], t$95$2, If[LessEqual[z, -8.5e-214], N[(x - N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5e+25], t$95$2, t$95$1]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \leq -3.2 \cdot 10^{-199}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;z \leq -8.5 \cdot 10^{-214}:\\
\;\;\;\;x - x \cdot y\\

\mathbf{elif}\;z \leq 5 \cdot 10^{+25}:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -4.4000000000000003e69 or 5.00000000000000024e25 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.4000000000000003e69 < z < -3.1999999999999999e-199 or -8.5000000000000006e-214 < z < 5.00000000000000024e25

    1. Initial program 100.0%

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

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

    if -3.1999999999999999e-199 < z < -8.5000000000000006e-214

    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 z around 0 100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{+69}:\\ \;\;\;\;z \cdot \left(x - t\right)\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-199}:\\ \;\;\;\;x + \left(y - z\right) \cdot t\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-214}:\\ \;\;\;\;x - x \cdot y\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+25}:\\ \;\;\;\;x + \left(y - z\right) \cdot t\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(x - t\right)\\ \end{array} \]

Alternative 5: 84.1% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.115000000000000005 or 1.45e29 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.115000000000000005 < z < 1.45e29

    1. Initial program 100.0%

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

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

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

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

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

Alternative 6: 84.3% accurate, 0.8× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -0.104999999999999996 or 1.79999999999999988e29 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -0.104999999999999996 < z < 1.79999999999999988e29

    1. Initial program 100.0%

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

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

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

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

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

Alternative 7: 55.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{-12} \lor \neg \left(z \leq 3.8 \cdot 10^{-6}\right):\\
\;\;\;\;z \cdot \left(x - t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.29999999999999991e-12 or 3.8e-6 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.29999999999999991e-12 < z < 3.8e-6

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

Alternative 8: 71.5% accurate, 1.0× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -4.4999999999999998e-14 or 2.55e12 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.4999999999999998e-14 < z < 2.55e12

    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-in99.1%

        \[\leadsto x + \color{blue}{\left(\left(y - z\right) \cdot t + \left(y - z\right) \cdot \left(-x\right)\right)} \]
    3. Applied egg-rr99.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 z around 0 90.4%

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

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

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

Alternative 9: 36.6% accurate, 1.3× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.55e9 or 0.0189999999999999995 < z

    1. Initial program 100.0%

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

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

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

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

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

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

      \[\leadsto \color{blue}{z \cdot x + x} \]
    6. Taylor expanded in z around inf 46.0%

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

    if -1.55e9 < z < 0.0189999999999999995

    1. Initial program 100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1550000000:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 0.019:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot z\\ \end{array} \]

Alternative 10: 17.6% 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 y around 0 64.9%

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

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

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

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

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

    \[\leadsto \color{blue}{x} \]
  6. Final simplification17.9%

    \[\leadsto x \]

Developer target: 96.4% accurate, 0.6× speedup?

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

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

Reproduce

?
herbie shell --seed 2023279 
(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))))