
(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 7 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 (<= y -3.3e-24)
(+
x
(- 0.0 (/ (pow (pow (log1p (* y (expm1 z))) 3.0) 0.3333333333333333) t)))
(if (<= y 2.3e+86)
x
(-
x
(/
(log1p
(*
y
(+
z
(+
(* 0.041666666666666664 (pow z 4.0))
(+ (* 0.16666666666666666 (pow z 3.0)) (* 0.5 (pow z 2.0)))))))
t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.3e-24) {
tmp = x + (0.0 - (pow(pow(log1p((y * expm1(z))), 3.0), 0.3333333333333333) / t));
} else if (y <= 2.3e+86) {
tmp = x;
} else {
tmp = x - (log1p((y * (z + ((0.041666666666666664 * pow(z, 4.0)) + ((0.16666666666666666 * pow(z, 3.0)) + (0.5 * pow(z, 2.0))))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.3e-24) {
tmp = x + (0.0 - (Math.pow(Math.pow(Math.log1p((y * Math.expm1(z))), 3.0), 0.3333333333333333) / t));
} else if (y <= 2.3e+86) {
tmp = x;
} else {
tmp = x - (Math.log1p((y * (z + ((0.041666666666666664 * Math.pow(z, 4.0)) + ((0.16666666666666666 * Math.pow(z, 3.0)) + (0.5 * Math.pow(z, 2.0))))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.3e-24: tmp = x + (0.0 - (math.pow(math.pow(math.log1p((y * math.expm1(z))), 3.0), 0.3333333333333333) / t)) elif y <= 2.3e+86: tmp = x else: tmp = x - (math.log1p((y * (z + ((0.041666666666666664 * math.pow(z, 4.0)) + ((0.16666666666666666 * math.pow(z, 3.0)) + (0.5 * math.pow(z, 2.0))))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.3e-24) tmp = Float64(x + Float64(0.0 - Float64(((log1p(Float64(y * expm1(z))) ^ 3.0) ^ 0.3333333333333333) / t))); elseif (y <= 2.3e+86) tmp = x; else tmp = Float64(x - Float64(log1p(Float64(y * Float64(z + Float64(Float64(0.041666666666666664 * (z ^ 4.0)) + Float64(Float64(0.16666666666666666 * (z ^ 3.0)) + Float64(0.5 * (z ^ 2.0))))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.3e-24], N[(x + N[(0.0 - N[(N[Power[N[Power[N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.3e+86], x, N[(x - N[(N[Log[1 + N[(y * N[(z + N[(N[(0.041666666666666664 * N[Power[z, 4.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.16666666666666666 * N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{-24}:\\
\;\;\;\;x + \left(0 - \frac{{\left({\left(\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)\right)}^{3}\right)}^{0.3333333333333333}}{t}\right)\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+86}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \left(z + \left(0.041666666666666664 \cdot {z}^{4} + \left(0.16666666666666666 \cdot {z}^{3} + 0.5 \cdot {z}^{2}\right)\right)\right)\right)}{t}\\
\end{array}
\end{array}
if y < -3.29999999999999984e-24Initial program 41.2%
sub-neg41.2%
neg-mul-141.2%
associate-+l+86.7%
*-commutative86.7%
distribute-rgt-in86.7%
+-commutative86.7%
metadata-eval86.7%
sub-neg86.7%
expm1-udef96.4%
log1p-udef93.7%
add-cbrt-cube97.9%
pow1/394.5%
pow394.5%
Applied egg-rr94.5%
if -3.29999999999999984e-24 < y < 2.2999999999999999e86Initial program 94.3%
Taylor expanded in x around inf 99.4%
if 2.2999999999999999e86 < y Initial program 3.0%
remove-double-neg3.0%
neg-mul-13.0%
neg-mul-13.0%
remove-double-neg3.0%
sub-neg3.0%
associate-+l+56.0%
cancel-sign-sub56.0%
log1p-def56.0%
cancel-sign-sub56.0%
+-commutative56.0%
neg-mul-156.0%
*-commutative56.0%
distribute-lft-out56.0%
Simplified56.0%
Taylor expanded in z around 0 95.8%
Final simplification97.9%
(FPCore (x y z t)
:precision binary64
(if (<= y -3.15e-24)
(+
x
(- 0.0 (/ (pow (pow (log1p (* y (expm1 z))) 3.0) 0.3333333333333333) t)))
(if (<= y 1.6e+96)
x
(-
x
(/
(log1p
(*
y
(+ z (+ (* 0.16666666666666666 (pow z 3.0)) (* 0.5 (pow z 2.0))))))
t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.15e-24) {
tmp = x + (0.0 - (pow(pow(log1p((y * expm1(z))), 3.0), 0.3333333333333333) / t));
} else if (y <= 1.6e+96) {
tmp = x;
} else {
tmp = x - (log1p((y * (z + ((0.16666666666666666 * pow(z, 3.0)) + (0.5 * pow(z, 2.0)))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.15e-24) {
tmp = x + (0.0 - (Math.pow(Math.pow(Math.log1p((y * Math.expm1(z))), 3.0), 0.3333333333333333) / t));
} else if (y <= 1.6e+96) {
tmp = x;
} else {
tmp = x - (Math.log1p((y * (z + ((0.16666666666666666 * Math.pow(z, 3.0)) + (0.5 * Math.pow(z, 2.0)))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.15e-24: tmp = x + (0.0 - (math.pow(math.pow(math.log1p((y * math.expm1(z))), 3.0), 0.3333333333333333) / t)) elif y <= 1.6e+96: tmp = x else: tmp = x - (math.log1p((y * (z + ((0.16666666666666666 * math.pow(z, 3.0)) + (0.5 * math.pow(z, 2.0)))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.15e-24) tmp = Float64(x + Float64(0.0 - Float64(((log1p(Float64(y * expm1(z))) ^ 3.0) ^ 0.3333333333333333) / t))); elseif (y <= 1.6e+96) tmp = x; else tmp = Float64(x - Float64(log1p(Float64(y * Float64(z + Float64(Float64(0.16666666666666666 * (z ^ 3.0)) + Float64(0.5 * (z ^ 2.0)))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.15e-24], N[(x + N[(0.0 - N[(N[Power[N[Power[N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.6e+96], x, N[(x - N[(N[Log[1 + N[(y * N[(z + N[(N[(0.16666666666666666 * N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.15 \cdot 10^{-24}:\\
\;\;\;\;x + \left(0 - \frac{{\left({\left(\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)\right)}^{3}\right)}^{0.3333333333333333}}{t}\right)\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+96}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \left(z + \left(0.16666666666666666 \cdot {z}^{3} + 0.5 \cdot {z}^{2}\right)\right)\right)}{t}\\
\end{array}
\end{array}
if y < -3.1499999999999999e-24Initial program 41.2%
sub-neg41.2%
neg-mul-141.2%
associate-+l+86.7%
*-commutative86.7%
distribute-rgt-in86.7%
+-commutative86.7%
metadata-eval86.7%
sub-neg86.7%
expm1-udef96.4%
log1p-udef93.7%
add-cbrt-cube97.9%
pow1/394.5%
pow394.5%
Applied egg-rr94.5%
if -3.1499999999999999e-24 < y < 1.60000000000000003e96Initial program 94.3%
Taylor expanded in x around inf 99.4%
if 1.60000000000000003e96 < y Initial program 3.0%
remove-double-neg3.0%
neg-mul-13.0%
neg-mul-13.0%
remove-double-neg3.0%
sub-neg3.0%
associate-+l+56.0%
cancel-sign-sub56.0%
log1p-def56.0%
cancel-sign-sub56.0%
+-commutative56.0%
neg-mul-156.0%
*-commutative56.0%
distribute-lft-out56.0%
Simplified56.0%
Taylor expanded in z around 0 95.8%
Final simplification97.9%
(FPCore (x y z t)
:precision binary64
(if (<= y -3.2e-24)
(- x (/ (log1p (* y (expm1 z))) t))
(if (<= y 5.9e+91)
x
(-
x
(/
(log1p
(*
y
(+ z (+ (* 0.16666666666666666 (pow z 3.0)) (* 0.5 (pow z 2.0))))))
t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.2e-24) {
tmp = x - (log1p((y * expm1(z))) / t);
} else if (y <= 5.9e+91) {
tmp = x;
} else {
tmp = x - (log1p((y * (z + ((0.16666666666666666 * pow(z, 3.0)) + (0.5 * pow(z, 2.0)))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.2e-24) {
tmp = x - (Math.log1p((y * Math.expm1(z))) / t);
} else if (y <= 5.9e+91) {
tmp = x;
} else {
tmp = x - (Math.log1p((y * (z + ((0.16666666666666666 * Math.pow(z, 3.0)) + (0.5 * Math.pow(z, 2.0)))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.2e-24: tmp = x - (math.log1p((y * math.expm1(z))) / t) elif y <= 5.9e+91: tmp = x else: tmp = x - (math.log1p((y * (z + ((0.16666666666666666 * math.pow(z, 3.0)) + (0.5 * math.pow(z, 2.0)))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.2e-24) tmp = Float64(x - Float64(log1p(Float64(y * expm1(z))) / t)); elseif (y <= 5.9e+91) tmp = x; else tmp = Float64(x - Float64(log1p(Float64(y * Float64(z + Float64(Float64(0.16666666666666666 * (z ^ 3.0)) + Float64(0.5 * (z ^ 2.0)))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.2e-24], N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.9e+91], x, N[(x - N[(N[Log[1 + N[(y * N[(z + N[(N[(0.16666666666666666 * N[Power[z, 3.0], $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-24}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\
\mathbf{elif}\;y \leq 5.9 \cdot 10^{+91}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \left(z + \left(0.16666666666666666 \cdot {z}^{3} + 0.5 \cdot {z}^{2}\right)\right)\right)}{t}\\
\end{array}
\end{array}
if y < -3.20000000000000012e-24Initial program 41.2%
remove-double-neg41.2%
neg-mul-141.2%
*-commutative41.2%
*-commutative41.2%
neg-mul-141.2%
remove-double-neg41.2%
sub-neg41.2%
associate-+l+86.7%
cancel-sign-sub86.7%
log1p-def88.2%
cancel-sign-sub88.2%
+-commutative88.2%
unsub-neg88.2%
*-rgt-identity88.2%
distribute-lft-out--88.2%
expm1-def93.7%
Simplified93.7%
if -3.20000000000000012e-24 < y < 5.9000000000000002e91Initial program 94.3%
Taylor expanded in x around inf 99.4%
if 5.9000000000000002e91 < y Initial program 3.0%
remove-double-neg3.0%
neg-mul-13.0%
neg-mul-13.0%
remove-double-neg3.0%
sub-neg3.0%
associate-+l+56.0%
cancel-sign-sub56.0%
log1p-def56.0%
cancel-sign-sub56.0%
+-commutative56.0%
neg-mul-156.0%
*-commutative56.0%
distribute-lft-out56.0%
Simplified56.0%
Taylor expanded in z around 0 95.8%
Final simplification97.7%
(FPCore (x y z t) :precision binary64 (if (<= y -3.5e-24) (- x (/ (log1p (* y (expm1 z))) t)) (if (<= y 2.2e+96) x (- x (/ (log1p (* y (+ z (* 0.5 (pow z 2.0))))) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.5e-24) {
tmp = x - (log1p((y * expm1(z))) / t);
} else if (y <= 2.2e+96) {
tmp = x;
} else {
tmp = x - (log1p((y * (z + (0.5 * pow(z, 2.0))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.5e-24) {
tmp = x - (Math.log1p((y * Math.expm1(z))) / t);
} else if (y <= 2.2e+96) {
tmp = x;
} else {
tmp = x - (Math.log1p((y * (z + (0.5 * Math.pow(z, 2.0))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.5e-24: tmp = x - (math.log1p((y * math.expm1(z))) / t) elif y <= 2.2e+96: tmp = x else: tmp = x - (math.log1p((y * (z + (0.5 * math.pow(z, 2.0))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.5e-24) tmp = Float64(x - Float64(log1p(Float64(y * expm1(z))) / t)); elseif (y <= 2.2e+96) tmp = x; else tmp = Float64(x - Float64(log1p(Float64(y * Float64(z + Float64(0.5 * (z ^ 2.0))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.5e-24], N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.2e+96], x, N[(x - N[(N[Log[1 + N[(y * N[(z + N[(0.5 * N[Power[z, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{-24}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+96}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \left(z + 0.5 \cdot {z}^{2}\right)\right)}{t}\\
\end{array}
\end{array}
if y < -3.4999999999999996e-24Initial program 41.2%
remove-double-neg41.2%
neg-mul-141.2%
*-commutative41.2%
*-commutative41.2%
neg-mul-141.2%
remove-double-neg41.2%
sub-neg41.2%
associate-+l+86.7%
cancel-sign-sub86.7%
log1p-def88.2%
cancel-sign-sub88.2%
+-commutative88.2%
unsub-neg88.2%
*-rgt-identity88.2%
distribute-lft-out--88.2%
expm1-def93.7%
Simplified93.7%
if -3.4999999999999996e-24 < y < 2.1999999999999999e96Initial program 94.3%
Taylor expanded in x around inf 99.4%
if 2.1999999999999999e96 < y Initial program 3.0%
remove-double-neg3.0%
neg-mul-13.0%
neg-mul-13.0%
remove-double-neg3.0%
sub-neg3.0%
associate-+l+56.0%
cancel-sign-sub56.0%
log1p-def56.0%
cancel-sign-sub56.0%
+-commutative56.0%
neg-mul-156.0%
*-commutative56.0%
distribute-lft-out56.0%
Simplified56.0%
Taylor expanded in z around 0 95.8%
Final simplification97.7%
(FPCore (x y z t) :precision binary64 (if (<= y -3.5e-24) (- x (/ (log1p (* y (expm1 z))) t)) (if (<= y 6.1e+88) x (- x (/ (log1p (* y z)) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.5e-24) {
tmp = x - (log1p((y * expm1(z))) / t);
} else if (y <= 6.1e+88) {
tmp = x;
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.5e-24) {
tmp = x - (Math.log1p((y * Math.expm1(z))) / t);
} else if (y <= 6.1e+88) {
tmp = x;
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.5e-24: tmp = x - (math.log1p((y * math.expm1(z))) / t) elif y <= 6.1e+88: tmp = x else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.5e-24) tmp = Float64(x - Float64(log1p(Float64(y * expm1(z))) / t)); elseif (y <= 6.1e+88) tmp = x; else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.5e-24], N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.1e+88], x, N[(x - N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{-24}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\
\mathbf{elif}\;y \leq 6.1 \cdot 10^{+88}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if y < -3.4999999999999996e-24Initial program 41.2%
remove-double-neg41.2%
neg-mul-141.2%
*-commutative41.2%
*-commutative41.2%
neg-mul-141.2%
remove-double-neg41.2%
sub-neg41.2%
associate-+l+86.7%
cancel-sign-sub86.7%
log1p-def88.2%
cancel-sign-sub88.2%
+-commutative88.2%
unsub-neg88.2%
*-rgt-identity88.2%
distribute-lft-out--88.2%
expm1-def93.7%
Simplified93.7%
if -3.4999999999999996e-24 < y < 6.0999999999999998e88Initial program 94.3%
Taylor expanded in x around inf 99.4%
if 6.0999999999999998e88 < y Initial program 3.0%
remove-double-neg3.0%
neg-mul-13.0%
neg-mul-13.0%
remove-double-neg3.0%
sub-neg3.0%
associate-+l+56.0%
cancel-sign-sub56.0%
log1p-def56.0%
cancel-sign-sub56.0%
+-commutative56.0%
neg-mul-156.0%
*-commutative56.0%
distribute-lft-out56.0%
Simplified56.0%
Taylor expanded in z around 0 95.8%
Final simplification97.7%
(FPCore (x y z t) :precision binary64 (if (<= y 8e+85) x (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8e+85) {
tmp = x;
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8e+85) {
tmp = x;
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 8e+85: tmp = x else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 8e+85) tmp = x; else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 8e+85], x, N[(x - N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{+85}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if y < 8.0000000000000001e85Initial program 79.7%
Taylor expanded in x around inf 92.3%
if 8.0000000000000001e85 < y Initial program 3.0%
remove-double-neg3.0%
neg-mul-13.0%
neg-mul-13.0%
remove-double-neg3.0%
sub-neg3.0%
associate-+l+56.0%
cancel-sign-sub56.0%
log1p-def56.0%
cancel-sign-sub56.0%
+-commutative56.0%
neg-mul-156.0%
*-commutative56.0%
distribute-lft-out56.0%
Simplified56.0%
Taylor expanded in z around 0 95.8%
Final simplification92.5%
(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 73.7%
Taylor expanded in x around inf 89.4%
Final simplification89.4%
(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 2024031
(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)))