
(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 61.4%
associate-+l-78.6%
sub-neg78.6%
log1p-def84.0%
neg-sub084.0%
associate-+l-84.0%
neg-sub084.0%
neg-mul-184.0%
*-commutative84.0%
distribute-rgt-out84.0%
+-commutative84.0%
metadata-eval84.0%
sub-neg84.0%
expm1-def99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (* t (+ 0.5 (/ 1.0 (* y (expm1 z))))))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / (t * (0.5 + (1.0 / (y * expm1(z))))));
}
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / (t * (0.5 + (1.0 / (y * Math.expm1(z))))));
}
def code(x, y, z, t): return x + (-1.0 / (t * (0.5 + (1.0 / (y * math.expm1(z))))))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(t * Float64(0.5 + Float64(1.0 / Float64(y * expm1(z))))))) end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(t * N[(0.5 + N[(1.0 / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{t \cdot \left(0.5 + \frac{1}{y \cdot \mathsf{expm1}\left(z\right)}\right)}
\end{array}
Initial program 61.4%
associate-+l-78.6%
sub-neg78.6%
log1p-def84.0%
neg-sub084.0%
associate-+l-84.0%
neg-sub084.0%
neg-mul-184.0%
*-commutative84.0%
distribute-rgt-out84.0%
+-commutative84.0%
metadata-eval84.0%
sub-neg84.0%
expm1-def99.0%
Simplified99.0%
clear-num99.0%
inv-pow99.0%
Applied egg-rr99.0%
unpow-199.0%
Applied egg-rr99.0%
Taylor expanded in y around 0 78.2%
expm1-def88.9%
*-commutative88.9%
associate-/r*87.5%
*-commutative87.5%
Simplified87.5%
Taylor expanded in t around 0 78.2%
*-commutative78.2%
expm1-def88.8%
*-commutative88.8%
Simplified88.8%
Final simplification88.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.6e-33) (not (<= y 3.5e-7))) (+ x (/ -1.0 (+ (/ t (* y z)) (* t 0.5)))) (- x (* y (/ (expm1 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.6e-33) || !(y <= 3.5e-7)) {
tmp = x + (-1.0 / ((t / (y * z)) + (t * 0.5)));
} 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.6e-33) || !(y <= 3.5e-7)) {
tmp = x + (-1.0 / ((t / (y * z)) + (t * 0.5)));
} else {
tmp = x - (y * (Math.expm1(z) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.6e-33) or not (y <= 3.5e-7): tmp = x + (-1.0 / ((t / (y * z)) + (t * 0.5))) else: tmp = x - (y * (math.expm1(z) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.6e-33) || !(y <= 3.5e-7)) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / Float64(y * z)) + Float64(t * 0.5)))); else tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.6e-33], N[Not[LessEqual[y, 3.5e-7]], $MachinePrecision]], N[(x + N[(-1.0 / N[(N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * 0.5), $MachinePrecision]), $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 -2.6 \cdot 10^{-33} \lor \neg \left(y \leq 3.5 \cdot 10^{-7}\right):\\
\;\;\;\;x + \frac{-1}{\frac{t}{y \cdot z} + t \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -2.59999999999999994e-33 or 3.49999999999999984e-7 < y Initial program 35.0%
associate-+l-73.6%
sub-neg73.6%
log1p-def73.6%
neg-sub073.6%
associate-+l-73.6%
neg-sub073.6%
neg-mul-173.6%
*-commutative73.6%
distribute-rgt-out73.6%
+-commutative73.6%
metadata-eval73.6%
sub-neg73.6%
expm1-def99.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 60.7%
expm1-def77.1%
*-commutative77.1%
associate-/r*72.1%
*-commutative72.1%
Simplified72.1%
Taylor expanded in z around 0 77.1%
*-commutative77.1%
Simplified77.1%
if -2.59999999999999994e-33 < y < 3.49999999999999984e-7Initial program 82.6%
associate-+l-82.6%
sub-neg82.6%
log1p-def92.4%
neg-sub092.4%
associate-+l-92.4%
neg-sub092.4%
neg-mul-192.4%
*-commutative92.4%
distribute-rgt-out92.3%
+-commutative92.3%
metadata-eval92.3%
sub-neg92.3%
expm1-def98.4%
Simplified98.4%
Taylor expanded in y around 0 92.2%
associate-/l*92.2%
associate-/r/92.2%
expm1-def99.8%
Simplified99.8%
Final simplification89.7%
(FPCore (x y z t) :precision binary64 (if (or (<= y -4.6e+16) (not (<= y 3.5e-7))) (+ x (/ -1.0 (+ (/ t (* y z)) (* t 0.5)))) (- x (/ y (/ t (expm1 z))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -4.6e+16) || !(y <= 3.5e-7)) {
tmp = x + (-1.0 / ((t / (y * z)) + (t * 0.5)));
} else {
tmp = x - (y / (t / expm1(z)));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -4.6e+16) || !(y <= 3.5e-7)) {
tmp = x + (-1.0 / ((t / (y * z)) + (t * 0.5)));
} else {
tmp = x - (y / (t / Math.expm1(z)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -4.6e+16) or not (y <= 3.5e-7): tmp = x + (-1.0 / ((t / (y * z)) + (t * 0.5))) else: tmp = x - (y / (t / math.expm1(z))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -4.6e+16) || !(y <= 3.5e-7)) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / Float64(y * z)) + Float64(t * 0.5)))); else tmp = Float64(x - Float64(y / Float64(t / expm1(z)))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -4.6e+16], N[Not[LessEqual[y, 3.5e-7]], $MachinePrecision]], N[(x + N[(-1.0 / N[(N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / N[(t / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6 \cdot 10^{+16} \lor \neg \left(y \leq 3.5 \cdot 10^{-7}\right):\\
\;\;\;\;x + \frac{-1}{\frac{t}{y \cdot z} + t \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\end{array}
\end{array}
if y < -4.6e16 or 3.49999999999999984e-7 < y Initial program 30.6%
associate-+l-71.9%
sub-neg71.9%
log1p-def71.9%
neg-sub071.9%
associate-+l-71.9%
neg-sub071.9%
neg-mul-171.9%
*-commutative71.9%
distribute-rgt-out71.9%
+-commutative71.9%
metadata-eval71.9%
sub-neg71.9%
expm1-def99.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 57.8%
expm1-def74.9%
*-commutative74.9%
associate-/r*69.5%
*-commutative69.5%
Simplified69.5%
Taylor expanded in z around 0 74.9%
*-commutative74.9%
Simplified74.9%
if -4.6e16 < y < 3.49999999999999984e-7Initial program 82.5%
associate-+l-83.2%
sub-neg83.2%
log1p-def92.2%
neg-sub092.2%
associate-+l-92.2%
neg-sub092.2%
neg-mul-192.2%
*-commutative92.2%
distribute-rgt-out92.2%
+-commutative92.2%
metadata-eval92.2%
sub-neg92.2%
expm1-def98.5%
Simplified98.5%
Taylor expanded in y around 0 92.1%
associate-/l*92.1%
associate-/r/92.1%
expm1-def99.8%
Simplified99.8%
*-commutative99.8%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Final simplification89.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ (/ t (* y z)) (* t 0.5))))
(if (<= z -2.2e-9)
(+ x (/ -1.0 (- t_1 (* 0.5 (/ t y)))))
(+ x (/ -1.0 t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = (t / (y * z)) + (t * 0.5);
double tmp;
if (z <= -2.2e-9) {
tmp = x + (-1.0 / (t_1 - (0.5 * (t / y))));
} else {
tmp = x + (-1.0 / t_1);
}
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 = (t / (y * z)) + (t * 0.5d0)
if (z <= (-2.2d-9)) then
tmp = x + ((-1.0d0) / (t_1 - (0.5d0 * (t / y))))
else
tmp = x + ((-1.0d0) / t_1)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (t / (y * z)) + (t * 0.5);
double tmp;
if (z <= -2.2e-9) {
tmp = x + (-1.0 / (t_1 - (0.5 * (t / y))));
} else {
tmp = x + (-1.0 / t_1);
}
return tmp;
}
def code(x, y, z, t): t_1 = (t / (y * z)) + (t * 0.5) tmp = 0 if z <= -2.2e-9: tmp = x + (-1.0 / (t_1 - (0.5 * (t / y)))) else: tmp = x + (-1.0 / t_1) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(t / Float64(y * z)) + Float64(t * 0.5)) tmp = 0.0 if (z <= -2.2e-9) tmp = Float64(x + Float64(-1.0 / Float64(t_1 - Float64(0.5 * Float64(t / y))))); else tmp = Float64(x + Float64(-1.0 / t_1)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (t / (y * z)) + (t * 0.5); tmp = 0.0; if (z <= -2.2e-9) tmp = x + (-1.0 / (t_1 - (0.5 * (t / y)))); else tmp = x + (-1.0 / t_1); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.2e-9], N[(x + N[(-1.0 / N[(t$95$1 - N[(0.5 * N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(-1.0 / t$95$1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t}{y \cdot z} + t \cdot 0.5\\
\mathbf{if}\;z \leq -2.2 \cdot 10^{-9}:\\
\;\;\;\;x + \frac{-1}{t_1 - 0.5 \cdot \frac{t}{y}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{t_1}\\
\end{array}
\end{array}
if z < -2.1999999999999998e-9Initial program 82.6%
associate-+l-82.6%
sub-neg82.6%
log1p-def99.8%
neg-sub099.8%
associate-+l-99.8%
neg-sub099.8%
neg-mul-199.8%
*-commutative99.8%
distribute-rgt-out99.8%
+-commutative99.8%
metadata-eval99.8%
sub-neg99.8%
expm1-def99.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 81.7%
expm1-def81.7%
*-commutative81.7%
associate-/r*81.7%
*-commutative81.7%
Simplified81.7%
Taylor expanded in z around 0 67.0%
if -2.1999999999999998e-9 < z Initial program 51.8%
associate-+l-76.8%
sub-neg76.8%
log1p-def76.8%
neg-sub076.8%
associate-+l-76.8%
neg-sub076.8%
neg-mul-176.8%
*-commutative76.8%
distribute-rgt-out76.8%
+-commutative76.8%
metadata-eval76.8%
sub-neg76.8%
expm1-def98.7%
Simplified98.7%
clear-num98.6%
inv-pow98.6%
Applied egg-rr98.6%
unpow-198.6%
Applied egg-rr98.6%
Taylor expanded in y around 0 76.7%
expm1-def92.1%
*-commutative92.1%
associate-/r*90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in z around 0 92.1%
*-commutative92.1%
Simplified92.1%
Final simplification84.2%
(FPCore (x y z t) :precision binary64 (if (<= z -8.2e+108) x (+ x (/ -1.0 (+ (/ t (* y z)) (* t 0.5))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.2e+108) {
tmp = x;
} else {
tmp = x + (-1.0 / ((t / (y * z)) + (t * 0.5)));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-8.2d+108)) then
tmp = x
else
tmp = x + ((-1.0d0) / ((t / (y * z)) + (t * 0.5d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.2e+108) {
tmp = x;
} else {
tmp = x + (-1.0 / ((t / (y * z)) + (t * 0.5)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.2e+108: tmp = x else: tmp = x + (-1.0 / ((t / (y * z)) + (t * 0.5))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.2e+108) tmp = x; else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / Float64(y * z)) + Float64(t * 0.5)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -8.2e+108) tmp = x; else tmp = x + (-1.0 / ((t / (y * z)) + (t * 0.5))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.2e+108], x, N[(x + N[(-1.0 / N[(N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.2 \cdot 10^{+108}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{\frac{t}{y \cdot z} + t \cdot 0.5}\\
\end{array}
\end{array}
if z < -8.1999999999999998e108Initial program 84.1%
associate-+l-84.1%
sub-neg84.1%
log1p-def99.8%
neg-sub099.8%
associate-+l-99.8%
neg-sub099.8%
neg-mul-199.8%
*-commutative99.8%
distribute-rgt-out99.8%
+-commutative99.8%
metadata-eval99.8%
sub-neg99.8%
expm1-def99.8%
Simplified99.8%
Taylor expanded in z around 0 5.8%
*-commutative5.8%
fma-def6.1%
*-commutative6.1%
associate-*l*6.1%
unpow26.1%
+-commutative6.1%
mul-1-neg6.1%
unsub-neg6.1%
unpow26.1%
Simplified6.1%
Taylor expanded in y around inf 5.5%
associate-/l*5.5%
unpow25.5%
unpow25.5%
Simplified5.5%
Taylor expanded in x around inf 62.0%
if -8.1999999999999998e108 < z Initial program 56.6%
associate-+l-77.4%
sub-neg77.4%
log1p-def80.6%
neg-sub080.6%
associate-+l-80.6%
neg-sub080.6%
neg-mul-180.6%
*-commutative80.6%
distribute-rgt-out80.6%
+-commutative80.6%
metadata-eval80.6%
sub-neg80.6%
expm1-def98.9%
Simplified98.9%
clear-num98.8%
inv-pow98.8%
Applied egg-rr98.8%
unpow-198.8%
Applied egg-rr98.8%
Taylor expanded in y around 0 77.7%
expm1-def90.6%
*-commutative90.6%
associate-/r*89.0%
*-commutative89.0%
Simplified89.0%
Taylor expanded in z around 0 87.6%
*-commutative87.6%
Simplified87.6%
Final simplification83.1%
(FPCore (x y z t) :precision binary64 (if (<= z -1.9e+21) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.9e+21) {
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.9d+21)) 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.9e+21) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.9e+21: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.9e+21) 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.9e+21) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.9e+21], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{+21}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -1.9e21Initial program 82.2%
associate-+l-82.2%
sub-neg82.2%
log1p-def99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
metadata-eval99.9%
sub-neg99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in z around 0 21.6%
*-commutative21.6%
fma-def21.8%
*-commutative21.8%
associate-*l*21.8%
unpow221.8%
+-commutative21.8%
mul-1-neg21.8%
unsub-neg21.8%
unpow221.8%
Simplified21.8%
Taylor expanded in y around inf 21.7%
associate-/l*20.3%
unpow220.3%
unpow220.3%
Simplified20.3%
Taylor expanded in x around inf 62.1%
if -1.9e21 < z Initial program 53.2%
associate-+l-77.2%
sub-neg77.2%
log1p-def77.7%
neg-sub077.7%
associate-+l-77.7%
neg-sub077.7%
neg-mul-177.7%
*-commutative77.7%
distribute-rgt-out77.6%
+-commutative77.6%
metadata-eval77.6%
sub-neg77.6%
expm1-def98.7%
Simplified98.7%
Taylor expanded in z around 0 87.4%
associate-/l*88.1%
associate-/r/85.2%
Simplified85.2%
Final simplification78.6%
(FPCore (x y z t) :precision binary64 (if (<= z -3.7e+21) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.7e+21) {
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 <= (-3.7d+21)) 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 <= -3.7e+21) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.7e+21: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.7e+21) 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 <= -3.7e+21) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.7e+21], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{+21}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -3.7e21Initial program 82.2%
associate-+l-82.2%
sub-neg82.2%
log1p-def99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
neg-mul-199.9%
*-commutative99.9%
distribute-rgt-out99.9%
+-commutative99.9%
metadata-eval99.9%
sub-neg99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in z around 0 21.6%
*-commutative21.6%
fma-def21.8%
*-commutative21.8%
associate-*l*21.8%
unpow221.8%
+-commutative21.8%
mul-1-neg21.8%
unsub-neg21.8%
unpow221.8%
Simplified21.8%
Taylor expanded in y around inf 21.7%
associate-/l*20.3%
unpow220.3%
unpow220.3%
Simplified20.3%
Taylor expanded in x around inf 62.1%
if -3.7e21 < z Initial program 53.2%
associate-+l-77.2%
sub-neg77.2%
log1p-def77.7%
neg-sub077.7%
associate-+l-77.7%
neg-sub077.7%
neg-mul-177.7%
*-commutative77.7%
distribute-rgt-out77.6%
+-commutative77.6%
metadata-eval77.6%
sub-neg77.6%
expm1-def98.7%
Simplified98.7%
clear-num98.7%
inv-pow98.7%
Applied egg-rr98.7%
Taylor expanded in z around 0 87.4%
associate-/l*88.1%
Simplified88.1%
Final simplification80.7%
(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 61.4%
associate-+l-78.6%
sub-neg78.6%
log1p-def84.0%
neg-sub084.0%
associate-+l-84.0%
neg-sub084.0%
neg-mul-184.0%
*-commutative84.0%
distribute-rgt-out84.0%
+-commutative84.0%
metadata-eval84.0%
sub-neg84.0%
expm1-def99.0%
Simplified99.0%
Taylor expanded in z around 0 61.3%
*-commutative61.3%
fma-def61.3%
*-commutative61.3%
associate-*l*61.3%
unpow261.3%
+-commutative61.3%
mul-1-neg61.3%
unsub-neg61.3%
unpow261.3%
Simplified61.3%
Taylor expanded in y around inf 52.6%
associate-/l*52.2%
unpow252.2%
unpow252.2%
Simplified52.2%
Taylor expanded in x around inf 72.0%
Final simplification72.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 2023199
(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)))