
(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 12 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 z) -2.0) t) 2.0)))
double code(double x, double y, double z, double t) {
return (x / y) + ((((2.0 / z) - -2.0) / t) - 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 = (x / y) + ((((2.0d0 / z) - (-2.0d0)) / t) - 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
return (x / y) + ((((2.0 / z) - -2.0) / t) - 2.0);
}
def code(x, y, z, t): return (x / y) + ((((2.0 / z) - -2.0) / t) - 2.0)
function code(x, y, z, t) return Float64(Float64(x / y) + Float64(Float64(Float64(Float64(2.0 / z) - -2.0) / t) - 2.0)) end
function tmp = code(x, y, z, t) tmp = (x / y) + ((((2.0 / z) - -2.0) / t) - 2.0); end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] + N[(N[(N[(N[(2.0 / z), $MachinePrecision] - -2.0), $MachinePrecision] / t), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} + \left(\frac{\frac{2}{z} - -2}{t} - 2\right)
\end{array}
Initial program 86.6%
Taylor expanded in z around 0
Applied rewrites99.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))
(if (or (<= t_1 -2e+249) (not (or (<= t_1 5e+28) (not (<= t_1 INFINITY)))))
(/ 2.0 (* t z))
(+ (/ x y) -2.0))))
double code(double x, double y, double z, double t) {
double t_1 = (2.0 + ((z * 2.0) * (1.0 - t))) / (t * z);
double tmp;
if ((t_1 <= -2e+249) || !((t_1 <= 5e+28) || !(t_1 <= ((double) INFINITY)))) {
tmp = 2.0 / (t * z);
} else {
tmp = (x / y) + -2.0;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (2.0 + ((z * 2.0) * (1.0 - t))) / (t * z);
double tmp;
if ((t_1 <= -2e+249) || !((t_1 <= 5e+28) || !(t_1 <= Double.POSITIVE_INFINITY))) {
tmp = 2.0 / (t * z);
} else {
tmp = (x / y) + -2.0;
}
return tmp;
}
def code(x, y, z, t): t_1 = (2.0 + ((z * 2.0) * (1.0 - t))) / (t * z) tmp = 0 if (t_1 <= -2e+249) or not ((t_1 <= 5e+28) or not (t_1 <= math.inf)): tmp = 2.0 / (t * z) else: tmp = (x / y) + -2.0 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(2.0 + Float64(Float64(z * 2.0) * Float64(1.0 - t))) / Float64(t * z)) tmp = 0.0 if ((t_1 <= -2e+249) || !((t_1 <= 5e+28) || !(t_1 <= Inf))) tmp = Float64(2.0 / Float64(t * z)); else tmp = Float64(Float64(x / y) + -2.0); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (2.0 + ((z * 2.0) * (1.0 - t))) / (t * z); tmp = 0.0; if ((t_1 <= -2e+249) || ~(((t_1 <= 5e+28) || ~((t_1 <= Inf))))) tmp = 2.0 / (t * z); else tmp = (x / y) + -2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(2.0 + N[(N[(z * 2.0), $MachinePrecision] * N[(1.0 - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e+249], N[Not[Or[LessEqual[t$95$1, 5e+28], N[Not[LessEqual[t$95$1, Infinity]], $MachinePrecision]]], $MachinePrecision]], N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{2 + \left(z \cdot 2\right) \cdot \left(1 - t\right)}{t \cdot z}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+249} \lor \neg \left(t\_1 \leq 5 \cdot 10^{+28} \lor \neg \left(t\_1 \leq \infty\right)\right):\\
\;\;\;\;\frac{2}{t \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + -2\\
\end{array}
\end{array}
if (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < -1.9999999999999998e249 or 4.99999999999999957e28 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < +inf.0Initial program 97.8%
Taylor expanded in z around 0
Applied rewrites97.9%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f6463.6
Applied rewrites63.6%
if -1.9999999999999998e249 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) < 4.99999999999999957e28 or +inf.0 < (/.f64 (+.f64 #s(literal 2 binary64) (*.f64 (*.f64 z #s(literal 2 binary64)) (-.f64 #s(literal 1 binary64) t))) (*.f64 t z)) Initial program 79.0%
Taylor expanded in t around inf
Applied rewrites82.9%
Final simplification75.1%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -6.6e+66) (not (<= (/ x y) 4.8e+28))) (+ (/ x y) (/ 2.0 t)) (- (/ (- (/ 2.0 z) -2.0) t) 2.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -6.6e+66) || !((x / y) <= 4.8e+28)) {
tmp = (x / y) + (2.0 / t);
} else {
tmp = (((2.0 / z) - -2.0) / t) - 2.0;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x / y) <= (-6.6d+66)) .or. (.not. ((x / y) <= 4.8d+28))) then
tmp = (x / y) + (2.0d0 / t)
else
tmp = (((2.0d0 / z) - (-2.0d0)) / t) - 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -6.6e+66) || !((x / y) <= 4.8e+28)) {
tmp = (x / y) + (2.0 / t);
} else {
tmp = (((2.0 / z) - -2.0) / t) - 2.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -6.6e+66) or not ((x / y) <= 4.8e+28): tmp = (x / y) + (2.0 / t) else: tmp = (((2.0 / z) - -2.0) / t) - 2.0 return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -6.6e+66) || !(Float64(x / y) <= 4.8e+28)) tmp = Float64(Float64(x / y) + Float64(2.0 / t)); else tmp = Float64(Float64(Float64(Float64(2.0 / z) - -2.0) / t) - 2.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -6.6e+66) || ~(((x / y) <= 4.8e+28))) tmp = (x / y) + (2.0 / t); else tmp = (((2.0 / z) - -2.0) / t) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -6.6e+66], N[Not[LessEqual[N[(x / y), $MachinePrecision], 4.8e+28]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(2.0 / t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(2.0 / z), $MachinePrecision] - -2.0), $MachinePrecision] / t), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -6.6 \cdot 10^{+66} \lor \neg \left(\frac{x}{y} \leq 4.8 \cdot 10^{+28}\right):\\
\;\;\;\;\frac{x}{y} + \frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{z} - -2}{t} - 2\\
\end{array}
\end{array}
if (/.f64 x y) < -6.6000000000000003e66 or 4.79999999999999962e28 < (/.f64 x y) Initial program 88.8%
Taylor expanded in t around 0
associate-/l/N/A
Applied rewrites98.3%
Taylor expanded in z around inf
Applied rewrites81.4%
if -6.6000000000000003e66 < (/.f64 x y) < 4.79999999999999962e28Initial program 84.4%
Taylor expanded in x around 0
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
associate-*r/N/A
metadata-evalN/A
associate--l+N/A
lower--.f64N/A
Applied rewrites94.0%
Final simplification87.8%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -6.6e+66) (not (<= (/ x y) 4.8e+28))) (+ (/ x y) (/ 2.0 t)) (- (/ (fma z 2.0 2.0) (* t z)) 2.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -6.6e+66) || !((x / y) <= 4.8e+28)) {
tmp = (x / y) + (2.0 / t);
} else {
tmp = (fma(z, 2.0, 2.0) / (t * z)) - 2.0;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -6.6e+66) || !(Float64(x / y) <= 4.8e+28)) tmp = Float64(Float64(x / y) + Float64(2.0 / t)); else tmp = Float64(Float64(fma(z, 2.0, 2.0) / Float64(t * z)) - 2.0); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -6.6e+66], N[Not[LessEqual[N[(x / y), $MachinePrecision], 4.8e+28]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(2.0 / t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * 2.0 + 2.0), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -6.6 \cdot 10^{+66} \lor \neg \left(\frac{x}{y} \leq 4.8 \cdot 10^{+28}\right):\\
\;\;\;\;\frac{x}{y} + \frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, 2, 2\right)}{t \cdot z} - 2\\
\end{array}
\end{array}
if (/.f64 x y) < -6.6000000000000003e66 or 4.79999999999999962e28 < (/.f64 x y) Initial program 88.8%
Taylor expanded in t around 0
associate-/l/N/A
Applied rewrites98.3%
Taylor expanded in z around inf
Applied rewrites81.4%
if -6.6000000000000003e66 < (/.f64 x y) < 4.79999999999999962e28Initial program 84.4%
Taylor expanded in x around 0
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
associate-*r/N/A
metadata-evalN/A
associate--l+N/A
lower--.f64N/A
Applied rewrites94.0%
Taylor expanded in z around inf
Applied rewrites56.7%
Taylor expanded in z around 0
Applied rewrites93.9%
Final simplification87.7%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -4.8e+67) (not (<= (/ x y) 5.6e+28))) (/ x y) (- (/ (fma z 2.0 2.0) (* t z)) 2.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -4.8e+67) || !((x / y) <= 5.6e+28)) {
tmp = x / y;
} else {
tmp = (fma(z, 2.0, 2.0) / (t * z)) - 2.0;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -4.8e+67) || !(Float64(x / y) <= 5.6e+28)) tmp = Float64(x / y); else tmp = Float64(Float64(fma(z, 2.0, 2.0) / Float64(t * z)) - 2.0); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -4.8e+67], N[Not[LessEqual[N[(x / y), $MachinePrecision], 5.6e+28]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(N[(N[(z * 2.0 + 2.0), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -4.8 \cdot 10^{+67} \lor \neg \left(\frac{x}{y} \leq 5.6 \cdot 10^{+28}\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, 2, 2\right)}{t \cdot z} - 2\\
\end{array}
\end{array}
if (/.f64 x y) < -4.80000000000000004e67 or 5.6000000000000003e28 < (/.f64 x y) Initial program 88.8%
Taylor expanded in x around inf
lower-/.f6475.6
Applied rewrites75.6%
if -4.80000000000000004e67 < (/.f64 x y) < 5.6000000000000003e28Initial program 84.4%
Taylor expanded in x around 0
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
associate-*r/N/A
metadata-evalN/A
associate--l+N/A
lower--.f64N/A
Applied rewrites94.0%
Taylor expanded in z around inf
Applied rewrites56.7%
Taylor expanded in z around 0
Applied rewrites93.9%
Final simplification84.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -17000.0) (not (<= z 1.4e-18))) (+ (/ x y) (- -2.0 (/ -2.0 t))) (+ (/ x y) (- (/ (/ 2.0 z) t) 2.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -17000.0) || !(z <= 1.4e-18)) {
tmp = (x / y) + (-2.0 - (-2.0 / t));
} else {
tmp = (x / y) + (((2.0 / z) / t) - 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 ((z <= (-17000.0d0)) .or. (.not. (z <= 1.4d-18))) then
tmp = (x / y) + ((-2.0d0) - ((-2.0d0) / t))
else
tmp = (x / y) + (((2.0d0 / z) / t) - 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -17000.0) || !(z <= 1.4e-18)) {
tmp = (x / y) + (-2.0 - (-2.0 / t));
} else {
tmp = (x / y) + (((2.0 / z) / t) - 2.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -17000.0) or not (z <= 1.4e-18): tmp = (x / y) + (-2.0 - (-2.0 / t)) else: tmp = (x / y) + (((2.0 / z) / t) - 2.0) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -17000.0) || !(z <= 1.4e-18)) tmp = Float64(Float64(x / y) + Float64(-2.0 - Float64(-2.0 / t))); else tmp = Float64(Float64(x / y) + Float64(Float64(Float64(2.0 / z) / t) - 2.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -17000.0) || ~((z <= 1.4e-18))) tmp = (x / y) + (-2.0 - (-2.0 / t)); else tmp = (x / y) + (((2.0 / z) / t) - 2.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -17000.0], N[Not[LessEqual[z, 1.4e-18]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(-2.0 - N[(-2.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + N[(N[(N[(2.0 / z), $MachinePrecision] / t), $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -17000 \lor \neg \left(z \leq 1.4 \cdot 10^{-18}\right):\\
\;\;\;\;\frac{x}{y} + \left(-2 - \frac{-2}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + \left(\frac{\frac{2}{z}}{t} - 2\right)\\
\end{array}
\end{array}
if z < -17000 or 1.40000000000000006e-18 < z Initial program 75.8%
Taylor expanded in z around inf
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
metadata-evalN/A
sub-negN/A
lower--.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
if -17000 < z < 1.40000000000000006e-18Initial program 98.2%
Taylor expanded in z around 0
Applied rewrites98.2%
Taylor expanded in z around 0
Applied rewrites98.1%
Final simplification98.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -17000.0) (not (<= z 2.5e-19))) (+ (/ x y) (- -2.0 (/ -2.0 t))) (+ (/ x y) (/ (/ 2.0 z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -17000.0) || !(z <= 2.5e-19)) {
tmp = (x / y) + (-2.0 - (-2.0 / t));
} 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 <= (-17000.0d0)) .or. (.not. (z <= 2.5d-19))) then
tmp = (x / y) + ((-2.0d0) - ((-2.0d0) / t))
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 <= -17000.0) || !(z <= 2.5e-19)) {
tmp = (x / y) + (-2.0 - (-2.0 / t));
} else {
tmp = (x / y) + ((2.0 / z) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -17000.0) or not (z <= 2.5e-19): tmp = (x / y) + (-2.0 - (-2.0 / t)) else: tmp = (x / y) + ((2.0 / z) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -17000.0) || !(z <= 2.5e-19)) tmp = Float64(Float64(x / y) + Float64(-2.0 - Float64(-2.0 / t))); else tmp = Float64(Float64(x / y) + Float64(Float64(2.0 / z) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -17000.0) || ~((z <= 2.5e-19))) tmp = (x / y) + (-2.0 - (-2.0 / t)); else tmp = (x / y) + ((2.0 / z) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -17000.0], N[Not[LessEqual[z, 2.5e-19]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(-2.0 - N[(-2.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + N[(N[(2.0 / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -17000 \lor \neg \left(z \leq 2.5 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{x}{y} + \left(-2 - \frac{-2}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + \frac{\frac{2}{z}}{t}\\
\end{array}
\end{array}
if z < -17000 or 2.5000000000000002e-19 < z Initial program 75.8%
Taylor expanded in z around inf
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
metadata-evalN/A
sub-negN/A
lower--.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
if -17000 < z < 2.5000000000000002e-19Initial program 98.2%
Taylor expanded in t around 0
associate-/l/N/A
Applied rewrites89.6%
Taylor expanded in z around 0
Applied rewrites89.4%
Final simplification94.8%
(FPCore (x y z t) :precision binary64 (if (or (<= (/ x y) -1.9e+44) (not (<= (/ x y) 1000.0))) (/ x y) (- (/ 2.0 t) 2.0)))
double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -1.9e+44) || !((x / y) <= 1000.0)) {
tmp = x / y;
} else {
tmp = (2.0 / t) - 2.0;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (((x / y) <= (-1.9d+44)) .or. (.not. ((x / y) <= 1000.0d0))) then
tmp = x / y
else
tmp = (2.0d0 / t) - 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x / y) <= -1.9e+44) || !((x / y) <= 1000.0)) {
tmp = x / y;
} else {
tmp = (2.0 / t) - 2.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x / y) <= -1.9e+44) or not ((x / y) <= 1000.0): tmp = x / y else: tmp = (2.0 / t) - 2.0 return tmp
function code(x, y, z, t) tmp = 0.0 if ((Float64(x / y) <= -1.9e+44) || !(Float64(x / y) <= 1000.0)) tmp = Float64(x / y); else tmp = Float64(Float64(2.0 / t) - 2.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x / y) <= -1.9e+44) || ~(((x / y) <= 1000.0))) tmp = x / y; else tmp = (2.0 / t) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[N[(x / y), $MachinePrecision], -1.9e+44], N[Not[LessEqual[N[(x / y), $MachinePrecision], 1000.0]], $MachinePrecision]], N[(x / y), $MachinePrecision], N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -1.9 \cdot 10^{+44} \lor \neg \left(\frac{x}{y} \leq 1000\right):\\
\;\;\;\;\frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{t} - 2\\
\end{array}
\end{array}
if (/.f64 x y) < -1.9000000000000001e44 or 1e3 < (/.f64 x y) Initial program 88.4%
Taylor expanded in x around inf
lower-/.f6471.6
Applied rewrites71.6%
if -1.9000000000000001e44 < (/.f64 x y) < 1e3Initial program 84.4%
Taylor expanded in x around 0
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
associate-*r/N/A
metadata-evalN/A
associate--l+N/A
lower--.f64N/A
Applied rewrites98.1%
Taylor expanded in z around inf
Applied rewrites61.7%
Final simplification67.1%
(FPCore (x y z t) :precision binary64 (if (<= (/ x y) -1.9e+44) (/ x y) (if (<= (/ x y) 38.0) (- (/ 2.0 t) 2.0) (+ (/ x y) -2.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -1.9e+44) {
tmp = x / y;
} else if ((x / y) <= 38.0) {
tmp = (2.0 / t) - 2.0;
} else {
tmp = (x / y) + -2.0;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x / y) <= (-1.9d+44)) then
tmp = x / y
else if ((x / y) <= 38.0d0) then
tmp = (2.0d0 / t) - 2.0d0
else
tmp = (x / y) + (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x / y) <= -1.9e+44) {
tmp = x / y;
} else if ((x / y) <= 38.0) {
tmp = (2.0 / t) - 2.0;
} else {
tmp = (x / y) + -2.0;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x / y) <= -1.9e+44: tmp = x / y elif (x / y) <= 38.0: tmp = (2.0 / t) - 2.0 else: tmp = (x / y) + -2.0 return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x / y) <= -1.9e+44) tmp = Float64(x / y); elseif (Float64(x / y) <= 38.0) tmp = Float64(Float64(2.0 / t) - 2.0); else tmp = Float64(Float64(x / y) + -2.0); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x / y) <= -1.9e+44) tmp = x / y; elseif ((x / y) <= 38.0) tmp = (2.0 / t) - 2.0; else tmp = (x / y) + -2.0; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x / y), $MachinePrecision], -1.9e+44], N[(x / y), $MachinePrecision], If[LessEqual[N[(x / y), $MachinePrecision], 38.0], N[(N[(2.0 / t), $MachinePrecision] - 2.0), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + -2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{y} \leq -1.9 \cdot 10^{+44}:\\
\;\;\;\;\frac{x}{y}\\
\mathbf{elif}\;\frac{x}{y} \leq 38:\\
\;\;\;\;\frac{2}{t} - 2\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + -2\\
\end{array}
\end{array}
if (/.f64 x y) < -1.9000000000000001e44Initial program 89.6%
Taylor expanded in x around inf
lower-/.f6477.2
Applied rewrites77.2%
if -1.9000000000000001e44 < (/.f64 x y) < 38Initial program 84.4%
Taylor expanded in x around 0
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
associate-*r/N/A
metadata-evalN/A
associate--l+N/A
lower--.f64N/A
Applied rewrites98.1%
Taylor expanded in z around inf
Applied rewrites61.7%
if 38 < (/.f64 x y) Initial program 87.2%
Taylor expanded in t around inf
Applied rewrites67.6%
(FPCore (x y z t) :precision binary64 (if (or (<= z -17000.0) (not (<= z 2.5e-19))) (+ (/ x y) (- -2.0 (/ -2.0 t))) (+ (/ x y) (/ 2.0 (* t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -17000.0) || !(z <= 2.5e-19)) {
tmp = (x / y) + (-2.0 - (-2.0 / t));
} else {
tmp = (x / y) + (2.0 / (t * z));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-17000.0d0)) .or. (.not. (z <= 2.5d-19))) then
tmp = (x / y) + ((-2.0d0) - ((-2.0d0) / t))
else
tmp = (x / y) + (2.0d0 / (t * z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -17000.0) || !(z <= 2.5e-19)) {
tmp = (x / y) + (-2.0 - (-2.0 / t));
} else {
tmp = (x / y) + (2.0 / (t * z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -17000.0) or not (z <= 2.5e-19): tmp = (x / y) + (-2.0 - (-2.0 / t)) else: tmp = (x / y) + (2.0 / (t * z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -17000.0) || !(z <= 2.5e-19)) tmp = Float64(Float64(x / y) + Float64(-2.0 - Float64(-2.0 / t))); else tmp = Float64(Float64(x / y) + Float64(2.0 / Float64(t * z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -17000.0) || ~((z <= 2.5e-19))) tmp = (x / y) + (-2.0 - (-2.0 / t)); else tmp = (x / y) + (2.0 / (t * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -17000.0], N[Not[LessEqual[z, 2.5e-19]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(-2.0 - N[(-2.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] + N[(2.0 / N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -17000 \lor \neg \left(z \leq 2.5 \cdot 10^{-19}\right):\\
\;\;\;\;\frac{x}{y} + \left(-2 - \frac{-2}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} + \frac{2}{t \cdot z}\\
\end{array}
\end{array}
if z < -17000 or 2.5000000000000002e-19 < z Initial program 75.8%
Taylor expanded in z around inf
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
metadata-evalN/A
sub-negN/A
lower--.f64N/A
lower-/.f6499.7
Applied rewrites99.7%
if -17000 < z < 2.5000000000000002e-19Initial program 98.2%
Taylor expanded in z around 0
Applied rewrites89.4%
Final simplification94.8%
(FPCore (x y z t) :precision binary64 (if (or (<= z -6.2e-103) (not (<= z 1.02e-27))) (+ (/ x y) (- -2.0 (/ -2.0 t))) (- (/ (fma z 2.0 2.0) (* t z)) 2.0)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -6.2e-103) || !(z <= 1.02e-27)) {
tmp = (x / y) + (-2.0 - (-2.0 / t));
} else {
tmp = (fma(z, 2.0, 2.0) / (t * z)) - 2.0;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -6.2e-103) || !(z <= 1.02e-27)) tmp = Float64(Float64(x / y) + Float64(-2.0 - Float64(-2.0 / t))); else tmp = Float64(Float64(fma(z, 2.0, 2.0) / Float64(t * z)) - 2.0); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -6.2e-103], N[Not[LessEqual[z, 1.02e-27]], $MachinePrecision]], N[(N[(x / y), $MachinePrecision] + N[(-2.0 - N[(-2.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * 2.0 + 2.0), $MachinePrecision] / N[(t * z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{-103} \lor \neg \left(z \leq 1.02 \cdot 10^{-27}\right):\\
\;\;\;\;\frac{x}{y} + \left(-2 - \frac{-2}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(z, 2, 2\right)}{t \cdot z} - 2\\
\end{array}
\end{array}
if z < -6.2000000000000003e-103 or 1.02000000000000002e-27 < z Initial program 79.7%
Taylor expanded in z around inf
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
+-commutativeN/A
remove-double-negN/A
mul-1-negN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
metadata-evalN/A
sub-negN/A
lower--.f64N/A
lower-/.f6495.0
Applied rewrites95.0%
if -6.2000000000000003e-103 < z < 1.02000000000000002e-27Initial program 97.8%
Taylor expanded in x around 0
div-subN/A
sub-negN/A
*-inversesN/A
metadata-evalN/A
distribute-lft-inN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
associate-*r/N/A
metadata-evalN/A
associate--l+N/A
lower--.f64N/A
Applied rewrites77.2%
Taylor expanded in z around inf
Applied rewrites10.7%
Taylor expanded in z around 0
Applied rewrites77.2%
Final simplification88.3%
(FPCore (x y z t) :precision binary64 (/ x y))
double code(double x, double y, double z, double t) {
return 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 = x / y
end function
public static double code(double x, double y, double z, double t) {
return x / y;
}
def code(x, y, z, t): return x / y
function code(x, y, z, t) return Float64(x / y) end
function tmp = code(x, y, z, t) tmp = x / y; end
code[x_, y_, z_, t_] := N[(x / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y}
\end{array}
Initial program 86.6%
Taylor expanded in x around inf
lower-/.f6440.8
Applied rewrites40.8%
(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 2024318
(FPCore (x y z t)
:name "Data.HashTable.ST.Basic:computeOverhead from hashtables-1.2.0.2"
:precision binary64
:alt
(! :herbie-platform default (- (/ (+ (/ 2 z) 2) t) (- 2 (/ x y))))
(+ (/ x y) (/ (+ 2.0 (* (* z 2.0) (- 1.0 t))) (* t z))))