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

Percentage Accurate: 86.8% → 99.1%
Time: 11.2s
Alternatives: 12
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 12 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.8% 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.1× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 2: 68.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{2}{t} + \frac{x}{y}\\ t_2 := \frac{2}{t \cdot z}\\ t_3 := \frac{x}{y} - 2\\ \mathbf{if}\;t \leq -1:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -5.8 \cdot 10^{-247}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.42 \cdot 10^{-300}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 5 \cdot 10^{-258}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;t \leq 7.2 \cdot 10^{-156}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.3 \cdot 10^{-90}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.9 \cdot 10^{-66}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 6.4 \cdot 10^{-17}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ (/ 2.0 t) (/ x y)))
        (t_2 (/ 2.0 (* t z)))
        (t_3 (- (/ x y) 2.0)))
   (if (<= t -1.0)
     t_3
     (if (<= t -5.8e-247)
       t_1
       (if (<= t -1.42e-300)
         t_2
         (if (<= t 5e-258)
           (/ 2.0 t)
           (if (<= t 7.2e-156)
             t_2
             (if (<= t 1.3e-90)
               t_1
               (if (<= t 1.9e-66) t_2 (if (<= t 6.4e-17) t_1 t_3))))))))))
double code(double x, double y, double z, double t) {
	double t_1 = (2.0 / t) + (x / y);
	double t_2 = 2.0 / (t * z);
	double t_3 = (x / y) - 2.0;
	double tmp;
	if (t <= -1.0) {
		tmp = t_3;
	} else if (t <= -5.8e-247) {
		tmp = t_1;
	} else if (t <= -1.42e-300) {
		tmp = t_2;
	} else if (t <= 5e-258) {
		tmp = 2.0 / t;
	} else if (t <= 7.2e-156) {
		tmp = t_2;
	} else if (t <= 1.3e-90) {
		tmp = t_1;
	} else if (t <= 1.9e-66) {
		tmp = t_2;
	} else if (t <= 6.4e-17) {
		tmp = t_1;
	} else {
		tmp = t_3;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_1 = (2.0d0 / t) + (x / y)
    t_2 = 2.0d0 / (t * z)
    t_3 = (x / y) - 2.0d0
    if (t <= (-1.0d0)) then
        tmp = t_3
    else if (t <= (-5.8d-247)) then
        tmp = t_1
    else if (t <= (-1.42d-300)) then
        tmp = t_2
    else if (t <= 5d-258) then
        tmp = 2.0d0 / t
    else if (t <= 7.2d-156) then
        tmp = t_2
    else if (t <= 1.3d-90) then
        tmp = t_1
    else if (t <= 1.9d-66) then
        tmp = t_2
    else if (t <= 6.4d-17) then
        tmp = t_1
    else
        tmp = t_3
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = (2.0 / t) + (x / y);
	double t_2 = 2.0 / (t * z);
	double t_3 = (x / y) - 2.0;
	double tmp;
	if (t <= -1.0) {
		tmp = t_3;
	} else if (t <= -5.8e-247) {
		tmp = t_1;
	} else if (t <= -1.42e-300) {
		tmp = t_2;
	} else if (t <= 5e-258) {
		tmp = 2.0 / t;
	} else if (t <= 7.2e-156) {
		tmp = t_2;
	} else if (t <= 1.3e-90) {
		tmp = t_1;
	} else if (t <= 1.9e-66) {
		tmp = t_2;
	} else if (t <= 6.4e-17) {
		tmp = t_1;
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (2.0 / t) + (x / y)
	t_2 = 2.0 / (t * z)
	t_3 = (x / y) - 2.0
	tmp = 0
	if t <= -1.0:
		tmp = t_3
	elif t <= -5.8e-247:
		tmp = t_1
	elif t <= -1.42e-300:
		tmp = t_2
	elif t <= 5e-258:
		tmp = 2.0 / t
	elif t <= 7.2e-156:
		tmp = t_2
	elif t <= 1.3e-90:
		tmp = t_1
	elif t <= 1.9e-66:
		tmp = t_2
	elif t <= 6.4e-17:
		tmp = t_1
	else:
		tmp = t_3
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(2.0 / t) + Float64(x / y))
	t_2 = Float64(2.0 / Float64(t * z))
	t_3 = Float64(Float64(x / y) - 2.0)
	tmp = 0.0
	if (t <= -1.0)
		tmp = t_3;
	elseif (t <= -5.8e-247)
		tmp = t_1;
	elseif (t <= -1.42e-300)
		tmp = t_2;
	elseif (t <= 5e-258)
		tmp = Float64(2.0 / t);
	elseif (t <= 7.2e-156)
		tmp = t_2;
	elseif (t <= 1.3e-90)
		tmp = t_1;
	elseif (t <= 1.9e-66)
		tmp = t_2;
	elseif (t <= 6.4e-17)
		tmp = t_1;
	else
		tmp = t_3;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (2.0 / t) + (x / y);
	t_2 = 2.0 / (t * z);
	t_3 = (x / y) - 2.0;
	tmp = 0.0;
	if (t <= -1.0)
		tmp = t_3;
	elseif (t <= -5.8e-247)
		tmp = t_1;
	elseif (t <= -1.42e-300)
		tmp = t_2;
	elseif (t <= 5e-258)
		tmp = 2.0 / t;
	elseif (t <= 7.2e-156)
		tmp = t_2;
	elseif (t <= 1.3e-90)
		tmp = t_1;
	elseif (t <= 1.9e-66)
		tmp = t_2;
	elseif (t <= 6.4e-17)
		tmp = t_1;
	else
		tmp = t_3;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(2.0 / t), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision]}, If[LessEqual[t, -1.0], t$95$3, If[LessEqual[t, -5.8e-247], t$95$1, If[LessEqual[t, -1.42e-300], t$95$2, If[LessEqual[t, 5e-258], N[(2.0 / t), $MachinePrecision], If[LessEqual[t, 7.2e-156], t$95$2, If[LessEqual[t, 1.3e-90], t$95$1, If[LessEqual[t, 1.9e-66], t$95$2, If[LessEqual[t, 6.4e-17], t$95$1, t$95$3]]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \frac{2}{t} + \frac{x}{y}\\
t_2 := \frac{2}{t \cdot z}\\
t_3 := \frac{x}{y} - 2\\
\mathbf{if}\;t \leq -1:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t \leq -5.8 \cdot 10^{-247}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t \leq -1.42 \cdot 10^{-300}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t \leq 5 \cdot 10^{-258}:\\
\;\;\;\;\frac{2}{t}\\

\mathbf{elif}\;t \leq 7.2 \cdot 10^{-156}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t \leq 1.3 \cdot 10^{-90}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t \leq 1.9 \cdot 10^{-66}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t \leq 6.4 \cdot 10^{-17}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if t < -1 or 6.4000000000000005e-17 < t

    1. Initial program 74.0%

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

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

    if -1 < t < -5.8e-247 or 7.19999999999999998e-156 < t < 1.3e-90 or 1.8999999999999999e-66 < t < 6.4000000000000005e-17

    1. Initial program 98.7%

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

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

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

        \[\leadsto \frac{x}{y} + \color{blue}{\frac{2}{\frac{t}{1 - t}}} \]
    4. Simplified70.0%

      \[\leadsto \frac{x}{y} + \color{blue}{\frac{2}{\frac{t}{1 - t}}} \]
    5. Taylor expanded in t around 0 69.6%

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

    if -5.8e-247 < t < -1.42e-300 or 4.9999999999999999e-258 < t < 7.19999999999999998e-156 or 1.3e-90 < t < 1.8999999999999999e-66

    1. Initial program 95.3%

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

      \[\leadsto \frac{x}{y} + \color{blue}{\frac{2}{t \cdot z}} \]
    3. Taylor expanded in x around 0 75.4%

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

    if -1.42e-300 < t < 4.9999999999999999e-258

    1. Initial program 91.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1:\\ \;\;\;\;\frac{x}{y} - 2\\ \mathbf{elif}\;t \leq -5.8 \cdot 10^{-247}:\\ \;\;\;\;\frac{2}{t} + \frac{x}{y}\\ \mathbf{elif}\;t \leq -1.42 \cdot 10^{-300}:\\ \;\;\;\;\frac{2}{t \cdot z}\\ \mathbf{elif}\;t \leq 5 \cdot 10^{-258}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;t \leq 7.2 \cdot 10^{-156}:\\ \;\;\;\;\frac{2}{t \cdot z}\\ \mathbf{elif}\;t \leq 1.3 \cdot 10^{-90}:\\ \;\;\;\;\frac{2}{t} + \frac{x}{y}\\ \mathbf{elif}\;t \leq 1.9 \cdot 10^{-66}:\\ \;\;\;\;\frac{2}{t \cdot z}\\ \mathbf{elif}\;t \leq 6.4 \cdot 10^{-17}:\\ \;\;\;\;\frac{2}{t} + \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} - 2\\ \end{array} \]

Alternative 3: 49.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.16 \cdot 10^{+59}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq -6.4 \cdot 10^{-18}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;\frac{x}{y} \leq -1.55 \cdot 10^{-220}:\\ \;\;\;\;-2\\ \mathbf{elif}\;\frac{x}{y} \leq 2.8 \cdot 10^{-181}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;\frac{x}{y} \leq 2500:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (if (<= (/ x y) -1.16e+59)
   (/ x y)
   (if (<= (/ x y) -6.4e-18)
     (/ 2.0 t)
     (if (<= (/ x y) -1.55e-220)
       -2.0
       (if (<= (/ x y) 2.8e-181)
         (/ 2.0 t)
         (if (<= (/ x y) 2500.0) -2.0 (/ x y)))))))
double code(double x, double y, double z, double t) {
	double tmp;
	if ((x / y) <= -1.16e+59) {
		tmp = x / y;
	} else if ((x / y) <= -6.4e-18) {
		tmp = 2.0 / t;
	} else if ((x / y) <= -1.55e-220) {
		tmp = -2.0;
	} else if ((x / y) <= 2.8e-181) {
		tmp = 2.0 / t;
	} else if ((x / y) <= 2500.0) {
		tmp = -2.0;
	} 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) <= (-1.16d+59)) then
        tmp = x / y
    else if ((x / y) <= (-6.4d-18)) then
        tmp = 2.0d0 / t
    else if ((x / y) <= (-1.55d-220)) then
        tmp = -2.0d0
    else if ((x / y) <= 2.8d-181) then
        tmp = 2.0d0 / t
    else if ((x / y) <= 2500.0d0) then
        tmp = -2.0d0
    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) <= -1.16e+59) {
		tmp = x / y;
	} else if ((x / y) <= -6.4e-18) {
		tmp = 2.0 / t;
	} else if ((x / y) <= -1.55e-220) {
		tmp = -2.0;
	} else if ((x / y) <= 2.8e-181) {
		tmp = 2.0 / t;
	} else if ((x / y) <= 2500.0) {
		tmp = -2.0;
	} else {
		tmp = x / y;
	}
	return tmp;
}
def code(x, y, z, t):
	tmp = 0
	if (x / y) <= -1.16e+59:
		tmp = x / y
	elif (x / y) <= -6.4e-18:
		tmp = 2.0 / t
	elif (x / y) <= -1.55e-220:
		tmp = -2.0
	elif (x / y) <= 2.8e-181:
		tmp = 2.0 / t
	elif (x / y) <= 2500.0:
		tmp = -2.0
	else:
		tmp = x / y
	return tmp
