
(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 10 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 85.0%
sub-neg85.0%
distribute-rgt-in85.0%
*-lft-identity85.0%
associate-+r+85.0%
cancel-sign-sub-inv85.0%
div-sub75.6%
associate-*r*75.6%
associate-*l/75.6%
*-inverses99.1%
metadata-eval99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
+-commutative99.1%
metadata-eval99.1%
associate-/l/99.1%
Simplified99.1%
div-inv99.0%
fma-def99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -4e+33) (not (<= (/ x y) 10000000.0))) (+ (/ x y) (- (/ 2.0 t) 2.0)) (* (/ 2.0 t) (+ 1.0 (- (/ 1.0 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -4e+33) || !((x / y) <= 10000000.0)) {
tmp = (x / y) + ((2.0 / t) - 2.0);
} else {
tmp = (2.0 / t) * (1.0 + ((1.0 / z) - t));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x / y) <= (-4d+33)) .or. (.not. ((x / y) <= 10000000.0d0))) then
tmp = (x / y) + ((2.0d0 / t) - 2.0d0)
else
tmp = (2.0d0 / t) * (1.0d0 + ((1.0d0 / z) - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -4e+33) || !((x / y) <= 10000000.0)) {
tmp = (x / y) + ((2.0 / t) - 2.0);
} else {
tmp = (2.0 / t) * (1.0 + ((1.0 / z) - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -4e+33) or not ((x / y) <= 10000000.0): tmp = (x / y) + ((2.0 / t) - 2.0) else: tmp = (2.0 / t) * (1.0 + ((1.0 / z) - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -4e+33) || !(Float64(x / y) <= 10000000.0)) tmp = Float64(Float64(x / y) + Float64(Float64(2.0 / t) - 2.0)); else tmp = Float64(Float64(2.0 / t) * Float64(1.0 + Float64(Float64(1.0 / z) - t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -4e+33) || ~(((x / y) <= 10000000.0))) tmp = (x / y) + ((2.0 / t) - 2.0); else tmp = (2.0 / t) * (1.0 + ((1.0 / z) - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -4e+33], N[Not[LessEqual[N[(x / y), $MachinePrecision], 10000000.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / t), $MachinePrecision] * N[(1.0 + N[(N[(1.0 / z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -4 \cdot 10^{+33} \lor \neg \left(\frac{x}{y} \leq 10000000\right):\\
\;\;\;\;\frac{x}{y} + \left(\frac{2}{t} - 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{t} \cdot \left(1 + \left(\frac{1}{z} - t\right)\right)\\
\end{array}
\end{array}
if (/.f64 x y) < -3.9999999999999998e33 or 1e7 < (/.f64 x y) Initial program 85.5%
sub-neg85.5%
distribute-rgt-in85.5%
*-lft-identity85.5%
associate-+r+85.5%
cancel-sign-sub-inv85.5%
div-sub77.5%
associate-*r*77.5%
associate-*l/77.5%
*-inverses98.3%
metadata-eval98.3%
sub-neg98.3%
metadata-eval98.3%
metadata-eval98.3%
+-commutative98.3%
metadata-eval98.3%
associate-/l/98.3%
Simplified98.3%
Taylor expanded in z around inf 83.2%
associate--l+83.2%
associate-*r/83.2%
metadata-eval83.2%
Simplified83.2%
if -3.9999999999999998e33 < (/.f64 x y) < 1e7Initial program 84.4%
+-commutative84.4%
*-commutative84.4%
associate-*r*84.4%
distribute-rgt1-in84.4%
*-commutative84.4%
times-frac84.8%
fma-def84.8%
*-commutative84.8%
fma-def84.8%
Simplified84.8%
Taylor expanded in z around 0 99.6%
Taylor expanded in x around 0 98.8%
associate-+r-98.8%
associate-*r/98.8%
associate-*l/98.6%
Simplified98.6%
Final simplification91.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (/ 2.0 t) 2.0)))
(if (or (<= (/ x y) -4e+33) (not (<= (/ x y) 10000000.0)))
(+ (/ x y) t_1)
(+ t_1 (/ 2.0 (* z t))))))
double code(double x, double y, double z, double t) {
double t_1 = (2.0 / t) - 2.0;
double tmp;
if (((x / y) <= -4e+33) || !((x / y) <= 10000000.0)) {
tmp = (x / y) + t_1;
} else {
tmp = t_1 + (2.0 / (z * t));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (2.0d0 / t) - 2.0d0
if (((x / y) <= (-4d+33)) .or. (.not. ((x / y) <= 10000000.0d0))) then
tmp = (x / y) + t_1
else
tmp = t_1 + (2.0d0 / (z * t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (2.0 / t) - 2.0;
double tmp;
if (((x / y) <= -4e+33) || !((x / y) <= 10000000.0)) {
tmp = (x / y) + t_1;
} else {
tmp = t_1 + (2.0 / (z * t));
}
return tmp;
}
def code(x, y, z, t): t_1 = (2.0 / t) - 2.0 tmp = 0 if ((x / y) <= -4e+33) or not ((x / y) <= 10000000.0): tmp = (x / y) + t_1 else: tmp = t_1 + (2.0 / (z * t)) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(2.0 / t) - 2.0) tmp = 0.0 if ((Float64(x / y) <= -4e+33) || !(Float64(x / y) <= 10000000.0)) tmp = Float64(Float64(x / y) + t_1); else tmp = Float64(t_1 + Float64(2.0 / Float64(z * t))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (2.0 / t) - 2.0; tmp = 0.0; if (((x / y) <= -4e+33) || ~(((x / y) <= 10000000.0))) tmp = (x / y) + t_1; else tmp = t_1 + (2.0 / (z * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision]}, If[Or[LessEqual[N[(x / y), $MachinePrecision], -4e+33], N[Not[LessEqual[N[(x / y), $MachinePrecision], 10000000.0]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + t$95$1), $MachinePrecision], N[(t$95$1 + N[(2.0 / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{2}{t} - 2\\
\mathbf{if}\;\frac{x}{y} \leq -4 \cdot 10^{+33} \lor \neg \left(\frac{x}{y} \leq 10000000\right):\\
\;\;\;\;\frac{x}{y} + t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 + \frac{2}{z \cdot t}\\
\end{array}
\end{array}
if (/.f64 x y) < -3.9999999999999998e33 or 1e7 < (/.f64 x y) Initial program 85.5%
sub-neg85.5%
distribute-rgt-in85.5%
*-lft-identity85.5%
associate-+r+85.5%
cancel-sign-sub-inv85.5%
div-sub77.5%
associate-*r*77.5%
associate-*l/77.5%
*-inverses98.3%
metadata-eval98.3%
sub-neg98.3%
metadata-eval98.3%
metadata-eval98.3%
+-commutative98.3%
metadata-eval98.3%
associate-/l/98.3%
Simplified98.3%
Taylor expanded in z around inf 83.2%
associate--l+83.2%
associate-*r/83.2%
metadata-eval83.2%
Simplified83.2%
if -3.9999999999999998e33 < (/.f64 x y) < 1e7Initial program 84.4%
sub-neg84.4%
distribute-rgt-in84.5%
*-lft-identity84.5%
associate-+r+84.5%
cancel-sign-sub-inv84.5%
div-sub73.8%
associate-*r*73.8%
associate-*l/73.8%
*-inverses99.7%
metadata-eval99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
+-commutative99.7%
metadata-eval99.7%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in x around 0 98.9%
associate-*r/98.9%
metadata-eval98.9%
+-commutative98.9%
associate--l+98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
Final simplification91.2%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.3e-36) (not (<= t 1.5e-67))) (+ (/ 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 <= -1.3e-36) || !(t <= 1.5e-67)) {
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 <= (-1.3d-36)) .or. (.not. (t <= 1.5d-67))) 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 <= -1.3e-36) || !(t <= 1.5e-67)) {
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 <= -1.3e-36) or not (t <= 1.5e-67): 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 <= -1.3e-36) || !(t <= 1.5e-67)) 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 <= -1.3e-36) || ~((t <= 1.5e-67))) 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, -1.3e-36], N[Not[LessEqual[t, 1.5e-67]], $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 -1.3 \cdot 10^{-36} \lor \neg \left(t \leq 1.5 \cdot 10^{-67}\right):\\
\;\;\;\;\frac{x}{y} + \left(\frac{2}{t} - 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \frac{2}{z}}{t}\\
\end{array}
\end{array}
if t < -1.3e-36 or 1.50000000000000016e-67 < t Initial program 77.2%
sub-neg77.2%
distribute-rgt-in77.2%
*-lft-identity77.2%
associate-+r+77.2%
cancel-sign-sub-inv77.2%
div-sub76.6%
associate-*r*76.6%
associate-*l/76.6%
*-inverses99.3%
metadata-eval99.3%
sub-neg99.3%
metadata-eval99.3%
metadata-eval99.3%
+-commutative99.3%
metadata-eval99.3%
associate-/l/99.3%
Simplified99.3%
Taylor expanded in z around inf 84.3%
associate--l+84.3%
associate-*r/84.3%
metadata-eval84.3%
Simplified84.3%
if -1.3e-36 < t < 1.50000000000000016e-67Initial program 98.7%
sub-neg98.7%
distribute-rgt-in98.7%
*-lft-identity98.7%
associate-+r+98.7%
cancel-sign-sub-inv98.7%
div-sub73.9%
associate-*r*73.9%
associate-*l/73.9%
*-inverses98.7%
metadata-eval98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
+-commutative98.7%
metadata-eval98.7%
associate-/l/98.8%
Simplified98.8%
Taylor expanded in t around 0 86.3%
associate-*r/86.3%
metadata-eval86.3%
Simplified86.3%
Final simplification85.0%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -6.8e+29) (/ x y) (if (<= (/ x y) 8200000000.0) (+ -2.0 (/ 2.0 t)) (/ x y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -6.8e+29) {
tmp = x / y;
} else if ((x / y) <= 8200000000.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) <= (-6.8d+29)) then
tmp = x / y
else if ((x / y) <= 8200000000.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) <= -6.8e+29) {
tmp = x / y;
} else if ((x / y) <= 8200000000.0) {
tmp = -2.0 + (2.0 / t);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -6.8e+29: tmp = x / y elif (x / y) <= 8200000000.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) <= -6.8e+29) tmp = Float64(x / y); elseif (Float64(x / y) <= 8200000000.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) <= -6.8e+29) tmp = x / y; elseif ((x / y) <= 8200000000.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], -6.8e+29], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 8200000000.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 -6.8 \cdot 10^{+29}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 8200000000:\\
\;\;\;\;-2 + \frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -6.79999999999999963e29 or 8.2e9 < (/.f64 x y) Initial program 85.4%
sub-neg85.4%
distribute-rgt-in85.4%
*-lft-identity85.4%
associate-+r+85.4%
cancel-sign-sub-inv85.4%
div-sub77.4%
associate-*r*77.4%
associate-*l/77.4%
*-inverses98.3%
metadata-eval98.3%
sub-neg98.3%
metadata-eval98.3%
metadata-eval98.3%
+-commutative98.3%
metadata-eval98.3%
associate-/l/98.3%
Simplified98.3%
Taylor expanded in x around inf 73.3%
if -6.79999999999999963e29 < (/.f64 x y) < 8.2e9Initial program 84.6%
sub-neg84.6%
distribute-rgt-in84.6%
*-lft-identity84.6%
associate-+r+84.6%
cancel-sign-sub-inv84.6%
div-sub74.0%
associate-*r*74.0%
associate-*l/74.0%
*-inverses99.7%
metadata-eval99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
+-commutative99.7%
metadata-eval99.7%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in x around 0 98.9%
associate-*r/98.9%
metadata-eval98.9%
+-commutative98.9%
associate--l+98.9%
associate-*r/98.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in z around inf 65.0%
sub-neg65.0%
metadata-eval65.0%
associate-*r/65.0%
metadata-eval65.0%
+-commutative65.0%
Simplified65.0%
Final simplification69.1%
(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 85.0%
sub-neg85.0%
distribute-rgt-in85.0%
*-lft-identity85.0%
associate-+r+85.0%
cancel-sign-sub-inv85.0%
div-sub75.6%
associate-*r*75.6%
associate-*l/75.6%
*-inverses99.1%
metadata-eval99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
+-commutative99.1%
metadata-eval99.1%
associate-/l/99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -3.8e-9) (not (<= t 1.65e-55))) (- (/ x y) 2.0) (/ (+ 2.0 (/ 2.0 z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.8e-9) || !(t <= 1.65e-55)) {
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 <= (-3.8d-9)) .or. (.not. (t <= 1.65d-55))) 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 <= -3.8e-9) || !(t <= 1.65e-55)) {
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 <= -3.8e-9) or not (t <= 1.65e-55): 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 <= -3.8e-9) || !(t <= 1.65e-55)) 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 <= -3.8e-9) || ~((t <= 1.65e-55))) 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, -3.8e-9], N[Not[LessEqual[t, 1.65e-55]], $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 -3.8 \cdot 10^{-9} \lor \neg \left(t \leq 1.65 \cdot 10^{-55}\right):\\
\;\;\;\;\frac{x}{y} - 2\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \frac{2}{z}}{t}\\
\end{array}
\end{array}
if t < -3.80000000000000011e-9 or 1.65e-55 < t Initial program 75.6%
sub-neg75.6%
distribute-rgt-in75.6%
*-lft-identity75.6%
associate-+r+75.6%
cancel-sign-sub-inv75.6%
div-sub75.6%
associate-*r*75.6%
associate-*l/75.6%
*-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 81.6%
if -3.80000000000000011e-9 < t < 1.65e-55Initial program 97.9%
sub-neg97.9%
distribute-rgt-in97.9%
*-lft-identity97.9%
associate-+r+97.9%
cancel-sign-sub-inv97.9%
div-sub75.7%
associate-*r*75.7%
associate-*l/75.7%
*-inverses97.9%
metadata-eval97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
+-commutative97.9%
metadata-eval97.9%
associate-/l/98.0%
Simplified98.0%
Taylor expanded in t around 0 83.4%
associate-*r/83.4%
metadata-eval83.4%
Simplified83.4%
Final simplification82.4%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -6.2e+29) (/ x y) (if (<= (/ x y) 2.0) -2.0 (/ x y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -6.2e+29) {
tmp = x / y;
} else if ((x / y) <= 2.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) <= (-6.2d+29)) then
tmp = x / y
else if ((x / y) <= 2.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) <= -6.2e+29) {
tmp = x / y;
} else if ((x / y) <= 2.0) {
tmp = -2.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -6.2e+29: tmp = x / y elif (x / y) <= 2.0: tmp = -2.0 else: tmp = x / y return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -6.2e+29) tmp = Float64(x / y); elseif (Float64(x / y) <= 2.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) <= -6.2e+29) tmp = x / y; elseif ((x / y) <= 2.0) tmp = -2.0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -6.2e+29], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 2.0], -2.0, N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -6.2 \cdot 10^{+29}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 2:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -6.1999999999999998e29 or 2 < (/.f64 x y) Initial program 85.9%
sub-neg85.9%
distribute-rgt-in85.9%
*-lft-identity85.9%
associate-+r+85.9%
cancel-sign-sub-inv85.9%
div-sub78.1%
associate-*r*78.1%
associate-*l/78.1%
*-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.1%
if -6.1999999999999998e29 < (/.f64 x y) < 2Initial program 84.1%
sub-neg84.1%
distribute-rgt-in84.1%
*-lft-identity84.1%
associate-+r+84.1%
cancel-sign-sub-inv84.1%
div-sub73.2%
associate-*r*73.2%
associate-*l/73.2%
*-inverses99.7%
metadata-eval99.7%
sub-neg99.7%
metadata-eval99.7%
metadata-eval99.7%
+-commutative99.7%
metadata-eval99.7%
associate-/l/99.8%
Simplified99.8%
Taylor expanded in x around 0 98.8%
associate-*r/98.8%
metadata-eval98.8%
+-commutative98.8%
associate--l+98.8%
associate-*r/98.8%
metadata-eval98.8%
Simplified98.8%
Taylor expanded in t around inf 39.5%
Final simplification55.3%
(FPCore (x y z t) :precision binary64 (if (<= t -290000.0) -2.0 (if (<= t 5400.0) (/ 2.0 t) -2.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -290000.0) {
tmp = -2.0;
} else if (t <= 5400.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 <= (-290000.0d0)) then
tmp = -2.0d0
else if (t <= 5400.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 <= -290000.0) {
tmp = -2.0;
} else if (t <= 5400.0) {
tmp = 2.0 / t;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -290000.0: tmp = -2.0 elif t <= 5400.0: tmp = 2.0 / t else: tmp = -2.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -290000.0) tmp = -2.0; elseif (t <= 5400.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 <= -290000.0) tmp = -2.0; elseif (t <= 5400.0) tmp = 2.0 / t; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -290000.0], -2.0, If[LessEqual[t, 5400.0], N[(2.0 / t), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -290000:\\
\;\;\;\;-2\\
\mathbf{elif}\;t \leq 5400:\\
\;\;\;\;\frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if t < -2.9e5 or 5400 < t Initial program 71.6%
sub-neg71.6%
distribute-rgt-in71.6%
*-lft-identity71.6%
associate-+r+71.6%
cancel-sign-sub-inv71.6%
div-sub71.6%
associate-*r*71.6%
associate-*l/71.6%
*-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 0 54.8%
associate-*r/54.8%
metadata-eval54.8%
+-commutative54.8%
associate--l+54.8%
associate-*r/54.8%
metadata-eval54.8%
Simplified54.8%
Taylor expanded in t around inf 39.8%
if -2.9e5 < t < 5400Initial program 98.2%
sub-neg98.2%
distribute-rgt-in98.2%
*-lft-identity98.2%
associate-+r+98.2%
cancel-sign-sub-inv98.2%
div-sub79.6%
associate-*r*79.6%
associate-*l/79.6%
*-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 t around 0 75.5%
associate-*r/75.5%
metadata-eval75.5%
Simplified75.5%
Taylor expanded in z around inf 38.3%
Final simplification39.1%
(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}
Initial program 85.0%
sub-neg85.0%
distribute-rgt-in85.0%
*-lft-identity85.0%
associate-+r+85.0%
cancel-sign-sub-inv85.0%
div-sub75.6%
associate-*r*75.6%
associate-*l/75.6%
*-inverses99.1%
metadata-eval99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
+-commutative99.1%
metadata-eval99.1%
associate-/l/99.1%
Simplified99.1%
Taylor expanded in x around 0 65.8%
associate-*r/65.8%
metadata-eval65.8%
+-commutative65.8%
associate--l+65.8%
associate-*r/65.8%
metadata-eval65.8%
Simplified65.8%
Taylor expanded in t around inf 21.0%
Final simplification21.0%
(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 2023238
(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))))