Data.HashTable.ST.Basic:computeOverhead from hashtables-1.2.0.2

Percentage Accurate: 86.3% → 99.1%
Time: 11.0s
Alternatives: 11
Speedup: 1.3×

Specification

?
\[\begin{array}{l} \\ \frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
double code(double x, double y, double z, double t) {
	return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * 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 / y) + ((2.0d0 + ((z * 2.0d0) * (1.0d0 - t))) / (t * z))
end function
public static double code(double x, double y, double z, double t) {
	return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
}
def code(x, y, z, t):
	return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z))
function code(x, y, z, t)
	return Float64(Float64(x / y) + Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z)))
end
function tmp = code(x, y, z, t)
	tmp = (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 86.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
double code(double x, double y, double z, double t) {
	return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * 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 / y) + ((2.0d0 + ((z * 2.0d0) * (1.0d0 - t))) / (t * z))
end function
public static double code(double x, double y, double z, double t) {
	return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
}
def code(x, y, z, t):
	return (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z))
function code(x, y, z, t)
	return Float64(Float64(x / y) + Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z)))
end
function tmp = code(x, y, z, t)
	tmp = (x / y) + ((2.0 + ((z * 2.0) * (1.0 - t))) / (t * z));
end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \left(-2 + \frac{x}{y}\right) + \frac{2 + \frac{2}{z}}{t} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (+ -2.0 (/ x y)) (/ (+ 2.0 (/ 2.0 z)) t)))
double code(double x, double y, double z, double t) {
	return (-2.0 + (x / y)) + ((2.0 + (2.0 / z)) / 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 = ((-2.0d0) + (x / y)) + ((2.0d0 + (2.0d0 / z)) / t)
end function
public static double code(double x, double y, double z, double t) {
	return (-2.0 + (x / y)) + ((2.0 + (2.0 / z)) / t);
}
def code(x, y, z, t):
	return (-2.0 + (x / y)) + ((2.0 + (2.0 / z)) / t)
function code(x, y, z, t)
	return Float64(Float64(-2.0 + Float64(x / y)) + Float64(Float64(2.0 + Float64(2.0 / z)) / t))
end
function tmp = code(x, y, z, t)
	tmp = (-2.0 + (x / y)) + ((2.0 + (2.0 / z)) / t);
end
code[x_, y_, z_, t_] := N[(N[(-2.0 + N[(x / y), $MachinePrecision]), $MachinePrecision] + N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

    \[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \]
  2. Step-by-step derivation
    1. +-commutative86.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot \left(1 - t\right)} + 1, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
    11. fma-define86.2%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(z, 1 - t, 1\right)}, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
    12. *-commutative86.2%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{\color{blue}{z \cdot t}}, -\frac{-x}{y}\right) \]
    13. distribute-frac-neg86.2%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, -\color{blue}{\left(-\frac{x}{y}\right)}\right) \]
    14. remove-double-neg86.2%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \color{blue}{\frac{x}{y}}\right) \]
  3. Simplified86.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \frac{x}{y}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in t around inf 99.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(-2 + \frac{x}{y}\right) + \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
  7. Simplified99.9%

    \[\leadsto \color{blue}{\left(-2 + \frac{x}{y}\right) + \frac{2 + \frac{2}{z}}{t}} \]
  8. Add Preprocessing

Alternative 2: 84.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{2 + \frac{2}{z}}{t}\\ t_2 := -2 + t\_1\\ \mathbf{if}\;\frac{x}{y} \leq -4 \cdot 10^{+115}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq -1 \cdot 10^{+60}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\frac{x}{y} \leq -5 \cdot 10^{+44}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq -2 \cdot 10^{+19}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\frac{x}{y} \leq -50:\\ \;\;\;\;\frac{x}{y} - 2\\ \mathbf{elif}\;\frac{x}{y} \leq 10^{+83}:\\ \;\;\;\;t\_2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (+ 2.0 (/ 2.0 z)) t)) (t_2 (+ -2.0 t_1)))
   (if (<= (/ x y) -4e+115)
     (/ x y)
     (if (<= (/ x y) -1e+60)
       t_2
       (if (<= (/ x y) -5e+44)
         (/ x y)
         (if (<= (/ x y) -2e+19)
           t_1
           (if (<= (/ x y) -50.0)
             (- (/ x y) 2.0)
             (if (<= (/ x y) 1e+83) t_2 (/ x y)))))))))
