
(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 56.4%
associate-+l-76.5%
sub-neg76.5%
log1p-def82.4%
neg-sub082.4%
associate-+l-82.4%
neg-sub082.4%
neg-mul-182.4%
*-commutative82.4%
distribute-rgt-out82.4%
+-commutative82.4%
metadata-eval82.4%
sub-neg82.4%
expm1-def99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x y z t) :precision binary64 (if (<= z -7.6e+20) (+ x (/ -1.0 (+ (/ t (* y (expm1 z))) (* t 0.5)))) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.6e+20) {
tmp = x + (-1.0 / ((t / (y * expm1(z))) + (t * 0.5)));
} 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 <= -7.6e+20) {
tmp = x + (-1.0 / ((t / (y * Math.expm1(z))) + (t * 0.5)));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.6e+20: tmp = x + (-1.0 / ((t / (y * math.expm1(z))) + (t * 0.5))) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.6e+20) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / Float64(y * expm1(z))) + Float64(t * 0.5)))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.6e+20], N[(x + N[(-1.0 / N[(N[(t / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t * 0.5), $MachinePrecision]), $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 -7.6 \cdot 10^{+20}:\\
\;\;\;\;x + \frac{-1}{\frac{t}{y \cdot \mathsf{expm1}\left(z\right)} + t \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -7.6e20Initial program 81.2%
associate-+l-81.2%
sub-neg81.2%
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.9%
associate-/r/99.9%
Applied egg-rr99.9%
associate-*l/100.0%
*-un-lft-identity100.0%
*-commutative100.0%
clear-num99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 89.9%
expm1-def89.9%
*-commutative89.9%
*-commutative89.9%
Simplified89.9%
if -7.6e20 < z Initial program 46.8%
associate-+l-74.7%
sub-neg74.7%
log1p-def75.7%
neg-sub075.7%
associate-+l-75.7%
neg-sub075.7%
neg-mul-175.7%
*-commutative75.7%
distribute-rgt-out75.7%
+-commutative75.7%
metadata-eval75.7%
sub-neg75.7%
expm1-def98.8%
Simplified98.8%
Taylor expanded in z around 0 97.4%
*-commutative97.4%
Simplified97.4%
Final simplification95.3%
(FPCore (x y z t) :precision binary64 (if (or (<= y -30000.0) (not (<= y 1.4e-11))) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (- x (* y (/ (expm1 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -30000.0) || !(y <= 1.4e-11)) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} 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 <= -30000.0) || !(y <= 1.4e-11)) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (y * (Math.expm1(z) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -30000.0) or not (y <= 1.4e-11): tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x - (y * (math.expm1(z) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -30000.0) || !(y <= 1.4e-11)) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -30000.0], N[Not[LessEqual[y, 1.4e-11]], $MachinePrecision]], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $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 -30000 \lor \neg \left(y \leq 1.4 \cdot 10^{-11}\right):\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -3e4 or 1.4e-11 < y Initial program 26.0%
associate-+l-71.2%
sub-neg71.2%
log1p-def71.2%
neg-sub071.2%
associate-+l-71.2%
neg-sub071.2%
neg-mul-171.2%
*-commutative71.2%
distribute-rgt-out71.2%
+-commutative71.2%
metadata-eval71.2%
sub-neg71.2%
expm1-def99.9%
Simplified99.9%
Taylor expanded in z around 0 89.2%
*-commutative89.2%
Simplified89.2%
clear-num89.2%
inv-pow89.2%
*-commutative89.2%
Applied egg-rr89.2%
unpow-189.2%
*-commutative89.2%
Simplified89.2%
Taylor expanded in z around 0 82.1%
if -3e4 < y < 1.4e-11Initial program 80.7%
associate-+l-80.7%
sub-neg80.7%
log1p-def91.4%
neg-sub091.4%
associate-+l-91.4%
neg-sub091.4%
neg-mul-191.4%
*-commutative91.4%
distribute-rgt-out91.4%
+-commutative91.4%
metadata-eval91.4%
sub-neg91.4%
expm1-def98.6%
Simplified98.6%
Taylor expanded in y around 0 90.9%
associate-/l*90.9%
associate-/r/90.9%
expm1-def99.4%
Simplified99.4%
Final simplification91.7%
(FPCore (x y z t) :precision binary64 (if (<= z -7.6e+20) (+ x (/ (* y (- 1.0 (exp z))) t)) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.6e+20) {
tmp = x + ((y * (1.0 - exp(z))) / 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 <= -7.6e+20) {
tmp = x + ((y * (1.0 - Math.exp(z))) / t);
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.6e+20: tmp = x + ((y * (1.0 - math.exp(z))) / t) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.6e+20) tmp = Float64(x + Float64(Float64(y * Float64(1.0 - exp(z))) / t)); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.6e+20], N[(x + N[(N[(y * N[(1.0 - N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $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 -7.6 \cdot 10^{+20}:\\
\;\;\;\;x + \frac{y \cdot \left(1 - e^{z}\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -7.6e20Initial program 81.2%
associate-+l-81.2%
sub-neg81.2%
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%
Taylor expanded in y around 0 85.9%
if -7.6e20 < z Initial program 46.8%
associate-+l-74.7%
sub-neg74.7%
log1p-def75.7%
neg-sub075.7%
associate-+l-75.7%
neg-sub075.7%
neg-mul-175.7%
*-commutative75.7%
distribute-rgt-out75.7%
+-commutative75.7%
metadata-eval75.7%
sub-neg75.7%
expm1-def98.8%
Simplified98.8%
Taylor expanded in z around 0 97.4%
*-commutative97.4%
Simplified97.4%
Final simplification94.2%
(FPCore (x y z t) :precision binary64 (if (<= z -7.8e+20) (- x (* y (/ (expm1 z) t))) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.8e+20) {
tmp = x - (y * (expm1(z) / 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 <= -7.8e+20) {
tmp = x - (y * (Math.expm1(z) / t));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.8e+20: tmp = x - (y * (math.expm1(z) / t)) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.8e+20) tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.8e+20], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / 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 -7.8 \cdot 10^{+20}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -7.8e20Initial program 81.2%
associate-+l-81.2%
sub-neg81.2%
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%
Taylor expanded in y around 0 85.9%
associate-/l*85.9%
associate-/r/85.9%
expm1-def85.9%
Simplified85.9%
if -7.8e20 < z Initial program 46.8%
associate-+l-74.7%
sub-neg74.7%
log1p-def75.7%
neg-sub075.7%
associate-+l-75.7%
neg-sub075.7%
neg-mul-175.7%
*-commutative75.7%
distribute-rgt-out75.7%
+-commutative75.7%
metadata-eval75.7%
sub-neg75.7%
expm1-def98.8%
Simplified98.8%
Taylor expanded in z around 0 97.4%
*-commutative97.4%
Simplified97.4%
Final simplification94.2%
(FPCore (x y z t) :precision binary64 (if (<= z -1.1e+65) x (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.1e+65) {
tmp = x;
} else {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * 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 <= (-1.1d+65)) then
tmp = x
else
tmp = x + ((-1.0d0) / ((t * 0.5d0) + (t / (y * z))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.1e+65) {
tmp = x;
} else {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.1e+65: tmp = x else: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.1e+65) tmp = x; else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.1e+65) tmp = x; else tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.1e+65], x, N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{+65}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\end{array}
\end{array}
if z < -1.0999999999999999e65Initial program 83.4%
associate-+l-83.4%
sub-neg83.4%
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 x around inf 69.6%
if -1.0999999999999999e65 < z Initial program 48.6%
associate-+l-74.5%
sub-neg74.5%
log1p-def77.4%
neg-sub077.4%
associate-+l-77.4%
neg-sub077.4%
neg-mul-177.4%
*-commutative77.4%
distribute-rgt-out77.4%
+-commutative77.4%
metadata-eval77.4%
sub-neg77.4%
expm1-def98.9%
Simplified98.9%
Taylor expanded in z around 0 94.8%
*-commutative94.8%
Simplified94.8%
clear-num94.7%
inv-pow94.7%
*-commutative94.7%
Applied egg-rr94.7%
unpow-194.7%
*-commutative94.7%
Simplified94.7%
Taylor expanded in z around 0 89.1%
Final simplification84.8%
(FPCore (x y z t) :precision binary64 (if (<= z -7.5e+47) x (+ x (/ -1.0 (/ (/ t z) y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.5e+47) {
tmp = x;
} else {
tmp = x + (-1.0 / ((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+47)) then
tmp = x
else
tmp = x + ((-1.0d0) / ((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+47) {
tmp = x;
} else {
tmp = x + (-1.0 / ((t / z) / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.5e+47: tmp = x else: tmp = x + (-1.0 / ((t / z) / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.5e+47) tmp = x; else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / z) / y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -7.5e+47) tmp = x; else tmp = x + (-1.0 / ((t / z) / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.5e+47], x, N[(x + N[(-1.0 / N[(N[(t / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{+47}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{\frac{\frac{t}{z}}{y}}\\
\end{array}
\end{array}
if z < -7.4999999999999999e47Initial program 83.5%
associate-+l-83.5%
sub-neg83.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%
Taylor expanded in x around inf 71.0%
if -7.4999999999999999e47 < z Initial program 47.5%
associate-+l-74.2%
sub-neg74.2%
log1p-def76.7%
neg-sub076.7%
associate-+l-76.7%
neg-sub076.7%
neg-mul-176.7%
*-commutative76.7%
distribute-rgt-out76.7%
+-commutative76.7%
metadata-eval76.7%
sub-neg76.7%
expm1-def98.9%
Simplified98.9%
Taylor expanded in z around 0 95.6%
*-commutative95.6%
Simplified95.6%
clear-num95.6%
inv-pow95.6%
*-commutative95.6%
Applied egg-rr95.6%
unpow-195.6%
*-commutative95.6%
Simplified95.6%
Taylor expanded in z around 0 85.7%
associate-/l/86.5%
Simplified86.5%
Final simplification82.7%
(FPCore (x y z t) :precision binary64 (if (<= z -1.16e+48) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.16e+48) {
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 <= (-1.16d+48)) 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 <= -1.16e+48) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.16e+48: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.16e+48) 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 <= -1.16e+48) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.16e+48], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.16 \cdot 10^{+48}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -1.15999999999999992e48Initial program 83.5%
associate-+l-83.5%
sub-neg83.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%
Taylor expanded in x around inf 71.0%
if -1.15999999999999992e48 < z Initial program 47.5%
associate-+l-74.2%
sub-neg74.2%
log1p-def76.7%
neg-sub076.7%
associate-+l-76.7%
neg-sub076.7%
neg-mul-176.7%
*-commutative76.7%
distribute-rgt-out76.7%
+-commutative76.7%
metadata-eval76.7%
sub-neg76.7%
expm1-def98.9%
Simplified98.9%
Taylor expanded in z around 0 85.7%
associate-/l*86.4%
Simplified86.4%
Final simplification82.6%
(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 56.4%
associate-+l-76.5%
sub-neg76.5%
log1p-def82.4%
neg-sub082.4%
associate-+l-82.4%
neg-sub082.4%
neg-mul-182.4%
*-commutative82.4%
distribute-rgt-out82.4%
+-commutative82.4%
metadata-eval82.4%
sub-neg82.4%
expm1-def99.1%
Simplified99.1%
Taylor expanded in x around inf 71.9%
Final simplification71.9%
(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 2023240
(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)))