Data.Metrics.Snapshot:quantile from metrics-0.3.0.2

Percentage Accurate: 100.0% → 100.0%
Time: 5.4s
Alternatives: 9
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 9 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(t - x\right) \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (* (- y z) (- t x))))
double code(double x, double y, double z, double t) {
	return x + ((y - z) * (t - x));
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y - z) * (t - x))
end function
public static double code(double x, double y, double z, double t) {
	return x + ((y - z) * (t - x));
}
def code(x, y, z, t):
	return x + ((y - z) * (t - x))
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y - z) * Float64(t - x)))
end
function tmp = code(x, y, z, t)
	tmp = x + ((y - z) * (t - x));
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

Alternative 2: 54.6% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;z \leq 2.95 \cdot 10^{+26}:\\
\;\;\;\;x + y \cdot t\\

\mathbf{elif}\;z \leq 2.7 \cdot 10^{+250} \lor \neg \left(z \leq 3 \cdot 10^{+258}\right):\\
\;\;\;\;x - z \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -1.59999999999999986e30

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto x + z \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-t\right)\right)} \]
      6. remove-double-neg74.0%

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{z \cdot x} \]
    10. Simplified48.1%

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

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

    if -1.59999999999999986e30 < z < 2.95000000000000015e26

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto x + x \cdot \color{blue}{\frac{t \cdot \left(y - z\right)}{x}} \]
    7. Step-by-step derivation
      1. associate-/l*57.4%

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

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

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

    if 2.95000000000000015e26 < z < 2.7e250 or 3e258 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto x + x \cdot \color{blue}{\frac{t \cdot \left(y - z\right)}{x}} \]
    7. Step-by-step derivation
      1. associate-/l*51.5%

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

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

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

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

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

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

    if 2.7e250 < z < 3e258

    1. Initial program 99.7%

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

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

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

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

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

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

        \[\leadsto x + z \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-t\right)\right)} \]
      6. remove-double-neg99.7%

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{z \cdot x} \]
    10. Simplified92.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.6 \cdot 10^{+30}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 2.95 \cdot 10^{+26}:\\ \;\;\;\;x + y \cdot t\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{+250} \lor \neg \left(z \leq 3 \cdot 10^{+258}\right):\\ \;\;\;\;x - z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 84.0% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+53} \lor \neg \left(z \leq 2.2 \cdot 10^{+44}\right):\\
\;\;\;\;x + z \cdot \left(x - t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.19999999999999996e53 or 2.19999999999999996e44 < z

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto x + z \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-t\right)\right)} \]
      6. remove-double-neg85.7%

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

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

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

    if -5.19999999999999996e53 < z < 2.19999999999999996e44

    1. Initial program 100.0%

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

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

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

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

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

Alternative 4: 76.5% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+30} \lor \neg \left(z \leq 1.2 \cdot 10^{+55}\right):\\
\;\;\;\;x + z \cdot \left(x - t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.25e30 or 1.2e55 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

    if -1.25e30 < z < 1.2e55

    1. Initial program 100.0%

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

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

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

Alternative 5: 70.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -7.5 \cdot 10^{-131} \lor \neg \left(t \leq 8.8 \cdot 10^{-144}\right):\\
\;\;\;\;x + \left(y - z\right) \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -7.49999999999999964e-131 or 8.80000000000000025e-144 < t

    1. Initial program 100.0%

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

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

    if -7.49999999999999964e-131 < t < 8.80000000000000025e-144

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto x + z \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-t\right)\right)} \]
      6. remove-double-neg64.0%

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{z \cdot x} \]
    10. Simplified57.1%

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

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

Alternative 6: 54.5% accurate, 0.6× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.69999999999999991e29 or 2.1000000000000001e51 < z

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{z \cdot x} \]
    10. Simplified42.7%

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

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

    if -1.69999999999999991e29 < z < 2.1000000000000001e51

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto x + x \cdot \color{blue}{\frac{t \cdot \left(y - z\right)}{x}} \]
    7. Step-by-step derivation
      1. associate-/l*57.3%

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

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

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

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

Alternative 7: 54.4% accurate, 0.6× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.64999999999999996e31

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto x + z \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-t\right)\right)} \]
      6. remove-double-neg74.0%

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{z \cdot x} \]
    10. Simplified48.1%

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

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

    if -1.64999999999999996e31 < z < 2.2e52

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto x + x \cdot \color{blue}{\frac{t \cdot \left(y - z\right)}{x}} \]
    7. Step-by-step derivation
      1. associate-/l*57.3%

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

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

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

    if 2.2e52 < z

    1. Initial program 99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{z \cdot x} \]
    10. Simplified37.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.65 \cdot 10^{+31}:\\ \;\;\;\;x \cdot z\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+52}:\\ \;\;\;\;x + y \cdot t\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot z\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 37.0% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-5} \lor \neg \left(z \leq 0.215\right):\\
\;\;\;\;x \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.00000000000000008e-5 or 0.214999999999999997 < z

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto x + z \cdot \color{blue}{\left(\left(-\left(-x\right)\right) + \left(-t\right)\right)} \]
      6. remove-double-neg75.7%

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{z \cdot x} \]
    10. Simplified36.9%

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

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

    if -1.00000000000000008e-5 < z < 0.214999999999999997

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x + \color{blue}{z \cdot x} \]
    10. Simplified32.5%

      \[\leadsto x + \color{blue}{z \cdot x} \]
    11. Taylor expanded in z around 0 32.2%

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

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

Alternative 9: 17.7% accurate, 9.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto x + \color{blue}{\left(z \cdot x + z \cdot \left(-t\right)\right)} \]
  7. Applied egg-rr55.8%

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

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

      \[\leadsto x + \color{blue}{z \cdot x} \]
  10. Simplified34.6%

    \[\leadsto x + \color{blue}{z \cdot x} \]
  11. Taylor expanded in z around 0 18.0%

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

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

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

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