
(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 (if (<= (exp z) 1.0) (- x (/ (log1p (* y (expm1 z))) t)) (- x (/ 2.0 t))))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 1.0) {
tmp = x - (log1p((y * expm1(z))) / t);
} else {
tmp = x - (2.0 / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.exp(z) <= 1.0) {
tmp = x - (Math.log1p((y * Math.expm1(z))) / t);
} else {
tmp = x - (2.0 / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.exp(z) <= 1.0: tmp = x - (math.log1p((y * math.expm1(z))) / t) else: tmp = x - (2.0 / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 1.0) tmp = Float64(x - Float64(log1p(Float64(y * expm1(z))) / t)); else tmp = Float64(x - Float64(2.0 / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 1.0], N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(2.0 / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 1:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{2}{t}\\
\end{array}
\end{array}
if (exp.f64 z) < 1Initial program 61.4%
associate-+l-78.2%
sub-neg78.2%
log1p-define84.6%
neg-sub084.6%
associate-+l-84.6%
neg-sub084.6%
+-commutative84.6%
unsub-neg84.6%
*-rgt-identity84.6%
distribute-lft-out--84.6%
expm1-define99.4%
Simplified99.4%
if 1 < (exp.f64 z) Initial program 27.4%
associate-+l-27.4%
sub-neg27.4%
log1p-define27.4%
neg-sub027.4%
associate-+l-27.4%
neg-sub027.4%
+-commutative27.4%
unsub-neg27.4%
*-rgt-identity27.4%
distribute-lft-out--27.4%
expm1-define27.4%
Simplified27.4%
clear-num27.4%
inv-pow27.4%
Applied egg-rr27.4%
unpow-127.4%
Applied egg-rr27.4%
Taylor expanded in y around 0 77.6%
Taylor expanded in y around inf 78.0%
Final simplification98.7%
(FPCore (x y z t) :precision binary64 (if (<= (exp z) 5e-33) (- x (/ y (* t (- (/ 1.0 (expm1 z)) (* y -0.5))))) (- x (/ (log1p (* z (+ y (* 0.5 (* z y))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 5e-33) {
tmp = x - (y / (t * ((1.0 / expm1(z)) - (y * -0.5))));
} else {
tmp = x - (log1p((z * (y + (0.5 * (z * y))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.exp(z) <= 5e-33) {
tmp = x - (y / (t * ((1.0 / Math.expm1(z)) - (y * -0.5))));
} else {
tmp = x - (Math.log1p((z * (y + (0.5 * (z * y))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.exp(z) <= 5e-33: tmp = x - (y / (t * ((1.0 / math.expm1(z)) - (y * -0.5)))) else: tmp = x - (math.log1p((z * (y + (0.5 * (z * y))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 5e-33) tmp = Float64(x - Float64(y / Float64(t * Float64(Float64(1.0 / expm1(z)) - Float64(y * -0.5))))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(0.5 * Float64(z * y))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 5e-33], N[(x - N[(y / N[(t * N[(N[(1.0 / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] - N[(y * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(0.5 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 5 \cdot 10^{-33}:\\
\;\;\;\;x - \frac{y}{t \cdot \left(\frac{1}{\mathsf{expm1}\left(z\right)} - y \cdot -0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + 0.5 \cdot \left(z \cdot y\right)\right)\right)}{t}\\
\end{array}
\end{array}
if (exp.f64 z) < 5.00000000000000028e-33Initial program 80.3%
associate-+l-80.3%
sub-neg80.3%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 83.8%
Taylor expanded in t around -inf 83.9%
associate-*r/83.9%
neg-mul-183.9%
*-commutative83.9%
expm1-define83.9%
Simplified83.9%
if 5.00000000000000028e-33 < (exp.f64 z) Initial program 51.1%
associate-+l-74.9%
sub-neg74.9%
log1p-define74.9%
neg-sub074.9%
associate-+l-74.9%
neg-sub074.9%
+-commutative74.9%
unsub-neg74.9%
*-rgt-identity74.9%
distribute-lft-out--74.9%
expm1-define95.9%
Simplified95.9%
Taylor expanded in z around 0 97.6%
Final simplification93.3%
(FPCore (x y z t)
:precision binary64
(if (<= z -0.025)
(- x (/ y (* t (- (/ 1.0 (expm1 z)) (* y -0.5)))))
(-
x
(/
(log1p
(*
z
(+
y
(*
z
(+
(* y 0.5)
(*
z
(+ (* 0.041666666666666664 (* z y)) (* y 0.16666666666666666))))))))
t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.025) {
tmp = x - (y / (t * ((1.0 / expm1(z)) - (y * -0.5))));
} else {
tmp = x - (log1p((z * (y + (z * ((y * 0.5) + (z * ((0.041666666666666664 * (z * y)) + (y * 0.16666666666666666)))))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.025) {
tmp = x - (y / (t * ((1.0 / Math.expm1(z)) - (y * -0.5))));
} else {
tmp = x - (Math.log1p((z * (y + (z * ((y * 0.5) + (z * ((0.041666666666666664 * (z * y)) + (y * 0.16666666666666666)))))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.025: tmp = x - (y / (t * ((1.0 / math.expm1(z)) - (y * -0.5)))) else: tmp = x - (math.log1p((z * (y + (z * ((y * 0.5) + (z * ((0.041666666666666664 * (z * y)) + (y * 0.16666666666666666)))))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.025) tmp = Float64(x - Float64(y / Float64(t * Float64(Float64(1.0 / expm1(z)) - Float64(y * -0.5))))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(z * Float64(Float64(y * 0.5) + Float64(z * Float64(Float64(0.041666666666666664 * Float64(z * y)) + Float64(y * 0.16666666666666666)))))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.025], N[(x - N[(y / N[(t * N[(N[(1.0 / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] - N[(y * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(z * N[(N[(y * 0.5), $MachinePrecision] + N[(z * N[(N[(0.041666666666666664 * N[(z * y), $MachinePrecision]), $MachinePrecision] + N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.025:\\
\;\;\;\;x - \frac{y}{t \cdot \left(\frac{1}{\mathsf{expm1}\left(z\right)} - y \cdot -0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + z \cdot \left(y \cdot 0.5 + z \cdot \left(0.041666666666666664 \cdot \left(z \cdot y\right) + y \cdot 0.16666666666666666\right)\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -0.025000000000000001Initial program 80.3%
associate-+l-80.3%
sub-neg80.3%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 83.8%
Taylor expanded in t around -inf 83.9%
associate-*r/83.9%
neg-mul-183.9%
*-commutative83.9%
expm1-define83.9%
Simplified83.9%
if -0.025000000000000001 < z Initial program 51.1%
associate-+l-74.9%
sub-neg74.9%
log1p-define74.9%
neg-sub074.9%
associate-+l-74.9%
neg-sub074.9%
+-commutative74.9%
unsub-neg74.9%
*-rgt-identity74.9%
distribute-lft-out--74.9%
expm1-define95.9%
Simplified95.9%
Taylor expanded in z around 0 97.6%
Final simplification93.3%
(FPCore (x y z t)
:precision binary64
(if (<= z -75.0)
(- x (/ y (* t (- (/ 1.0 (expm1 z)) (* y -0.5)))))
(-
x
(/
(log1p (* z (+ y (* z (+ (* y 0.5) (* (* z y) 0.16666666666666666))))))
t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -75.0) {
tmp = x - (y / (t * ((1.0 / expm1(z)) - (y * -0.5))));
} else {
tmp = x - (log1p((z * (y + (z * ((y * 0.5) + ((z * y) * 0.16666666666666666)))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -75.0) {
tmp = x - (y / (t * ((1.0 / Math.expm1(z)) - (y * -0.5))));
} else {
tmp = x - (Math.log1p((z * (y + (z * ((y * 0.5) + ((z * y) * 0.16666666666666666)))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -75.0: tmp = x - (y / (t * ((1.0 / math.expm1(z)) - (y * -0.5)))) else: tmp = x - (math.log1p((z * (y + (z * ((y * 0.5) + ((z * y) * 0.16666666666666666)))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -75.0) tmp = Float64(x - Float64(y / Float64(t * Float64(Float64(1.0 / expm1(z)) - Float64(y * -0.5))))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(z * Float64(Float64(y * 0.5) + Float64(Float64(z * y) * 0.16666666666666666)))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -75.0], N[(x - N[(y / N[(t * N[(N[(1.0 / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] - N[(y * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(z * N[(N[(y * 0.5), $MachinePrecision] + N[(N[(z * y), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -75:\\
\;\;\;\;x - \frac{y}{t \cdot \left(\frac{1}{\mathsf{expm1}\left(z\right)} - y \cdot -0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + z \cdot \left(y \cdot 0.5 + \left(z \cdot y\right) \cdot 0.16666666666666666\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -75Initial program 80.1%
associate-+l-80.1%
sub-neg80.1%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 83.6%
Taylor expanded in t around -inf 83.7%
associate-*r/83.7%
neg-mul-183.7%
*-commutative83.7%
expm1-define83.7%
Simplified83.7%
if -75 < z Initial program 51.4%
associate-+l-75.0%
sub-neg75.0%
log1p-define75.0%
neg-sub075.0%
associate-+l-75.0%
neg-sub075.0%
+-commutative75.0%
unsub-neg75.0%
*-rgt-identity75.0%
distribute-lft-out--75.0%
expm1-define95.9%
Simplified95.9%
Taylor expanded in z around 0 97.6%
Final simplification93.3%
(FPCore (x y z t)
:precision binary64
(if (<= y -6.1e+113)
(- x (/ 2.0 t))
(if (<= y 1e+29)
(- x (* y (/ (expm1 z) t)))
(- x (/ (log1p (* z (+ y (* 0.5 (* z y))))) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.1e+113) {
tmp = x - (2.0 / t);
} else if (y <= 1e+29) {
tmp = x - (y * (expm1(z) / t));
} else {
tmp = x - (log1p((z * (y + (0.5 * (z * y))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -6.1e+113) {
tmp = x - (2.0 / t);
} else if (y <= 1e+29) {
tmp = x - (y * (Math.expm1(z) / t));
} else {
tmp = x - (Math.log1p((z * (y + (0.5 * (z * y))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -6.1e+113: tmp = x - (2.0 / t) elif y <= 1e+29: tmp = x - (y * (math.expm1(z) / t)) else: tmp = x - (math.log1p((z * (y + (0.5 * (z * y))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -6.1e+113) tmp = Float64(x - Float64(2.0 / t)); elseif (y <= 1e+29) tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(0.5 * Float64(z * y))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -6.1e+113], N[(x - N[(2.0 / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e+29], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(0.5 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.1 \cdot 10^{+113}:\\
\;\;\;\;x - \frac{2}{t}\\
\mathbf{elif}\;y \leq 10^{+29}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + 0.5 \cdot \left(z \cdot y\right)\right)\right)}{t}\\
\end{array}
\end{array}
if y < -6.09999999999999996e113Initial program 56.5%
associate-+l-86.6%
sub-neg86.6%
log1p-define86.6%
neg-sub086.6%
associate-+l-86.6%
neg-sub086.6%
+-commutative86.6%
unsub-neg86.6%
*-rgt-identity86.6%
distribute-lft-out--86.6%
expm1-define99.9%
Simplified99.9%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 44.2%
Taylor expanded in y around inf 70.7%
if -6.09999999999999996e113 < y < 9.99999999999999914e28Initial program 74.7%
associate-+l-79.9%
sub-neg79.9%
log1p-define88.8%
neg-sub088.8%
associate-+l-88.8%
neg-sub088.8%
+-commutative88.8%
unsub-neg88.8%
*-rgt-identity88.8%
distribute-lft-out--88.8%
expm1-define98.7%
Simplified98.7%
Taylor expanded in y around 0 85.0%
associate-/l*85.0%
expm1-define94.5%
Simplified94.5%
if 9.99999999999999914e28 < y Initial program 4.4%
associate-+l-54.9%
sub-neg54.9%
log1p-define54.9%
neg-sub054.9%
associate-+l-54.9%
neg-sub054.9%
+-commutative54.9%
unsub-neg54.9%
*-rgt-identity54.9%
distribute-lft-out--54.9%
expm1-define88.5%
Simplified88.5%
Taylor expanded in z around 0 95.5%
Final simplification91.3%
(FPCore (x y z t)
:precision binary64
(if (<= y -3.8e+113)
(- x (/ 2.0 t))
(if (<= y 7.2e+28)
(- x (* y (/ (expm1 z) t)))
(+ x (/ -1.0 (/ (/ (+ t (* z (* 0.5 (- (* y t) t)))) z) y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.8e+113) {
tmp = x - (2.0 / t);
} else if (y <= 7.2e+28) {
tmp = x - (y * (expm1(z) / t));
} else {
tmp = x + (-1.0 / (((t + (z * (0.5 * ((y * t) - t)))) / z) / y));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.8e+113) {
tmp = x - (2.0 / t);
} else if (y <= 7.2e+28) {
tmp = x - (y * (Math.expm1(z) / t));
} else {
tmp = x + (-1.0 / (((t + (z * (0.5 * ((y * t) - t)))) / z) / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.8e+113: tmp = x - (2.0 / t) elif y <= 7.2e+28: tmp = x - (y * (math.expm1(z) / t)) else: tmp = x + (-1.0 / (((t + (z * (0.5 * ((y * t) - t)))) / z) / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.8e+113) tmp = Float64(x - Float64(2.0 / t)); elseif (y <= 7.2e+28) tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); else tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(t + Float64(z * Float64(0.5 * Float64(Float64(y * t) - t)))) / z) / y))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.8e+113], N[(x - N[(2.0 / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.2e+28], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(-1.0 / N[(N[(N[(t + N[(z * N[(0.5 * N[(N[(y * t), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{+113}:\\
\;\;\;\;x - \frac{2}{t}\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{+28}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{\frac{\frac{t + z \cdot \left(0.5 \cdot \left(y \cdot t - t\right)\right)}{z}}{y}}\\
\end{array}
\end{array}
if y < -3.8000000000000003e113Initial program 56.5%
associate-+l-86.6%
sub-neg86.6%
log1p-define86.6%
neg-sub086.6%
associate-+l-86.6%
neg-sub086.6%
+-commutative86.6%
unsub-neg86.6%
*-rgt-identity86.6%
distribute-lft-out--86.6%
expm1-define99.9%
Simplified99.9%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 44.2%
Taylor expanded in y around inf 70.7%
if -3.8000000000000003e113 < y < 7.1999999999999999e28Initial program 74.7%
associate-+l-79.9%
sub-neg79.9%
log1p-define88.8%
neg-sub088.8%
associate-+l-88.8%
neg-sub088.8%
+-commutative88.8%
unsub-neg88.8%
*-rgt-identity88.8%
distribute-lft-out--88.8%
expm1-define98.7%
Simplified98.7%
Taylor expanded in y around 0 85.0%
associate-/l*85.0%
expm1-define94.5%
Simplified94.5%
if 7.1999999999999999e28 < y Initial program 4.4%
associate-+l-54.9%
sub-neg54.9%
log1p-define54.9%
neg-sub054.9%
associate-+l-54.9%
neg-sub054.9%
+-commutative54.9%
unsub-neg54.9%
*-rgt-identity54.9%
distribute-lft-out--54.9%
expm1-define88.5%
Simplified88.5%
clear-num88.5%
inv-pow88.5%
Applied egg-rr88.5%
unpow-188.5%
Applied egg-rr88.5%
Taylor expanded in y around 0 64.2%
Taylor expanded in z around 0 81.9%
distribute-lft-out--81.9%
*-commutative81.9%
Simplified81.9%
Final simplification89.0%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (/ (/ (+ t (* z (* 0.5 (- (* y t) t)))) z) y))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / (((t + (z * (0.5 * ((y * t) - t)))) / z) / 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 + (z * (0.5d0 * ((y * t) - t)))) / z) / y))
end function
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / (((t + (z * (0.5 * ((y * t) - t)))) / z) / y));
}
def code(x, y, z, t): return x + (-1.0 / (((t + (z * (0.5 * ((y * t) - t)))) / z) / y))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(Float64(t + Float64(z * Float64(0.5 * Float64(Float64(y * t) - t)))) / z) / y))) end
function tmp = code(x, y, z, t) tmp = x + (-1.0 / (((t + (z * (0.5 * ((y * t) - t)))) / z) / y)); end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(N[(t + N[(z * N[(0.5 * N[(N[(y * t), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{\frac{\frac{t + z \cdot \left(0.5 \cdot \left(y \cdot t - t\right)\right)}{z}}{y}}
\end{array}
Initial program 60.4%
associate-+l-76.6%
sub-neg76.6%
log1p-define82.8%
neg-sub082.8%
associate-+l-82.8%
neg-sub082.8%
+-commutative82.8%
unsub-neg82.8%
*-rgt-identity82.8%
distribute-lft-out--82.8%
expm1-define97.1%
Simplified97.1%
clear-num97.1%
inv-pow97.1%
Applied egg-rr97.1%
unpow-197.1%
Applied egg-rr97.1%
Taylor expanded in y around 0 75.0%
Taylor expanded in z around 0 83.2%
distribute-lft-out--83.2%
*-commutative83.2%
Simplified83.2%
Final simplification83.2%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (/ (+ (* 0.5 (* y t)) (/ t z)) y))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / 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) / (((0.5d0 * (y * t)) + (t / z)) / y))
end function
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y));
}
def code(x, y, z, t): return x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(Float64(0.5 * Float64(y * t)) + Float64(t / z)) / y))) end
function tmp = code(x, y, z, t) tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y)); end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(N[(0.5 * N[(y * t), $MachinePrecision]), $MachinePrecision] + N[(t / z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{\frac{0.5 \cdot \left(y \cdot t\right) + \frac{t}{z}}{y}}
\end{array}
Initial program 60.4%
associate-+l-76.6%
sub-neg76.6%
log1p-define82.8%
neg-sub082.8%
associate-+l-82.8%
neg-sub082.8%
+-commutative82.8%
unsub-neg82.8%
*-rgt-identity82.8%
distribute-lft-out--82.8%
expm1-define97.1%
Simplified97.1%
clear-num97.1%
inv-pow97.1%
Applied egg-rr97.1%
unpow-197.1%
Applied egg-rr97.1%
Taylor expanded in y around 0 75.0%
Taylor expanded in z around 0 78.0%
Final simplification78.0%
(FPCore (x y z t) :precision binary64 (if (<= z -1.26e+26) (- x (/ 2.0 t)) (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.26e+26) {
tmp = x - (2.0 / t);
} 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 <= (-1.26d+26)) then
tmp = x - (2.0d0 / t)
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 <= -1.26e+26) {
tmp = x - (2.0 / t);
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.26e+26: tmp = x - (2.0 / t) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.26e+26) tmp = Float64(x - Float64(2.0 / t)); 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 <= -1.26e+26) tmp = x - (2.0 / t); else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.26e+26], N[(x - N[(2.0 / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.26 \cdot 10^{+26}:\\
\;\;\;\;x - \frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -1.25999999999999995e26Initial program 82.3%
associate-+l-82.3%
sub-neg82.3%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 83.4%
Taylor expanded in y around inf 55.5%
if -1.25999999999999995e26 < z Initial program 51.4%
associate-+l-74.3%
sub-neg74.3%
log1p-define75.9%
neg-sub075.9%
associate-+l-75.9%
neg-sub075.9%
+-commutative75.9%
unsub-neg75.9%
*-rgt-identity75.9%
distribute-lft-out--75.9%
expm1-define96.0%
Simplified96.0%
Taylor expanded in z around 0 88.2%
associate-/l*88.3%
Simplified88.3%
Final simplification78.8%
(FPCore (x y z t) :precision binary64 (- x (/ 2.0 t)))
double code(double x, double y, double z, double t) {
return x - (2.0 / 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 - (2.0d0 / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (2.0 / t);
}
def code(x, y, z, t): return x - (2.0 / t)
function code(x, y, z, t) return Float64(x - Float64(2.0 / t)) end
function tmp = code(x, y, z, t) tmp = x - (2.0 / t); end
code[x_, y_, z_, t_] := N[(x - N[(2.0 / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{2}{t}
\end{array}
Initial program 60.4%
associate-+l-76.6%
sub-neg76.6%
log1p-define82.8%
neg-sub082.8%
associate-+l-82.8%
neg-sub082.8%
+-commutative82.8%
unsub-neg82.8%
*-rgt-identity82.8%
distribute-lft-out--82.8%
expm1-define97.1%
Simplified97.1%
clear-num97.1%
inv-pow97.1%
Applied egg-rr97.1%
unpow-197.1%
Applied egg-rr97.1%
Taylor expanded in y around 0 75.0%
Taylor expanded in y around inf 57.0%
Final simplification57.0%
(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 2024076
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:precision binary64
:alt
(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)))