
(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 64.5%
associate-+l-78.9%
sub-neg78.9%
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-def98.4%
Simplified98.4%
Final simplification98.4%
(FPCore (x y z t) :precision binary64 (if (<= y -1.5e+14) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (+ x (/ -1.0 (+ (* t 0.5) (/ (/ t y) (expm1 z)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.5e+14) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x + (-1.0 / ((t * 0.5) + ((t / y) / expm1(z))));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.5e+14) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x + (-1.0 / ((t * 0.5) + ((t / y) / Math.expm1(z))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.5e+14: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x + (-1.0 / ((t * 0.5) + ((t / y) / math.expm1(z)))) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.5e+14) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(Float64(t / y) / expm1(z))))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.5e+14], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(N[(t / y), $MachinePrecision] / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{+14}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{\frac{t}{y}}{\mathsf{expm1}\left(z\right)}}\\
\end{array}
\end{array}
if y < -1.5e14Initial program 43.2%
associate-+l-75.4%
sub-neg75.4%
log1p-def75.4%
neg-sub075.4%
associate-+l-75.4%
neg-sub075.4%
neg-mul-175.4%
*-commutative75.4%
distribute-rgt-out75.4%
+-commutative75.4%
metadata-eval75.4%
sub-neg75.4%
expm1-def99.8%
Simplified99.8%
clear-num99.7%
associate-/r/99.6%
Applied egg-rr99.6%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 60.1%
expm1-def77.0%
associate-/l/69.4%
*-commutative69.4%
Simplified69.4%
Taylor expanded in z around 0 77.0%
*-commutative77.0%
Simplified77.0%
if -1.5e14 < y Initial program 72.0%
associate-+l-80.1%
sub-neg80.1%
log1p-def87.1%
neg-sub087.1%
associate-+l-87.1%
neg-sub087.1%
neg-mul-187.1%
*-commutative87.1%
distribute-rgt-out87.1%
+-commutative87.1%
metadata-eval87.1%
sub-neg87.1%
expm1-def98.0%
Simplified98.0%
clear-num97.9%
associate-/r/97.9%
Applied egg-rr97.9%
associate-/r/97.9%
Applied egg-rr97.9%
Taylor expanded in y around 0 86.3%
expm1-def94.8%
associate-/l/95.8%
*-commutative95.8%
Simplified95.8%
Final simplification90.9%
(FPCore (x y z t) :precision binary64 (if (<= y -3e+27) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (+ x (/ (* (expm1 z) (/ 1.0 t)) (/ -1.0 y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3e+27) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x + ((expm1(z) * (1.0 / t)) / (-1.0 / y));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3e+27) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x + ((Math.expm1(z) * (1.0 / t)) / (-1.0 / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3e+27: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x + ((math.expm1(z) * (1.0 / t)) / (-1.0 / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3e+27) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x + Float64(Float64(expm1(z) * Float64(1.0 / t)) / Float64(-1.0 / y))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3e+27], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(Exp[z] - 1), $MachinePrecision] * N[(1.0 / t), $MachinePrecision]), $MachinePrecision] / N[(-1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+27}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\mathsf{expm1}\left(z\right) \cdot \frac{1}{t}}{\frac{-1}{y}}\\
\end{array}
\end{array}
if y < -2.99999999999999976e27Initial program 43.6%
associate-+l-75.8%
sub-neg75.8%
log1p-def75.8%
neg-sub075.8%
associate-+l-75.8%
neg-sub075.8%
neg-mul-175.8%
*-commutative75.8%
distribute-rgt-out75.8%
+-commutative75.8%
metadata-eval75.8%
sub-neg75.8%
expm1-def99.8%
Simplified99.8%
clear-num99.7%
associate-/r/99.6%
Applied egg-rr99.6%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 59.8%
expm1-def75.9%
associate-/l/68.2%
*-commutative68.2%
Simplified68.2%
Taylor expanded in z around 0 75.9%
*-commutative75.9%
Simplified75.9%
if -2.99999999999999976e27 < y Initial program 71.4%
associate-+l-79.9%
sub-neg79.9%
log1p-def86.8%
neg-sub086.8%
associate-+l-86.8%
neg-sub086.8%
neg-mul-186.8%
*-commutative86.8%
distribute-rgt-out86.8%
+-commutative86.8%
metadata-eval86.8%
sub-neg86.8%
expm1-def98.0%
Simplified98.0%
Taylor expanded in y around 0 86.4%
associate-/l*85.8%
expm1-def95.3%
Simplified95.3%
*-un-lft-identity95.3%
div-inv95.3%
times-frac95.0%
Applied egg-rr95.0%
frac-2neg95.0%
associate-*r/95.7%
distribute-neg-frac95.7%
metadata-eval95.7%
Applied egg-rr95.7%
Final simplification90.7%
(FPCore (x y z t) :precision binary64 (if (<= y -1.4e+14) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (- x (/ (expm1 z) (/ t y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.4e+14) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (expm1(z) / (t / y));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.4e+14) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (Math.expm1(z) / (t / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.4e+14: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x - (math.expm1(z) / (t / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.4e+14) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x - Float64(expm1(z) / Float64(t / y))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.4e+14], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{+14}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{expm1}\left(z\right)}{\frac{t}{y}}\\
\end{array}
\end{array}
if y < -1.4e14Initial program 43.2%
associate-+l-75.4%
sub-neg75.4%
log1p-def75.4%
neg-sub075.4%
associate-+l-75.4%
neg-sub075.4%
neg-mul-175.4%
*-commutative75.4%
distribute-rgt-out75.4%
+-commutative75.4%
metadata-eval75.4%
sub-neg75.4%
expm1-def99.8%
Simplified99.8%
clear-num99.7%
associate-/r/99.6%
Applied egg-rr99.6%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 60.1%
expm1-def77.0%
associate-/l/69.4%
*-commutative69.4%
Simplified69.4%
Taylor expanded in z around 0 77.0%
*-commutative77.0%
Simplified77.0%
if -1.4e14 < y Initial program 72.0%
associate-+l-80.1%
sub-neg80.1%
log1p-def87.1%
neg-sub087.1%
associate-+l-87.1%
neg-sub087.1%
neg-mul-187.1%
*-commutative87.1%
distribute-rgt-out87.1%
+-commutative87.1%
metadata-eval87.1%
sub-neg87.1%
expm1-def98.0%
Simplified98.0%
Taylor expanded in y around 0 86.7%
associate-/l*86.1%
expm1-def95.3%
Simplified95.3%
Final simplification90.5%
(FPCore (x y z t) :precision binary64 (if (<= z 1.05e-297) (+ x (/ -1.0 (- (+ (* t 0.5) (/ t (* y z))) (* 0.5 (/ t y))))) (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 1.05e-297) {
tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y))));
} 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.05d-297) then
tmp = x + ((-1.0d0) / (((t * 0.5d0) + (t / (y * z))) - (0.5d0 * (t / y))))
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.05e-297) {
tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y))));
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 1.05e-297: tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y)))) else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 1.05e-297) tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))) - Float64(0.5 * Float64(t / y))))); 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.05e-297) tmp = x + (-1.0 / (((t * 0.5) + (t / (y * z))) - (0.5 * (t / y)))); else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 1.05e-297], N[(x + N[(-1.0 / N[(N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.05 \cdot 10^{-297}:\\
\;\;\;\;x + \frac{-1}{\left(t \cdot 0.5 + \frac{t}{y \cdot z}\right) - 0.5 \cdot \frac{t}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < 1.05000000000000007e-297Initial program 67.4%
associate-+l-79.6%
sub-neg79.6%
log1p-def87.3%
neg-sub087.3%
associate-+l-87.3%
neg-sub087.3%
neg-mul-187.3%
*-commutative87.3%
distribute-rgt-out87.3%
+-commutative87.3%
metadata-eval87.3%
sub-neg87.3%
expm1-def99.4%
Simplified99.4%
clear-num99.3%
associate-/r/99.3%
Applied egg-rr99.3%
associate-/r/99.3%
Applied egg-rr99.3%
Taylor expanded in y around 0 81.3%
expm1-def90.4%
associate-/l/89.7%
*-commutative89.7%
Simplified89.7%
Taylor expanded in z around 0 84.1%
if 1.05000000000000007e-297 < z Initial program 58.7%
associate-+l-77.4%
sub-neg77.4%
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-def96.6%
Simplified96.6%
Taylor expanded in z around 0 88.9%
associate-/l*91.5%
Simplified91.5%
Final simplification86.5%
(FPCore (x y z t) :precision binary64 (if (<= z -0.00185) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.00185) {
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 <= (-0.00185d0)) 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 <= -0.00185) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.00185: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.00185) 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 <= -0.00185) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.00185], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.00185:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -0.0018500000000000001Initial program 85.1%
associate-+l-85.1%
sub-neg85.1%
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 70.6%
if -0.0018500000000000001 < z Initial program 54.8%
associate-+l-75.9%
sub-neg75.9%
log1p-def76.6%
neg-sub076.6%
associate-+l-76.6%
neg-sub076.6%
neg-mul-176.6%
*-commutative76.6%
distribute-rgt-out76.6%
+-commutative76.6%
metadata-eval76.6%
sub-neg76.6%
expm1-def97.8%
Simplified97.8%
Taylor expanded in z around 0 90.3%
associate-/l*90.5%
associate-/r/85.4%
Simplified85.4%
Final simplification80.7%
(FPCore (x y z t) :precision binary64 (if (<= z -0.0032) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -0.0032) {
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 <= (-0.0032d0)) 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 <= -0.0032) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -0.0032: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -0.0032) 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 <= -0.0032) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -0.0032], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.0032:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -0.00320000000000000015Initial program 85.1%
associate-+l-85.1%
sub-neg85.1%
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 70.6%
if -0.00320000000000000015 < z Initial program 54.8%
associate-+l-75.9%
sub-neg75.9%
log1p-def76.6%
neg-sub076.6%
associate-+l-76.6%
neg-sub076.6%
neg-mul-176.6%
*-commutative76.6%
distribute-rgt-out76.6%
+-commutative76.6%
metadata-eval76.6%
sub-neg76.6%
expm1-def97.8%
Simplified97.8%
Taylor expanded in z around 0 90.3%
associate-/l*90.5%
associate-/r/85.4%
Simplified85.4%
*-commutative85.4%
clear-num85.4%
un-div-inv87.0%
Applied egg-rr87.0%
associate-/r/91.2%
Simplified91.2%
Final simplification84.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 64.5%
associate-+l-78.9%
sub-neg78.9%
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-def98.4%
Simplified98.4%
Taylor expanded in x around inf 73.6%
Final simplification73.6%
(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 2023230
(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)))