function code(x, y, z, t)
	tmp = 0.0
	if (Float64(x / y) <= -1.16e+59)
		tmp = Float64(x / y);
	elseif (Float64(x / y) <= -6.4e-18)
		tmp = Float64(2.0 / t);
	elseif (Float64(x / y) <= -1.55e-220)
		tmp = -2.0;
	elseif (Float64(x / y) <= 2.8e-181)
		tmp = Float64(2.0 / t);
	elseif (Float64(x / y) <= 2500.0)
		tmp = -2.0;
	else
		tmp = Float64(x / y);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	tmp = 0.0;
	if ((x / y) <= -1.16e+59)
		tmp = x / y;
	elseif ((x / y) <= -6.4e-18)
		tmp = 2.0 / t;
	elseif ((x / y) <= -1.55e-220)
		tmp = -2.0;
	elseif ((x / y) <= 2.8e-181)
		tmp = 2.0 / t;
	elseif ((x / y) <= 2500.0)
		tmp = -2.0;
	else
		tmp = x / y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -1.16e+59], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], -6.4e-18], N[(2.0 / t), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], -1.55e-220], -2.0, If[LessEqual[N[(x / y), $MachinePrecision], 2.8e-181], N[(2.0 / t), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 2500.0], -2.0, N[(x / y), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\frac{x}{y} \leq -6.4 \cdot 10^{-18}:\\
\;\;\;\;\frac{2}{t}\\

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

\mathbf{elif}\;\frac{x}{y} \leq 2.8 \cdot 10^{-181}:\\
\;\;\;\;\frac{2}{t}\\

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

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


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

    1. Initial program 87.1%

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

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

    if -1.16000000000000001e59 < (/.f64 x y) < -6.3999999999999998e-18 or -1.55000000000000006e-220 < (/.f64 x y) < 2.79999999999999986e-181

    1. Initial program 93.2%

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

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

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

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

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

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

    if -6.3999999999999998e-18 < (/.f64 x y) < -1.55000000000000006e-220 or 2.79999999999999986e-181 < (/.f64 x y) < 2500

    1. Initial program 82.4%

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

      \[\leadsto \color{blue}{\frac{x}{y} - 2} \]
    3. Taylor expanded in x around 0 39.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1.16 \cdot 10^{+59}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq -6.4 \cdot 10^{-18}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;\frac{x}{y} \leq -1.55 \cdot 10^{-220}:\\ \;\;\;\;-2\\ \mathbf{elif}\;\frac{x}{y} \leq 2.8 \cdot 10^{-181}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;\frac{x}{y} \leq 2500:\\ \;\;\;\;-2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 4: 98.2% accurate, 0.8× speedup?

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

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

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


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

    1. Initial program 87.2%

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

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

    if -2.5 < (/.f64 x y) < 2500

    1. Initial program 87.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 62.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{2}{t \cdot z}\\ t_2 := \frac{x}{y} - 2\\ \mathbf{if}\;t \leq -3.4 \cdot 10^{-77}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.5 \cdot 10^{-119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.45 \cdot 10^{-193}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -6.2 \cdot 10^{-301}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.9 \cdot 10^{-258}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{+18}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ 2.0 (* t z))) (t_2 (- (/ x y) 2.0)))
   (if (<= t -3.4e-77)
     t_2
     (if (<= t -1.5e-119)
       t_1
       (if (<= t -1.45e-193)
         t_2
         (if (<= t -6.2e-301)
           t_1
           (if (<= t 5.9e-258) (/ 2.0 t) (if (<= t 6.2e+18) t_1 t_2))))))))