double code(double x, double y, double z, double t) {
	double t_1 = (2.0 + (2.0 / z)) / t;
	double t_2 = -2.0 + t_1;
	double tmp;
	if ((x / y) <= -4e+115) {
		tmp = x / y;
	} else if ((x / y) <= -1e+60) {
		tmp = t_2;
	} else if ((x / y) <= -5e+44) {
		tmp = x / y;
	} else if ((x / y) <= -2e+19) {
		tmp = t_1;
	} else if ((x / y) <= -50.0) {
		tmp = (x / y) - 2.0;
	} else if ((x / y) <= 1e+83) {
		tmp = t_2;
	} else {
		tmp = x / y;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (2.0d0 + (2.0d0 / z)) / t
    t_2 = (-2.0d0) + t_1
    if ((x / y) <= (-4d+115)) then
        tmp = x / y
    else if ((x / y) <= (-1d+60)) then
        tmp = t_2
    else if ((x / y) <= (-5d+44)) then
        tmp = x / y
    else if ((x / y) <= (-2d+19)) then
        tmp = t_1
    else if ((x / y) <= (-50.0d0)) then
        tmp = (x / y) - 2.0d0
    else if ((x / y) <= 1d+83) then
        tmp = t_2
    else
        tmp = x / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = (2.0 + (2.0 / z)) / t;
	double t_2 = -2.0 + t_1;
	double tmp;
	if ((x / y) <= -4e+115) {
		tmp = x / y;
	} else if ((x / y) <= -1e+60) {
		tmp = t_2;
	} else if ((x / y) <= -5e+44) {
		tmp = x / y;
	} else if ((x / y) <= -2e+19) {
		tmp = t_1;
	} else if ((x / y) <= -50.0) {
		tmp = (x / y) - 2.0;
	} else if ((x / y) <= 1e+83) {
		tmp = t_2;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (2.0 + (2.0 / z)) / t
	t_2 = -2.0 + t_1
	tmp = 0
	if (x / y) <= -4e+115:
		tmp = x / y
	elif (x / y) <= -1e+60:
		tmp = t_2
	elif (x / y) <= -5e+44:
		tmp = x / y
	elif (x / y) <= -2e+19:
		tmp = t_1
	elif (x / y) <= -50.0:
		tmp = (x / y) - 2.0
	elif (x / y) <= 1e+83:
		tmp = t_2
	else:
		tmp = x / y
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(2.0 + Float64(2.0 / z)) / t)
	t_2 = Float64(-2.0 + t_1)
	tmp = 0.0
	if (Float64(x / y) <= -4e+115)
		tmp = Float64(x / y);
	elseif (Float64(x / y) <= -1e+60)
		tmp = t_2;
	elseif (Float64(x / y) <= -5e+44)
		tmp = Float64(x / y);
	elseif (Float64(x / y) <= -2e+19)
		tmp = t_1;
	elseif (Float64(x / y) <= -50.0)
		tmp = Float64(Float64(x / y) - 2.0);
	elseif (Float64(x / y) <= 1e+83)
		tmp = t_2;
	else
		tmp = Float64(x / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (2.0 + (2.0 / z)) / t;
	t_2 = -2.0 + t_1;
	tmp = 0.0;
	if ((x / y) <= -4e+115)
		tmp = x / y;
	elseif ((x / y) <= -1e+60)
		tmp = t_2;
	elseif ((x / y) <= -5e+44)
		tmp = x / y;
	elseif ((x / y) <= -2e+19)
		tmp = t_1;
	elseif ((x / y) <= -50.0)
		tmp = (x / y) - 2.0;
	elseif ((x / y) <= 1e+83)
		tmp = t_2;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]}, Block[{t$95$2 = N[(-2.0 + t$95$1), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -4e+115], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], -1e+60], t$95$2, If[LessEqual[N[(x / y), $MachinePrecision], -5e+44], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], -2e+19], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], -50.0], N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 1e+83], t$95$2, N[(x / y), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{2 + \frac{2}{z}}{t}\\
t_2 := -2 + t\_1\\
\mathbf{if}\;\frac{x}{y} \leq -4 \cdot 10^{+115}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;\frac{x}{y} \leq -1 \cdot 10^{+60}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\frac{x}{y} \leq -5 \cdot 10^{+44}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;\frac{x}{y} \leq -2 \cdot 10^{+19}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\frac{x}{y} \leq -50:\\
\;\;\;\;\frac{x}{y} - 2\\

\mathbf{elif}\;\frac{x}{y} \leq 10^{+83}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 x y) < -4.0000000000000001e115 or -9.9999999999999995e59 < (/.f64 x y) < -4.9999999999999996e44 or 1.00000000000000003e83 < (/.f64 x y)

    1. Initial program 85.8%

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

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

    if -4.0000000000000001e115 < (/.f64 x y) < -9.9999999999999995e59 or -50 < (/.f64 x y) < 1.00000000000000003e83

    1. Initial program 86.4%

      \[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \]
    2. Step-by-step derivation
      1. +-commutative86.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot \left(1 - t\right)} + 1, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
      11. fma-define86.4%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(z, 1 - t, 1\right)}, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
      12. *-commutative86.4%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{\color{blue}{z \cdot t}}, -\frac{-x}{y}\right) \]
      13. distribute-frac-neg86.4%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, -\color{blue}{\left(-\frac{x}{y}\right)}\right) \]
      14. remove-double-neg86.4%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \color{blue}{\frac{x}{y}}\right) \]
    3. Simplified86.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \frac{x}{y}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-2 + \frac{x}{y}\right) + \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
    7. Simplified99.9%

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

      \[\leadsto \color{blue}{-2} + \frac{2 + \frac{2}{z}}{t} \]

    if -4.9999999999999996e44 < (/.f64 x y) < -2e19

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{\frac{2 + 2 \cdot \frac{1}{z}}{t}} \]
    4. Step-by-step derivation
      1. associate-*r/99.7%

        \[\leadsto \frac{2 + \color{blue}{\frac{2 \cdot 1}{z}}}{t} \]
      2. metadata-eval99.7%

        \[\leadsto \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
    5. Simplified99.7%

      \[\leadsto \color{blue}{\frac{2 + \frac{2}{z}}{t}} \]

    if -2e19 < (/.f64 x y) < -50

    1. Initial program 77.8%

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

      \[\leadsto \color{blue}{\frac{x}{y} - 2} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 3: 88.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{if}\;\frac{x}{y} \leq -4 \cdot 10^{+115}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\frac{x}{y} \leq -2 \cdot 10^{+88}:\\ \;\;\;\;\frac{2}{z \cdot t}\\ \mathbf{elif}\;\frac{x}{y} \leq -50 \lor \neg \left(\frac{x}{y} \leq 5 \cdot 10^{-9}\right):\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ (/ x y) (+ -2.0 (/ 2.0 t)))))
   (if (<= (/ x y) -4e+115)
     t_1
     (if (<= (/ x y) -2e+88)
       (/ 2.0 (* z t))
       (if (or (<= (/ x y) -50.0) (not (<= (/ x y) 5e-9)))
         t_1
         (+ -2.0 (/ (+ 2.0 (/ 2.0 z)) t)))))))
