
(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 56.0%
sub-neg56.0%
associate-+l+71.5%
cancel-sign-sub71.5%
log1p-def78.3%
cancel-sign-sub78.3%
+-commutative78.3%
unsub-neg78.3%
*-rgt-identity78.3%
distribute-lft-out--78.4%
expm1-def96.9%
Simplified96.9%
Final simplification96.9%
(FPCore (x y z t) :precision binary64 (if (<= (exp z) 0.9996) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y (+ (exp z) -1.0)))))) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 0.9996) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (exp(z) + -1.0)))));
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.exp(z) <= 0.9996) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (Math.exp(z) + -1.0)))));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.exp(z) <= 0.9996: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (math.exp(z) + -1.0))))) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 0.9996) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * Float64(exp(z) + -1.0)))))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 0.9996], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * N[(N[Exp[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $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}\;e^{z} \leq 0.9996:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \left(e^{z} + -1\right)}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if (exp.f64 z) < 0.99960000000000004Initial program 79.2%
sub-neg79.2%
associate-+l+79.2%
cancel-sign-sub79.2%
log1p-def99.7%
cancel-sign-sub99.7%
+-commutative99.7%
unsub-neg99.7%
*-rgt-identity99.7%
distribute-lft-out--99.8%
expm1-def99.9%
Simplified99.9%
clear-num99.8%
associate-/r/99.8%
Applied egg-rr99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 83.4%
if 0.99960000000000004 < (exp.f64 z) Initial program 45.6%
sub-neg45.6%
associate-+l+68.1%
cancel-sign-sub68.1%
log1p-def68.8%
cancel-sign-sub68.8%
+-commutative68.8%
unsub-neg68.8%
*-rgt-identity68.8%
distribute-lft-out--68.8%
expm1-def95.5%
Simplified95.5%
Taylor expanded in z around 0 94.7%
Final simplification91.2%
(FPCore (x y z t) :precision binary64 (if (or (<= y -16000000000.0) (not (<= y 4.5e+37))) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (- x (* (expm1 z) (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -16000000000.0) || !(y <= 4.5e+37)) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (expm1(z) * (y / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -16000000000.0) || !(y <= 4.5e+37)) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (Math.expm1(z) * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -16000000000.0) or not (y <= 4.5e+37): tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x - (math.expm1(z) * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -16000000000.0) || !(y <= 4.5e+37)) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -16000000000.0], N[Not[LessEqual[y, 4.5e+37]], $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[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -16000000000 \lor \neg \left(y \leq 4.5 \cdot 10^{+37}\right):\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\end{array}
\end{array}
if y < -1.6e10 or 4.49999999999999962e37 < y Initial program 34.5%
sub-neg34.5%
associate-+l+67.8%
cancel-sign-sub67.8%
log1p-def67.8%
cancel-sign-sub67.8%
+-commutative67.8%
unsub-neg67.8%
*-rgt-identity67.8%
distribute-lft-out--67.8%
expm1-def99.9%
Simplified99.9%
clear-num99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 82.4%
associate-*l/82.5%
associate-/l*82.4%
Applied egg-rr82.4%
Taylor expanded in y around 0 71.8%
if -1.6e10 < y < 4.49999999999999962e37Initial program 71.7%
sub-neg71.7%
associate-+l+74.3%
cancel-sign-sub74.3%
log1p-def86.0%
cancel-sign-sub86.0%
+-commutative86.0%
unsub-neg86.0%
*-rgt-identity86.0%
distribute-lft-out--86.1%
expm1-def94.7%
Simplified94.7%
Taylor expanded in y around 0 85.7%
associate-/l*85.7%
associate-/r/85.7%
expm1-def99.5%
Simplified99.5%
Final simplification87.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -16000000000.0) (not (<= y 0.0185))) (- x (/ (log1p (* y z)) t)) (- x (* (expm1 z) (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -16000000000.0) || !(y <= 0.0185)) {
tmp = x - (log1p((y * z)) / t);
} else {
tmp = x - (expm1(z) * (y / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -16000000000.0) || !(y <= 0.0185)) {
tmp = x - (Math.log1p((y * z)) / t);
} else {
tmp = x - (Math.expm1(z) * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -16000000000.0) or not (y <= 0.0185): tmp = x - (math.log1p((y * z)) / t) else: tmp = x - (math.expm1(z) * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -16000000000.0) || !(y <= 0.0185)) tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); else tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -16000000000.0], N[Not[LessEqual[y, 0.0185]], $MachinePrecision]], N[(x - N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -16000000000 \lor \neg \left(y \leq 0.0185\right):\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\end{array}
\end{array}
if y < -1.6e10 or 0.0184999999999999991 < y Initial program 35.4%
sub-neg35.4%
associate-+l+68.6%
cancel-sign-sub68.6%
log1p-def68.6%
cancel-sign-sub68.6%
+-commutative68.6%
unsub-neg68.6%
*-rgt-identity68.6%
distribute-lft-out--68.6%
expm1-def99.9%
Simplified99.9%
Taylor expanded in z around 0 84.2%
if -1.6e10 < y < 0.0184999999999999991Initial program 74.2%
sub-neg74.2%
associate-+l+74.2%
cancel-sign-sub74.2%
log1p-def86.9%
cancel-sign-sub86.9%
+-commutative86.9%
unsub-neg86.9%
*-rgt-identity86.9%
distribute-lft-out--87.0%
expm1-def94.2%
Simplified94.2%
Taylor expanded in y around 0 86.7%
associate-/l*86.7%
associate-/r/86.7%
expm1-def99.5%
Simplified99.5%
Final simplification92.3%
(FPCore (x y z t) :precision binary64 (if (<= y -16000000000.0) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (if (<= y 3e+179) (- x (* (expm1 z) (/ y t))) (- x (/ (log (* y z)) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -16000000000.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else if (y <= 3e+179) {
tmp = x - (expm1(z) * (y / t));
} else {
tmp = x - (log((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -16000000000.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else if (y <= 3e+179) {
tmp = x - (Math.expm1(z) * (y / t));
} else {
tmp = x - (Math.log((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -16000000000.0: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) elif y <= 3e+179: tmp = x - (math.expm1(z) * (y / t)) else: tmp = x - (math.log((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -16000000000.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); elseif (y <= 3e+179) tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); else tmp = Float64(x - Float64(log(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -16000000000.0], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3e+179], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -16000000000:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+179}:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\log \left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if y < -1.6e10Initial program 48.6%
sub-neg48.6%
associate-+l+70.2%
cancel-sign-sub70.2%
log1p-def70.2%
cancel-sign-sub70.2%
+-commutative70.2%
unsub-neg70.2%
*-rgt-identity70.2%
distribute-lft-out--70.2%
expm1-def99.8%
Simplified99.8%
clear-num99.7%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 73.1%
associate-*l/73.1%
associate-/l*73.1%
Applied egg-rr73.1%
Taylor expanded in y around 0 64.5%
if -1.6e10 < y < 2.9999999999999998e179Initial program 63.1%
sub-neg63.1%
associate-+l+71.8%
cancel-sign-sub71.8%
log1p-def82.0%
cancel-sign-sub82.0%
+-commutative82.0%
unsub-neg82.0%
*-rgt-identity82.0%
distribute-lft-out--82.1%
expm1-def95.3%
Simplified95.3%
Taylor expanded in y around 0 81.8%
associate-/l*81.8%
associate-/r/81.7%
expm1-def96.9%
Simplified96.9%
if 2.9999999999999998e179 < y Initial program 16.7%
sub-neg16.7%
associate-+l+74.6%
cancel-sign-sub74.6%
log1p-def74.6%
cancel-sign-sub74.6%
+-commutative74.6%
unsub-neg74.6%
*-rgt-identity74.6%
distribute-lft-out--74.5%
expm1-def100.0%
Simplified100.0%
clear-num99.9%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 97.9%
Taylor expanded in y around inf 92.4%
mul-1-neg92.4%
log-rec92.4%
remove-double-neg92.4%
log-prod92.4%
*-commutative92.4%
Simplified92.4%
Final simplification87.9%
(FPCore (x y z t) :precision binary64 (if (or (<= y -5.5e-67) (not (<= y 1.1e-81))) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (- x (/ (/ y t) (/ 1.0 z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -5.5e-67) || !(y <= 1.1e-81)) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - ((y / t) / (1.0 / 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 ((y <= (-5.5d-67)) .or. (.not. (y <= 1.1d-81))) then
tmp = x + ((-1.0d0) / ((t * 0.5d0) + (t / (y * z))))
else
tmp = x - ((y / t) / (1.0d0 / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -5.5e-67) || !(y <= 1.1e-81)) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - ((y / t) / (1.0 / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -5.5e-67) or not (y <= 1.1e-81): tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x - ((y / t) / (1.0 / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -5.5e-67) || !(y <= 1.1e-81)) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x - Float64(Float64(y / t) / Float64(1.0 / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -5.5e-67) || ~((y <= 1.1e-81))) tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))); else tmp = x - ((y / t) / (1.0 / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -5.5e-67], N[Not[LessEqual[y, 1.1e-81]], $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[(N[(y / t), $MachinePrecision] / N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{-67} \lor \neg \left(y \leq 1.1 \cdot 10^{-81}\right):\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\frac{y}{t}}{\frac{1}{z}}\\
\end{array}
\end{array}
if y < -5.5000000000000003e-67 or 1.1e-81 < y Initial program 43.5%
sub-neg43.5%
associate-+l+68.7%
cancel-sign-sub68.7%
log1p-def72.5%
cancel-sign-sub72.5%
+-commutative72.5%
unsub-neg72.5%
*-rgt-identity72.5%
distribute-lft-out--72.6%
expm1-def99.9%
Simplified99.9%
clear-num99.7%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 81.9%
associate-*l/82.0%
associate-/l*82.0%
Applied egg-rr82.0%
Taylor expanded in y around 0 76.1%
if -5.5000000000000003e-67 < y < 1.1e-81Initial program 76.1%
sub-neg76.1%
associate-+l+76.1%
cancel-sign-sub76.1%
log1p-def87.6%
cancel-sign-sub87.6%
+-commutative87.6%
unsub-neg87.6%
*-rgt-identity87.6%
distribute-lft-out--87.7%
expm1-def92.0%
Simplified92.0%
Taylor expanded in z around 0 73.1%
associate-/l*81.0%
Simplified81.0%
associate-/r/82.9%
Applied egg-rr82.9%
clear-num82.9%
associate-/r/82.9%
div-inv82.9%
associate-/r*82.9%
clear-num82.9%
Applied egg-rr82.9%
Final simplification78.7%
(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.0%
sub-neg56.0%
associate-+l+71.5%
cancel-sign-sub71.5%
log1p-def78.3%
cancel-sign-sub78.3%
+-commutative78.3%
unsub-neg78.3%
*-rgt-identity78.3%
distribute-lft-out--78.4%
expm1-def96.9%
Simplified96.9%
Taylor expanded in z around 0 66.0%
associate-/l*68.3%
Simplified68.3%
associate-/r/68.6%
Applied egg-rr68.6%
Final simplification68.6%
(FPCore (x y z t) :precision binary64 (- x (/ z (/ t y))))
double code(double x, double y, double z, double t) {
return x - (z / (t / y));
}
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 / (t / y))
end function
public static double code(double x, double y, double z, double t) {
return x - (z / (t / y));
}
def code(x, y, z, t): return x - (z / (t / y))
function code(x, y, z, t) return Float64(x - Float64(z / Float64(t / y))) end
function tmp = code(x, y, z, t) tmp = x - (z / (t / y)); end
code[x_, y_, z_, t_] := N[(x - N[(z / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{z}{\frac{t}{y}}
\end{array}
Initial program 56.0%
sub-neg56.0%
associate-+l+71.5%
cancel-sign-sub71.5%
log1p-def78.3%
cancel-sign-sub78.3%
+-commutative78.3%
unsub-neg78.3%
*-rgt-identity78.3%
distribute-lft-out--78.4%
expm1-def96.9%
Simplified96.9%
Taylor expanded in z around 0 66.0%
associate-/l*68.3%
Simplified68.3%
associate-/r/68.6%
Applied egg-rr68.6%
*-commutative68.6%
clear-num68.6%
div-inv68.6%
Applied egg-rr68.6%
Final simplification68.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 2024010
(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)))