
(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:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (x y z t) :precision binary64 (fma x (/ 1.0 y) (+ -2.0 (/ (+ 2.0 (/ 2.0 z)) t))))
double code(double x, double y, double z, double t) {
return fma(x, (1.0 / y), (-2.0 + ((2.0 + (2.0 / z)) / t)));
}
function code(x, y, z, t) return fma(x, Float64(1.0 / y), Float64(-2.0 + Float64(Float64(2.0 + Float64(2.0 / z)) / t))) end
code[x_, y_, z_, t_] := N[(x * N[(1.0 / y), $MachinePrecision] + N[(-2.0 + N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \frac{1}{y}, -2 + \frac{2 + \frac{2}{z}}{t}\right)
\end{array}
Initial program 86.2%
sub-neg86.2%
distribute-rgt-in86.2%
*-lft-identity86.2%
associate-+r+86.2%
cancel-sign-sub-inv86.2%
div-sub78.0%
associate-*r*78.0%
associate-*l/78.0%
*-inverses99.1%
metadata-eval99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
+-commutative99.1%
metadata-eval99.1%
associate-/l/99.2%
Simplified99.2%
div-inv99.0%
fma-def99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ -2.0 (/ 2.0 (* z t)))))
(if (<= (/ x y) -3.8e+44)
(/ x y)
(if (<= (/ x y) 1.02e-286)
t_1
(if (<= (/ x y) 9.5e-141)
(+ -2.0 (/ 2.0 t))
(if (<= (/ x y) 1.6e-6) 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 tmp;
if ((x / y) <= -3.8e+44) {
tmp = x / y;
} else if ((x / y) <= 1.02e-286) {
tmp = t_1;
} else if ((x / y) <= 9.5e-141) {
tmp = -2.0 + (2.0 / t);
} else if ((x / y) <= 1.6e-6) {
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) :: tmp
t_1 = (-2.0d0) + (2.0d0 / (z * t))
if ((x / y) <= (-3.8d+44)) then
tmp = x / y
else if ((x / y) <= 1.02d-286) then
tmp = t_1
else if ((x / y) <= 9.5d-141) then
tmp = (-2.0d0) + (2.0d0 / t)
else if ((x / y) <= 1.6d-6) 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 tmp;
if ((x / y) <= -3.8e+44) {
tmp = x / y;
} else if ((x / y) <= 1.02e-286) {
tmp = t_1;
} else if ((x / y) <= 9.5e-141) {
tmp = -2.0 + (2.0 / t);
} else if ((x / y) <= 1.6e-6) {
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)) tmp = 0 if (x / y) <= -3.8e+44: tmp = x / y elif (x / y) <= 1.02e-286: tmp = t_1 elif (x / y) <= 9.5e-141: tmp = -2.0 + (2.0 / t) elif (x / y) <= 1.6e-6: tmp = t_1 else: tmp = (x / y) - 2.0 return tmp
function code(x, y, z, t) t_1 = Float64(-2.0 + Float64(2.0 / Float64(z * t))) tmp = 0.0 if (Float64(x / y) <= -3.8e+44) tmp = Float64(x / y); elseif (Float64(x / y) <= 1.02e-286) tmp = t_1; elseif (Float64(x / y) <= 9.5e-141) tmp = Float64(-2.0 + Float64(2.0 / t)); elseif (Float64(x / y) <= 1.6e-6) 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)); tmp = 0.0; if ((x / y) <= -3.8e+44) tmp = x / y; elseif ((x / y) <= 1.02e-286) tmp = t_1; elseif ((x / y) <= 9.5e-141) tmp = -2.0 + (2.0 / t); elseif ((x / y) <= 1.6e-6) tmp = t_1; else tmp = (x / y) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-2.0 + N[(2.0 / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x / y), $MachinePrecision], -3.8e+44], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 1.02e-286], t$95$1, If[LessEqual[N[(x / y), $MachinePrecision], 9.5e-141], N[(-2.0 + N[(2.0 / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 1.6e-6], t$95$1, N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -2 + \frac{2}{z \cdot t}\\
\mathbf{if}\;\frac{x}{y} \leq -3.8 \cdot 10^{+44}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 1.02 \cdot 10^{-286}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{x}{y} \leq 9.5 \cdot 10^{-141}:\\
\;\;\;\;-2 + \frac{2}{t}\\
\mathbf{elif}\;\frac{x}{y} \leq 1.6 \cdot 10^{-6}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} - 2\\
\end{array}
\end{array}
if (/.f64 x y) < -3.8000000000000002e44Initial program 86.7%
sub-neg86.7%
distribute-rgt-in86.7%
*-lft-identity86.7%
associate-+r+86.7%
cancel-sign-sub-inv86.7%
div-sub84.8%
associate-*r*84.8%
associate-*l/84.8%
*-inverses99.9%
metadata-eval99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
metadata-eval99.9%
associate-/l/99.9%
Simplified99.9%
Taylor expanded in x around inf 81.9%
if -3.8000000000000002e44 < (/.f64 x y) < 1.01999999999999996e-286 or 9.49999999999999996e-141 < (/.f64 x y) < 1.5999999999999999e-6Initial program 86.6%
sub-neg86.6%
distribute-rgt-in86.6%
*-lft-identity86.6%
associate-+r+86.6%
cancel-sign-sub-inv86.6%
div-sub72.5%
associate-*r*72.5%
associate-*l/72.5%
*-inverses99.8%
metadata-eval99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
+-commutative99.8%
metadata-eval99.8%
associate-/l/99.9%
Simplified99.9%
Taylor expanded in z around 0 76.0%
Taylor expanded in x around 0 72.7%
sub-neg72.7%
associate-*r/72.7%
metadata-eval72.7%
*-commutative72.7%
metadata-eval72.7%
+-commutative72.7%
*-commutative72.7%
Simplified72.7%
if 1.01999999999999996e-286 < (/.f64 x y) < 9.49999999999999996e-141Initial program 84.8%
sub-neg84.8%
distribute-rgt-in84.8%
*-lft-identity84.8%
associate-+r+84.8%
cancel-sign-sub-inv84.8%
div-sub79.8%
associate-*r*79.8%
associate-*l/79.8%
*-inverses99.8%
metadata-eval99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
+-commutative99.8%
metadata-eval99.8%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in z around inf 81.4%
associate--l+81.4%
associate-*r/81.4%
metadata-eval81.4%
Simplified81.4%
Taylor expanded in x around 0 81.4%
sub-neg81.4%
associate-*r/81.4%
metadata-eval81.4%
metadata-eval81.4%
Simplified81.4%
if 1.5999999999999999e-6 < (/.f64 x y) Initial program 85.6%
sub-neg85.6%
distribute-rgt-in85.6%
*-lft-identity85.6%
associate-+r+85.6%
cancel-sign-sub-inv85.6%
div-sub80.4%
associate-*r*80.4%
associate-*l/80.4%
*-inverses97.3%
metadata-eval97.3%
sub-neg97.3%
metadata-eval97.3%
metadata-eval97.3%
+-commutative97.3%
metadata-eval97.3%
associate-/l/97.3%
Simplified97.3%
Taylor expanded in t around inf 70.0%
Final simplification74.5%
(FPCore (x y z t) :precision binary64 (if (or (<= z -17000000.0) (not (<= z 0.0009))) (+ (/ x y) (- (/ 2.0 t) 2.0)) (+ (/ x y) (+ -2.0 (/ (/ 2.0 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -17000000.0) || !(z <= 0.0009)) {
tmp = (x / y) + ((2.0 / t) - 2.0);
} else {
tmp = (x / y) + (-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 ((z <= (-17000000.0d0)) .or. (.not. (z <= 0.0009d0))) then
tmp = (x / y) + ((2.0d0 / t) - 2.0d0)
else
tmp = (x / y) + ((-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 ((z <= -17000000.0) || !(z <= 0.0009)) {
tmp = (x / y) + ((2.0 / t) - 2.0);
} else {
tmp = (x / y) + (-2.0 + ((2.0 / z) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -17000000.0) or not (z <= 0.0009): tmp = (x / y) + ((2.0 / t) - 2.0) else: tmp = (x / y) + (-2.0 + ((2.0 / z) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -17000000.0) || !(z <= 0.0009)) tmp = Float64(Float64(x / y) + Float64(Float64(2.0 / t) - 2.0)); else tmp = Float64(Float64(x / y) + 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 ((z <= -17000000.0) || ~((z <= 0.0009))) tmp = (x / y) + ((2.0 / t) - 2.0); else tmp = (x / y) + (-2.0 + ((2.0 / z) / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -17000000.0], N[Not[LessEqual[z, 0.0009]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + N[(-2.0 + N[(N[(2.0 / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -17000000 \lor \neg \left(z \leq 0.0009\right):\\
\;\;\;\;\frac{x}{y} + \left(\frac{2}{t} - 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + \left(-2 + \frac{\frac{2}{z}}{t}\right)\\
\end{array}
\end{array}
if z < -1.7e7 or 8.9999999999999998e-4 < z Initial program 75.2%
sub-neg75.2%
distribute-rgt-in75.2%
*-lft-identity75.2%
associate-+r+75.2%
cancel-sign-sub-inv75.2%
div-sub75.2%
associate-*r*75.2%
associate-*l/75.2%
*-inverses99.8%
metadata-eval99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
+-commutative99.8%
metadata-eval99.8%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in z around inf 98.7%
associate--l+98.7%
associate-*r/98.7%
metadata-eval98.7%
Simplified98.7%
if -1.7e7 < z < 8.9999999999999998e-4Initial program 98.2%
sub-neg98.2%
distribute-rgt-in98.2%
*-lft-identity98.2%
associate-+r+98.2%
cancel-sign-sub-inv98.2%
div-sub81.0%
associate-*r*81.0%
associate-*l/81.0%
*-inverses98.2%
metadata-eval98.2%
sub-neg98.2%
metadata-eval98.2%
metadata-eval98.2%
+-commutative98.2%
metadata-eval98.2%
associate-/l/98.3%
Simplified98.3%
Taylor expanded in z around 0 97.9%
Final simplification98.3%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -8e-7) (not (<= (/ x y) 1.65e-22))) (- (/ x y) 2.0) (+ -2.0 (/ 2.0 t))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -8e-7) || !((x / y) <= 1.65e-22)) {
tmp = (x / y) - 2.0;
} else {
tmp = -2.0 + (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 (((x / y) <= (-8d-7)) .or. (.not. ((x / y) <= 1.65d-22))) then
tmp = (x / y) - 2.0d0
else
tmp = (-2.0d0) + (2.0d0 / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -8e-7) || !((x / y) <= 1.65e-22)) {
tmp = (x / y) - 2.0;
} else {
tmp = -2.0 + (2.0 / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -8e-7) or not ((x / y) <= 1.65e-22): tmp = (x / y) - 2.0 else: tmp = -2.0 + (2.0 / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -8e-7) || !(Float64(x / y) <= 1.65e-22)) tmp = Float64(Float64(x / y) - 2.0); else tmp = Float64(-2.0 + Float64(2.0 / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -8e-7) || ~(((x / y) <= 1.65e-22))) tmp = (x / y) - 2.0; else tmp = -2.0 + (2.0 / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -8e-7], N[Not[LessEqual[N[(x / y), $MachinePrecision], 1.65e-22]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision], N[(-2.0 + N[(2.0 / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -8 \cdot 10^{-7} \lor \neg \left(\frac{x}{y} \leq 1.65 \cdot 10^{-22}\right):\\
\;\;\;\;\frac{x}{y} - 2\\
\mathbf{else}:\\
\;\;\;\;-2 + \frac{2}{t}\\
\end{array}
\end{array}
if (/.f64 x y) < -7.9999999999999996e-7 or 1.65e-22 < (/.f64 x y) Initial program 86.1%
sub-neg86.1%
distribute-rgt-in86.1%
*-lft-identity86.1%
associate-+r+86.1%
cancel-sign-sub-inv86.1%
div-sub79.9%
associate-*r*79.9%
associate-*l/79.9%
*-inverses98.5%
metadata-eval98.5%
sub-neg98.5%
metadata-eval98.5%
metadata-eval98.5%
+-commutative98.5%
metadata-eval98.5%
associate-/l/98.6%
Simplified98.6%
Taylor expanded in t around inf 71.0%
if -7.9999999999999996e-7 < (/.f64 x y) < 1.65e-22Initial program 86.3%
sub-neg86.3%
distribute-rgt-in86.3%
*-lft-identity86.3%
associate-+r+86.3%
cancel-sign-sub-inv86.3%
div-sub75.5%
associate-*r*75.5%
associate-*l/75.5%
*-inverses99.8%
metadata-eval99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
+-commutative99.8%
metadata-eval99.8%
associate-/l/99.9%
Simplified99.9%
Taylor expanded in z around inf 70.3%
associate--l+70.3%
associate-*r/70.3%
metadata-eval70.3%
Simplified70.3%
Taylor expanded in x around 0 70.2%
sub-neg70.2%
associate-*r/70.2%
metadata-eval70.2%
metadata-eval70.2%
Simplified70.2%
Final simplification70.6%
(FPCore (x y z t) :precision binary64 (if (or (<= t -2.2e-194) (not (<= t 2.3e-98))) (+ (/ x y) (- (/ 2.0 t) 2.0)) (/ (+ 2.0 (/ 2.0 z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.2e-194) || !(t <= 2.3e-98)) {
tmp = (x / y) + ((2.0 / t) - 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 ((t <= (-2.2d-194)) .or. (.not. (t <= 2.3d-98))) then
tmp = (x / y) + ((2.0d0 / t) - 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 ((t <= -2.2e-194) || !(t <= 2.3e-98)) {
tmp = (x / y) + ((2.0 / t) - 2.0);
} else {
tmp = (2.0 + (2.0 / z)) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -2.2e-194) or not (t <= 2.3e-98): tmp = (x / y) + ((2.0 / t) - 2.0) else: tmp = (2.0 + (2.0 / z)) / t return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -2.2e-194) || !(t <= 2.3e-98)) tmp = Float64(Float64(x / y) + Float64(Float64(2.0 / t) - 2.0)); else tmp = Float64(Float64(2.0 + Float64(2.0 / z)) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -2.2e-194) || ~((t <= 2.3e-98))) tmp = (x / y) + ((2.0 / t) - 2.0); else tmp = (2.0 + (2.0 / z)) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -2.2e-194], N[Not[LessEqual[t, 2.3e-98]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.2 \cdot 10^{-194} \lor \neg \left(t \leq 2.3 \cdot 10^{-98}\right):\\
\;\;\;\;\frac{x}{y} + \left(\frac{2}{t} - 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \frac{2}{z}}{t}\\
\end{array}
\end{array}
if t < -2.2000000000000001e-194 or 2.30000000000000001e-98 < t Initial program 81.9%
sub-neg81.9%
distribute-rgt-in81.9%
*-lft-identity81.9%
associate-+r+81.9%
cancel-sign-sub-inv81.9%
div-sub82.0%
associate-*r*82.0%
associate-*l/82.0%
*-inverses99.9%
metadata-eval99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
metadata-eval99.9%
associate-/l/99.9%
Simplified99.9%
Taylor expanded in z around inf 84.8%
associate--l+84.8%
associate-*r/84.8%
metadata-eval84.8%
Simplified84.8%
if -2.2000000000000001e-194 < t < 2.30000000000000001e-98Initial program 97.0%
sub-neg97.0%
distribute-rgt-in97.0%
*-lft-identity97.0%
associate-+r+97.0%
cancel-sign-sub-inv97.0%
div-sub67.9%
associate-*r*67.9%
associate-*l/67.9%
*-inverses97.0%
metadata-eval97.0%
sub-neg97.0%
metadata-eval97.0%
metadata-eval97.0%
+-commutative97.0%
metadata-eval97.0%
associate-/l/97.2%
Simplified97.2%
Taylor expanded in t around 0 86.8%
associate-*r/86.8%
metadata-eval86.8%
Simplified86.8%
Final simplification85.4%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -3.6e+14) (/ x y) (if (<= (/ x y) 8200000.0) (+ -2.0 (/ 2.0 t)) (/ x y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -3.6e+14) {
tmp = x / y;
} else if ((x / y) <= 8200000.0) {
tmp = -2.0 + (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) <= (-3.6d+14)) then
tmp = x / y
else if ((x / y) <= 8200000.0d0) then
tmp = (-2.0d0) + (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) <= -3.6e+14) {
tmp = x / y;
} else if ((x / y) <= 8200000.0) {
tmp = -2.0 + (2.0 / t);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -3.6e+14: tmp = x / y elif (x / y) <= 8200000.0: tmp = -2.0 + (2.0 / t) else: tmp = x / y return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -3.6e+14) tmp = Float64(x / y); elseif (Float64(x / y) <= 8200000.0) tmp = Float64(-2.0 + 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) <= -3.6e+14) tmp = x / y; elseif ((x / y) <= 8200000.0) tmp = -2.0 + (2.0 / t); else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -3.6e+14], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 8200000.0], N[(-2.0 + N[(2.0 / t), $MachinePrecision]), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -3.6 \cdot 10^{+14}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 8200000:\\
\;\;\;\;-2 + \frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -3.6e14 or 8.2e6 < (/.f64 x y) Initial program 86.5%
sub-neg86.5%
distribute-rgt-in86.5%
*-lft-identity86.5%
associate-+r+86.5%
cancel-sign-sub-inv86.5%
div-sub80.5%
associate-*r*80.5%
associate-*l/80.5%
*-inverses98.4%
metadata-eval98.4%
sub-neg98.4%
metadata-eval98.4%
metadata-eval98.4%
+-commutative98.4%
metadata-eval98.4%
associate-/l/98.4%
Simplified98.4%
Taylor expanded in x around inf 71.5%
if -3.6e14 < (/.f64 x y) < 8.2e6Initial program 85.9%
sub-neg85.9%
distribute-rgt-in85.9%
*-lft-identity85.9%
associate-+r+85.9%
cancel-sign-sub-inv85.9%
div-sub75.2%
associate-*r*75.2%
associate-*l/75.2%
*-inverses99.8%
metadata-eval99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
+-commutative99.8%
metadata-eval99.8%
associate-/l/99.9%
Simplified99.9%
Taylor expanded in z around inf 70.2%
associate--l+70.2%
associate-*r/70.2%
metadata-eval70.2%
Simplified70.2%
Taylor expanded in x around 0 67.7%
sub-neg67.7%
associate-*r/67.7%
metadata-eval67.7%
metadata-eval67.7%
Simplified67.7%
Final simplification69.7%
(FPCore (x y z t) :precision binary64 (+ (+ -2.0 (/ (+ 2.0 (/ 2.0 z)) t)) (/ x y)))
double code(double x, double y, double z, double t) {
return (-2.0 + ((2.0 + (2.0 / z)) / t)) + (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) + ((2.0d0 + (2.0d0 / z)) / t)) + (x / y)
end function
public static double code(double x, double y, double z, double t) {
return (-2.0 + ((2.0 + (2.0 / z)) / t)) + (x / y);
}
def code(x, y, z, t): return (-2.0 + ((2.0 + (2.0 / z)) / t)) + (x / y)
function code(x, y, z, t) return Float64(Float64(-2.0 + Float64(Float64(2.0 + Float64(2.0 / z)) / t)) + Float64(x / y)) end
function tmp = code(x, y, z, t) tmp = (-2.0 + ((2.0 + (2.0 / z)) / t)) + (x / y); end
code[x_, y_, z_, t_] := N[(N[(-2.0 + N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] + N[(x / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(-2 + \frac{2 + \frac{2}{z}}{t}\right) + \frac{x}{y}
\end{array}
Initial program 86.2%
sub-neg86.2%
distribute-rgt-in86.2%
*-lft-identity86.2%
associate-+r+86.2%
cancel-sign-sub-inv86.2%
div-sub78.0%
associate-*r*78.0%
associate-*l/78.0%
*-inverses99.1%
metadata-eval99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
+-commutative99.1%
metadata-eval99.1%
associate-/l/99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (/ x y) 2.0)))
(if (<= t -1.85e-185)
t_1
(if (<= t 4.7e-238) (/ 2.0 t) (if (<= t 0.0021) (/ 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.85e-185) {
tmp = t_1;
} else if (t <= 4.7e-238) {
tmp = 2.0 / t;
} else if (t <= 0.0021) {
tmp = 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.85d-185)) then
tmp = t_1
else if (t <= 4.7d-238) then
tmp = 2.0d0 / t
else if (t <= 0.0021d0) then
tmp = 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.85e-185) {
tmp = t_1;
} else if (t <= 4.7e-238) {
tmp = 2.0 / t;
} else if (t <= 0.0021) {
tmp = 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.85e-185: tmp = t_1 elif t <= 4.7e-238: tmp = 2.0 / t elif t <= 0.0021: tmp = 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.85e-185) tmp = t_1; elseif (t <= 4.7e-238) tmp = Float64(2.0 / t); elseif (t <= 0.0021) tmp = Float64(2.0 / Float64(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.85e-185) tmp = t_1; elseif (t <= 4.7e-238) tmp = 2.0 / t; elseif (t <= 0.0021) tmp = 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.85e-185], t$95$1, If[LessEqual[t, 4.7e-238], N[(2.0 / t), $MachinePrecision], If[LessEqual[t, 0.0021], N[(2.0 / N[(z * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{y} - 2\\
\mathbf{if}\;t \leq -1.85 \cdot 10^{-185}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t \leq 4.7 \cdot 10^{-238}:\\
\;\;\;\;\frac{2}{t}\\
\mathbf{elif}\;t \leq 0.0021:\\
\;\;\;\;\frac{2}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if t < -1.85e-185 or 0.00209999999999999987 < t Initial program 80.4%
sub-neg80.4%
distribute-rgt-in80.4%
*-lft-identity80.4%
associate-+r+80.4%
cancel-sign-sub-inv80.4%
div-sub80.4%
associate-*r*80.4%
associate-*l/80.4%
*-inverses99.9%
metadata-eval99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
metadata-eval99.9%
associate-/l/99.9%
Simplified99.9%
Taylor expanded in t around inf 80.8%
if -1.85e-185 < t < 4.70000000000000023e-238Initial program 99.8%
sub-neg99.8%
distribute-rgt-in99.8%
*-lft-identity99.8%
associate-+r+99.8%
cancel-sign-sub-inv99.8%
div-sub72.5%
associate-*r*72.5%
associate-*l/72.5%
*-inverses99.8%
metadata-eval99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
+-commutative99.8%
metadata-eval99.8%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in t around 0 94.1%
associate-*r/94.1%
metadata-eval94.1%
Simplified94.1%
Taylor expanded in z around inf 61.9%
if 4.70000000000000023e-238 < t < 0.00209999999999999987Initial program 95.2%
sub-neg95.2%
distribute-rgt-in95.2%
*-lft-identity95.2%
associate-+r+95.2%
cancel-sign-sub-inv95.2%
div-sub74.3%
associate-*r*74.3%
associate-*l/74.3%
*-inverses95.2%
metadata-eval95.2%
sub-neg95.2%
metadata-eval95.2%
metadata-eval95.2%
+-commutative95.2%
metadata-eval95.2%
associate-/l/95.2%
Simplified95.2%
Taylor expanded in z around 0 50.4%
Final simplification72.5%
(FPCore (x y z t) :precision binary64 (if (or (<= t -4e-11) (not (<= t 0.0011))) (- (/ x y) 2.0) (/ (+ 2.0 (/ 2.0 z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -4e-11) || !(t <= 0.0011)) {
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 ((t <= (-4d-11)) .or. (.not. (t <= 0.0011d0))) 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 ((t <= -4e-11) || !(t <= 0.0011)) {
tmp = (x / y) - 2.0;
} else {
tmp = (2.0 + (2.0 / z)) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -4e-11) or not (t <= 0.0011): 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 ((t <= -4e-11) || !(t <= 0.0011)) tmp = Float64(Float64(x / y) - 2.0); else tmp = Float64(Float64(2.0 + Float64(2.0 / z)) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -4e-11) || ~((t <= 0.0011))) tmp = (x / y) - 2.0; else tmp = (2.0 + (2.0 / z)) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -4e-11], N[Not[LessEqual[t, 0.0011]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision], N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4 \cdot 10^{-11} \lor \neg \left(t \leq 0.0011\right):\\
\;\;\;\;\frac{x}{y} - 2\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \frac{2}{z}}{t}\\
\end{array}
\end{array}
if t < -3.99999999999999976e-11 or 0.00110000000000000007 < t Initial program 76.2%
sub-neg76.2%
distribute-rgt-in76.2%
*-lft-identity76.2%
associate-+r+76.2%
cancel-sign-sub-inv76.2%
div-sub76.2%
associate-*r*76.2%
associate-*l/76.2%
*-inverses99.9%
metadata-eval99.9%
sub-neg99.9%
metadata-eval99.9%
metadata-eval99.9%
+-commutative99.9%
metadata-eval99.9%
associate-/l/100.0%
Simplified100.0%
Taylor expanded in t around inf 88.5%
if -3.99999999999999976e-11 < t < 0.00110000000000000007Initial program 98.1%
sub-neg98.1%
distribute-rgt-in98.1%
*-lft-identity98.1%
associate-+r+98.1%
cancel-sign-sub-inv98.1%
div-sub80.1%
associate-*r*80.1%
associate-*l/80.1%
*-inverses98.1%
metadata-eval98.1%
sub-neg98.1%
metadata-eval98.1%
metadata-eval98.1%
+-commutative98.1%
metadata-eval98.1%
associate-/l/98.2%
Simplified98.2%
Taylor expanded in t around 0 75.8%
associate-*r/75.8%
metadata-eval75.8%
Simplified75.8%
Final simplification82.7%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -1.1e+21) (/ x y) (if (<= (/ x y) 4.6e-16) (/ 2.0 t) (/ x y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -1.1e+21) {
tmp = x / y;
} else if ((x / y) <= 4.6e-16) {
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) <= (-1.1d+21)) then
tmp = x / y
else if ((x / y) <= 4.6d-16) 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) <= -1.1e+21) {
tmp = x / y;
} else if ((x / y) <= 4.6e-16) {
tmp = 2.0 / t;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -1.1e+21: tmp = x / y elif (x / y) <= 4.6e-16: tmp = 2.0 / t else: tmp = x / y return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -1.1e+21) tmp = Float64(x / y); elseif (Float64(x / y) <= 4.6e-16) 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) <= -1.1e+21) tmp = x / y; elseif ((x / y) <= 4.6e-16) tmp = 2.0 / t; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -1.1e+21], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 4.6e-16], N[(2.0 / t), $MachinePrecision], N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -1.1 \cdot 10^{+21}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 4.6 \cdot 10^{-16}:\\
\;\;\;\;\frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -1.1e21 or 4.5999999999999998e-16 < (/.f64 x y) Initial program 87.0%
sub-neg87.0%
distribute-rgt-in87.0%
*-lft-identity87.0%
associate-+r+87.0%
cancel-sign-sub-inv87.0%
div-sub81.2%
associate-*r*81.2%
associate-*l/81.2%
*-inverses98.5%
metadata-eval98.5%
sub-neg98.5%
metadata-eval98.5%
metadata-eval98.5%
+-commutative98.5%
metadata-eval98.5%
associate-/l/98.5%
Simplified98.5%
Taylor expanded in x around inf 69.0%
if -1.1e21 < (/.f64 x y) < 4.5999999999999998e-16Initial program 85.3%
sub-neg85.3%
distribute-rgt-in85.3%
*-lft-identity85.3%
associate-+r+85.3%
cancel-sign-sub-inv85.3%
div-sub74.2%
associate-*r*74.2%
associate-*l/74.2%
*-inverses99.8%
metadata-eval99.8%
sub-neg99.8%
metadata-eval99.8%
metadata-eval99.8%
+-commutative99.8%
metadata-eval99.8%
associate-/l/99.9%
Simplified99.9%
Taylor expanded in t around 0 58.4%
associate-*r/58.4%
metadata-eval58.4%
Simplified58.4%
Taylor expanded in z around inf 29.2%
Final simplification50.8%
(FPCore (x y z t) :precision binary64 (/ 2.0 t))
double code(double x, double y, double z, double t) {
return 2.0 / 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 / t
end function
public static double code(double x, double y, double z, double t) {
return 2.0 / t;
}
def code(x, y, z, t): return 2.0 / t
function code(x, y, z, t) return Float64(2.0 / t) end
function tmp = code(x, y, z, t) tmp = 2.0 / t; end
code[x_, y_, z_, t_] := N[(2.0 / t), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{t}
\end{array}
Initial program 86.2%
sub-neg86.2%
distribute-rgt-in86.2%
*-lft-identity86.2%
associate-+r+86.2%
cancel-sign-sub-inv86.2%
div-sub78.0%
associate-*r*78.0%
associate-*l/78.0%
*-inverses99.1%
metadata-eval99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
+-commutative99.1%
metadata-eval99.1%
associate-/l/99.2%
Simplified99.2%
Taylor expanded in t around 0 41.5%
associate-*r/41.5%
metadata-eval41.5%
Simplified41.5%
Taylor expanded in z around inf 19.3%
Final simplification19.3%
(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}
herbie shell --seed 2023171
(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))))