
(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 13 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 62.2%
associate-+l-74.6%
sub-neg74.6%
log1p-define82.2%
neg-sub082.2%
associate-+l-82.2%
neg-sub082.2%
+-commutative82.2%
unsub-neg82.2%
*-rgt-identity82.2%
distribute-lft-out--82.2%
expm1-define99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x y z t)
:precision binary64
(if (<= z -0.145)
(- x (/ 1.0 (/ (+ (* 0.5 (* y t)) (/ t (+ (exp z) -1.0))) y)))
(-
x
(/
(log1p
(*
z
(+
y
(*
z
(+
(* z (+ (* 0.041666666666666664 (* y z)) (* y 0.16666666666666666)))
(* y 0.5))))))
t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.145) {
tmp = x - (1.0 / (((0.5 * (y * t)) + (t / (exp(z) + -1.0))) / y));
} else {
tmp = x - (log1p((z * (y + (z * ((z * ((0.041666666666666664 * (y * z)) + (y * 0.16666666666666666))) + (y * 0.5)))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.145) {
tmp = x - (1.0 / (((0.5 * (y * t)) + (t / (Math.exp(z) + -1.0))) / y));
} else {
tmp = x - (Math.log1p((z * (y + (z * ((z * ((0.041666666666666664 * (y * z)) + (y * 0.16666666666666666))) + (y * 0.5)))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.145: tmp = x - (1.0 / (((0.5 * (y * t)) + (t / (math.exp(z) + -1.0))) / y)) else: tmp = x - (math.log1p((z * (y + (z * ((z * ((0.041666666666666664 * (y * z)) + (y * 0.16666666666666666))) + (y * 0.5)))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.145) tmp = Float64(x - Float64(1.0 / Float64(Float64(Float64(0.5 * Float64(y * t)) + Float64(t / Float64(exp(z) + -1.0))) / y))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(z * Float64(Float64(z * Float64(Float64(0.041666666666666664 * Float64(y * z)) + Float64(y * 0.16666666666666666))) + Float64(y * 0.5)))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.145], N[(x - N[(1.0 / N[(N[(N[(0.5 * N[(y * t), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[Exp[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(z * N[(N[(z * N[(N[(0.041666666666666664 * N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(y * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.145:\\
\;\;\;\;x - \frac{1}{\frac{0.5 \cdot \left(y \cdot t\right) + \frac{t}{e^{z} + -1}}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + z \cdot \left(z \cdot \left(0.041666666666666664 \cdot \left(y \cdot z\right) + y \cdot 0.16666666666666666\right) + y \cdot 0.5\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -0.14499999999999999Initial program 75.3%
associate-+l-75.3%
sub-neg75.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%
associate-/r/99.8%
Applied egg-rr99.8%
*-commutative99.8%
div-inv99.9%
clear-num99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 82.0%
if -0.14499999999999999 < z Initial program 56.8%
associate-+l-74.4%
sub-neg74.4%
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-define99.0%
Simplified99.0%
Taylor expanded in z around 0 98.1%
Final simplification93.4%
(FPCore (x y z t) :precision binary64 (if (<= z -0.0305) (- x (/ 1.0 (/ (+ (* 0.5 (* y t)) (/ t (+ (exp z) -1.0))) y))) (- x (/ (log1p (* z (+ y (* z (* y 0.5))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.0305) {
tmp = x - (1.0 / (((0.5 * (y * t)) + (t / (exp(z) + -1.0))) / y));
} else {
tmp = x - (log1p((z * (y + (z * (y * 0.5))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.0305) {
tmp = x - (1.0 / (((0.5 * (y * t)) + (t / (Math.exp(z) + -1.0))) / y));
} else {
tmp = x - (Math.log1p((z * (y + (z * (y * 0.5))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.0305: tmp = x - (1.0 / (((0.5 * (y * t)) + (t / (math.exp(z) + -1.0))) / y)) else: tmp = x - (math.log1p((z * (y + (z * (y * 0.5))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.0305) tmp = Float64(x - Float64(1.0 / Float64(Float64(Float64(0.5 * Float64(y * t)) + Float64(t / Float64(exp(z) + -1.0))) / y))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(z * Float64(y * 0.5))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.0305], N[(x - N[(1.0 / N[(N[(N[(0.5 * N[(y * t), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[Exp[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(z * N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0305:\\
\;\;\;\;x - \frac{1}{\frac{0.5 \cdot \left(y \cdot t\right) + \frac{t}{e^{z} + -1}}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + z \cdot \left(y \cdot 0.5\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -0.030499999999999999Initial program 75.3%
associate-+l-75.3%
sub-neg75.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%
associate-/r/99.8%
Applied egg-rr99.8%
*-commutative99.8%
div-inv99.9%
clear-num99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 82.0%
if -0.030499999999999999 < z Initial program 56.8%
associate-+l-74.4%
sub-neg74.4%
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-define99.0%
Simplified99.0%
Taylor expanded in z around 0 97.9%
associate-*r*97.9%
*-commutative97.9%
Simplified97.9%
Final simplification93.2%
(FPCore (x y z t)
:precision binary64
(if (<= z -0.042)
(- x (/ 1.0 (/ (+ (* 0.5 (* y t)) (/ t (+ (exp z) -1.0))) y)))
(-
x
(/ (log1p (* z (+ y (* y (* z (+ 0.5 (* z 0.16666666666666666))))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.042) {
tmp = x - (1.0 / (((0.5 * (y * t)) + (t / (exp(z) + -1.0))) / y));
} else {
tmp = x - (log1p((z * (y + (y * (z * (0.5 + (z * 0.16666666666666666))))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.042) {
tmp = x - (1.0 / (((0.5 * (y * t)) + (t / (Math.exp(z) + -1.0))) / y));
} else {
tmp = x - (Math.log1p((z * (y + (y * (z * (0.5 + (z * 0.16666666666666666))))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.042: tmp = x - (1.0 / (((0.5 * (y * t)) + (t / (math.exp(z) + -1.0))) / y)) else: tmp = x - (math.log1p((z * (y + (y * (z * (0.5 + (z * 0.16666666666666666))))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.042) tmp = Float64(x - Float64(1.0 / Float64(Float64(Float64(0.5 * Float64(y * t)) + Float64(t / Float64(exp(z) + -1.0))) / y))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(y * Float64(z * Float64(0.5 + Float64(z * 0.16666666666666666))))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.042], N[(x - N[(1.0 / N[(N[(N[(0.5 * N[(y * t), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[Exp[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(y * N[(z * N[(0.5 + N[(z * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.042:\\
\;\;\;\;x - \frac{1}{\frac{0.5 \cdot \left(y \cdot t\right) + \frac{t}{e^{z} + -1}}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + y \cdot \left(z \cdot \left(0.5 + z \cdot 0.16666666666666666\right)\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -0.0420000000000000026Initial program 75.3%
associate-+l-75.3%
sub-neg75.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%
associate-/r/99.8%
Applied egg-rr99.8%
*-commutative99.8%
div-inv99.9%
clear-num99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 82.0%
if -0.0420000000000000026 < z Initial program 56.8%
associate-+l-74.4%
sub-neg74.4%
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-define99.0%
Simplified99.0%
Taylor expanded in z around 0 98.0%
Taylor expanded in y around 0 98.0%
*-commutative98.0%
Simplified98.0%
Final simplification93.3%
(FPCore (x y z t) :precision binary64 (if (<= z -1.0) (- x (* (expm1 z) (/ y t))) (- x (/ (log1p (* z (+ y (* z (* y 0.5))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.0) {
tmp = x - (expm1(z) * (y / t));
} else {
tmp = x - (log1p((z * (y + (z * (y * 0.5))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.0) {
tmp = x - (Math.expm1(z) * (y / t));
} else {
tmp = x - (Math.log1p((z * (y + (z * (y * 0.5))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.0: tmp = x - (math.expm1(z) * (y / t)) else: tmp = x - (math.log1p((z * (y + (z * (y * 0.5))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.0) tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(z * Float64(y * 0.5))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.0], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(z * N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + z \cdot \left(y \cdot 0.5\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -1Initial program 75.3%
associate-+l-75.3%
sub-neg75.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%
Taylor expanded in y around 0 71.5%
*-commutative71.5%
associate-/l*71.5%
expm1-define71.5%
Simplified71.5%
if -1 < z Initial program 56.8%
associate-+l-74.4%
sub-neg74.4%
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-define99.0%
Simplified99.0%
Taylor expanded in z around 0 97.9%
associate-*r*97.9%
*-commutative97.9%
Simplified97.9%
Final simplification90.2%
(FPCore (x y z t) :precision binary64 (if (<= z -0.061) (+ x (/ (/ y t) (+ (* y -0.5) (/ -1.0 (expm1 z))))) (- x (/ (log1p (* z (+ y (* z (* y 0.5))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.061) {
tmp = x + ((y / t) / ((y * -0.5) + (-1.0 / expm1(z))));
} else {
tmp = x - (log1p((z * (y + (z * (y * 0.5))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.061) {
tmp = x + ((y / t) / ((y * -0.5) + (-1.0 / Math.expm1(z))));
} else {
tmp = x - (Math.log1p((z * (y + (z * (y * 0.5))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.061: tmp = x + ((y / t) / ((y * -0.5) + (-1.0 / math.expm1(z)))) else: tmp = x - (math.log1p((z * (y + (z * (y * 0.5))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.061) tmp = Float64(x + Float64(Float64(y / t) / Float64(Float64(y * -0.5) + Float64(-1.0 / expm1(z))))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(z * Float64(y * 0.5))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.061], N[(x + N[(N[(y / t), $MachinePrecision] / N[(N[(y * -0.5), $MachinePrecision] + N[(-1.0 / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(z * N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.061:\\
\;\;\;\;x + \frac{\frac{y}{t}}{y \cdot -0.5 + \frac{-1}{\mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + z \cdot \left(y \cdot 0.5\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -0.060999999999999999Initial program 75.3%
associate-+l-75.3%
sub-neg75.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%
associate-/r/99.8%
Applied egg-rr99.8%
*-commutative99.8%
div-inv99.9%
clear-num99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 82.0%
Taylor expanded in t around -inf 82.1%
mul-1-neg82.1%
associate-/r*81.7%
*-commutative81.7%
expm1-define81.7%
Simplified81.7%
if -0.060999999999999999 < z Initial program 56.8%
associate-+l-74.4%
sub-neg74.4%
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-define99.0%
Simplified99.0%
Taylor expanded in z around 0 97.9%
associate-*r*97.9%
*-commutative97.9%
Simplified97.9%
Final simplification93.1%
(FPCore (x y z t) :precision binary64 (if (<= y -1560.0) (+ x (/ -1.0 (/ (+ (* 0.5 (* y t)) (/ t z)) y))) (- x (* y (/ (expm1 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1560.0) {
tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / 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 <= -1560.0) {
tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y));
} else {
tmp = x - (y * (Math.expm1(z) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1560.0: tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y)) else: tmp = x - (y * (math.expm1(z) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1560.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(0.5 * Float64(y * t)) + Float64(t / z)) / y))); else tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1560.0], N[(x + N[(-1.0 / N[(N[(N[(0.5 * N[(y * t), $MachinePrecision]), $MachinePrecision] + N[(t / z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1560:\\
\;\;\;\;x + \frac{-1}{\frac{0.5 \cdot \left(y \cdot t\right) + \frac{t}{z}}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -1560Initial program 49.2%
associate-+l-69.3%
sub-neg69.3%
log1p-define69.3%
neg-sub069.3%
associate-+l-69.3%
neg-sub069.3%
+-commutative69.3%
unsub-neg69.3%
*-rgt-identity69.3%
distribute-lft-out--69.3%
expm1-define99.8%
Simplified99.8%
clear-num99.6%
associate-/r/99.8%
Applied egg-rr99.8%
*-commutative99.8%
div-inv99.8%
clear-num99.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 40.9%
Taylor expanded in z around 0 63.1%
if -1560 < y Initial program 66.4%
associate-+l-76.3%
sub-neg76.3%
log1p-define86.3%
neg-sub086.3%
associate-+l-86.3%
neg-sub086.3%
+-commutative86.3%
unsub-neg86.3%
*-rgt-identity86.3%
distribute-lft-out--86.3%
expm1-define99.0%
Simplified99.0%
Taylor expanded in y around 0 84.3%
associate-/l*84.2%
expm1-define95.0%
Simplified95.0%
Final simplification87.3%
(FPCore (x y z t) :precision binary64 (if (<= z -0.051) (- x (* (expm1 z) (/ y t))) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.051) {
tmp = x - (expm1(z) * (y / t));
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.051) {
tmp = x - (Math.expm1(z) * (y / t));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.051: tmp = x - (math.expm1(z) * (y / t)) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.051) tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.051], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $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}\;z \leq -0.051:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -0.0509999999999999967Initial program 75.3%
associate-+l-75.3%
sub-neg75.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%
Taylor expanded in y around 0 71.5%
*-commutative71.5%
associate-/l*71.5%
expm1-define71.5%
Simplified71.5%
if -0.0509999999999999967 < z Initial program 56.8%
associate-+l-74.4%
sub-neg74.4%
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-define99.0%
Simplified99.0%
Taylor expanded in z around 0 97.4%
Final simplification89.8%
(FPCore (x y z t) :precision binary64 (if (<= z -1.65) x (+ x (* y (* z (- (/ -1.0 t) (* 0.5 (/ z t))))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.65) {
tmp = x;
} else {
tmp = x + (y * (z * ((-1.0 / t) - (0.5 * (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.65d0)) then
tmp = x
else
tmp = x + (y * (z * (((-1.0d0) / t) - (0.5d0 * (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.65) {
tmp = x;
} else {
tmp = x + (y * (z * ((-1.0 / t) - (0.5 * (z / t)))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.65: tmp = x else: tmp = x + (y * (z * ((-1.0 / t) - (0.5 * (z / t))))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.65) tmp = x; else tmp = Float64(x + Float64(y * Float64(z * Float64(Float64(-1.0 / t) - Float64(0.5 * Float64(z / t)))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.65) tmp = x; else tmp = x + (y * (z * ((-1.0 / t) - (0.5 * (z / t))))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.65], x, N[(x + N[(y * N[(z * N[(N[(-1.0 / t), $MachinePrecision] - N[(0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\frac{-1}{t} - 0.5 \cdot \frac{z}{t}\right)\right)\\
\end{array}
\end{array}
if z < -1.6499999999999999Initial program 75.3%
associate-+l-75.3%
sub-neg75.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%
Taylor expanded in y around 0 71.5%
*-commutative71.5%
associate-/l*71.5%
expm1-define71.5%
Simplified71.5%
Taylor expanded in x around inf 54.6%
if -1.6499999999999999 < z Initial program 56.8%
associate-+l-74.4%
sub-neg74.4%
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-define99.0%
Simplified99.0%
Taylor expanded in y around 0 72.4%
*-commutative72.4%
associate-/l*71.1%
expm1-define85.8%
Simplified85.8%
clear-num85.8%
un-div-inv86.0%
Applied egg-rr86.0%
associate-/r/88.4%
Simplified88.4%
Taylor expanded in z around 0 88.4%
Final simplification78.5%
(FPCore (x y z t) :precision binary64 (if (<= z -7.5e+169) x (+ x (/ -1.0 (/ (+ (* 0.5 (* y t)) (/ t z)) y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.5e+169) {
tmp = x;
} else {
tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-7.5d+169)) then
tmp = x
else
tmp = x + ((-1.0d0) / (((0.5d0 * (y * t)) + (t / z)) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.5e+169) {
tmp = x;
} else {
tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.5e+169: tmp = x else: tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.5e+169) tmp = x; else tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(0.5 * Float64(y * t)) + Float64(t / z)) / y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -7.5e+169) tmp = x; else tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.5e+169], x, 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}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{+169}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{\frac{0.5 \cdot \left(y \cdot t\right) + \frac{t}{z}}{y}}\\
\end{array}
\end{array}
if z < -7.49999999999999992e169Initial program 83.8%
associate-+l-83.8%
sub-neg83.8%
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%
Taylor expanded in y around 0 63.7%
*-commutative63.7%
associate-/l*63.7%
expm1-define63.7%
Simplified63.7%
Taylor expanded in x around inf 57.1%
if -7.49999999999999992e169 < z Initial program 59.5%
associate-+l-73.5%
sub-neg73.5%
log1p-define79.9%
neg-sub079.9%
associate-+l-79.9%
neg-sub079.9%
+-commutative79.9%
unsub-neg79.9%
*-rgt-identity79.9%
distribute-lft-out--80.0%
expm1-define99.1%
Simplified99.1%
clear-num99.1%
associate-/r/99.1%
Applied egg-rr99.1%
*-commutative99.1%
div-inv99.1%
clear-num99.1%
Applied egg-rr99.1%
Taylor expanded in y around 0 74.2%
Taylor expanded in z around 0 81.4%
Final simplification78.6%
(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 62.2%
associate-+l-74.6%
sub-neg74.6%
log1p-define82.2%
neg-sub082.2%
associate-+l-82.2%
neg-sub082.2%
+-commutative82.2%
unsub-neg82.2%
*-rgt-identity82.2%
distribute-lft-out--82.2%
expm1-define99.2%
Simplified99.2%
clear-num99.2%
associate-/r/99.2%
Applied egg-rr99.2%
*-commutative99.2%
div-inv99.2%
clear-num99.2%
Applied egg-rr99.2%
Taylor expanded in y around 0 74.3%
Taylor expanded in z around 0 81.4%
distribute-lft-out--81.4%
*-commutative81.4%
Simplified81.4%
Final simplification81.4%
(FPCore (x y z t) :precision binary64 (if (<= z -5.5e+34) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.5e+34) {
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 <= (-5.5d+34)) 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 <= -5.5e+34) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5.5e+34: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5.5e+34) 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 <= -5.5e+34) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.5e+34], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.5 \cdot 10^{+34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -5.4999999999999996e34Initial program 77.7%
associate-+l-77.7%
sub-neg77.7%
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%
Taylor expanded in y around 0 67.7%
*-commutative67.7%
associate-/l*67.7%
expm1-define67.7%
Simplified67.7%
Taylor expanded in x around inf 54.3%
if -5.4999999999999996e34 < z Initial program 56.8%
associate-+l-73.6%
sub-neg73.6%
log1p-define76.1%
neg-sub076.1%
associate-+l-76.1%
neg-sub076.1%
+-commutative76.1%
unsub-neg76.1%
*-rgt-identity76.1%
distribute-lft-out--76.1%
expm1-define99.0%
Simplified99.0%
Taylor expanded in z around 0 86.3%
associate-/l*86.8%
Simplified86.8%
Final simplification78.4%
(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 62.2%
associate-+l-74.6%
sub-neg74.6%
log1p-define82.2%
neg-sub082.2%
associate-+l-82.2%
neg-sub082.2%
+-commutative82.2%
unsub-neg82.2%
*-rgt-identity82.2%
distribute-lft-out--82.2%
expm1-define99.2%
Simplified99.2%
Taylor expanded in y around 0 72.2%
*-commutative72.2%
associate-/l*71.2%
expm1-define81.7%
Simplified81.7%
Taylor expanded in x around inf 67.2%
Final simplification67.2%
(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 2024066
(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)))