double code(double x, double y, double z, double t) {
	double t_1 = (x / y) + (-2.0 + (2.0 / t));
	double tmp;
	if ((x / y) <= -4e+115) {
		tmp = t_1;
	} else if ((x / y) <= -2e+88) {
		tmp = 2.0 / (z * t);
	} else if (((x / y) <= -50.0) || !((x / y) <= 5e-9)) {
		tmp = t_1;
	} else {
		tmp = -2.0 + ((2.0 + (2.0 / 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) :: t_1
    real(8) :: tmp
    t_1 = (x / y) + ((-2.0d0) + (2.0d0 / t))
    if ((x / y) <= (-4d+115)) then
        tmp = t_1
    else if ((x / y) <= (-2d+88)) then
        tmp = 2.0d0 / (z * t)
    else if (((x / y) <= (-50.0d0)) .or. (.not. ((x / y) <= 5d-9))) then
        tmp = t_1
    else
        tmp = (-2.0d0) + ((2.0d0 + (2.0d0 / z)) / t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = (x / y) + (-2.0 + (2.0 / t));
	double tmp;
	if ((x / y) <= -4e+115) {
		tmp = t_1;
	} else if ((x / y) <= -2e+88) {
		tmp = 2.0 / (z * t);
	} else if (((x / y) <= -50.0) || !((x / y) <= 5e-9)) {
		tmp = t_1;
	} else {
		tmp = -2.0 + ((2.0 + (2.0 / z)) / t);
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (x / y) + (-2.0 + (2.0 / t))
	tmp = 0
	if (x / y) <= -4e+115:
		tmp = t_1
	elif (x / y) <= -2e+88:
		tmp = 2.0 / (z * t)
	elif ((x / y) <= -50.0) or not ((x / y) <= 5e-9):
		tmp = t_1
	else:
		tmp = -2.0 + ((2.0 + (2.0 / z)) / t)
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(x / y) + Float64(-2.0 + Float64(2.0 / t)))
	tmp = 0.0
	if (Float64(x / y) <= -4e+115)
		tmp = t_1;
	elseif (Float64(x / y) <= -2e+88)
		tmp = Float64(2.0 / Float64(z * t));
	elseif ((Float64(x / y) <= -50.0) || !(Float64(x / y) <= 5e-9))
		tmp = t_1;
	else
		tmp = Float64(-2.0 + Float64(Float64(2.0 + Float64(2.0 / z)) / t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x / y) + (-2.0 + (2.0 / t));
	tmp = 0.0;
	if ((x / y) <= -4e+115)
		tmp = t_1;
	elseif ((x / y) <= -2e+88)
		tmp = 2.0 / (z * t);
	elseif (((x / y) <= -50.0) || ~(((x / y) <= 5e-9)))
		tmp = t_1;
	else
		tmp = -2.0 + ((2.0 + (2.0 / z)) / t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] + N[(-2.0 + N[(2.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -4e+115], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], -2e+88], N[(2.0 / N[(z * t), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(x / y), $MachinePrecision], -50.0], N[Not[LessEqual[N[(x / y), $MachinePrecision], 5e-9]], $MachinePrecision]], t$95$1, N[(-2.0 + N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\
\mathbf{if}\;\frac{x}{y} \leq -4 \cdot 10^{+115}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\frac{x}{y} \leq -2 \cdot 10^{+88}:\\
\;\;\;\;\frac{2}{z \cdot t}\\

\mathbf{elif}\;\frac{x}{y} \leq -50 \lor \neg \left(\frac{x}{y} \leq 5 \cdot 10^{-9}\right):\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 x y) < -4.0000000000000001e115 or -1.99999999999999992e88 < (/.f64 x y) < -50 or 5.0000000000000001e-9 < (/.f64 x y)

    1. Initial program 84.9%

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

      \[\leadsto \frac{x}{y} + \color{blue}{2 \cdot \frac{1 - t}{t}} \]
    4. Step-by-step derivation
      1. div-sub84.8%

        \[\leadsto \frac{x}{y} + 2 \cdot \color{blue}{\left(\frac{1}{t} - \frac{t}{t}\right)} \]
      2. sub-neg84.8%

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

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

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

        \[\leadsto \frac{x}{y} + \color{blue}{\left(2 \cdot \frac{1}{t} + 2 \cdot -1\right)} \]
      6. associate-*r/84.8%

        \[\leadsto \frac{x}{y} + \left(\color{blue}{\frac{2 \cdot 1}{t}} + 2 \cdot -1\right) \]
      7. metadata-eval84.8%

        \[\leadsto \frac{x}{y} + \left(\frac{\color{blue}{2}}{t} + 2 \cdot -1\right) \]
      8. metadata-eval84.8%

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

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

    if -4.0000000000000001e115 < (/.f64 x y) < -1.99999999999999992e88

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{2 + 2 \cdot \frac{1}{z}}{t}} \]
    4. Step-by-step derivation
      1. associate-*r/99.7%

        \[\leadsto \frac{2 + \color{blue}{\frac{2 \cdot 1}{z}}}{t} \]
      2. metadata-eval99.7%

        \[\leadsto \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
    5. Simplified99.7%

      \[\leadsto \color{blue}{\frac{2 + \frac{2}{z}}{t}} \]
    6. Taylor expanded in z around 0 100.0%

      \[\leadsto \color{blue}{\frac{2}{t \cdot z}} \]

    if -50 < (/.f64 x y) < 5.0000000000000001e-9

    1. Initial program 87.1%

      \[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \]
    2. Step-by-step derivation
      1. +-commutative87.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot \left(1 - t\right)} + 1, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
      11. fma-define87.1%

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{\color{blue}{z \cdot t}}, -\frac{-x}{y}\right) \]
      13. distribute-frac-neg87.1%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, -\color{blue}{\left(-\frac{x}{y}\right)}\right) \]
      14. remove-double-neg87.1%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \frac{x}{y}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-2 + \frac{x}{y}\right) + \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
    7. Simplified99.9%

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

      \[\leadsto \color{blue}{-2} + \frac{2 + \frac{2}{z}}{t} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification92.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -4 \cdot 10^{+115}:\\ \;\;\;\;\frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{elif}\;\frac{x}{y} \leq -2 \cdot 10^{+88}:\\ \;\;\;\;\frac{2}{z \cdot t}\\ \mathbf{elif}\;\frac{x}{y} \leq -50 \lor \neg \left(\frac{x}{y} \leq 5 \cdot 10^{-9}\right):\\ \;\;\;\;\frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;-2 + \frac{2 + \frac{2}{z}}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 70.8% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -1.45 \cdot 10^{+114}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;\frac{x}{y} \leq -1.85 \cdot 10^{+88}:\\
\;\;\;\;\frac{2}{z \cdot t}\\

\mathbf{elif}\;\frac{x}{y} \leq -1.65 \lor \neg \left(\frac{x}{y} \leq 0.35\right):\\
\;\;\;\;\frac{x}{y} - 2\\

\mathbf{else}:\\
\;\;\;\;-2 + \frac{\frac{2}{z}}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 x y) < -1.45e114

    1. Initial program 87.7%

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

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

    if -1.45e114 < (/.f64 x y) < -1.84999999999999997e88

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{2 + 2 \cdot \frac{1}{z}}{t}} \]
    4. Step-by-step derivation
      1. associate-*r/99.7%

        \[\leadsto \frac{2 + \color{blue}{\frac{2 \cdot 1}{z}}}{t} \]
      2. metadata-eval99.7%

        \[\leadsto \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
    5. Simplified99.7%

      \[\leadsto \color{blue}{\frac{2 + \frac{2}{z}}{t}} \]
    6. Taylor expanded in z around 0 100.0%

      \[\leadsto \color{blue}{\frac{2}{t \cdot z}} \]

    if -1.84999999999999997e88 < (/.f64 x y) < -1.6499999999999999 or 0.34999999999999998 < (/.f64 x y)

    1. Initial program 83.2%

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

      \[\leadsto \color{blue}{\frac{x}{y} - 2} \]

    if -1.6499999999999999 < (/.f64 x y) < 0.34999999999999998

    1. Initial program 87.1%

      \[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \]
    2. Step-by-step derivation
      1. +-commutative87.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot \left(1 - t\right)} + 1, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
      11. fma-define87.1%

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

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{\color{blue}{z \cdot t}}, -\frac{-x}{y}\right) \]
      13. distribute-frac-neg87.1%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, -\color{blue}{\left(-\frac{x}{y}\right)}\right) \]
      14. remove-double-neg87.1%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \frac{x}{y}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 99.9%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-2 + \frac{x}{y}\right) + \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
    7. Simplified99.9%

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

      \[\leadsto \color{blue}{-2} + \frac{2 + \frac{2}{z}}{t} \]
    9. Taylor expanded in z around 0 83.0%

      \[\leadsto -2 + \frac{\color{blue}{\frac{2}{z}}}{t} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification79.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.45 \cdot 10^{+114}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq -1.85 \cdot 10^{+88}:\\ \;\;\;\;\frac{2}{z \cdot t}\\ \mathbf{elif}\;\frac{x}{y} \leq -1.65 \lor \neg \left(\frac{x}{y} \leq 0.35\right):\\ \;\;\;\;\frac{x}{y} - 2\\ \mathbf{else}:\\ \;\;\;\;-2 + \frac{\frac{2}{z}}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 78.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{x}{y} - 2\\ \mathbf{if}\;t \leq -5.8 \cdot 10^{-12}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \leq 3.6 \cdot 10^{-93}:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \mathbf{elif}\;t \leq 1.8 \cdot 10^{+18}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;t \leq 1.12 \cdot 10^{+66}:\\ \;\;\;\;-2 + \frac{\frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (- (/ x y) 2.0)))
   (if (<= t -5.8e-12)
     t_1
     (if (<= t 3.6e-93)
       (/ (+ 2.0 (/ 2.0 z)) t)
       (if (<= t 1.8e+18)
         (/ x y)
         (if (<= t 1.12e+66) (+ -2.0 (/ (/ 2.0 z) t)) t_1))))))