double code(double x, double y, double z, double t) {
	double t_1 = 2.0 / (t * z);
	double t_2 = (x / y) - 2.0;
	double tmp;
	if (t <= -3.4e-77) {
		tmp = t_2;
	} else if (t <= -1.5e-119) {
		tmp = t_1;
	} else if (t <= -1.45e-193) {
		tmp = t_2;
	} else if (t <= -6.2e-301) {
		tmp = t_1;
	} else if (t <= 5.9e-258) {
		tmp = 2.0 / t;
	} else if (t <= 6.2e+18) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = 2.0d0 / (t * z)
    t_2 = (x / y) - 2.0d0
    if (t <= (-3.4d-77)) then
        tmp = t_2
    else if (t <= (-1.5d-119)) then
        tmp = t_1
    else if (t <= (-1.45d-193)) then
        tmp = t_2
    else if (t <= (-6.2d-301)) then
        tmp = t_1
    else if (t <= 5.9d-258) then
        tmp = 2.0d0 / t
    else if (t <= 6.2d+18) then
        tmp = t_1
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	double t_1 = 2.0 / (t * z);
	double t_2 = (x / y) - 2.0;
	double tmp;
	if (t <= -3.4e-77) {
		tmp = t_2;
	} else if (t <= -1.5e-119) {
		tmp = t_1;
	} else if (t <= -1.45e-193) {
		tmp = t_2;
	} else if (t <= -6.2e-301) {
		tmp = t_1;
	} else if (t <= 5.9e-258) {
		tmp = 2.0 / t;
	} else if (t <= 6.2e+18) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = 2.0 / (t * z)
	t_2 = (x / y) - 2.0
	tmp = 0
	if t <= -3.4e-77:
		tmp = t_2
	elif t <= -1.5e-119:
		tmp = t_1
	elif t <= -1.45e-193:
		tmp = t_2
	elif t <= -6.2e-301:
		tmp = t_1
	elif t <= 5.9e-258:
		tmp = 2.0 / t
	elif t <= 6.2e+18:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t)
	t_1 = Float64(2.0 / Float64(t * z))
	t_2 = Float64(Float64(x / y) - 2.0)
	tmp = 0.0
	if (t <= -3.4e-77)
		tmp = t_2;
	elseif (t <= -1.5e-119)
		tmp = t_1;
	elseif (t <= -1.45e-193)
		tmp = t_2;
	elseif (t <= -6.2e-301)
		tmp = t_1;
	elseif (t <= 5.9e-258)
		tmp = Float64(2.0 / t);
	elseif (t <= 6.2e+18)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = 2.0 / (t * z);
	t_2 = (x / y) - 2.0;
	tmp = 0.0;
	if (t <= -3.4e-77)
		tmp = t_2;
	elseif (t <= -1.5e-119)
		tmp = t_1;
	elseif (t <= -1.45e-193)
		tmp = t_2;
	elseif (t <= -6.2e-301)
		tmp = t_1;
	elseif (t <= 5.9e-258)
		tmp = 2.0 / t;
	elseif (t <= 6.2e+18)
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision]}, If[LessEqual[t, -3.4e-77], t$95$2, If[LessEqual[t, -1.5e-119], t$95$1, If[LessEqual[t, -1.45e-193], t$95$2, If[LessEqual[t, -6.2e-301], t$95$1, If[LessEqual[t, 5.9e-258], N[(2.0 / t), $MachinePrecision], If[LessEqual[t, 6.2e+18], t$95$1, t$95$2]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t \leq -1.5 \cdot 10^{-119}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t \leq -1.45 \cdot 10^{-193}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t \leq -6.2 \cdot 10^{-301}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t \leq 5.9 \cdot 10^{-258}:\\
\;\;\;\;\frac{2}{t}\\

\mathbf{elif}\;t \leq 6.2 \cdot 10^{+18}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -3.39999999999999983e-77 or -1.5000000000000001e-119 < t < -1.45000000000000003e-193 or 6.2e18 < t

    1. Initial program 80.1%

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

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

    if -3.39999999999999983e-77 < t < -1.5000000000000001e-119 or -1.45000000000000003e-193 < t < -6.20000000000000029e-301 or 5.8999999999999997e-258 < t < 6.2e18

    1. Initial program 96.8%

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

      \[\leadsto \frac{x}{y} + \color{blue}{\frac{2}{t \cdot z}} \]
    3. Taylor expanded in x around 0 59.0%

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

    if -6.20000000000000029e-301 < t < 5.8999999999999997e-258

    1. Initial program 91.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -3.4 \cdot 10^{-77}:\\ \;\;\;\;\frac{x}{y} - 2\\ \mathbf{elif}\;t \leq -1.5 \cdot 10^{-119}:\\ \;\;\;\;\frac{2}{t \cdot z}\\ \mathbf{elif}\;t \leq -1.45 \cdot 10^{-193}:\\ \;\;\;\;\frac{x}{y} - 2\\ \mathbf{elif}\;t \leq -6.2 \cdot 10^{-301}:\\ \;\;\;\;\frac{2}{t \cdot z}\\ \mathbf{elif}\;t \leq 5.9 \cdot 10^{-258}:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{+18}:\\ \;\;\;\;\frac{2}{t \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} - 2\\ \end{array} \]

Alternative 6: 79.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{2 + \frac{2}{z}}{t}\\ t_2 := -2 + \left(\frac{2}{t} + \frac{x}{y}\right)\\ \mathbf{if}\;t \leq -5.5 \cdot 10^{-77}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -7.2 \cdot 10^{-115}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.05 \cdot 10^{-193}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{+18}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} - 2\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (+ 2.0 (/ 2.0 z)) t)) (t_2 (+ -2.0 (+ (/ 2.0 t) (/ x y)))))
   (if (<= t -5.5e-77)
     t_2
     (if (<= t -7.2e-115)
       t_1
       (if (<= t -1.05e-193) t_2 (if (<= t 6.2e+18) t_1 (- (/ x y) 2.0)))))))
