
(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(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 - (log(((1.0d0 - y) + (y * exp(z)))) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function tmp = code(x, y, z, t) tmp = x - (log(((1.0 - y) + (y * exp(z)))) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(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 - (log(((1.0d0 - y) + (y * exp(z)))) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function tmp = code(x, y, z, t) tmp = x - (log(((1.0 - y) + (y * exp(z)))) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (- x (/ (log1p (* y (expm1 z))) t)))
double code(double x, double y, double z, double t) {
return x - (log1p((y * expm1(z))) / t);
}
public static double code(double x, double y, double z, double t) {
return x - (Math.log1p((y * Math.expm1(z))) / t);
}
def code(x, y, z, t): return x - (math.log1p((y * math.expm1(z))) / t)
function code(x, y, z, t) return Float64(x - Float64(log1p(Float64(y * expm1(z))) / t)) end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}
\end{array}
Initial program 65.3%
remove-double-neg65.3%
neg-mul-165.3%
*-commutative65.3%
*-commutative65.3%
neg-mul-165.3%
remove-double-neg65.3%
sub-neg65.3%
associate-+l+76.2%
cancel-sign-sub76.2%
log1p-def82.6%
cancel-sign-sub82.6%
+-commutative82.6%
unsub-neg82.6%
*-rgt-identity82.6%
distribute-lft-out--82.6%
expm1-def98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x y z t)
:precision binary64
(if (<= y -20000000.0)
(+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z)))))
(if (<= y 5e-5)
(- x (/ y (/ t (expm1 z))))
(+ x (* (log1p (* y z)) (/ -1.0 t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -20000000.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else if (y <= 5e-5) {
tmp = x - (y / (t / expm1(z)));
} else {
tmp = x + (log1p((y * z)) * (-1.0 / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -20000000.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else if (y <= 5e-5) {
tmp = x - (y / (t / Math.expm1(z)));
} else {
tmp = x + (Math.log1p((y * z)) * (-1.0 / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -20000000.0: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) elif y <= 5e-5: tmp = x - (y / (t / math.expm1(z))) else: tmp = x + (math.log1p((y * z)) * (-1.0 / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -20000000.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); elseif (y <= 5e-5) tmp = Float64(x - Float64(y / Float64(t / expm1(z)))); else tmp = Float64(x + Float64(log1p(Float64(y * z)) * Float64(-1.0 / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -20000000.0], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e-5], N[(x - N[(y / N[(t / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] * N[(-1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -20000000:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-5}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x + \mathsf{log1p}\left(y \cdot z\right) \cdot \frac{-1}{t}\\
\end{array}
\end{array}
if y < -2e7Initial program 56.6%
remove-double-neg56.6%
neg-mul-156.6%
*-commutative56.6%
*-commutative56.6%
neg-mul-156.6%
remove-double-neg56.6%
sub-neg56.6%
associate-+l+77.8%
cancel-sign-sub77.8%
log1p-def77.8%
cancel-sign-sub77.8%
+-commutative77.8%
unsub-neg77.8%
*-rgt-identity77.8%
distribute-lft-out--77.8%
expm1-def99.7%
Simplified99.7%
Taylor expanded in z around 0 63.3%
clear-num63.3%
inv-pow63.3%
Applied egg-rr63.3%
unpow-163.3%
Simplified63.3%
Taylor expanded in y around 0 74.7%
if -2e7 < y < 5.00000000000000024e-5Initial program 79.6%
remove-double-neg79.6%
neg-mul-179.6%
*-commutative79.6%
*-commutative79.6%
neg-mul-179.6%
remove-double-neg79.6%
sub-neg79.6%
associate-+l+79.6%
cancel-sign-sub79.6%
log1p-def89.1%
cancel-sign-sub89.1%
+-commutative89.1%
unsub-neg89.1%
*-rgt-identity89.1%
distribute-lft-out--89.1%
expm1-def98.3%
Simplified98.3%
Taylor expanded in y around 0 89.1%
associate-/l*89.1%
expm1-def100.0%
Simplified100.0%
if 5.00000000000000024e-5 < y Initial program 7.5%
remove-double-neg7.5%
neg-mul-17.5%
*-commutative7.5%
*-commutative7.5%
neg-mul-17.5%
remove-double-neg7.5%
sub-neg7.5%
associate-+l+56.9%
cancel-sign-sub56.9%
log1p-def56.9%
cancel-sign-sub56.9%
+-commutative56.9%
unsub-neg56.9%
*-rgt-identity56.9%
distribute-lft-out--57.0%
expm1-def99.8%
Simplified99.8%
Taylor expanded in z around 0 98.1%
clear-num98.1%
associate-/r/98.2%
Applied egg-rr98.2%
Final simplification94.6%
(FPCore (x y z t) :precision binary64 (if (<= z -0.0245) (+ x (/ (/ -1.0 t) (+ 0.5 (/ (/ 1.0 y) (expm1 z))))) (+ x (/ -1.0 (/ t (log1p (* y z)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.0245) {
tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / y) / expm1(z))));
} else {
tmp = x + (-1.0 / (t / log1p((y * z))));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.0245) {
tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / y) / Math.expm1(z))));
} else {
tmp = x + (-1.0 / (t / Math.log1p((y * z))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.0245: tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / y) / math.expm1(z)))) else: tmp = x + (-1.0 / (t / math.log1p((y * z)))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.0245) tmp = Float64(x + Float64(Float64(-1.0 / t) / Float64(0.5 + Float64(Float64(1.0 / y) / expm1(z))))); else tmp = Float64(x + Float64(-1.0 / Float64(t / log1p(Float64(y * z))))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.0245], N[(x + N[(N[(-1.0 / t), $MachinePrecision] / N[(0.5 + N[(N[(1.0 / y), $MachinePrecision] / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(-1.0 / N[(t / N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0245:\\
\;\;\;\;x + \frac{\frac{-1}{t}}{0.5 + \frac{\frac{1}{y}}{\mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{\frac{t}{\mathsf{log1p}\left(y \cdot z\right)}}\\
\end{array}
\end{array}
if z < -0.024500000000000001Initial program 79.6%
remove-double-neg79.6%
neg-mul-179.6%
*-commutative79.6%
*-commutative79.6%
neg-mul-179.6%
remove-double-neg79.6%
sub-neg79.6%
associate-+l+79.6%
cancel-sign-sub79.6%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-def99.9%
Simplified99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
div-inv99.8%
associate-/r*99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 88.1%
associate-/r*88.1%
expm1-def88.1%
Simplified88.1%
if -0.024500000000000001 < z Initial program 58.9%
remove-double-neg58.9%
neg-mul-158.9%
*-commutative58.9%
*-commutative58.9%
neg-mul-158.9%
remove-double-neg58.9%
sub-neg58.9%
associate-+l+74.7%
cancel-sign-sub74.7%
log1p-def74.7%
cancel-sign-sub74.7%
+-commutative74.7%
unsub-neg74.7%
*-rgt-identity74.7%
distribute-lft-out--74.7%
expm1-def98.3%
Simplified98.3%
Taylor expanded in z around 0 98.0%
clear-num98.0%
inv-pow98.0%
Applied egg-rr98.0%
unpow-198.0%
Simplified98.0%
Final simplification94.9%
(FPCore (x y z t) :precision binary64 (if (<= y -3300000.0) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (if (<= y 5e-5) (- x (/ y (/ t (expm1 z)))) (- x (/ (log1p (* y z)) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3300000.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else if (y <= 5e-5) {
tmp = x - (y / (t / expm1(z)));
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3300000.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else if (y <= 5e-5) {
tmp = x - (y / (t / Math.expm1(z)));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3300000.0: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) elif y <= 5e-5: tmp = x - (y / (t / math.expm1(z))) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3300000.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); elseif (y <= 5e-5) tmp = Float64(x - Float64(y / Float64(t / expm1(z)))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3300000.0], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5e-5], N[(x - N[(y / N[(t / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3300000:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-5}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if y < -3.3e6Initial program 56.6%
remove-double-neg56.6%
neg-mul-156.6%
*-commutative56.6%
*-commutative56.6%
neg-mul-156.6%
remove-double-neg56.6%
sub-neg56.6%
associate-+l+77.8%
cancel-sign-sub77.8%
log1p-def77.8%
cancel-sign-sub77.8%
+-commutative77.8%
unsub-neg77.8%
*-rgt-identity77.8%
distribute-lft-out--77.8%
expm1-def99.7%
Simplified99.7%
Taylor expanded in z around 0 63.3%
clear-num63.3%
inv-pow63.3%
Applied egg-rr63.3%
unpow-163.3%
Simplified63.3%
Taylor expanded in y around 0 74.7%
if -3.3e6 < y < 5.00000000000000024e-5Initial program 79.6%
remove-double-neg79.6%
neg-mul-179.6%
*-commutative79.6%
*-commutative79.6%
neg-mul-179.6%
remove-double-neg79.6%
sub-neg79.6%
associate-+l+79.6%
cancel-sign-sub79.6%
log1p-def89.1%
cancel-sign-sub89.1%
+-commutative89.1%
unsub-neg89.1%
*-rgt-identity89.1%
distribute-lft-out--89.1%
expm1-def98.3%
Simplified98.3%
Taylor expanded in y around 0 89.1%
associate-/l*89.1%
expm1-def100.0%
Simplified100.0%
if 5.00000000000000024e-5 < y Initial program 7.5%
remove-double-neg7.5%
neg-mul-17.5%
*-commutative7.5%
*-commutative7.5%
neg-mul-17.5%
remove-double-neg7.5%
sub-neg7.5%
associate-+l+56.9%
cancel-sign-sub56.9%
log1p-def56.9%
cancel-sign-sub56.9%
+-commutative56.9%
unsub-neg56.9%
*-rgt-identity56.9%
distribute-lft-out--57.0%
expm1-def99.8%
Simplified99.8%
Taylor expanded in z around 0 98.1%
Final simplification94.6%
(FPCore (x y z t) :precision binary64 (if (<= y -3300000.0) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (- x (/ y (/ t (expm1 z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3300000.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (y / (t / expm1(z)));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3300000.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (y / (t / Math.expm1(z)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3300000.0: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x - (y / (t / math.expm1(z))) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3300000.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x - Float64(y / Float64(t / expm1(z)))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3300000.0], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / N[(t / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3300000:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\end{array}
\end{array}
if y < -3.3e6Initial program 56.6%
remove-double-neg56.6%
neg-mul-156.6%
*-commutative56.6%
*-commutative56.6%
neg-mul-156.6%
remove-double-neg56.6%
sub-neg56.6%
associate-+l+77.8%
cancel-sign-sub77.8%
log1p-def77.8%
cancel-sign-sub77.8%
+-commutative77.8%
unsub-neg77.8%
*-rgt-identity77.8%
distribute-lft-out--77.8%
expm1-def99.7%
Simplified99.7%
Taylor expanded in z around 0 63.3%
clear-num63.3%
inv-pow63.3%
Applied egg-rr63.3%
unpow-163.3%
Simplified63.3%
Taylor expanded in y around 0 74.7%
if -3.3e6 < y Initial program 67.6%
remove-double-neg67.6%
neg-mul-167.6%
*-commutative67.6%
*-commutative67.6%
neg-mul-167.6%
remove-double-neg67.6%
sub-neg67.6%
associate-+l+75.8%
cancel-sign-sub75.8%
log1p-def83.8%
cancel-sign-sub83.8%
+-commutative83.8%
unsub-neg83.8%
*-rgt-identity83.8%
distribute-lft-out--83.8%
expm1-def98.6%
Simplified98.6%
Taylor expanded in y around 0 83.3%
associate-/l*83.3%
expm1-def94.6%
Simplified94.6%
Final simplification90.5%
(FPCore (x y z t) :precision binary64 (if (<= z -1.45e+53) x (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.45e+53) {
tmp = x;
} else {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * 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 <= (-1.45d+53)) then
tmp = x
else
tmp = x + ((-1.0d0) / ((t * 0.5d0) + (t / (y * z))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.45e+53) {
tmp = x;
} else {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.45e+53: tmp = x else: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.45e+53) tmp = x; else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.45e+53) tmp = x; else tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.45e+53], x, N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{+53}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\end{array}
\end{array}
if z < -1.4500000000000001e53Initial program 81.2%
remove-double-neg81.2%
neg-mul-181.2%
*-commutative81.2%
*-commutative81.2%
neg-mul-181.2%
remove-double-neg81.2%
sub-neg81.2%
associate-+l+81.2%
cancel-sign-sub81.2%
log1p-def100.0%
cancel-sign-sub100.0%
+-commutative100.0%
unsub-neg100.0%
*-rgt-identity100.0%
distribute-lft-out--100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 68.1%
if -1.4500000000000001e53 < z Initial program 59.8%
remove-double-neg59.8%
neg-mul-159.8%
*-commutative59.8%
*-commutative59.8%
neg-mul-159.8%
remove-double-neg59.8%
sub-neg59.8%
associate-+l+74.5%
cancel-sign-sub74.5%
log1p-def76.5%
cancel-sign-sub76.5%
+-commutative76.5%
unsub-neg76.5%
*-rgt-identity76.5%
distribute-lft-out--76.5%
expm1-def98.4%
Simplified98.4%
Taylor expanded in z around 0 93.4%
clear-num93.4%
inv-pow93.4%
Applied egg-rr93.4%
unpow-193.4%
Simplified93.4%
Taylor expanded in y around 0 88.5%
Final simplification83.2%
(FPCore (x y z t) :precision binary64 (+ x (/ (/ -1.0 t) (+ 0.5 (- (/ 1.0 (* y z)) (/ 0.5 y))))))
double code(double x, double y, double z, double t) {
return x + ((-1.0 / t) / (0.5 + ((1.0 / (y * z)) - (0.5 / 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 + (((-1.0d0) / t) / (0.5d0 + ((1.0d0 / (y * z)) - (0.5d0 / y))))
end function
public static double code(double x, double y, double z, double t) {
return x + ((-1.0 / t) / (0.5 + ((1.0 / (y * z)) - (0.5 / y))));
}
def code(x, y, z, t): return x + ((-1.0 / t) / (0.5 + ((1.0 / (y * z)) - (0.5 / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(-1.0 / t) / Float64(0.5 + Float64(Float64(1.0 / Float64(y * z)) - Float64(0.5 / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((-1.0 / t) / (0.5 + ((1.0 / (y * z)) - (0.5 / y)))); end
code[x_, y_, z_, t_] := N[(x + N[(N[(-1.0 / t), $MachinePrecision] / N[(0.5 + N[(N[(1.0 / N[(y * z), $MachinePrecision]), $MachinePrecision] - N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\frac{-1}{t}}{0.5 + \left(\frac{1}{y \cdot z} - \frac{0.5}{y}\right)}
\end{array}
Initial program 65.3%
remove-double-neg65.3%
neg-mul-165.3%
*-commutative65.3%
*-commutative65.3%
neg-mul-165.3%
remove-double-neg65.3%
sub-neg65.3%
associate-+l+76.2%
cancel-sign-sub76.2%
log1p-def82.6%
cancel-sign-sub82.6%
+-commutative82.6%
unsub-neg82.6%
*-rgt-identity82.6%
distribute-lft-out--82.6%
expm1-def98.8%
Simplified98.8%
clear-num98.8%
inv-pow98.8%
Applied egg-rr98.8%
unpow-198.8%
div-inv98.5%
associate-/r*98.5%
Applied egg-rr98.5%
Taylor expanded in y around 0 78.5%
associate-/r*78.5%
expm1-def89.9%
Simplified89.9%
Taylor expanded in z around 0 84.6%
associate-*r/84.6%
metadata-eval84.6%
Simplified84.6%
Final simplification84.6%
(FPCore (x y z t) :precision binary64 (if (<= z -5e-21) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5e-21) {
tmp = x;
} else {
tmp = x - (y * (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 <= (-5d-21)) then
tmp = x
else
tmp = x - (y * (z / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5e-21) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5e-21: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5e-21) tmp = x; else tmp = Float64(x - Float64(y * Float64(z / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -5e-21) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5e-21], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-21}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -4.99999999999999973e-21Initial program 78.5%
remove-double-neg78.5%
neg-mul-178.5%
*-commutative78.5%
*-commutative78.5%
neg-mul-178.5%
remove-double-neg78.5%
sub-neg78.5%
associate-+l+79.8%
cancel-sign-sub79.8%
log1p-def98.9%
cancel-sign-sub98.9%
+-commutative98.9%
unsub-neg98.9%
*-rgt-identity98.9%
distribute-lft-out--98.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 66.1%
if -4.99999999999999973e-21 < z Initial program 58.8%
remove-double-neg58.8%
neg-mul-158.8%
*-commutative58.8%
*-commutative58.8%
neg-mul-158.8%
remove-double-neg58.8%
sub-neg58.8%
associate-+l+74.4%
cancel-sign-sub74.4%
log1p-def74.4%
cancel-sign-sub74.4%
+-commutative74.4%
unsub-neg74.4%
*-rgt-identity74.4%
distribute-lft-out--74.4%
expm1-def98.3%
Simplified98.3%
clear-num98.3%
inv-pow98.3%
Applied egg-rr98.3%
Taylor expanded in z around 0 89.3%
associate-*r/91.5%
Simplified91.5%
Final simplification83.1%
(FPCore (x y z t) :precision binary64 (if (<= z -8.5e-25) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.5e-25) {
tmp = x;
} else {
tmp = x - (y / (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 <= (-8.5d-25)) then
tmp = x
else
tmp = x - (y / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.5e-25) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.5e-25: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.5e-25) tmp = x; else tmp = Float64(x - Float64(y / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -8.5e-25) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.5e-25], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-25}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -8.49999999999999981e-25Initial program 78.5%
remove-double-neg78.5%
neg-mul-178.5%
*-commutative78.5%
*-commutative78.5%
neg-mul-178.5%
remove-double-neg78.5%
sub-neg78.5%
associate-+l+79.8%
cancel-sign-sub79.8%
log1p-def98.9%
cancel-sign-sub98.9%
+-commutative98.9%
unsub-neg98.9%
*-rgt-identity98.9%
distribute-lft-out--98.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 66.1%
if -8.49999999999999981e-25 < z Initial program 58.8%
remove-double-neg58.8%
neg-mul-158.8%
*-commutative58.8%
*-commutative58.8%
neg-mul-158.8%
remove-double-neg58.8%
sub-neg58.8%
associate-+l+74.4%
cancel-sign-sub74.4%
log1p-def74.4%
cancel-sign-sub74.4%
+-commutative74.4%
unsub-neg74.4%
*-rgt-identity74.4%
distribute-lft-out--74.4%
expm1-def98.3%
Simplified98.3%
Taylor expanded in z around 0 89.3%
associate-/l*91.5%
Simplified91.5%
Final simplification83.1%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
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
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 65.3%
remove-double-neg65.3%
neg-mul-165.3%
*-commutative65.3%
*-commutative65.3%
neg-mul-165.3%
remove-double-neg65.3%
sub-neg65.3%
associate-+l+76.2%
cancel-sign-sub76.2%
log1p-def82.6%
cancel-sign-sub82.6%
+-commutative82.6%
unsub-neg82.6%
*-rgt-identity82.6%
distribute-lft-out--82.6%
expm1-def98.8%
Simplified98.8%
Taylor expanded in x around inf 71.3%
Final simplification71.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (- 0.5) (* y t))))
(if (< z -2.8874623088207947e+119)
(- (- x (/ t_1 (* z z))) (* t_1 (/ (/ 2.0 z) (* z z))))
(- x (/ (log (+ 1.0 (* z y))) t)))))
double code(double x, double y, double z, double t) {
double t_1 = -0.5 / (y * t);
double tmp;
if (z < -2.8874623088207947e+119) {
tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z)));
} else {
tmp = x - (log((1.0 + (z * y))) / 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 = -0.5d0 / (y * t)
if (z < (-2.8874623088207947d+119)) then
tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0d0 / z) / (z * z)))
else
tmp = x - (log((1.0d0 + (z * y))) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -0.5 / (y * t);
double tmp;
if (z < -2.8874623088207947e+119) {
tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z)));
} else {
tmp = x - (Math.log((1.0 + (z * y))) / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = -0.5 / (y * t) tmp = 0 if z < -2.8874623088207947e+119: tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z))) else: tmp = x - (math.log((1.0 + (z * y))) / t) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(-0.5) / Float64(y * t)) tmp = 0.0 if (z < -2.8874623088207947e+119) tmp = Float64(Float64(x - Float64(t_1 / Float64(z * z))) - Float64(t_1 * Float64(Float64(2.0 / z) / Float64(z * z)))); else tmp = Float64(x - Float64(log(Float64(1.0 + Float64(z * y))) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -0.5 / (y * t); tmp = 0.0; if (z < -2.8874623088207947e+119) tmp = (x - (t_1 / (z * z))) - (t_1 * ((2.0 / z) / (z * z))); else tmp = x - (log((1.0 + (z * y))) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-0.5) / N[(y * t), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -2.8874623088207947e+119], N[(N[(x - N[(t$95$1 / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[(N[(2.0 / z), $MachinePrecision] / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(1.0 + N[(z * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{-0.5}{y \cdot t}\\
\mathbf{if}\;z < -2.8874623088207947 \cdot 10^{+119}:\\
\;\;\;\;\left(x - \frac{t\_1}{z \cdot z}\right) - t\_1 \cdot \frac{\frac{2}{z}}{z \cdot z}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(1 + z \cdot y\right)}{t}\\
\end{array}
\end{array}
herbie shell --seed 2024036
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:precision binary64
:herbie-target
(if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))