double code(double x, double y, double z, double t) {
	double t_1 = (x / y) - 2.0;
	double tmp;
	if (t <= -5.8e-12) {
		tmp = t_1;
	} else if (t <= 3.6e-93) {
		tmp = (2.0 + (2.0 / z)) / t;
	} else if (t <= 1.8e+18) {
		tmp = x / y;
	} else if (t <= 1.12e+66) {
		tmp = -2.0 + ((2.0 / z) / t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (x / y) - 2.0d0
    if (t <= (-5.8d-12)) then
        tmp = t_1
    else if (t <= 3.6d-93) then
        tmp = (2.0d0 + (2.0d0 / z)) / t
    else if (t <= 1.8d+18) then
        tmp = x / y
    else if (t <= 1.12d+66) then
        tmp = (-2.0d0) + ((2.0d0 / z) / t)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = (x / y) - 2.0;
	double tmp;
	if (t <= -5.8e-12) {
		tmp = t_1;
	} else if (t <= 3.6e-93) {
		tmp = (2.0 + (2.0 / z)) / t;
	} else if (t <= 1.8e+18) {
		tmp = x / y;
	} else if (t <= 1.12e+66) {
		tmp = -2.0 + ((2.0 / z) / t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (x / y) - 2.0
	tmp = 0
	if t <= -5.8e-12:
		tmp = t_1
	elif t <= 3.6e-93:
		tmp = (2.0 + (2.0 / z)) / t
	elif t <= 1.8e+18:
		tmp = x / y
	elif t <= 1.12e+66:
		tmp = -2.0 + ((2.0 / z) / t)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(x / y) - 2.0)
	tmp = 0.0
	if (t <= -5.8e-12)
		tmp = t_1;
	elseif (t <= 3.6e-93)
		tmp = Float64(Float64(2.0 + Float64(2.0 / z)) / t);
	elseif (t <= 1.8e+18)
		tmp = Float64(x / y);
	elseif (t <= 1.12e+66)
		tmp = Float64(-2.0 + Float64(Float64(2.0 / z) / t));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x / y) - 2.0;
	tmp = 0.0;
	if (t <= -5.8e-12)
		tmp = t_1;
	elseif (t <= 3.6e-93)
		tmp = (2.0 + (2.0 / z)) / t;
	elseif (t <= 1.8e+18)
		tmp = x / y;
	elseif (t <= 1.12e+66)
		tmp = -2.0 + ((2.0 / z) / t);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision]}, If[LessEqual[t, -5.8e-12], t$95$1, If[LessEqual[t, 3.6e-93], N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[t, 1.8e+18], N[(x / y), $MachinePrecision], If[LessEqual[t, 1.12e+66], N[(-2.0 + N[(N[(2.0 / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{x}{y} - 2\\
\mathbf{if}\;t \leq -5.8 \cdot 10^{-12}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \leq 3.6 \cdot 10^{-93}:\\
\;\;\;\;\frac{2 + \frac{2}{z}}{t}\\

\mathbf{elif}\;t \leq 1.8 \cdot 10^{+18}:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;t \leq 1.12 \cdot 10^{+66}:\\
\;\;\;\;-2 + \frac{\frac{2}{z}}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if t < -5.8000000000000003e-12 or 1.12e66 < t

    1. Initial program 71.9%

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

      \[\leadsto \color{blue}{\frac{x}{y} - 2} \]

    if -5.8000000000000003e-12 < t < 3.6000000000000002e-93

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\frac{2 + 2 \cdot \frac{1}{z}}{t}} \]
    4. Step-by-step derivation
      1. associate-*r/80.9%

        \[\leadsto \frac{2 + \color{blue}{\frac{2 \cdot 1}{z}}}{t} \]
      2. metadata-eval80.9%

        \[\leadsto \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
    5. Simplified80.9%

      \[\leadsto \color{blue}{\frac{2 + \frac{2}{z}}{t}} \]

    if 3.6000000000000002e-93 < t < 1.8e18

    1. Initial program 99.9%

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

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

    if 1.8e18 < t < 1.12e66

    1. Initial program 99.9%

      \[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \]
    2. Step-by-step derivation
      1. +-commutative99.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot \left(1 - t\right)} + 1, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
      11. fma-define99.9%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(z, 1 - t, 1\right)}, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
      12. *-commutative99.9%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{\color{blue}{z \cdot t}}, -\frac{-x}{y}\right) \]
      13. distribute-frac-neg99.9%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, -\color{blue}{\left(-\frac{x}{y}\right)}\right) \]
      14. remove-double-neg99.9%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \color{blue}{\frac{x}{y}}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \frac{x}{y}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in t around inf 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-2} + \frac{2 + \frac{2}{z}}{t} \]
    9. Taylor expanded in z around 0 73.2%

      \[\leadsto -2 + \frac{\color{blue}{\frac{2}{z}}}{t} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 6: 53.2% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -2:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 3 \cdot 10^{-15}:\\ \;\;\;\;-2\\ \mathbf{elif}\;\frac{x}{y} \leq 4.8 \cdot 10^{+25}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ x y) -2.0)
   (/ x y)
   (if (<= (/ x y) 3e-15) -2.0 (if (<= (/ x y) 4.8e+25) (/ 2.0 t) (/ x y)))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x / y) <= -2.0) {
		tmp = x / y;
	} else if ((x / y) <= 3e-15) {
		tmp = -2.0;
	} else if ((x / y) <= 4.8e+25) {
		tmp = 2.0 / t;
	} else {
		tmp = x / y;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((x / y) <= (-2.0d0)) then
        tmp = x / y
    else if ((x / y) <= 3d-15) then
        tmp = -2.0d0
    else if ((x / y) <= 4.8d+25) then
        tmp = 2.0d0 / t
    else
        tmp = x / y
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if ((x / y) <= -2.0) {
		tmp = x / y;
	} else if ((x / y) <= 3e-15) {
		tmp = -2.0;
	} else if ((x / y) <= 4.8e+25) {
		tmp = 2.0 / t;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (x / y) <= -2.0:
		tmp = x / y
	elif (x / y) <= 3e-15:
		tmp = -2.0
	elif (x / y) <= 4.8e+25:
		tmp = 2.0 / t
	else:
		tmp = x / y
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(x / y) <= -2.0)
		tmp = Float64(x / y);
	elseif (Float64(x / y) <= 3e-15)
		tmp = -2.0;
	elseif (Float64(x / y) <= 4.8e+25)
		tmp = Float64(2.0 / t);
	else
		tmp = Float64(x / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((x / y) <= -2.0)
		tmp = x / y;
	elseif ((x / y) <= 3e-15)
		tmp = -2.0;
	elseif ((x / y) <= 4.8e+25)
		tmp = 2.0 / t;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -2.0], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 3e-15], -2.0, If[LessEqual[N[(x / y), $MachinePrecision], 4.8e+25], N[(2.0 / t), $MachinePrecision], N[(x / y), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -2:\\
\;\;\;\;\frac{x}{y}\\

\mathbf{elif}\;\frac{x}{y} \leq 3 \cdot 10^{-15}:\\
\;\;\;\;-2\\

\mathbf{elif}\;\frac{x}{y} \leq 4.8 \cdot 10^{+25}:\\
\;\;\;\;\frac{2}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 x y) < -2 or 4.79999999999999992e25 < (/.f64 x y)

    1. Initial program 85.3%

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

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

    if -2 < (/.f64 x y) < 3e-15

    1. Initial program 86.7%

      \[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \]
    2. Step-by-step derivation
      1. +-commutative86.7%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\left(1 - t\right) \cdot z + 1, \frac{2}{t \cdot z}, -\frac{-x}{y}\right)} \]
      10. *-commutative86.6%

        \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot \left(1 - t\right)} + 1, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
      11. fma-define86.6%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(z, 1 - t, 1\right)}, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
      12. *-commutative86.6%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{\color{blue}{z \cdot t}}, -\frac{-x}{y}\right) \]
      13. distribute-frac-neg86.6%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, -\color{blue}{\left(-\frac{x}{y}\right)}\right) \]
      14. remove-double-neg86.6%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \color{blue}{\frac{x}{y}}\right) \]
    3. Simplified86.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \frac{x}{y}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 54.0%

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

      \[\leadsto \frac{x + \color{blue}{-2 \cdot y}}{y} \]
    7. Taylor expanded in x around 0 40.8%

      \[\leadsto \color{blue}{-2} \]

    if 3e-15 < (/.f64 x y) < 4.79999999999999992e25

    1. Initial program 91.5%

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

      \[\leadsto \color{blue}{\frac{2 + 2 \cdot \frac{1}{z}}{t}} \]
    4. Step-by-step derivation
      1. associate-*r/67.9%

        \[\leadsto \frac{2 + \color{blue}{\frac{2 \cdot 1}{z}}}{t} \]
      2. metadata-eval67.9%

        \[\leadsto \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
    5. Simplified67.9%

      \[\leadsto \color{blue}{\frac{2 + \frac{2}{z}}{t}} \]
    6. Taylor expanded in z around inf 59.9%

      \[\leadsto \color{blue}{\frac{2}{t}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 91.1% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{-62} \lor \neg \left(z \leq 2.5 \cdot 10^{-47}\right):\\
\;\;\;\;\frac{x}{y} + \left(-2 + \frac{2}{t}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + \frac{\frac{2}{t}}{z}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -1.69999999999999994e-62 or 2.50000000000000006e-47 < z

    1. Initial program 75.9%

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

      \[\leadsto \frac{x}{y} + \color{blue}{2 \cdot \frac{1 - t}{t}} \]
    4. Step-by-step derivation
      1. div-sub96.6%

        \[\leadsto \frac{x}{y} + 2 \cdot \color{blue}{\left(\frac{1}{t} - \frac{t}{t}\right)} \]
      2. sub-neg96.6%

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

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

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

        \[\leadsto \frac{x}{y} + \color{blue}{\left(2 \cdot \frac{1}{t} + 2 \cdot -1\right)} \]
      6. associate-*r/96.6%

        \[\leadsto \frac{x}{y} + \left(\color{blue}{\frac{2 \cdot 1}{t}} + 2 \cdot -1\right) \]
      7. metadata-eval96.6%

        \[\leadsto \frac{x}{y} + \left(\frac{\color{blue}{2}}{t} + 2 \cdot -1\right) \]
      8. metadata-eval96.6%

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

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

    if -1.69999999999999994e-62 < z < 2.50000000000000006e-47

    1. Initial program 99.9%

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

      \[\leadsto \frac{x}{y} + \color{blue}{\frac{2}{t \cdot z}} \]
    4. Step-by-step derivation
      1. associate-/r*93.7%

        \[\leadsto \frac{x}{y} + \color{blue}{\frac{\frac{2}{t}}{z}} \]
    5. Simplified93.7%

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

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

Alternative 8: 63.7% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-113} \lor \neg \left(z \leq 4.6 \cdot 10^{-61}\right):\\
\;\;\;\;\frac{x}{y} - 2\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{z \cdot t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.4999999999999995e-113 or 4.59999999999999984e-61 < z

    1. Initial program 78.0%

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

      \[\leadsto \color{blue}{\frac{x}{y} - 2} \]

    if -8.4999999999999995e-113 < z < 4.59999999999999984e-61

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\frac{2 + 2 \cdot \frac{1}{z}}{t}} \]
    4. Step-by-step derivation
      1. associate-*r/73.5%

        \[\leadsto \frac{2 + \color{blue}{\frac{2 \cdot 1}{z}}}{t} \]
      2. metadata-eval73.5%

        \[\leadsto \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
    5. Simplified73.5%

      \[\leadsto \color{blue}{\frac{2 + \frac{2}{z}}{t}} \]
    6. Taylor expanded in z around 0 73.5%

      \[\leadsto \color{blue}{\frac{2}{t \cdot z}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -8.5 \cdot 10^{-113} \lor \neg \left(z \leq 4.6 \cdot 10^{-61}\right):\\ \;\;\;\;\frac{x}{y} - 2\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{z \cdot t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 59.4% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.6 \cdot 10^{-120} \lor \neg \left(t \leq 8.7 \cdot 10^{-231}\right):\\
\;\;\;\;\frac{x}{y} - 2\\

\mathbf{else}:\\
\;\;\;\;\frac{2}{t}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -4.59999999999999973e-120 or 8.7000000000000002e-231 < t

    1. Initial program 83.1%

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

      \[\leadsto \color{blue}{\frac{x}{y} - 2} \]

    if -4.59999999999999973e-120 < t < 8.7000000000000002e-231

    1. Initial program 99.7%

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

      \[\leadsto \color{blue}{\frac{2 + 2 \cdot \frac{1}{z}}{t}} \]
    4. Step-by-step derivation
      1. associate-*r/94.0%

        \[\leadsto \frac{2 + \color{blue}{\frac{2 \cdot 1}{z}}}{t} \]
      2. metadata-eval94.0%

        \[\leadsto \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
    5. Simplified94.0%

      \[\leadsto \color{blue}{\frac{2 + \frac{2}{z}}{t}} \]
    6. Taylor expanded in z around inf 44.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -4.6 \cdot 10^{-120} \lor \neg \left(t \leq 8.7 \cdot 10^{-231}\right):\\ \;\;\;\;\frac{x}{y} - 2\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{t}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 36.4% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -1:\\ \;\;\;\;-2\\ \mathbf{elif}\;t \leq 5.8 \cdot 10^{+28}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= t -1.0) -2.0 (if (<= t 5.8e+28) (/ 2.0 t) -2.0)))
double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -1.0) {
		tmp = -2.0;
	} else if (t <= 5.8e+28) {
		tmp = 2.0 / t;
	} else {
		tmp = -2.0;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (t <= (-1.0d0)) then
        tmp = -2.0d0
    else if (t <= 5.8d+28) then
        tmp = 2.0d0 / t
    else
        tmp = -2.0d0
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double tmp;
	if (t <= -1.0) {
		tmp = -2.0;
	} else if (t <= 5.8e+28) {
		tmp = 2.0 / t;
	} else {
		tmp = -2.0;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if t <= -1.0:
		tmp = -2.0
	elif t <= 5.8e+28:
		tmp = 2.0 / t
	else:
		tmp = -2.0
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (t <= -1.0)
		tmp = -2.0;
	elseif (t <= 5.8e+28)
		tmp = Float64(2.0 / t);
	else
		tmp = -2.0;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if (t <= -1.0)
		tmp = -2.0;
	elseif (t <= 5.8e+28)
		tmp = 2.0 / t;
	else
		tmp = -2.0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.0], -2.0, If[LessEqual[t, 5.8e+28], N[(2.0 / t), $MachinePrecision], -2.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;t \leq -1:\\
\;\;\;\;-2\\

\mathbf{elif}\;t \leq 5.8 \cdot 10^{+28}:\\
\;\;\;\;\frac{2}{t}\\

\mathbf{else}:\\
\;\;\;\;-2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -1 or 5.8000000000000002e28 < t

    1. Initial program 73.4%

      \[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \]
    2. Step-by-step derivation
      1. +-commutative73.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot \left(1 - t\right)} + 1, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
      11. fma-define73.4%

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(z, 1 - t, 1\right)}, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
      12. *-commutative73.4%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{\color{blue}{z \cdot t}}, -\frac{-x}{y}\right) \]
      13. distribute-frac-neg73.4%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, -\color{blue}{\left(-\frac{x}{y}\right)}\right) \]
      14. remove-double-neg73.4%

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \color{blue}{\frac{x}{y}}\right) \]
    3. Simplified73.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \frac{x}{y}\right)} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 51.4%

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

      \[\leadsto \frac{x + \color{blue}{-2 \cdot y}}{y} \]
    7. Taylor expanded in x around 0 36.8%

      \[\leadsto \color{blue}{-2} \]

    if -1 < t < 5.8000000000000002e28

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\frac{2 + 2 \cdot \frac{1}{z}}{t}} \]
    4. Step-by-step derivation
      1. associate-*r/73.4%

        \[\leadsto \frac{2 + \color{blue}{\frac{2 \cdot 1}{z}}}{t} \]
      2. metadata-eval73.4%

        \[\leadsto \frac{2 + \frac{\color{blue}{2}}{z}}{t} \]
    5. Simplified73.4%

      \[\leadsto \color{blue}{\frac{2 + \frac{2}{z}}{t}} \]
    6. Taylor expanded in z around inf 28.4%

      \[\leadsto \color{blue}{\frac{2}{t}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 20.0% accurate, 17.0× speedup?

\[\begin{array}{l} \\ -2 \end{array} \]
(FPCore (x y z t) :precision binary64 -2.0)
double code(double x, double y, double z, double t) {
	return -2.0;
}
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 = -2.0d0
end function
public static double code(double x, double y, double z, double t) {
	return -2.0;
}
def code(x, y, z, t):
	return -2.0
function code(x, y, z, t)
	return -2.0
end
function tmp = code(x, y, z, t)
	tmp = -2.0;
end
code[x_, y_, z_, t_] := -2.0
\begin{array}{l}

\\
-2
\end{array}
Derivation
  1. Initial program 86.2%

    \[\frac{x}{y} + \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z} \]
  2. Step-by-step derivation
    1. +-commutative86.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{z \cdot \left(1 - t\right)} + 1, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
    11. fma-define86.2%

      \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(z, 1 - t, 1\right)}, \frac{2}{t \cdot z}, -\frac{-x}{y}\right) \]
    12. *-commutative86.2%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{\color{blue}{z \cdot t}}, -\frac{-x}{y}\right) \]
    13. distribute-frac-neg86.2%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, -\color{blue}{\left(-\frac{x}{y}\right)}\right) \]
    14. remove-double-neg86.2%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \color{blue}{\frac{x}{y}}\right) \]
  3. Simplified86.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, 1 - t, 1\right), \frac{2}{z \cdot t}, \frac{x}{y}\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in y around 0 66.4%

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

    \[\leadsto \frac{x + \color{blue}{-2 \cdot y}}{y} \]
  7. Taylor expanded in x around 0 20.3%

    \[\leadsto \color{blue}{-2} \]
  8. Add Preprocessing