double code(double x, double y, double z, double t) {
	double t_1 = (2.0 + (2.0 / z)) / t;
	double t_2 = -2.0 + ((2.0 / t) + (x / y));
	double tmp;
	if (t <= -5.5e-77) {
		tmp = t_2;
	} else if (t <= -7.2e-115) {
		tmp = t_1;
	} else if (t <= -1.05e-193) {
		tmp = t_2;
	} else if (t <= 6.2e+18) {
		tmp = t_1;
	} else {
		tmp = (x / y) - 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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (2.0d0 + (2.0d0 / z)) / t
    t_2 = (-2.0d0) + ((2.0d0 / t) + (x / y))
    if (t <= (-5.5d-77)) then
        tmp = t_2
    else if (t <= (-7.2d-115)) then
        tmp = t_1
    else if (t <= (-1.05d-193)) then
        tmp = t_2
    else if (t <= 6.2d+18) then
        tmp = t_1
    else
        tmp = (x / y) - 2.0d0
    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 + ((2.0 / t) + (x / y));
	double tmp;
	if (t <= -5.5e-77) {
		tmp = t_2;
	} else if (t <= -7.2e-115) {
		tmp = t_1;
	} else if (t <= -1.05e-193) {
		tmp = t_2;
	} else if (t <= 6.2e+18) {
		tmp = t_1;
	} else {
		tmp = (x / y) - 2.0;
	}
	return tmp;
}
def code(x, y, z, t):
	t_1 = (2.0 + (2.0 / z)) / t
	t_2 = -2.0 + ((2.0 / t) + (x / y))
	tmp = 0
	if t <= -5.5e-77:
		tmp = t_2
	elif t <= -7.2e-115:
		tmp = t_1
	elif t <= -1.05e-193:
		tmp = t_2
	elif t <= 6.2e+18:
		tmp = t_1
	else:
		tmp = (x / y) - 2.0
	return tmp
function code(x, y, z, t)
	t_1 = Float64(Float64(2.0 + Float64(2.0 / z)) / t)
	t_2 = Float64(-2.0 + Float64(Float64(2.0 / t) + Float64(x / y)))
	tmp = 0.0
	if (t <= -5.5e-77)
		tmp = t_2;
	elseif (t <= -7.2e-115)
		tmp = t_1;
	elseif (t <= -1.05e-193)
		tmp = t_2;
	elseif (t <= 6.2e+18)
		tmp = t_1;
	else
		tmp = Float64(Float64(x / y) - 2.0);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t)
	t_1 = (2.0 + (2.0 / z)) / t;
	t_2 = -2.0 + ((2.0 / t) + (x / y));
	tmp = 0.0;
	if (t <= -5.5e-77)
		tmp = t_2;
	elseif (t <= -7.2e-115)
		tmp = t_1;
	elseif (t <= -1.05e-193)
		tmp = t_2;
	elseif (t <= 6.2e+18)
		tmp = t_1;
	else
		tmp = (x / y) - 2.0;
	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 + N[(N[(2.0 / t), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -5.5e-77], t$95$2, If[LessEqual[t, -7.2e-115], t$95$1, If[LessEqual[t, -1.05e-193], t$95$2, If[LessEqual[t, 6.2e+18], t$95$1, N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t \leq -7.2 \cdot 10^{-115}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t \leq -1.05 \cdot 10^{-193}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t \leq 6.2 \cdot 10^{+18}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -5.49999999999999998e-77 or -7.20000000000000018e-115 < t < -1.05e-193

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.49999999999999998e-77 < t < -7.20000000000000018e-115 or -1.05e-193 < t < 6.2e18

    1. Initial program 96.3%

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

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

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

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

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

    if 6.2e18 < t

    1. Initial program 64.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -5.5 \cdot 10^{-77}:\\ \;\;\;\;-2 + \left(\frac{2}{t} + \frac{x}{y}\right)\\ \mathbf{elif}\;t \leq -7.2 \cdot 10^{-115}:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \mathbf{elif}\;t \leq -1.05 \cdot 10^{-193}:\\ \;\;\;\;-2 + \left(\frac{2}{t} + \frac{x}{y}\right)\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{+18}:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} - 2\\ \end{array} \]

Alternative 7: 78.6% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{x}{y} - 2\\ \mathbf{if}\;t \leq -1:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.8 \cdot 10^{-193}:\\ \;\;\;\;\frac{2}{t} + \frac{x}{y}\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{+18}:\\ \;\;\;\;\frac{2 + \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 -1.0)
     t_1
     (if (<= t -1.8e-193)
       (+ (/ 2.0 t) (/ x y))
       (if (<= t 6.2e+18) (/ (+ 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 <= -1.0) {
		tmp = t_1;
	} else if (t <= -1.8e-193) {
		tmp = (2.0 / t) + (x / y);
	} else if (t <= 6.2e+18) {
		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 <= (-1.0d0)) then
        tmp = t_1
    else if (t <= (-1.8d-193)) then
        tmp = (2.0d0 / t) + (x / y)
    else if (t <= 6.2d+18) 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 <= -1.0) {
		tmp = t_1;
	} else if (t <= -1.8e-193) {
		tmp = (2.0 / t) + (x / y);
	} else if (t <= 6.2e+18) {
		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 <= -1.0:
		tmp = t_1
	elif t <= -1.8e-193:
		tmp = (2.0 / t) + (x / y)
	elif t <= 6.2e+18:
		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 <= -1.0)
		tmp = t_1;
	elseif (t <= -1.8e-193)
		tmp = Float64(Float64(2.0 / t) + Float64(x / y));
	elseif (t <= 6.2e+18)
		tmp = Float64(Float64(2.0 + 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 <= -1.0)
		tmp = t_1;
	elseif (t <= -1.8e-193)
		tmp = (2.0 / t) + (x / y);
	elseif (t <= 6.2e+18)
		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, -1.0], t$95$1, If[LessEqual[t, -1.8e-193], N[(N[(2.0 / t), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 6.2e+18], N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;t \leq 6.2 \cdot 10^{+18}:\\
\;\;\;\;\frac{2 + \frac{2}{z}}{t}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if t < -1 or 6.2e18 < t

    1. Initial program 72.7%

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

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

    if -1 < t < -1.7999999999999999e-193

    1. Initial program 99.9%

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

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

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

        \[\leadsto \frac{x}{y} + \color{blue}{\frac{2}{\frac{t}{1 - t}}} \]
    4. Simplified73.2%

      \[\leadsto \frac{x}{y} + \color{blue}{\frac{2}{\frac{t}{1 - t}}} \]
    5. Taylor expanded in t around 0 72.3%

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

    if -1.7999999999999999e-193 < t < 6.2e18

    1. Initial program 96.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1:\\ \;\;\;\;\frac{x}{y} - 2\\ \mathbf{elif}\;t \leq -1.8 \cdot 10^{-193}:\\ \;\;\;\;\frac{2}{t} + \frac{x}{y}\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{+18}:\\ \;\;\;\;\frac{2 + \frac{2}{z}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} - 2\\ \end{array} \]

Alternative 8: 91.8% accurate, 1.3× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -3.20000000000000026e-4 or 6.9999999999999998e-9 < z

    1. Initial program 77.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.20000000000000026e-4 < z < 6.9999999999999998e-9

    1. Initial program 96.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.00032 \lor \neg \left(z \leq 7 \cdot 10^{-9}\right):\\ \;\;\;\;-2 + \left(\frac{2}{t} + \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{t \cdot z} + \frac{x}{y}\\ \end{array} \]

Alternative 9: 64.0% accurate, 1.3× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 x y) < -9.99999999999999972e58 or 1.6e15 < (/.f64 x y)

    1. Initial program 86.9%

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

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

    if -9.99999999999999972e58 < (/.f64 x y) < 1.6e15

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{2}}{t} - 2 \]
      3. sub-neg58.7%

        \[\leadsto \color{blue}{\frac{2}{t} + \left(-2\right)} \]
      4. metadata-eval58.7%

        \[\leadsto \frac{2}{t} + \color{blue}{-2} \]
    10. Simplified58.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -1 \cdot 10^{+59}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 1.6 \cdot 10^{+15}:\\ \;\;\;\;\frac{2}{t} + -2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y}\\ \end{array} \]

Alternative 10: 64.2% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;\frac{x}{y} \leq 2500:\\
\;\;\;\;\frac{2}{t} + -2\\

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


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

    1. Initial program 90.0%

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

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

    if -6.5999999999999999e59 < (/.f64 x y) < 2500

    1. Initial program 87.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{2 \cdot 1}{t}} - 2 \]
      2. metadata-eval58.8%

        \[\leadsto \frac{\color{blue}{2}}{t} - 2 \]
      3. sub-neg58.8%

        \[\leadsto \color{blue}{\frac{2}{t} + \left(-2\right)} \]
      4. metadata-eval58.8%

        \[\leadsto \frac{2}{t} + \color{blue}{-2} \]
    10. Simplified58.8%

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

    if 2500 < (/.f64 x y)

    1. Initial program 84.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x}{y} \leq -6.6 \cdot 10^{+59}:\\ \;\;\;\;\frac{x}{y}\\ \mathbf{elif}\;\frac{x}{y} \leq 2500:\\ \;\;\;\;\frac{2}{t} + -2\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} - 2\\ \end{array} \]

