
(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 8 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.3%
associate-+l-78.3%
sub-neg78.3%
log1p-def83.9%
neg-sub083.9%
associate-+l-83.9%
neg-sub083.9%
neg-mul-183.9%
*-commutative83.9%
distribute-rgt-out83.9%
+-commutative83.9%
metadata-eval83.9%
sub-neg83.9%
expm1-def99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (expm1 z))))
(if (<= y -2.25e+282)
(/ (- (log1p t_1)) t)
(if (<= y -1.55e+160) x (- x (/ t_1 t))))))
double code(double x, double y, double z, double t) {
double t_1 = y * expm1(z);
double tmp;
if (y <= -2.25e+282) {
tmp = -log1p(t_1) / t;
} else if (y <= -1.55e+160) {
tmp = x;
} else {
tmp = x - (t_1 / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = y * Math.expm1(z);
double tmp;
if (y <= -2.25e+282) {
tmp = -Math.log1p(t_1) / t;
} else if (y <= -1.55e+160) {
tmp = x;
} else {
tmp = x - (t_1 / t);
}
return tmp;
}
def code(x, y, z, t): t_1 = y * math.expm1(z) tmp = 0 if y <= -2.25e+282: tmp = -math.log1p(t_1) / t elif y <= -1.55e+160: tmp = x else: tmp = x - (t_1 / t) return tmp
function code(x, y, z, t) t_1 = Float64(y * expm1(z)) tmp = 0.0 if (y <= -2.25e+282) tmp = Float64(Float64(-log1p(t_1)) / t); elseif (y <= -1.55e+160) tmp = x; else tmp = Float64(x - Float64(t_1 / t)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.25e+282], N[((-N[Log[1 + t$95$1], $MachinePrecision]) / t), $MachinePrecision], If[LessEqual[y, -1.55e+160], x, N[(x - N[(t$95$1 / t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \mathsf{expm1}\left(z\right)\\
\mathbf{if}\;y \leq -2.25 \cdot 10^{+282}:\\
\;\;\;\;\frac{-\mathsf{log1p}\left(t_1\right)}{t}\\
\mathbf{elif}\;y \leq -1.55 \cdot 10^{+160}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{t_1}{t}\\
\end{array}
\end{array}
if y < -2.25000000000000011e282Initial program 40.2%
associate-+l-44.3%
sub-neg44.3%
log1p-def44.3%
neg-sub044.3%
associate-+l-44.3%
neg-sub044.3%
neg-mul-144.3%
*-commutative44.3%
distribute-rgt-out44.3%
+-commutative44.3%
metadata-eval44.3%
sub-neg44.3%
expm1-def99.4%
Simplified99.4%
Taylor expanded in x around 0 41.3%
mul-1-neg41.3%
log1p-def41.3%
*-commutative41.3%
expm1-def99.4%
distribute-frac-neg99.4%
expm1-def41.3%
*-commutative41.3%
expm1-def99.4%
Simplified99.4%
if -2.25000000000000011e282 < y < -1.5499999999999999e160Initial program 47.5%
associate-+l-79.6%
sub-neg79.6%
log1p-def79.6%
neg-sub079.6%
associate-+l-79.6%
neg-sub079.6%
neg-mul-179.6%
*-commutative79.6%
distribute-rgt-out79.6%
+-commutative79.6%
metadata-eval79.6%
sub-neg79.6%
expm1-def99.7%
Simplified99.7%
Taylor expanded in x around inf 66.9%
if -1.5499999999999999e160 < y Initial program 63.2%
associate-+l-78.9%
sub-neg78.9%
log1p-def85.2%
neg-sub085.2%
associate-+l-85.2%
neg-sub085.2%
neg-mul-185.2%
*-commutative85.2%
distribute-rgt-out85.2%
+-commutative85.2%
metadata-eval85.2%
sub-neg85.2%
expm1-def98.9%
Simplified98.9%
Taylor expanded in y around 0 83.5%
expm1-def94.0%
Simplified94.0%
Final simplification91.5%
(FPCore (x y z t) :precision binary64 (if (<= z -1e-132) (- x (/ (expm1 z) (/ t y))) (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1e-132) {
tmp = x - (expm1(z) / (t / y));
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1e-132) {
tmp = x - (Math.expm1(z) / (t / y));
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1e-132: tmp = x - (math.expm1(z) / (t / y)) else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1e-132) tmp = Float64(x - Float64(expm1(z) / Float64(t / y))); else tmp = Float64(x - Float64(y / Float64(t / z))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -1e-132], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-132}:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right)}{\frac{t}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -9.9999999999999999e-133Initial program 76.4%
associate-+l-81.2%
sub-neg81.2%
log1p-def94.7%
neg-sub094.7%
associate-+l-94.7%
neg-sub094.7%
neg-mul-194.7%
*-commutative94.7%
distribute-rgt-out94.7%
+-commutative94.7%
metadata-eval94.7%
sub-neg94.7%
expm1-def98.8%
Simplified98.8%
Taylor expanded in y around 0 82.3%
associate-/l*81.3%
expm1-def84.7%
Simplified84.7%
if -9.9999999999999999e-133 < z Initial program 50.4%
associate-+l-76.2%
sub-neg76.2%
log1p-def76.2%
neg-sub076.2%
associate-+l-76.2%
neg-sub076.2%
neg-mul-176.2%
*-commutative76.2%
distribute-rgt-out76.2%
+-commutative76.2%
metadata-eval76.2%
sub-neg76.2%
expm1-def99.1%
Simplified99.1%
Taylor expanded in z around 0 92.0%
associate-/l*92.1%
Simplified92.1%
Final simplification89.0%
(FPCore (x y z t) :precision binary64 (if (<= y -4.6e+161) x (- x (/ (* y (expm1 z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.6e+161) {
tmp = x;
} 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 <= -4.6e+161) {
tmp = x;
} else {
tmp = x - ((y * Math.expm1(z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.6e+161: tmp = x else: tmp = x - ((y * math.expm1(z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.6e+161) tmp = x; else tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.6e+161], x, N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6 \cdot 10^{+161}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -4.5999999999999999e161Initial program 46.2%
associate-+l-73.5%
sub-neg73.5%
log1p-def73.5%
neg-sub073.5%
associate-+l-73.5%
neg-sub073.5%
neg-mul-173.5%
*-commutative73.5%
distribute-rgt-out73.5%
+-commutative73.5%
metadata-eval73.5%
sub-neg73.5%
expm1-def99.7%
Simplified99.7%
Taylor expanded in x around inf 56.2%
if -4.5999999999999999e161 < y Initial program 63.2%
associate-+l-78.9%
sub-neg78.9%
log1p-def85.2%
neg-sub085.2%
associate-+l-85.2%
neg-sub085.2%
neg-mul-185.2%
*-commutative85.2%
distribute-rgt-out85.2%
+-commutative85.2%
metadata-eval85.2%
sub-neg85.2%
expm1-def98.9%
Simplified98.9%
Taylor expanded in y around 0 83.5%
expm1-def94.0%
Simplified94.0%
Final simplification89.7%
(FPCore (x y z t) :precision binary64 (if (<= x -8.8e+39) x (if (<= x 4.4e-103) (- x (* z (/ y t))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -8.8e+39) {
tmp = x;
} else if (x <= 4.4e-103) {
tmp = x - (z * (y / t));
} else {
tmp = x;
}
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 (x <= (-8.8d+39)) then
tmp = x
else if (x <= 4.4d-103) then
tmp = x - (z * (y / t))
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -8.8e+39) {
tmp = x;
} else if (x <= 4.4e-103) {
tmp = x - (z * (y / t));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -8.8e+39: tmp = x elif x <= 4.4e-103: tmp = x - (z * (y / t)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -8.8e+39) tmp = x; elseif (x <= 4.4e-103) tmp = Float64(x - Float64(z * Float64(y / t))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -8.8e+39) tmp = x; elseif (x <= 4.4e-103) tmp = x - (z * (y / t)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -8.8e+39], x, If[LessEqual[x, 4.4e-103], N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.8 \cdot 10^{+39}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 4.4 \cdot 10^{-103}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -8.8000000000000006e39 or 4.3999999999999999e-103 < x Initial program 69.3%
associate-+l-92.3%
sub-neg92.3%
log1p-def93.5%
neg-sub093.5%
associate-+l-93.5%
neg-sub093.5%
neg-mul-193.5%
*-commutative93.5%
distribute-rgt-out93.5%
+-commutative93.5%
metadata-eval93.5%
sub-neg93.5%
expm1-def99.3%
Simplified99.3%
Taylor expanded in x around inf 91.6%
if -8.8000000000000006e39 < x < 4.3999999999999999e-103Initial program 48.9%
associate-+l-56.8%
sub-neg56.8%
log1p-def69.2%
neg-sub069.2%
associate-+l-69.2%
neg-sub069.2%
neg-mul-169.2%
*-commutative69.2%
distribute-rgt-out69.2%
+-commutative69.2%
metadata-eval69.2%
sub-neg69.2%
expm1-def98.4%
Simplified98.4%
Taylor expanded in z around 0 67.1%
associate-/l*67.6%
associate-/r/63.5%
Simplified63.5%
Final simplification80.5%
(FPCore (x y z t) :precision binary64 (if (<= z -3.25e-65) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.25e-65) {
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 <= (-3.25d-65)) 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 <= -3.25e-65) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.25e-65: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.25e-65) 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 <= -3.25e-65) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.25e-65], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.25 \cdot 10^{-65}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -3.25e-65Initial program 80.9%
associate-+l-82.1%
sub-neg82.1%
log1p-def98.9%
neg-sub098.9%
associate-+l-98.9%
neg-sub098.9%
neg-mul-198.9%
*-commutative98.9%
distribute-rgt-out98.9%
+-commutative98.9%
metadata-eval98.9%
sub-neg98.9%
expm1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 71.9%
if -3.25e-65 < z Initial program 51.3%
associate-+l-76.4%
sub-neg76.4%
log1p-def76.4%
neg-sub076.4%
associate-+l-76.4%
neg-sub076.4%
neg-mul-176.4%
*-commutative76.4%
distribute-rgt-out76.4%
+-commutative76.4%
metadata-eval76.4%
sub-neg76.4%
expm1-def98.4%
Simplified98.4%
Taylor expanded in z around 0 91.6%
associate-/l*91.9%
associate-/r/83.8%
Simplified83.8%
*-commutative83.8%
clear-num83.9%
un-div-inv83.8%
Applied egg-rr83.8%
associate-/r/91.9%
Simplified91.9%
Final simplification85.2%
(FPCore (x y z t) :precision binary64 (if (<= z -3.25e-65) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.25e-65) {
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.25d-65)) 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.25e-65) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.25e-65: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.25e-65) 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.25e-65) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.25e-65], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.25 \cdot 10^{-65}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -3.25e-65Initial program 80.9%
associate-+l-82.1%
sub-neg82.1%
log1p-def98.9%
neg-sub098.9%
associate-+l-98.9%
neg-sub098.9%
neg-mul-198.9%
*-commutative98.9%
distribute-rgt-out98.9%
+-commutative98.9%
metadata-eval98.9%
sub-neg98.9%
expm1-def100.0%
Simplified100.0%
Taylor expanded in x around inf 71.9%
if -3.25e-65 < z Initial program 51.3%
associate-+l-76.4%
sub-neg76.4%
log1p-def76.4%
neg-sub076.4%
associate-+l-76.4%
neg-sub076.4%
neg-mul-176.4%
*-commutative76.4%
distribute-rgt-out76.4%
+-commutative76.4%
metadata-eval76.4%
sub-neg76.4%
expm1-def98.4%
Simplified98.4%
Taylor expanded in z around 0 91.6%
associate-/l*91.9%
Simplified91.9%
Final simplification85.2%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 61.3%
associate-+l-78.3%
sub-neg78.3%
log1p-def83.9%
neg-sub083.9%
associate-+l-83.9%
neg-sub083.9%
neg-mul-183.9%
*-commutative83.9%
distribute-rgt-out83.9%
+-commutative83.9%
metadata-eval83.9%
sub-neg83.9%
expm1-def99.0%
Simplified99.0%
Taylor expanded in x around inf 75.2%
Final simplification75.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 2023224
(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)))