Developer target: 99.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \frac{\frac{2}{z} + 2}{t} - \left(2 - \frac{x}{y}\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (- (/ (+ (/ 2.0 z) 2.0) t) (- 2.0 (/ x y))))
double code(double x, double y, double z, double t) {
	return (((2.0 / z) + 2.0) / t) - (2.0 - (x / y));
}
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 = (((2.0d0 / z) + 2.0d0) / t) - (2.0d0 - (x / y))
end function
public static double code(double x, double y, double z, double t) {
	return (((2.0 / z) + 2.0) / t) - (2.0 - (x / y));
}
def code(x, y, z, t):
	return (((2.0 / z) + 2.0) / t) - (2.0 - (x / y))
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(2.0 / z) + 2.0) / t) - Float64(2.0 - Float64(x / y)))
end
function tmp = code(x, y, z, t)
	tmp = (((2.0 / z) + 2.0) / t) - (2.0 - (x / y));
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(2.0 / z), $MachinePrecision] + 2.0), $MachinePrecision] / t), $MachinePrecision] - N[(2.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Reproduce

?
herbie shell --seed 2024110 
(FPCore (x y z t)
  :name "Data.HashTable.ST.Basic:computeOverhead from hashtables-1.2.0.2"
  :precision binary64

  :alt
  (- (/ (+ (/ 2.0 z) 2.0) t) (- 2.0 (/ x y)))

  (+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))