Alternative 11: 36.1% accurate, 2.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;t \leq -1:\\ \;\;\;\;-2\\ \mathbf{elif}\;t \leq 1050:\\ \;\;\;\;\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 1050.0) (/ 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 <= 1050.0) {
		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 <= 1050.0d0) 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 <= 1050.0) {
		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 <= 1050.0:
		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 <= 1050.0)
		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 <= 1050.0)
		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, 1050.0], N[(2.0 / t), $MachinePrecision], -2.0]]
\begin{array}{l}

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

\mathbf{elif}\;t \leq 1050:\\
\;\;\;\;\frac{2}{t}\\

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


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

    1. Initial program 73.2%

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

      \[\leadsto \color{blue}{\frac{x}{y} - 2} \]
    3. Taylor expanded in x around 0 35.3%

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

    if -1 < t < 1050

    1. Initial program 97.1%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -1:\\ \;\;\;\;-2\\ \mathbf{elif}\;t \leq 1050:\\ \;\;\;\;\frac{2}{t}\\ \mathbf{else}:\\ \;\;\;\;-2\\ \end{array} \]

Alternative 12: 19.9% 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 87.3%

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

    \[\leadsto \color{blue}{\frac{x}{y} - 2} \]
  3. Taylor expanded in x around 0 15.9%

    \[\leadsto \color{blue}{-2} \]
  4. Final simplification15.9%

    \[\leadsto -2 \]

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 2023297 
(FPCore (x y z t)
  :name "Data.HashTable.ST.Basic:computeOverhead from hashtables-1.2.0.2"
  :precision binary64

  :herbie-target
  (- (/ (+ (/ 2.0 z) 2.0) t) (- 2.0 (/ x y)))

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