
(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 (<= (exp z) 20.0) (- x (/ (log1p (* y (expm1 z))) t)) (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 20.0) {
tmp = x - (log1p((y * expm1(z))) / t);
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.exp(z) <= 20.0) {
tmp = x - (Math.log1p((y * Math.expm1(z))) / t);
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.exp(z) <= 20.0: tmp = x - (math.log1p((y * math.expm1(z))) / t) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 20.0) tmp = Float64(x - Float64(log1p(Float64(y * expm1(z))) / t)); else tmp = Float64(x - Float64(y * Float64(z / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 20.0], N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 20:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if (exp.f64 z) < 20Initial program 56.6%
associate-+l-65.1%
sub-neg65.1%
log1p-def73.6%
neg-sub073.6%
associate-+l-73.6%
neg-sub073.6%
neg-mul-173.6%
*-commutative73.6%
distribute-rgt-out73.5%
+-commutative73.5%
metadata-eval73.5%
sub-neg73.5%
expm1-def99.5%
Simplified99.5%
if 20 < (exp.f64 z) Initial program 57.0%
associate-+l-57.0%
sub-neg57.0%
log1p-def57.0%
neg-sub057.0%
associate-+l-57.0%
neg-sub057.0%
neg-mul-157.0%
*-commutative57.0%
distribute-rgt-out57.0%
+-commutative57.0%
metadata-eval57.0%
sub-neg57.0%
expm1-def57.0%
Simplified57.0%
Taylor expanded in y around 0 57.0%
associate-/l*57.0%
associate-/r/57.0%
expm1-def57.0%
Simplified57.0%
Taylor expanded in z around 0 66.1%
Final simplification93.7%
(FPCore (x y z t)
:precision binary64
(if (<= z -2.4)
(+ x (/ -1.0 (+ (* t 0.5) (/ t (* y (expm1 z))))))
(if (<= z 5.7e+28)
(- x (/ (log1p (* z (+ y (* z (* y 0.5))))) t))
(- x (* y (/ z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.4) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * expm1(z)))));
} else if (z <= 5.7e+28) {
tmp = x - (log1p((z * (y + (z * (y * 0.5))))) / t);
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.4) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * Math.expm1(z)))));
} else if (z <= 5.7e+28) {
tmp = x - (Math.log1p((z * (y + (z * (y * 0.5))))) / t);
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.4: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * math.expm1(z))))) elif z <= 5.7e+28: tmp = x - (math.log1p((z * (y + (z * (y * 0.5))))) / t) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.4) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * expm1(z)))))); elseif (z <= 5.7e+28) tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(z * Float64(y * 0.5))))) / t)); else tmp = Float64(x - Float64(y * Float64(z / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.4], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 5.7e+28], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(z * N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \mathsf{expm1}\left(z\right)}}\\
\mathbf{elif}\;z \leq 5.7 \cdot 10^{+28}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + z \cdot \left(y \cdot 0.5\right)\right)\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -2.39999999999999991Initial program 71.5%
associate-+l-71.5%
sub-neg71.5%
log1p-def100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
neg-mul-1100.0%
*-commutative100.0%
distribute-rgt-out100.0%
+-commutative100.0%
metadata-eval100.0%
sub-neg100.0%
expm1-def100.0%
Simplified100.0%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 79.4%
+-commutative79.4%
*-commutative79.4%
expm1-def79.4%
*-commutative79.4%
Simplified79.4%
if -2.39999999999999991 < z < 5.7000000000000003e28Initial program 49.8%
associate-+l-61.2%
sub-neg61.2%
log1p-def62.1%
neg-sub062.1%
associate-+l-62.1%
neg-sub062.1%
neg-mul-162.1%
*-commutative62.1%
distribute-rgt-out62.1%
+-commutative62.1%
metadata-eval62.1%
sub-neg62.1%
expm1-def96.9%
Simplified96.9%
Taylor expanded in z around 0 97.7%
*-commutative97.7%
fma-def97.7%
*-commutative97.7%
*-commutative97.7%
associate-*l*97.7%
unpow297.7%
Simplified97.7%
expm1-log1p-u74.6%
expm1-udef62.8%
fma-udef62.8%
associate-*l*62.8%
distribute-lft-out62.8%
Applied egg-rr62.8%
expm1-def74.6%
expm1-log1p97.7%
Simplified97.7%
if 5.7000000000000003e28 < z Initial program 62.3%
associate-+l-62.3%
sub-neg62.3%
log1p-def62.3%
neg-sub062.3%
associate-+l-62.3%
neg-sub062.3%
neg-mul-162.3%
*-commutative62.3%
distribute-rgt-out62.3%
+-commutative62.3%
metadata-eval62.3%
sub-neg62.3%
expm1-def62.3%
Simplified62.3%
Taylor expanded in y around 0 62.3%
associate-/l*62.3%
associate-/r/62.3%
expm1-def62.3%
Simplified62.3%
Taylor expanded in z around 0 67.4%
Final simplification88.8%
(FPCore (x y z t) :precision binary64 (if (<= z 2.05e-139) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y (expm1 z)))))) (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 2.05e-139) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * expm1(z)))));
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 2.05e-139) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * Math.expm1(z)))));
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 2.05e-139: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * math.expm1(z))))) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 2.05e-139) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * expm1(z)))))); else tmp = Float64(x - Float64(y * Float64(z / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, 2.05e-139], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.05 \cdot 10^{-139}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < 2.05000000000000007e-139Initial program 54.2%
associate-+l-63.9%
sub-neg63.9%
log1p-def74.3%
neg-sub074.3%
associate-+l-74.3%
neg-sub074.3%
neg-mul-174.3%
*-commutative74.3%
distribute-rgt-out74.3%
+-commutative74.3%
metadata-eval74.3%
sub-neg74.3%
expm1-def99.9%
Simplified99.9%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 67.4%
+-commutative67.4%
*-commutative67.4%
expm1-def90.6%
*-commutative90.6%
Simplified90.6%
if 2.05000000000000007e-139 < z Initial program 61.9%
associate-+l-63.3%
sub-neg63.3%
log1p-def63.3%
neg-sub063.3%
associate-+l-63.3%
neg-sub063.3%
neg-mul-163.3%
*-commutative63.3%
distribute-rgt-out63.3%
+-commutative63.3%
metadata-eval63.3%
sub-neg63.3%
expm1-def76.0%
Simplified76.0%
Taylor expanded in y around 0 62.2%
associate-/l*62.0%
associate-/r/62.2%
expm1-def70.5%
Simplified70.5%
Taylor expanded in z around 0 75.3%
Final simplification85.6%
(FPCore (x y z t) :precision binary64 (if (<= z 2e-73) (- x (* y (/ (expm1 z) t))) (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 2e-73) {
tmp = x - (y * (expm1(z) / t));
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 2e-73) {
tmp = x - (y * (Math.expm1(z) / t));
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 2e-73: tmp = x - (y * (math.expm1(z) / t)) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 2e-73) tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); else tmp = Float64(x - Float64(y * Float64(z / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, 2e-73], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2 \cdot 10^{-73}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < 1.99999999999999999e-73Initial program 54.8%
associate-+l-63.8%
sub-neg63.8%
log1p-def72.8%
neg-sub072.8%
associate-+l-72.8%
neg-sub072.8%
neg-mul-172.8%
*-commutative72.8%
distribute-rgt-out72.8%
+-commutative72.8%
metadata-eval72.8%
sub-neg72.8%
expm1-def99.4%
Simplified99.4%
Taylor expanded in y around 0 64.0%
associate-/l*60.6%
associate-/r/64.0%
expm1-def85.3%
Simplified85.3%
if 1.99999999999999999e-73 < z Initial program 63.3%
associate-+l-63.3%
sub-neg63.3%
log1p-def63.3%
neg-sub063.3%
associate-+l-63.3%
neg-sub063.3%
neg-mul-163.3%
*-commutative63.3%
distribute-rgt-out63.3%
+-commutative63.3%
metadata-eval63.3%
sub-neg63.3%
expm1-def66.8%
Simplified66.8%
Taylor expanded in y around 0 61.7%
associate-/l*61.7%
associate-/r/61.7%
expm1-def63.6%
Simplified63.6%
Taylor expanded in z around 0 70.6%
Final simplification82.0%
(FPCore (x y z t) :precision binary64 (if (<= z 1e-179) (- x (/ (* y (expm1 z)) t)) (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 1e-179) {
tmp = x - ((y * expm1(z)) / t);
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 1e-179) {
tmp = x - ((y * Math.expm1(z)) / t);
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 1e-179: tmp = x - ((y * math.expm1(z)) / t) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 1e-179) tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); else tmp = Float64(x - Float64(y * Float64(z / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, 1e-179], N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{-179}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < 1e-179Initial program 54.6%
associate-+l-64.2%
sub-neg64.2%
log1p-def75.2%
neg-sub075.2%
associate-+l-75.2%
neg-sub075.2%
neg-mul-175.2%
*-commutative75.2%
distribute-rgt-out75.2%
+-commutative75.2%
metadata-eval75.2%
sub-neg75.2%
expm1-def99.9%
Simplified99.9%
Taylor expanded in y around 0 64.5%
expm1-def85.1%
Simplified85.1%
if 1e-179 < z Initial program 60.4%
associate-+l-62.7%
sub-neg62.7%
log1p-def62.7%
neg-sub062.7%
associate-+l-62.7%
neg-sub062.7%
neg-mul-162.7%
*-commutative62.7%
distribute-rgt-out62.7%
+-commutative62.7%
metadata-eval62.7%
sub-neg62.7%
expm1-def78.3%
Simplified78.3%
Taylor expanded in y around 0 61.7%
associate-/l*61.6%
associate-/r/61.7%
expm1-def72.4%
Simplified72.4%
Taylor expanded in z around 0 76.7%
Final simplification82.1%
(FPCore (x y z t) :precision binary64 (- x (* z (/ y t))))
double code(double x, double y, double z, double t) {
return x - (z * (y / 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 - (z * (y / t))
end function
public static double code(double x, double y, double z, double t) {
return x - (z * (y / t));
}
def code(x, y, z, t): return x - (z * (y / t))
function code(x, y, z, t) return Float64(x - Float64(z * Float64(y / t))) end
function tmp = code(x, y, z, t) tmp = x - (z * (y / t)); end
code[x_, y_, z_, t_] := N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - z \cdot \frac{y}{t}
\end{array}
Initial program 56.7%
associate-+l-63.7%
sub-neg63.7%
log1p-def70.7%
neg-sub070.7%
associate-+l-70.7%
neg-sub070.7%
neg-mul-170.7%
*-commutative70.7%
distribute-rgt-out70.7%
+-commutative70.7%
metadata-eval70.7%
sub-neg70.7%
expm1-def92.2%
Simplified92.2%
Taylor expanded in z around 0 67.2%
associate-/l*68.9%
associate-/r/61.6%
Simplified61.6%
Final simplification61.6%
(FPCore (x y z t) :precision binary64 (- x (* y (/ z t))))
double code(double x, double y, double z, double t) {
return x - (y * (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 - (y * (z / t))
end function
public static double code(double x, double y, double z, double t) {
return x - (y * (z / t));
}
def code(x, y, z, t): return x - (y * (z / t))
function code(x, y, z, t) return Float64(x - Float64(y * Float64(z / t))) end
function tmp = code(x, y, z, t) tmp = x - (y * (z / t)); end
code[x_, y_, z_, t_] := N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - y \cdot \frac{z}{t}
\end{array}
Initial program 56.7%
associate-+l-63.7%
sub-neg63.7%
log1p-def70.7%
neg-sub070.7%
associate-+l-70.7%
neg-sub070.7%
neg-mul-170.7%
*-commutative70.7%
distribute-rgt-out70.7%
+-commutative70.7%
metadata-eval70.7%
sub-neg70.7%
expm1-def92.2%
Simplified92.2%
Taylor expanded in y around 0 63.5%
associate-/l*60.9%
associate-/r/63.5%
expm1-def80.5%
Simplified80.5%
Taylor expanded in z around 0 69.4%
Final simplification69.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 2023278
(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)))