
(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 9 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 68.3%
remove-double-neg68.3%
neg-mul-168.3%
*-commutative68.3%
*-commutative68.3%
neg-mul-168.3%
remove-double-neg68.3%
sub-neg68.3%
associate-+l+82.9%
cancel-sign-sub82.9%
log1p-def85.9%
cancel-sign-sub85.9%
+-commutative85.9%
unsub-neg85.9%
*-rgt-identity85.9%
distribute-lft-out--85.9%
expm1-def98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y z t) :precision binary64 (if (<= y -1.5e+157) (/ (- (log1p (* y (expm1 z)))) t) (if (<= y 4.8e+156) (+ x (/ -1.0 (/ (/ t y) (expm1 z)))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.5e+157) {
tmp = -log1p((y * expm1(z))) / t;
} else if (y <= 4.8e+156) {
tmp = x + (-1.0 / ((t / y) / expm1(z)));
} else {
tmp = x;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.5e+157) {
tmp = -Math.log1p((y * Math.expm1(z))) / t;
} else if (y <= 4.8e+156) {
tmp = x + (-1.0 / ((t / y) / Math.expm1(z)));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.5e+157: tmp = -math.log1p((y * math.expm1(z))) / t elif y <= 4.8e+156: tmp = x + (-1.0 / ((t / y) / math.expm1(z))) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.5e+157) tmp = Float64(Float64(-log1p(Float64(y * expm1(z)))) / t); elseif (y <= 4.8e+156) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / y) / expm1(z)))); else tmp = x; end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.5e+157], N[((-N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t), $MachinePrecision], If[LessEqual[y, 4.8e+156], N[(x + N[(-1.0 / N[(N[(t / y), $MachinePrecision] / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{+157}:\\
\;\;\;\;\frac{-\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+156}:\\
\;\;\;\;x + \frac{-1}{\frac{\frac{t}{y}}{\mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.50000000000000005e157Initial program 61.8%
remove-double-neg61.8%
neg-mul-161.8%
*-commutative61.8%
*-commutative61.8%
neg-mul-161.8%
remove-double-neg61.8%
sub-neg61.8%
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-def99.9%
Simplified99.9%
Taylor expanded in x around 0 33.9%
associate-*r/33.9%
log1p-def33.9%
expm1-def56.6%
neg-mul-156.6%
Simplified56.6%
if -1.50000000000000005e157 < y < 4.8000000000000002e156Initial program 73.2%
remove-double-neg73.2%
neg-mul-173.2%
*-commutative73.2%
*-commutative73.2%
neg-mul-173.2%
remove-double-neg73.2%
sub-neg73.2%
associate-+l+83.9%
cancel-sign-sub83.9%
log1p-def87.6%
cancel-sign-sub87.6%
+-commutative87.6%
unsub-neg87.6%
*-rgt-identity87.6%
distribute-lft-out--87.6%
expm1-def97.6%
Simplified97.6%
Taylor expanded in y around 0 84.2%
expm1-def92.3%
Simplified92.3%
clear-num92.2%
inv-pow92.2%
Applied egg-rr92.2%
unpow-192.2%
associate-/r*92.8%
Simplified92.8%
if 4.8000000000000002e156 < y Initial program 9.2%
remove-double-neg9.2%
neg-mul-19.2%
*-commutative9.2%
*-commutative9.2%
neg-mul-19.2%
remove-double-neg9.2%
sub-neg9.2%
associate-+l+85.9%
cancel-sign-sub85.9%
log1p-def85.9%
cancel-sign-sub85.9%
+-commutative85.9%
unsub-neg85.9%
*-rgt-identity85.9%
distribute-lft-out--85.9%
expm1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 83.2%
Final simplification87.9%
(FPCore (x y z t)
:precision binary64
(if (<= y -5.5e+38)
(+
x
(/
-1.0
(-
(fma -0.5 (/ t y) (/ t (* y z)))
(* z (* (/ t y) -0.08333333333333333)))))
(if (<= y 1e+158) (+ x (/ -1.0 (/ (/ t y) (expm1 z)))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -5.5e+38) {
tmp = x + (-1.0 / (fma(-0.5, (t / y), (t / (y * z))) - (z * ((t / y) * -0.08333333333333333))));
} else if (y <= 1e+158) {
tmp = x + (-1.0 / ((t / y) / expm1(z)));
} else {
tmp = x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= -5.5e+38) tmp = Float64(x + Float64(-1.0 / Float64(fma(-0.5, Float64(t / y), Float64(t / Float64(y * z))) - Float64(z * Float64(Float64(t / y) * -0.08333333333333333))))); elseif (y <= 1e+158) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / y) / expm1(z)))); else tmp = x; end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -5.5e+38], N[(x + N[(-1.0 / N[(N[(-0.5 * N[(t / y), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * N[(N[(t / y), $MachinePrecision] * -0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e+158], N[(x + N[(-1.0 / N[(N[(t / y), $MachinePrecision] / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+38}:\\
\;\;\;\;x + \frac{-1}{\mathsf{fma}\left(-0.5, \frac{t}{y}, \frac{t}{y \cdot z}\right) - z \cdot \left(\frac{t}{y} \cdot -0.08333333333333333\right)}\\
\mathbf{elif}\;y \leq 10^{+158}:\\
\;\;\;\;x + \frac{-1}{\frac{\frac{t}{y}}{\mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -5.5000000000000003e38Initial program 53.4%
remove-double-neg53.4%
neg-mul-153.4%
*-commutative53.4%
*-commutative53.4%
neg-mul-153.4%
remove-double-neg53.4%
sub-neg53.4%
associate-+l+78.6%
cancel-sign-sub78.6%
log1p-def78.6%
cancel-sign-sub78.6%
+-commutative78.6%
unsub-neg78.6%
*-rgt-identity78.6%
distribute-lft-out--78.6%
expm1-def99.9%
Simplified99.9%
Taylor expanded in y around 0 45.0%
expm1-def51.9%
Simplified51.9%
clear-num51.9%
inv-pow51.9%
Applied egg-rr51.9%
unpow-151.9%
associate-/r*47.6%
Simplified47.6%
Taylor expanded in z around 0 56.7%
+-commutative56.7%
mul-1-neg56.7%
unsub-neg56.7%
fma-def56.7%
distribute-rgt-out59.3%
metadata-eval59.3%
Simplified59.3%
if -5.5000000000000003e38 < y < 9.99999999999999953e157Initial program 77.1%
remove-double-neg77.1%
neg-mul-177.1%
*-commutative77.1%
*-commutative77.1%
neg-mul-177.1%
remove-double-neg77.1%
sub-neg77.1%
associate-+l+83.9%
cancel-sign-sub83.9%
log1p-def88.1%
cancel-sign-sub88.1%
+-commutative88.1%
unsub-neg88.1%
*-rgt-identity88.1%
distribute-lft-out--88.1%
expm1-def97.3%
Simplified97.3%
Taylor expanded in y around 0 86.5%
expm1-def95.0%
Simplified95.0%
clear-num94.9%
inv-pow94.9%
Applied egg-rr94.9%
unpow-194.9%
associate-/r*95.5%
Simplified95.5%
if 9.99999999999999953e157 < y Initial program 9.2%
remove-double-neg9.2%
neg-mul-19.2%
*-commutative9.2%
*-commutative9.2%
neg-mul-19.2%
remove-double-neg9.2%
sub-neg9.2%
associate-+l+85.9%
cancel-sign-sub85.9%
log1p-def85.9%
cancel-sign-sub85.9%
+-commutative85.9%
unsub-neg85.9%
*-rgt-identity85.9%
distribute-lft-out--85.9%
expm1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 83.2%
Final simplification87.1%
(FPCore (x y z t)
:precision binary64
(if (<= y -1.45e+55)
(+
x
(/
-1.0
(*
t
(+
(/ 1.0 (* y z))
(- (* 0.5 (/ -1.0 y)) (* -0.08333333333333333 (/ z y)))))))
(if (<= y 3.5e+157) (+ x (/ -1.0 (/ (/ t y) (expm1 z)))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.45e+55) {
tmp = x + (-1.0 / (t * ((1.0 / (y * z)) + ((0.5 * (-1.0 / y)) - (-0.08333333333333333 * (z / y))))));
} else if (y <= 3.5e+157) {
tmp = x + (-1.0 / ((t / y) / expm1(z)));
} else {
tmp = x;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.45e+55) {
tmp = x + (-1.0 / (t * ((1.0 / (y * z)) + ((0.5 * (-1.0 / y)) - (-0.08333333333333333 * (z / y))))));
} else if (y <= 3.5e+157) {
tmp = x + (-1.0 / ((t / y) / Math.expm1(z)));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.45e+55: tmp = x + (-1.0 / (t * ((1.0 / (y * z)) + ((0.5 * (-1.0 / y)) - (-0.08333333333333333 * (z / y)))))) elif y <= 3.5e+157: tmp = x + (-1.0 / ((t / y) / math.expm1(z))) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.45e+55) tmp = Float64(x + Float64(-1.0 / Float64(t * Float64(Float64(1.0 / Float64(y * z)) + Float64(Float64(0.5 * Float64(-1.0 / y)) - Float64(-0.08333333333333333 * Float64(z / y))))))); elseif (y <= 3.5e+157) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / y) / expm1(z)))); else tmp = x; end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.45e+55], N[(x + N[(-1.0 / N[(t * N[(N[(1.0 / N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(N[(0.5 * N[(-1.0 / y), $MachinePrecision]), $MachinePrecision] - N[(-0.08333333333333333 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.5e+157], N[(x + N[(-1.0 / N[(N[(t / y), $MachinePrecision] / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{+55}:\\
\;\;\;\;x + \frac{-1}{t \cdot \left(\frac{1}{y \cdot z} + \left(0.5 \cdot \frac{-1}{y} - -0.08333333333333333 \cdot \frac{z}{y}\right)\right)}\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+157}:\\
\;\;\;\;x + \frac{-1}{\frac{\frac{t}{y}}{\mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if y < -1.4499999999999999e55Initial 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+80.4%
cancel-sign-sub80.4%
log1p-def80.4%
cancel-sign-sub80.4%
+-commutative80.4%
unsub-neg80.4%
*-rgt-identity80.4%
distribute-lft-out--80.4%
expm1-def99.9%
Simplified99.9%
Taylor expanded in y around 0 45.1%
expm1-def50.7%
Simplified50.7%
clear-num50.7%
inv-pow50.7%
Applied egg-rr50.7%
unpow-150.7%
associate-/r*46.0%
Simplified46.0%
Taylor expanded in z around 0 56.2%
+-commutative56.2%
mul-1-neg56.2%
unsub-neg56.2%
fma-def56.2%
distribute-rgt-out58.8%
metadata-eval58.8%
Simplified58.8%
Taylor expanded in t around 0 58.8%
if -1.4499999999999999e55 < y < 3.50000000000000002e157Initial program 75.7%
remove-double-neg75.7%
neg-mul-175.7%
*-commutative75.7%
*-commutative75.7%
neg-mul-175.7%
remove-double-neg75.7%
sub-neg75.7%
associate-+l+83.3%
cancel-sign-sub83.3%
log1p-def87.4%
cancel-sign-sub87.4%
+-commutative87.4%
unsub-neg87.4%
*-rgt-identity87.4%
distribute-lft-out--87.4%
expm1-def97.4%
Simplified97.4%
Taylor expanded in y around 0 85.3%
expm1-def94.2%
Simplified94.2%
clear-num94.1%
inv-pow94.1%
Applied egg-rr94.1%
unpow-194.1%
associate-/r*94.7%
Simplified94.7%
if 3.50000000000000002e157 < y Initial program 9.2%
remove-double-neg9.2%
neg-mul-19.2%
*-commutative9.2%
*-commutative9.2%
neg-mul-19.2%
remove-double-neg9.2%
sub-neg9.2%
associate-+l+85.9%
cancel-sign-sub85.9%
log1p-def85.9%
cancel-sign-sub85.9%
+-commutative85.9%
unsub-neg85.9%
*-rgt-identity85.9%
distribute-lft-out--85.9%
expm1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 83.2%
Final simplification87.1%
(FPCore (x y z t)
:precision binary64
(if (<= y -2.8e+55)
(+
x
(/
-1.0
(*
t
(+
(/ 1.0 (* y z))
(- (* 0.5 (/ -1.0 y)) (* -0.08333333333333333 (/ z y)))))))
(- x (/ (* y (expm1 z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.8e+55) {
tmp = x + (-1.0 / (t * ((1.0 / (y * z)) + ((0.5 * (-1.0 / y)) - (-0.08333333333333333 * (z / y))))));
} else {
tmp = x - ((y * expm1(z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.8e+55) {
tmp = x + (-1.0 / (t * ((1.0 / (y * z)) + ((0.5 * (-1.0 / y)) - (-0.08333333333333333 * (z / y))))));
} else {
tmp = x - ((y * Math.expm1(z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.8e+55: tmp = x + (-1.0 / (t * ((1.0 / (y * z)) + ((0.5 * (-1.0 / y)) - (-0.08333333333333333 * (z / y)))))) else: tmp = x - ((y * math.expm1(z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.8e+55) tmp = Float64(x + Float64(-1.0 / Float64(t * Float64(Float64(1.0 / Float64(y * z)) + Float64(Float64(0.5 * Float64(-1.0 / y)) - Float64(-0.08333333333333333 * Float64(z / y))))))); else tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.8e+55], N[(x + N[(-1.0 / N[(t * N[(N[(1.0 / N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(N[(0.5 * N[(-1.0 / y), $MachinePrecision]), $MachinePrecision] - N[(-0.08333333333333333 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+55}:\\
\;\;\;\;x + \frac{-1}{t \cdot \left(\frac{1}{y \cdot z} + \left(0.5 \cdot \frac{-1}{y} - -0.08333333333333333 \cdot \frac{z}{y}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -2.8000000000000001e55Initial 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+80.4%
cancel-sign-sub80.4%
log1p-def80.4%
cancel-sign-sub80.4%
+-commutative80.4%
unsub-neg80.4%
*-rgt-identity80.4%
distribute-lft-out--80.4%
expm1-def99.9%
Simplified99.9%
Taylor expanded in y around 0 45.1%
expm1-def50.7%
Simplified50.7%
clear-num50.7%
inv-pow50.7%
Applied egg-rr50.7%
unpow-150.7%
associate-/r*46.0%
Simplified46.0%
Taylor expanded in z around 0 56.2%
+-commutative56.2%
mul-1-neg56.2%
unsub-neg56.2%
fma-def56.2%
distribute-rgt-out58.8%
metadata-eval58.8%
Simplified58.8%
Taylor expanded in t around 0 58.8%
if -2.8000000000000001e55 < y Initial program 71.2%
remove-double-neg71.2%
neg-mul-171.2%
*-commutative71.2%
*-commutative71.2%
neg-mul-171.2%
remove-double-neg71.2%
sub-neg71.2%
associate-+l+83.5%
cancel-sign-sub83.5%
log1p-def87.3%
cancel-sign-sub87.3%
+-commutative87.3%
unsub-neg87.3%
*-rgt-identity87.3%
distribute-lft-out--87.3%
expm1-def97.5%
Simplified97.5%
Taylor expanded in y around 0 84.9%
expm1-def91.8%
Simplified91.8%
Final simplification85.4%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (- (/ (/ t z) y) (* z (* (/ t y) -0.08333333333333333))))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / (((t / z) / y) - (z * ((t / y) * -0.08333333333333333))));
}
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 / z) / y) - (z * ((t / y) * (-0.08333333333333333d0)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / (((t / z) / y) - (z * ((t / y) * -0.08333333333333333))));
}
def code(x, y, z, t): return x + (-1.0 / (((t / z) / y) - (z * ((t / y) * -0.08333333333333333))))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(Float64(t / z) / y) - Float64(z * Float64(Float64(t / y) * -0.08333333333333333))))) end
function tmp = code(x, y, z, t) tmp = x + (-1.0 / (((t / z) / y) - (z * ((t / y) * -0.08333333333333333)))); end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(N[(t / z), $MachinePrecision] / y), $MachinePrecision] - N[(z * N[(N[(t / y), $MachinePrecision] * -0.08333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{\frac{\frac{t}{z}}{y} - z \cdot \left(\frac{t}{y} \cdot -0.08333333333333333\right)}
\end{array}
Initial program 68.3%
remove-double-neg68.3%
neg-mul-168.3%
*-commutative68.3%
*-commutative68.3%
neg-mul-168.3%
remove-double-neg68.3%
sub-neg68.3%
associate-+l+82.9%
cancel-sign-sub82.9%
log1p-def85.9%
cancel-sign-sub85.9%
+-commutative85.9%
unsub-neg85.9%
*-rgt-identity85.9%
distribute-lft-out--85.9%
expm1-def98.0%
Simplified98.0%
Taylor expanded in y around 0 77.1%
expm1-def83.8%
Simplified83.8%
clear-num83.7%
inv-pow83.7%
Applied egg-rr83.7%
unpow-183.7%
associate-/r*82.5%
Simplified82.5%
Taylor expanded in z around 0 66.4%
+-commutative66.4%
mul-1-neg66.4%
unsub-neg66.4%
fma-def66.4%
distribute-rgt-out76.3%
metadata-eval76.3%
Simplified76.3%
Taylor expanded in z around 0 82.2%
*-commutative82.2%
associate-/r*83.4%
Simplified83.4%
Final simplification83.4%
(FPCore (x y z t) :precision binary64 (if (<= z -1.95e-25) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.95e-25) {
tmp = x;
} else {
tmp = x - (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) :: tmp
if (z <= (-1.95d-25)) then
tmp = x
else
tmp = x - (z * (y / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.95e-25) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.95e-25: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.95e-25) tmp = x; else tmp = Float64(x - Float64(z * Float64(y / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.95e-25) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.95e-25], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.95 \cdot 10^{-25}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -1.95e-25Initial program 90.0%
remove-double-neg90.0%
neg-mul-190.0%
*-commutative90.0%
*-commutative90.0%
neg-mul-190.0%
remove-double-neg90.0%
sub-neg90.0%
associate-+l+91.2%
cancel-sign-sub91.2%
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%
Taylor expanded in x around inf 73.2%
if -1.95e-25 < z Initial program 56.7%
remove-double-neg56.7%
neg-mul-156.7%
*-commutative56.7%
*-commutative56.7%
neg-mul-156.7%
remove-double-neg56.7%
sub-neg56.7%
associate-+l+78.4%
cancel-sign-sub78.4%
log1p-def78.4%
cancel-sign-sub78.4%
+-commutative78.4%
unsub-neg78.4%
*-rgt-identity78.4%
distribute-lft-out--78.5%
expm1-def97.0%
Simplified97.0%
Taylor expanded in z around 0 88.3%
associate-/l*90.1%
associate-/r/86.4%
Simplified86.4%
Final simplification81.8%
(FPCore (x y z t) :precision binary64 (if (<= z -7e-27) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7e-27) {
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 <= (-7d-27)) 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 <= -7e-27) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7e-27: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7e-27) 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 <= -7e-27) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7e-27], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7 \cdot 10^{-27}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -7.0000000000000003e-27Initial program 90.0%
remove-double-neg90.0%
neg-mul-190.0%
*-commutative90.0%
*-commutative90.0%
neg-mul-190.0%
remove-double-neg90.0%
sub-neg90.0%
associate-+l+91.2%
cancel-sign-sub91.2%
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%
Taylor expanded in x around inf 73.2%
if -7.0000000000000003e-27 < z Initial program 56.7%
remove-double-neg56.7%
neg-mul-156.7%
*-commutative56.7%
*-commutative56.7%
neg-mul-156.7%
remove-double-neg56.7%
sub-neg56.7%
associate-+l+78.4%
cancel-sign-sub78.4%
log1p-def78.4%
cancel-sign-sub78.4%
+-commutative78.4%
unsub-neg78.4%
*-rgt-identity78.4%
distribute-lft-out--78.5%
expm1-def97.0%
Simplified97.0%
Taylor expanded in z around 0 88.3%
associate-/l*90.1%
Simplified90.1%
Final simplification84.2%
(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 68.3%
remove-double-neg68.3%
neg-mul-168.3%
*-commutative68.3%
*-commutative68.3%
neg-mul-168.3%
remove-double-neg68.3%
sub-neg68.3%
associate-+l+82.9%
cancel-sign-sub82.9%
log1p-def85.9%
cancel-sign-sub85.9%
+-commutative85.9%
unsub-neg85.9%
*-rgt-identity85.9%
distribute-lft-out--85.9%
expm1-def98.0%
Simplified98.0%
Taylor expanded in x around inf 76.3%
Final simplification76.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 2024029
(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)))