
(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 (+ (/ x y) (+ -2.0 (/ (+ 2.0 (/ 2.0 z)) t))))
double code(double x, double y, double z, double t) {
return (x / y) + (-2.0 + ((2.0 + (2.0 / z)) / t));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x / y) + ((-2.0d0) + ((2.0d0 + (2.0d0 / z)) / t))
end function
public static double code(double x, double y, double z, double t) {
return (x / y) + (-2.0 + ((2.0 + (2.0 / z)) / t));
}
def code(x, y, z, t): return (x / y) + (-2.0 + ((2.0 + (2.0 / z)) / t))
function code(x, y, z, t) return Float64(Float64(x / y) + Float64(-2.0 + Float64(Float64(2.0 + Float64(2.0 / z)) / t))) end
function tmp = code(x, y, z, t) tmp = (x / y) + (-2.0 + ((2.0 + (2.0 / z)) / t)); end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(-2.0 + N[(N[(2.0 + N[(2.0 / z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} + \left(-2 + \frac{2 + \frac{2}{z}}{t}\right)
\end{array}
Initial program 85.8%
sub-neg85.8%
distribute-rgt-in85.8%
*-lft-identity85.8%
associate-+r+85.8%
cancel-sign-sub-inv85.8%
div-sub75.3%
associate-*r*75.3%
associate-*l/75.3%
*-inverses98.7%
metadata-eval98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
+-commutative98.7%
metadata-eval98.7%
associate-/l/98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (/ x y) 2.0)))
(if (<= z -6.2e+173)
t_1
(if (<= z -510000000.0)
(+ -2.0 (/ 2.0 t))
(if (or (<= z -2e-80) (not (<= z 8e-70))) t_1 (/ 2.0 (* z t)))))))
double code(double x, double y, double z, double t) {
double t_1 = (x / y) - 2.0;
double tmp;
if (z <= -6.2e+173) {
tmp = t_1;
} else if (z <= -510000000.0) {
tmp = -2.0 + (2.0 / t);
} else if ((z <= -2e-80) || !(z <= 8e-70)) {
tmp = t_1;
} else {
tmp = 2.0 / (z * t);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (x / y) - 2.0d0
if (z <= (-6.2d+173)) then
tmp = t_1
else if (z <= (-510000000.0d0)) then
tmp = (-2.0d0) + (2.0d0 / t)
else if ((z <= (-2d-80)) .or. (.not. (z <= 8d-70))) then
tmp = t_1
else
tmp = 2.0d0 / (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x / y) - 2.0;
double tmp;
if (z <= -6.2e+173) {
tmp = t_1;
} else if (z <= -510000000.0) {
tmp = -2.0 + (2.0 / t);
} else if ((z <= -2e-80) || !(z <= 8e-70)) {
tmp = t_1;
} else {
tmp = 2.0 / (z * t);
}
return tmp;
}
def code(x, y, z, t): t_1 = (x / y) - 2.0 tmp = 0 if z <= -6.2e+173: tmp = t_1 elif z <= -510000000.0: tmp = -2.0 + (2.0 / t) elif (z <= -2e-80) or not (z <= 8e-70): tmp = t_1 else: tmp = 2.0 / (z * t) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x / y) - 2.0) tmp = 0.0 if (z <= -6.2e+173) tmp = t_1; elseif (z <= -510000000.0) tmp = Float64(-2.0 + Float64(2.0 / t)); elseif ((z <= -2e-80) || !(z <= 8e-70)) tmp = t_1; else tmp = Float64(2.0 / Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x / y) - 2.0; tmp = 0.0; if (z <= -6.2e+173) tmp = t_1; elseif (z <= -510000000.0) tmp = -2.0 + (2.0 / t); elseif ((z <= -2e-80) || ~((z <= 8e-70))) tmp = t_1; else tmp = 2.0 / (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] - 2.0), $MachinePrecision]}, If[LessEqual[z, -6.2e+173], t$95$1, If[LessEqual[z, -510000000.0], N[(-2.0 + N[(2.0 / t), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -2e-80], N[Not[LessEqual[z, 8e-70]], $MachinePrecision]], t$95$1, N[(2.0 / N[(z * t), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{y} - 2\\
\mathbf{if}\;z \leq -6.2 \cdot 10^{+173}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -510000000:\\
\;\;\;\;-2 + \frac{2}{t}\\
\mathbf{elif}\;z \leq -2 \cdot 10^{-80} \lor \neg \left(z \leq 8 \cdot 10^{-70}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z \cdot t}\\
\end{array}
\end{array}
if z < -6.2e173 or -5.1e8 < z < -1.99999999999999992e-80 or 7.99999999999999997e-70 < z Initial program 76.3%
sub-neg76.3%
distribute-rgt-in76.3%
*-lft-identity76.3%
associate-+r+76.3%
cancel-sign-sub-inv76.3%
div-sub74.6%
associate-*r*74.6%
associate-*l/74.6%
*-inverses99.0%
metadata-eval99.0%
sub-neg99.0%
metadata-eval99.0%
metadata-eval99.0%
+-commutative99.0%
metadata-eval99.0%
associate-/l/99.1%
Simplified99.1%
Taylor expanded in t around inf 70.5%
if -6.2e173 < z < -5.1e8Initial program 83.7%
sub-neg83.7%
distribute-rgt-in83.7%
*-lft-identity83.7%
associate-+r+83.7%
cancel-sign-sub-inv83.7%
div-sub83.7%
associate-*r*83.7%
associate-*l/83.7%
*-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 99.7%
associate--l+99.7%
associate-*r/99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 79.3%
sub-neg79.3%
associate-*r/79.3%
metadata-eval79.3%
metadata-eval79.3%
Simplified79.3%
if -1.99999999999999992e-80 < z < 7.99999999999999997e-70Initial program 97.9%
sub-neg97.9%
distribute-rgt-in97.9%
*-lft-identity97.9%
associate-+r+97.9%
cancel-sign-sub-inv97.9%
div-sub73.4%
associate-*r*73.4%
associate-*l/73.4%
*-inverses97.9%
metadata-eval97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
+-commutative97.9%
metadata-eval97.9%
associate-/l/97.9%
Simplified97.9%
Taylor expanded in z around 0 66.7%
Final simplification70.1%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -5.7e-8) (not (<= (/ x y) 5.9e-5))) (- (/ x y) 2.0) (+ -2.0 (/ 2.0 t))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -5.7e-8) || !((x / y) <= 5.9e-5)) {
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) <= (-5.7d-8)) .or. (.not. ((x / y) <= 5.9d-5))) 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) <= -5.7e-8) || !((x / y) <= 5.9e-5)) {
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) <= -5.7e-8) or not ((x / y) <= 5.9e-5): 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) <= -5.7e-8) || !(Float64(x / y) <= 5.9e-5)) 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) <= -5.7e-8) || ~(((x / y) <= 5.9e-5))) 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], -5.7e-8], N[Not[LessEqual[N[(x / y), $MachinePrecision], 5.9e-5]], $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 -5.7 \cdot 10^{-8} \lor \neg \left(\frac{x}{y} \leq 5.9 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{x}{y} - 2\\
\mathbf{else}:\\
\;\;\;\;-2 + \frac{2}{t}\\
\end{array}
\end{array}
if (/.f64 x y) < -5.70000000000000009e-8 or 5.8999999999999998e-5 < (/.f64 x y) Initial program 83.2%
sub-neg83.2%
distribute-rgt-in83.2%
*-lft-identity83.2%
associate-+r+83.2%
cancel-sign-sub-inv83.2%
div-sub72.5%
associate-*r*72.5%
associate-*l/72.5%
*-inverses97.9%
metadata-eval97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
+-commutative97.9%
metadata-eval97.9%
associate-/l/97.9%
Simplified97.9%
Taylor expanded in t around inf 65.2%
if -5.70000000000000009e-8 < (/.f64 x y) < 5.8999999999999998e-5Initial program 89.5%
sub-neg89.5%
distribute-rgt-in89.5%
*-lft-identity89.5%
associate-+r+89.5%
cancel-sign-sub-inv89.5%
div-sub79.1%
associate-*r*79.1%
associate-*l/79.1%
*-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 66.2%
associate--l+66.2%
associate-*r/66.2%
metadata-eval66.2%
Simplified66.2%
Taylor expanded in x around 0 65.7%
sub-neg65.7%
associate-*r/65.7%
metadata-eval65.7%
metadata-eval65.7%
Simplified65.7%
Final simplification65.4%
(FPCore (x y z t) :precision binary64 (if (or (<= t -6.2e-5) (not (<= t 3.1e-12))) (+ (/ 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 <= -6.2e-5) || !(t <= 3.1e-12)) {
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 <= (-6.2d-5)) .or. (.not. (t <= 3.1d-12))) 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 <= -6.2e-5) || !(t <= 3.1e-12)) {
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 <= -6.2e-5) or not (t <= 3.1e-12): 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 <= -6.2e-5) || !(t <= 3.1e-12)) 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 <= -6.2e-5) || ~((t <= 3.1e-12))) 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, -6.2e-5], N[Not[LessEqual[t, 3.1e-12]], $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 -6.2 \cdot 10^{-5} \lor \neg \left(t \leq 3.1 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{x}{y} + \left(\frac{2}{t} - 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \frac{2}{z}}{t}\\
\end{array}
\end{array}
if t < -6.20000000000000027e-5 or 3.1000000000000001e-12 < t Initial program 75.5%
sub-neg75.5%
distribute-rgt-in75.5%
*-lft-identity75.5%
associate-+r+75.5%
cancel-sign-sub-inv75.5%
div-sub75.5%
associate-*r*75.5%
associate-*l/75.5%
*-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 z around inf 87.7%
associate--l+87.7%
associate-*r/87.7%
metadata-eval87.7%
Simplified87.7%
if -6.20000000000000027e-5 < t < 3.1000000000000001e-12Initial program 97.3%
sub-neg97.3%
distribute-rgt-in97.3%
*-lft-identity97.3%
associate-+r+97.3%
cancel-sign-sub-inv97.3%
div-sub75.0%
associate-*r*75.0%
associate-*l/75.0%
*-inverses97.3%
metadata-eval97.3%
sub-neg97.3%
metadata-eval97.3%
metadata-eval97.3%
+-commutative97.3%
metadata-eval97.3%
associate-/l/97.4%
Simplified97.4%
Taylor expanded in t around 0 81.1%
associate-*r/81.1%
metadata-eval81.1%
Simplified81.1%
Final simplification84.5%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.4e-17) (not (<= z 6e-67))) (+ (/ x y) (- (/ 2.0 t) 2.0)) (+ (/ x y) (/ 2.0 (* z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.4e-17) || !(z <= 6e-67)) {
tmp = (x / y) + ((2.0 / t) - 2.0);
} else {
tmp = (x / y) + (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 <= (-3.4d-17)) .or. (.not. (z <= 6d-67))) then
tmp = (x / y) + ((2.0d0 / t) - 2.0d0)
else
tmp = (x / y) + (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 <= -3.4e-17) || !(z <= 6e-67)) {
tmp = (x / y) + ((2.0 / t) - 2.0);
} else {
tmp = (x / y) + (2.0 / (z * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.4e-17) or not (z <= 6e-67): tmp = (x / y) + ((2.0 / t) - 2.0) else: tmp = (x / y) + (2.0 / (z * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.4e-17) || !(z <= 6e-67)) tmp = Float64(Float64(x / y) + Float64(Float64(2.0 / t) - 2.0)); else tmp = Float64(Float64(x / y) + Float64(2.0 / Float64(z * t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.4e-17) || ~((z <= 6e-67))) tmp = (x / y) + ((2.0 / t) - 2.0); else tmp = (x / y) + (2.0 / (z * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.4e-17], N[Not[LessEqual[z, 6e-67]], $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[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{-17} \lor \neg \left(z \leq 6 \cdot 10^{-67}\right):\\
\;\;\;\;\frac{x}{y} + \left(\frac{2}{t} - 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + \frac{2}{z \cdot t}\\
\end{array}
\end{array}
if z < -3.3999999999999998e-17 or 6.00000000000000065e-67 < z Initial program 75.5%
sub-neg75.5%
distribute-rgt-in75.6%
*-lft-identity75.6%
associate-+r+75.6%
cancel-sign-sub-inv75.6%
div-sub74.8%
associate-*r*74.8%
associate-*l/74.8%
*-inverses99.1%
metadata-eval99.1%
sub-neg99.1%
metadata-eval99.1%
metadata-eval99.1%
+-commutative99.1%
metadata-eval99.1%
associate-/l/99.3%
Simplified99.3%
Taylor expanded in z around inf 97.2%
associate--l+97.2%
associate-*r/97.2%
metadata-eval97.2%
Simplified97.2%
if -3.3999999999999998e-17 < z < 6.00000000000000065e-67Initial program 98.2%
+-commutative98.2%
*-commutative98.2%
associate-*r*98.2%
distribute-rgt1-in98.2%
*-commutative98.2%
times-frac98.1%
fma-def98.9%
*-commutative98.9%
fma-def98.9%
Simplified98.9%
Taylor expanded in z around 0 94.8%
Taylor expanded in z around 0 94.0%
associate-*r/94.0%
metadata-eval94.0%
+-commutative94.0%
Simplified94.0%
Final simplification95.8%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -9.4e+36) (/ x y) (if (<= (/ x y) 2.3) (+ -2.0 (/ 2.0 t)) (/ x y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -9.4e+36) {
tmp = x / y;
} else if ((x / y) <= 2.3) {
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) <= (-9.4d+36)) then
tmp = x / y
else if ((x / y) <= 2.3d0) 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) <= -9.4e+36) {
tmp = x / y;
} else if ((x / y) <= 2.3) {
tmp = -2.0 + (2.0 / t);
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -9.4e+36: tmp = x / y elif (x / y) <= 2.3: 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) <= -9.4e+36) tmp = Float64(x / y); elseif (Float64(x / y) <= 2.3) 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) <= -9.4e+36) tmp = x / y; elseif ((x / y) <= 2.3) 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], -9.4e+36], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 2.3], 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 -9.4 \cdot 10^{+36}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 2.3:\\
\;\;\;\;-2 + \frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -9.39999999999999978e36 or 2.2999999999999998 < (/.f64 x y) Initial program 83.5%
sub-neg83.5%
distribute-rgt-in83.5%
*-lft-identity83.5%
associate-+r+83.5%
cancel-sign-sub-inv83.5%
div-sub72.7%
associate-*r*72.7%
associate-*l/72.7%
*-inverses97.7%
metadata-eval97.7%
sub-neg97.7%
metadata-eval97.7%
metadata-eval97.7%
+-commutative97.7%
metadata-eval97.7%
associate-/l/97.8%
Simplified97.8%
Taylor expanded in x around inf 67.1%
if -9.39999999999999978e36 < (/.f64 x y) < 2.2999999999999998Initial program 88.6%
sub-neg88.6%
distribute-rgt-in88.6%
*-lft-identity88.6%
associate-+r+88.6%
cancel-sign-sub-inv88.6%
div-sub78.3%
associate-*r*78.3%
associate-*l/78.3%
*-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 65.0%
associate--l+65.0%
associate-*r/65.0%
metadata-eval65.0%
Simplified65.0%
Taylor expanded in x around 0 62.6%
sub-neg62.6%
associate-*r/62.6%
metadata-eval62.6%
metadata-eval62.6%
Simplified62.6%
Final simplification65.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -0.21) (not (<= t 2.3e-11))) (- (/ x y) 2.0) (/ (+ 2.0 (/ 2.0 z)) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -0.21) || !(t <= 2.3e-11)) {
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 <= (-0.21d0)) .or. (.not. (t <= 2.3d-11))) 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 <= -0.21) || !(t <= 2.3e-11)) {
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 <= -0.21) or not (t <= 2.3e-11): 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 <= -0.21) || !(t <= 2.3e-11)) 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 <= -0.21) || ~((t <= 2.3e-11))) 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, -0.21], N[Not[LessEqual[t, 2.3e-11]], $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 -0.21 \lor \neg \left(t \leq 2.3 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{x}{y} - 2\\
\mathbf{else}:\\
\;\;\;\;\frac{2 + \frac{2}{z}}{t}\\
\end{array}
\end{array}
if t < -0.209999999999999992 or 2.30000000000000014e-11 < t Initial program 75.5%
sub-neg75.5%
distribute-rgt-in75.5%
*-lft-identity75.5%
associate-+r+75.5%
cancel-sign-sub-inv75.5%
div-sub75.5%
associate-*r*75.5%
associate-*l/75.5%
*-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 85.1%
if -0.209999999999999992 < t < 2.30000000000000014e-11Initial program 97.3%
sub-neg97.3%
distribute-rgt-in97.3%
*-lft-identity97.3%
associate-+r+97.3%
cancel-sign-sub-inv97.3%
div-sub75.0%
associate-*r*75.0%
associate-*l/75.0%
*-inverses97.3%
metadata-eval97.3%
sub-neg97.3%
metadata-eval97.3%
metadata-eval97.3%
+-commutative97.3%
metadata-eval97.3%
associate-/l/97.4%
Simplified97.4%
Taylor expanded in t around 0 81.1%
associate-*r/81.1%
metadata-eval81.1%
Simplified81.1%
Final simplification83.2%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -2.0) (/ x y) (if (<= (/ x y) 2.8e-5) -2.0 (/ x y))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -2.0) {
tmp = x / y;
} else if ((x / y) <= 2.8e-5) {
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) <= (-2.0d0)) then
tmp = x / y
else if ((x / y) <= 2.8d-5) 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) <= -2.0) {
tmp = x / y;
} else if ((x / y) <= 2.8e-5) {
tmp = -2.0;
} else {
tmp = x / y;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -2.0: tmp = x / y elif (x / y) <= 2.8e-5: tmp = -2.0 else: tmp = x / y return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -2.0) tmp = Float64(x / y); elseif (Float64(x / y) <= 2.8e-5) 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) <= -2.0) tmp = x / y; elseif ((x / y) <= 2.8e-5) tmp = -2.0; else tmp = x / y; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -2.0], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 2.8e-5], -2.0, N[(x / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -2:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 2.8 \cdot 10^{-5}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y}\\
\end{array}
\end{array}
if (/.f64 x y) < -2 or 2.79999999999999996e-5 < (/.f64 x y) Initial program 83.9%
sub-neg83.9%
distribute-rgt-in83.9%
*-lft-identity83.9%
associate-+r+83.9%
cancel-sign-sub-inv83.9%
div-sub73.2%
associate-*r*73.2%
associate-*l/73.2%
*-inverses97.9%
metadata-eval97.9%
sub-neg97.9%
metadata-eval97.9%
metadata-eval97.9%
+-commutative97.9%
metadata-eval97.9%
associate-/l/97.9%
Simplified97.9%
Taylor expanded in x around inf 63.3%
if -2 < (/.f64 x y) < 2.79999999999999996e-5Initial program 88.5%
sub-neg88.5%
distribute-rgt-in88.5%
*-lft-identity88.5%
associate-+r+88.5%
cancel-sign-sub-inv88.5%
div-sub78.2%
associate-*r*78.2%
associate-*l/78.2%
*-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 99.0%
associate-*r/99.0%
metadata-eval99.0%
+-commutative99.0%
associate--l+99.0%
associate-*r/99.0%
metadata-eval99.0%
Simplified99.0%
Taylor expanded in t around inf 40.0%
Final simplification53.7%
(FPCore (x y z t) :precision binary64 (if (<= t -1.0) -2.0 (if (<= t 1.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 <= 1.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 <= 1.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 <= 1.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 <= 1.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 <= 1.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 <= 1.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, 1.0], N[(2.0 / t), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1:\\
\;\;\;\;-2\\
\mathbf{elif}\;t \leq 1:\\
\;\;\;\;\frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if t < -1 or 1 < t Initial program 74.9%
sub-neg74.9%
distribute-rgt-in74.9%
*-lft-identity74.9%
associate-+r+74.9%
cancel-sign-sub-inv74.9%
div-sub74.9%
associate-*r*74.9%
associate-*l/74.9%
*-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 x around 0 46.3%
associate-*r/46.3%
metadata-eval46.3%
+-commutative46.3%
associate--l+46.3%
associate-*r/46.3%
metadata-eval46.3%
Simplified46.3%
Taylor expanded in t around inf 33.0%
if -1 < t < 1Initial program 97.4%
sub-neg97.4%
distribute-rgt-in97.4%
*-lft-identity97.4%
associate-+r+97.4%
cancel-sign-sub-inv97.4%
div-sub75.6%
associate-*r*75.6%
associate-*l/75.6%
*-inverses97.4%
metadata-eval97.4%
sub-neg97.4%
metadata-eval97.4%
metadata-eval97.4%
+-commutative97.4%
metadata-eval97.4%
associate-/l/97.4%
Simplified97.5%
Taylor expanded in z around inf 52.7%
associate--l+52.7%
associate-*r/52.7%
metadata-eval52.7%
Simplified52.7%
Taylor expanded in t around 0 32.9%
Final simplification32.9%
(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.8%
sub-neg85.8%
distribute-rgt-in85.8%
*-lft-identity85.8%
associate-+r+85.8%
cancel-sign-sub-inv85.8%
div-sub75.3%
associate-*r*75.3%
associate-*l/75.3%
*-inverses98.7%
metadata-eval98.7%
sub-neg98.7%
metadata-eval98.7%
metadata-eval98.7%
+-commutative98.7%
metadata-eval98.7%
associate-/l/98.7%
Simplified98.7%
Taylor expanded in x around 0 63.0%
associate-*r/63.0%
metadata-eval63.0%
+-commutative63.0%
associate--l+63.0%
associate-*r/63.0%
metadata-eval63.0%
Simplified63.0%
Taylor expanded in t around inf 18.1%
Final simplification18.1%
(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 2023185
(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))))