
(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 11 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 60.5%
sub-neg60.5%
associate-+l+74.0%
cancel-sign-sub74.0%
log1p-def79.8%
cancel-sign-sub79.8%
+-commutative79.8%
unsub-neg79.8%
*-rgt-identity79.8%
distribute-lft-out--79.8%
expm1-def97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (x y z t)
:precision binary64
(if (<= y -2.05e-22)
(+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z)))))
(if (<= y 8.2e+234)
(- x (/ y (/ t (expm1 z))))
(/ (- (log1p (* y (expm1 z)))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.05e-22) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else if (y <= 8.2e+234) {
tmp = x - (y / (t / expm1(z)));
} else {
tmp = -log1p((y * expm1(z))) / t;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.05e-22) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else if (y <= 8.2e+234) {
tmp = x - (y / (t / Math.expm1(z)));
} else {
tmp = -Math.log1p((y * Math.expm1(z))) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.05e-22: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) elif y <= 8.2e+234: tmp = x - (y / (t / math.expm1(z))) else: tmp = -math.log1p((y * math.expm1(z))) / t return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.05e-22) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); elseif (y <= 8.2e+234) tmp = Float64(x - Float64(y / Float64(t / expm1(z)))); else tmp = Float64(Float64(-log1p(Float64(y * expm1(z)))) / t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.05e-22], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.2e+234], N[(x - N[(y / N[(t / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{-22}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{+234}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\
\end{array}
\end{array}
if y < -2.05e-22Initial program 55.4%
sub-neg55.4%
associate-+l+80.0%
cancel-sign-sub80.0%
log1p-def80.0%
cancel-sign-sub80.0%
+-commutative80.0%
unsub-neg80.0%
*-rgt-identity80.0%
distribute-lft-out--79.9%
expm1-def99.8%
Simplified99.8%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 60.9%
Taylor expanded in z around 0 72.5%
*-commutative72.5%
Simplified72.5%
if -2.05e-22 < y < 8.19999999999999948e234Initial program 65.1%
sub-neg65.1%
associate-+l+74.3%
cancel-sign-sub74.3%
log1p-def82.6%
cancel-sign-sub82.6%
+-commutative82.6%
unsub-neg82.6%
*-rgt-identity82.6%
distribute-lft-out--82.6%
expm1-def97.0%
Simplified97.0%
clear-num96.9%
inv-pow96.9%
Applied egg-rr96.9%
unpow-196.9%
Applied egg-rr96.9%
add-cube-cbrt96.5%
pow396.5%
Applied egg-rr96.5%
Taylor expanded in y around 0 82.6%
expm1-def94.0%
associate-/l*96.4%
Simplified96.4%
if 8.19999999999999948e234 < y Initial program 1.2%
sub-neg1.2%
associate-+l+15.4%
cancel-sign-sub15.4%
log1p-def15.4%
cancel-sign-sub15.4%
+-commutative15.4%
unsub-neg15.4%
*-rgt-identity15.4%
distribute-lft-out--15.4%
expm1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 3.0%
associate-*r/3.0%
log1p-def3.0%
expm1-def82.8%
neg-mul-182.8%
Simplified82.8%
Final simplification89.6%
(FPCore (x y z t) :precision binary64 (if (<= z -2.4e-9) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y (+ (exp z) -1.0)))))) (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.4e-9) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (exp(z) + -1.0)))));
} 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 <= (-2.4d-9)) then
tmp = x + ((-1.0d0) / ((t * 0.5d0) + (t / (y * (exp(z) + (-1.0d0))))))
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 <= -2.4e-9) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (Math.exp(z) + -1.0)))));
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.4e-9: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (math.exp(z) + -1.0))))) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.4e-9) 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(y * Float64(z / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -2.4e-9) tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (exp(z) + -1.0))))); else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.4e-9], 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[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{-9}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \left(e^{z} + -1\right)}}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -2.4e-9Initial program 79.9%
sub-neg79.9%
associate-+l+79.9%
cancel-sign-sub79.9%
log1p-def99.3%
cancel-sign-sub99.3%
+-commutative99.3%
unsub-neg99.3%
*-rgt-identity99.3%
distribute-lft-out--99.3%
expm1-def99.9%
Simplified99.9%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 82.4%
if -2.4e-9 < z Initial program 52.1%
sub-neg52.1%
associate-+l+71.4%
cancel-sign-sub71.4%
log1p-def71.4%
cancel-sign-sub71.4%
+-commutative71.4%
unsub-neg71.4%
*-rgt-identity71.4%
distribute-lft-out--71.4%
expm1-def96.9%
Simplified96.9%
clear-num96.9%
inv-pow96.9%
Applied egg-rr96.9%
Taylor expanded in z around 0 88.4%
*-rgt-identity88.4%
*-commutative88.4%
times-frac90.4%
/-rgt-identity90.4%
Simplified90.4%
Final simplification88.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ t (* y z))))
(if (<= y -65000000000.0)
(+ x (/ -1.0 (+ (* t 0.5) t_1)))
(if (<= y 1.1e-49)
(- x (* (expm1 z) (/ y t)))
(+
x
(/
-1.0
(+
(* t 0.5)
(-
(+ (* (/ t y) -0.5) t_1)
(* z (+ (* -0.25 (/ t y)) (* (/ t y) 0.16666666666666666)))))))))))
double code(double x, double y, double z, double t) {
double t_1 = t / (y * z);
double tmp;
if (y <= -65000000000.0) {
tmp = x + (-1.0 / ((t * 0.5) + t_1));
} else if (y <= 1.1e-49) {
tmp = x - (expm1(z) * (y / t));
} else {
tmp = x + (-1.0 / ((t * 0.5) + ((((t / y) * -0.5) + t_1) - (z * ((-0.25 * (t / y)) + ((t / y) * 0.16666666666666666))))));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = t / (y * z);
double tmp;
if (y <= -65000000000.0) {
tmp = x + (-1.0 / ((t * 0.5) + t_1));
} else if (y <= 1.1e-49) {
tmp = x - (Math.expm1(z) * (y / t));
} else {
tmp = x + (-1.0 / ((t * 0.5) + ((((t / y) * -0.5) + t_1) - (z * ((-0.25 * (t / y)) + ((t / y) * 0.16666666666666666))))));
}
return tmp;
}
def code(x, y, z, t): t_1 = t / (y * z) tmp = 0 if y <= -65000000000.0: tmp = x + (-1.0 / ((t * 0.5) + t_1)) elif y <= 1.1e-49: tmp = x - (math.expm1(z) * (y / t)) else: tmp = x + (-1.0 / ((t * 0.5) + ((((t / y) * -0.5) + t_1) - (z * ((-0.25 * (t / y)) + ((t / y) * 0.16666666666666666)))))) return tmp
function code(x, y, z, t) t_1 = Float64(t / Float64(y * z)) tmp = 0.0 if (y <= -65000000000.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + t_1))); elseif (y <= 1.1e-49) tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(Float64(Float64(Float64(t / y) * -0.5) + t_1) - Float64(z * Float64(Float64(-0.25 * Float64(t / y)) + Float64(Float64(t / y) * 0.16666666666666666))))))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -65000000000.0], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e-49], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(N[(N[(N[(t / y), $MachinePrecision] * -0.5), $MachinePrecision] + t$95$1), $MachinePrecision] - N[(z * N[(N[(-0.25 * N[(t / y), $MachinePrecision]), $MachinePrecision] + N[(N[(t / y), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t}{y \cdot z}\\
\mathbf{if}\;y \leq -65000000000:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + t_1}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-49}:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \left(\left(\frac{t}{y} \cdot -0.5 + t_1\right) - z \cdot \left(-0.25 \cdot \frac{t}{y} + \frac{t}{y} \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if y < -6.5e10Initial program 55.0%
sub-neg55.0%
associate-+l+82.4%
cancel-sign-sub82.4%
log1p-def82.4%
cancel-sign-sub82.4%
+-commutative82.4%
unsub-neg82.4%
*-rgt-identity82.4%
distribute-lft-out--82.4%
expm1-def99.8%
Simplified99.8%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 61.1%
Taylor expanded in z around 0 69.4%
*-commutative69.4%
Simplified69.4%
if -6.5e10 < y < 1.09999999999999995e-49Initial program 78.5%
sub-neg78.5%
associate-+l+78.5%
cancel-sign-sub78.5%
log1p-def88.5%
cancel-sign-sub88.5%
+-commutative88.5%
unsub-neg88.5%
*-rgt-identity88.5%
distribute-lft-out--88.5%
expm1-def96.9%
Simplified96.9%
Taylor expanded in y around 0 88.5%
associate-/l*88.5%
associate-/r/88.5%
expm1-def100.0%
Simplified100.0%
if 1.09999999999999995e-49 < y Initial program 17.3%
sub-neg17.3%
associate-+l+51.5%
cancel-sign-sub51.5%
log1p-def52.8%
cancel-sign-sub52.8%
+-commutative52.8%
unsub-neg52.8%
*-rgt-identity52.8%
distribute-lft-out--52.9%
expm1-def98.0%
Simplified98.0%
clear-num97.8%
inv-pow97.8%
Applied egg-rr97.8%
unpow-197.8%
Applied egg-rr97.8%
Taylor expanded in y around 0 54.7%
Taylor expanded in z around 0 82.3%
Final simplification89.1%
(FPCore (x y z t) :precision binary64 (if (<= y -2.05e-22) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (- x (/ y (/ t (expm1 z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.05e-22) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (y / (t / expm1(z)));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -2.05e-22) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (y / (t / Math.expm1(z)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -2.05e-22: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x - (y / (t / math.expm1(z))) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -2.05e-22) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x - Float64(y / Float64(t / expm1(z)))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -2.05e-22], 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[(t / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{-22}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\end{array}
\end{array}
if y < -2.05e-22Initial program 55.4%
sub-neg55.4%
associate-+l+80.0%
cancel-sign-sub80.0%
log1p-def80.0%
cancel-sign-sub80.0%
+-commutative80.0%
unsub-neg80.0%
*-rgt-identity80.0%
distribute-lft-out--79.9%
expm1-def99.8%
Simplified99.8%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 60.9%
Taylor expanded in z around 0 72.5%
*-commutative72.5%
Simplified72.5%
if -2.05e-22 < y Initial program 62.3%
sub-neg62.3%
associate-+l+71.8%
cancel-sign-sub71.8%
log1p-def79.7%
cancel-sign-sub79.7%
+-commutative79.7%
unsub-neg79.7%
*-rgt-identity79.7%
distribute-lft-out--79.8%
expm1-def97.1%
Simplified97.1%
clear-num97.0%
inv-pow97.0%
Applied egg-rr97.0%
unpow-197.0%
Applied egg-rr97.0%
add-cube-cbrt96.5%
pow396.5%
Applied egg-rr96.5%
Taylor expanded in y around 0 79.8%
expm1-def91.8%
associate-/l*93.6%
Simplified93.6%
Final simplification88.0%
(FPCore (x y z t) :precision binary64 (if (<= z -1.36e-96) (+ x (/ -1.0 (+ (* t 0.5) (+ (* (/ t y) -0.5) (/ t (* y z)))))) (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.36e-96) {
tmp = x + (-1.0 / ((t * 0.5) + (((t / y) * -0.5) + (t / (y * z)))));
} 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 <= (-1.36d-96)) then
tmp = x + ((-1.0d0) / ((t * 0.5d0) + (((t / y) * (-0.5d0)) + (t / (y * z)))))
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 <= -1.36e-96) {
tmp = x + (-1.0 / ((t * 0.5) + (((t / y) * -0.5) + (t / (y * z)))));
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.36e-96: tmp = x + (-1.0 / ((t * 0.5) + (((t / y) * -0.5) + (t / (y * z))))) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.36e-96) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(Float64(Float64(t / y) * -0.5) + Float64(t / Float64(y * z)))))); 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 <= -1.36e-96) tmp = x + (-1.0 / ((t * 0.5) + (((t / y) * -0.5) + (t / (y * z))))); else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.36e-96], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(N[(N[(t / y), $MachinePrecision] * -0.5), $MachinePrecision] + N[(t / N[(y * z), $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 -1.36 \cdot 10^{-96}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \left(\frac{t}{y} \cdot -0.5 + \frac{t}{y \cdot z}\right)}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -1.36e-96Initial program 75.3%
sub-neg75.3%
associate-+l+77.3%
cancel-sign-sub77.3%
log1p-def92.6%
cancel-sign-sub92.6%
+-commutative92.6%
unsub-neg92.6%
*-rgt-identity92.6%
distribute-lft-out--92.6%
expm1-def99.9%
Simplified99.9%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 79.3%
Taylor expanded in z around 0 71.2%
if -1.36e-96 < z Initial program 51.3%
sub-neg51.3%
associate-+l+71.9%
cancel-sign-sub71.9%
log1p-def71.9%
cancel-sign-sub71.9%
+-commutative71.9%
unsub-neg71.9%
*-rgt-identity71.9%
distribute-lft-out--71.9%
expm1-def96.5%
Simplified96.5%
clear-num96.5%
inv-pow96.5%
Applied egg-rr96.5%
Taylor expanded in z around 0 88.7%
*-rgt-identity88.7%
*-commutative88.7%
times-frac90.9%
/-rgt-identity90.9%
Simplified90.9%
Final simplification83.4%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t * 0.5) + (t / (y * z))));
}
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 + ((-1.0d0) / ((t * 0.5d0) + (t / (y * z))))
end function
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t * 0.5) + (t / (y * z))));
}
def code(x, y, z, t): return x + (-1.0 / ((t * 0.5) + (t / (y * z))))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))) end
function tmp = code(x, y, z, t) tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))); end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}
\end{array}
Initial program 60.5%
sub-neg60.5%
associate-+l+74.0%
cancel-sign-sub74.0%
log1p-def79.8%
cancel-sign-sub79.8%
+-commutative79.8%
unsub-neg79.8%
*-rgt-identity79.8%
distribute-lft-out--79.8%
expm1-def97.8%
Simplified97.8%
clear-num97.8%
inv-pow97.7%
Applied egg-rr97.7%
unpow-197.8%
Applied egg-rr97.8%
Taylor expanded in y around 0 75.1%
Taylor expanded in z around 0 80.1%
*-commutative80.1%
Simplified80.1%
Final simplification80.1%
(FPCore (x y z t) :precision binary64 (if (<= t -1.15e-227) x (if (<= t 1.25e-213) (* (/ z t) (- y)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.15e-227) {
tmp = x;
} else if (t <= 1.25e-213) {
tmp = (z / t) * -y;
} 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 (t <= (-1.15d-227)) then
tmp = x
else if (t <= 1.25d-213) then
tmp = (z / t) * -y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.15e-227) {
tmp = x;
} else if (t <= 1.25e-213) {
tmp = (z / t) * -y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.15e-227: tmp = x elif t <= 1.25e-213: tmp = (z / t) * -y else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.15e-227) tmp = x; elseif (t <= 1.25e-213) tmp = Float64(Float64(z / t) * Float64(-y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.15e-227) tmp = x; elseif (t <= 1.25e-213) tmp = (z / t) * -y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.15e-227], x, If[LessEqual[t, 1.25e-213], N[(N[(z / t), $MachinePrecision] * (-y)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.15 \cdot 10^{-227}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 1.25 \cdot 10^{-213}:\\
\;\;\;\;\frac{z}{t} \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.15000000000000006e-227 or 1.24999999999999994e-213 < t Initial program 64.7%
sub-neg64.7%
associate-+l+80.4%
cancel-sign-sub80.4%
log1p-def84.1%
cancel-sign-sub84.1%
+-commutative84.1%
unsub-neg84.1%
*-rgt-identity84.1%
distribute-lft-out--84.1%
expm1-def97.9%
Simplified97.9%
Taylor expanded in x around inf 77.7%
if -1.15000000000000006e-227 < t < 1.24999999999999994e-213Initial program 35.0%
sub-neg35.0%
associate-+l+35.0%
cancel-sign-sub35.0%
log1p-def53.7%
cancel-sign-sub53.7%
+-commutative53.7%
unsub-neg53.7%
*-rgt-identity53.7%
distribute-lft-out--53.6%
expm1-def97.1%
Simplified97.1%
Taylor expanded in y around 0 33.3%
Taylor expanded in x around 0 22.4%
Taylor expanded in z around 0 40.5%
mul-1-neg40.5%
distribute-frac-neg40.5%
Simplified40.5%
Final simplification72.4%
(FPCore (x y z t) :precision binary64 (if (<= z -27000000000.0) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -27000000000.0) {
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 <= (-27000000000.0d0)) 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 <= -27000000000.0) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -27000000000.0: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -27000000000.0) 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 <= -27000000000.0) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -27000000000.0], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -27000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -2.7e10Initial program 83.3%
sub-neg83.3%
associate-+l+83.3%
cancel-sign-sub83.3%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 64.5%
if -2.7e10 < z Initial program 52.1%
sub-neg52.1%
associate-+l+70.5%
cancel-sign-sub70.5%
log1p-def72.4%
cancel-sign-sub72.4%
+-commutative72.4%
unsub-neg72.4%
*-rgt-identity72.4%
distribute-lft-out--72.4%
expm1-def97.0%
Simplified97.0%
Taylor expanded in z around 0 86.0%
associate-/l*87.9%
associate-/r/84.6%
Simplified84.6%
Final simplification79.2%
(FPCore (x y z t) :precision binary64 (if (<= z -27000000000.0) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -27000000000.0) {
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 <= (-27000000000.0d0)) 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 <= -27000000000.0) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -27000000000.0: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -27000000000.0) 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 <= -27000000000.0) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -27000000000.0], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -27000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -2.7e10Initial program 83.3%
sub-neg83.3%
associate-+l+83.3%
cancel-sign-sub83.3%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 64.5%
if -2.7e10 < z Initial program 52.1%
sub-neg52.1%
associate-+l+70.5%
cancel-sign-sub70.5%
log1p-def72.4%
cancel-sign-sub72.4%
+-commutative72.4%
unsub-neg72.4%
*-rgt-identity72.4%
distribute-lft-out--72.4%
expm1-def97.0%
Simplified97.0%
clear-num97.0%
inv-pow97.0%
Applied egg-rr97.0%
Taylor expanded in z around 0 86.0%
*-rgt-identity86.0%
*-commutative86.0%
times-frac87.9%
/-rgt-identity87.9%
Simplified87.9%
Final simplification81.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 60.5%
sub-neg60.5%
associate-+l+74.0%
cancel-sign-sub74.0%
log1p-def79.8%
cancel-sign-sub79.8%
+-commutative79.8%
unsub-neg79.8%
*-rgt-identity79.8%
distribute-lft-out--79.8%
expm1-def97.8%
Simplified97.8%
Taylor expanded in x around inf 68.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 2023308
(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)))