
(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 52.6%
sub-neg52.6%
associate-+l+73.3%
cancel-sign-sub73.3%
log1p-def81.3%
cancel-sign-sub81.3%
+-commutative81.3%
unsub-neg81.3%
*-rgt-identity81.3%
distribute-lft-out--81.3%
expm1-def98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (expm1 z))))
(if (<= y -1.35e+235)
(/ (- (log1p t_1)) t)
(+ x (/ -1.0 (+ (* t 0.5) (/ t t_1)))))))
double code(double x, double y, double z, double t) {
double t_1 = y * expm1(z);
double tmp;
if (y <= -1.35e+235) {
tmp = -log1p(t_1) / t;
} else {
tmp = x + (-1.0 / ((t * 0.5) + (t / t_1)));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = y * Math.expm1(z);
double tmp;
if (y <= -1.35e+235) {
tmp = -Math.log1p(t_1) / t;
} else {
tmp = x + (-1.0 / ((t * 0.5) + (t / t_1)));
}
return tmp;
}
def code(x, y, z, t): t_1 = y * math.expm1(z) tmp = 0 if y <= -1.35e+235: tmp = -math.log1p(t_1) / t else: tmp = x + (-1.0 / ((t * 0.5) + (t / t_1))) return tmp
function code(x, y, z, t) t_1 = Float64(y * expm1(z)) tmp = 0.0 if (y <= -1.35e+235) tmp = Float64(Float64(-log1p(t_1)) / t); else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / t_1)))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.35e+235], N[((-N[Log[1 + t$95$1], $MachinePrecision]) / t), $MachinePrecision], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot \mathsf{expm1}\left(z\right)\\
\mathbf{if}\;y \leq -1.35 \cdot 10^{+235}:\\
\;\;\;\;\frac{-\mathsf{log1p}\left(t_1\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{t_1}}\\
\end{array}
\end{array}
if y < -1.3499999999999999e235Initial program 47.5%
sub-neg47.5%
associate-+l+65.8%
cancel-sign-sub65.8%
log1p-def65.8%
cancel-sign-sub65.8%
+-commutative65.8%
unsub-neg65.8%
*-rgt-identity65.8%
distribute-lft-out--65.8%
expm1-def99.8%
Simplified99.8%
Taylor expanded in x around 0 37.9%
associate-*r/37.9%
log1p-def37.9%
expm1-def72.4%
neg-mul-172.4%
Simplified72.4%
if -1.3499999999999999e235 < y Initial program 53.0%
sub-neg53.0%
associate-+l+73.8%
cancel-sign-sub73.8%
log1p-def82.4%
cancel-sign-sub82.4%
+-commutative82.4%
unsub-neg82.4%
*-rgt-identity82.4%
distribute-lft-out--82.4%
expm1-def98.5%
Simplified98.5%
clear-num98.4%
inv-pow98.4%
Applied egg-rr98.4%
unpow-198.4%
Applied egg-rr98.4%
Taylor expanded in y around 0 80.1%
sub-neg80.1%
metadata-eval80.1%
Applied egg-rr80.1%
metadata-eval80.1%
sub-neg80.1%
expm1-def93.4%
Simplified93.4%
Final simplification92.0%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y (expm1 z)))))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t * 0.5) + (t / (y * expm1(z)))));
}
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t * 0.5) + (t / (y * Math.expm1(z)))));
}
def code(x, y, z, t): return x + (-1.0 / ((t * 0.5) + (t / (y * math.expm1(z)))))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * expm1(z)))))) end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \mathsf{expm1}\left(z\right)}}
\end{array}
Initial program 52.6%
sub-neg52.6%
associate-+l+73.3%
cancel-sign-sub73.3%
log1p-def81.3%
cancel-sign-sub81.3%
+-commutative81.3%
unsub-neg81.3%
*-rgt-identity81.3%
distribute-lft-out--81.3%
expm1-def98.5%
Simplified98.5%
clear-num98.4%
inv-pow98.4%
Applied egg-rr98.4%
unpow-198.4%
Applied egg-rr98.4%
Taylor expanded in y around 0 77.0%
sub-neg77.0%
metadata-eval77.0%
Applied egg-rr77.0%
metadata-eval77.0%
sub-neg77.0%
expm1-def89.6%
Simplified89.6%
Final simplification89.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ t (* y z))))
(if (<= y -23000000000.0)
(+ x (/ -1.0 (+ (* t 0.5) t_1)))
(if (<= y 7e-15)
(- x (/ y (/ t (expm1 z))))
(+
x
(/
-1.0
(+
(* t 0.5)
(-
(+ t_1 (* (/ t y) -0.5))
(* 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 <= -23000000000.0) {
tmp = x + (-1.0 / ((t * 0.5) + t_1));
} else if (y <= 7e-15) {
tmp = x - (y / (t / expm1(z)));
} else {
tmp = x + (-1.0 / ((t * 0.5) + ((t_1 + ((t / y) * -0.5)) - (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 <= -23000000000.0) {
tmp = x + (-1.0 / ((t * 0.5) + t_1));
} else if (y <= 7e-15) {
tmp = x - (y / (t / Math.expm1(z)));
} else {
tmp = x + (-1.0 / ((t * 0.5) + ((t_1 + ((t / y) * -0.5)) - (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 <= -23000000000.0: tmp = x + (-1.0 / ((t * 0.5) + t_1)) elif y <= 7e-15: tmp = x - (y / (t / math.expm1(z))) else: tmp = x + (-1.0 / ((t * 0.5) + ((t_1 + ((t / y) * -0.5)) - (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 <= -23000000000.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + t_1))); elseif (y <= 7e-15) tmp = Float64(x - Float64(y / Float64(t / expm1(z)))); else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(Float64(t_1 + Float64(Float64(t / y) * -0.5)) - 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, -23000000000.0], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e-15], N[(x - N[(y / N[(t / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(N[(t$95$1 + N[(N[(t / y), $MachinePrecision] * -0.5), $MachinePrecision]), $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 -23000000000:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + t_1}\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-15}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \left(\left(t_1 + \frac{t}{y} \cdot -0.5\right) - z \cdot \left(-0.25 \cdot \frac{t}{y} + \frac{t}{y} \cdot 0.16666666666666666\right)\right)}\\
\end{array}
\end{array}
if y < -2.3e10Initial program 35.7%
sub-neg35.7%
associate-+l+78.2%
cancel-sign-sub78.2%
log1p-def78.2%
cancel-sign-sub78.2%
+-commutative78.2%
unsub-neg78.2%
*-rgt-identity78.2%
distribute-lft-out--78.2%
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 62.2%
Taylor expanded in z around 0 74.8%
*-commutative74.8%
Simplified74.8%
if -2.3e10 < y < 7.0000000000000001e-15Initial program 73.8%
sub-neg73.8%
associate-+l+74.5%
cancel-sign-sub74.5%
log1p-def88.4%
cancel-sign-sub88.4%
+-commutative88.4%
unsub-neg88.4%
*-rgt-identity88.4%
distribute-lft-out--88.4%
expm1-def98.2%
Simplified98.2%
Taylor expanded in y around 0 88.2%
associate-/l*88.2%
expm1-def99.8%
Simplified99.8%
if 7.0000000000000001e-15 < y Initial program 3.8%
sub-neg3.8%
associate-+l+60.9%
cancel-sign-sub60.9%
log1p-def60.9%
cancel-sign-sub60.9%
+-commutative60.9%
unsub-neg60.9%
*-rgt-identity60.9%
distribute-lft-out--60.9%
expm1-def97.5%
Simplified97.5%
clear-num97.3%
inv-pow97.3%
Applied egg-rr97.3%
unpow-197.3%
Applied egg-rr97.3%
Taylor expanded in y around 0 60.3%
Taylor expanded in z around 0 83.3%
Final simplification90.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ t (* y z))))
(if (<= z -6.2e+37)
(+ x (/ -1.0 (+ (* t 0.5) (+ t_1 (* (/ t y) -0.5)))))
(if (<= z -130000000000.0)
(/ (- y) (/ t (expm1 z)))
(+ x (/ -1.0 (+ (* t 0.5) t_1)))))))
double code(double x, double y, double z, double t) {
double t_1 = t / (y * z);
double tmp;
if (z <= -6.2e+37) {
tmp = x + (-1.0 / ((t * 0.5) + (t_1 + ((t / y) * -0.5))));
} else if (z <= -130000000000.0) {
tmp = -y / (t / expm1(z));
} else {
tmp = x + (-1.0 / ((t * 0.5) + t_1));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = t / (y * z);
double tmp;
if (z <= -6.2e+37) {
tmp = x + (-1.0 / ((t * 0.5) + (t_1 + ((t / y) * -0.5))));
} else if (z <= -130000000000.0) {
tmp = -y / (t / Math.expm1(z));
} else {
tmp = x + (-1.0 / ((t * 0.5) + t_1));
}
return tmp;
}
def code(x, y, z, t): t_1 = t / (y * z) tmp = 0 if z <= -6.2e+37: tmp = x + (-1.0 / ((t * 0.5) + (t_1 + ((t / y) * -0.5)))) elif z <= -130000000000.0: tmp = -y / (t / math.expm1(z)) else: tmp = x + (-1.0 / ((t * 0.5) + t_1)) return tmp
function code(x, y, z, t) t_1 = Float64(t / Float64(y * z)) tmp = 0.0 if (z <= -6.2e+37) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t_1 + Float64(Float64(t / y) * -0.5))))); elseif (z <= -130000000000.0) tmp = Float64(Float64(-y) / Float64(t / expm1(z))); else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + t_1))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.2e+37], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t$95$1 + N[(N[(t / y), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -130000000000.0], N[((-y) / N[(t / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t}{y \cdot z}\\
\mathbf{if}\;z \leq -6.2 \cdot 10^{+37}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \left(t_1 + \frac{t}{y} \cdot -0.5\right)}\\
\mathbf{elif}\;z \leq -130000000000:\\
\;\;\;\;\frac{-y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + t_1}\\
\end{array}
\end{array}
if z < -6.2000000000000004e37Initial program 75.8%
sub-neg75.8%
associate-+l+75.8%
cancel-sign-sub75.8%
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%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 79.5%
Taylor expanded in z around 0 58.4%
if -6.2000000000000004e37 < z < -1.3e11Initial program 3.4%
sub-neg3.4%
associate-+l+3.4%
cancel-sign-sub3.4%
log1p-def100.0%
cancel-sign-sub100.0%
+-commutative100.0%
unsub-neg100.0%
*-rgt-identity100.0%
distribute-lft-out--100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
expm1-def100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
associate-/l*100.0%
expm1-def100.0%
distribute-frac-neg100.0%
Simplified100.0%
if -1.3e11 < z Initial program 47.6%
sub-neg47.6%
associate-+l+74.4%
cancel-sign-sub74.4%
log1p-def75.9%
cancel-sign-sub75.9%
+-commutative75.9%
unsub-neg75.9%
*-rgt-identity75.9%
distribute-lft-out--75.9%
expm1-def98.1%
Simplified98.1%
clear-num98.1%
inv-pow98.1%
Applied egg-rr98.1%
unpow-198.1%
Applied egg-rr98.1%
Taylor expanded in y around 0 75.8%
Taylor expanded in z around 0 91.0%
*-commutative91.0%
Simplified91.0%
Final simplification84.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ t (* y z))))
(if (<= y 7.5e-230)
(+ x (/ -1.0 (+ (* t 0.5) t_1)))
(+ x (/ -1.0 (+ (* t 0.5) (+ t_1 (* (/ t y) -0.5))))))))
double code(double x, double y, double z, double t) {
double t_1 = t / (y * z);
double tmp;
if (y <= 7.5e-230) {
tmp = x + (-1.0 / ((t * 0.5) + t_1));
} else {
tmp = x + (-1.0 / ((t * 0.5) + (t_1 + ((t / y) * -0.5))));
}
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 = t / (y * z)
if (y <= 7.5d-230) then
tmp = x + ((-1.0d0) / ((t * 0.5d0) + t_1))
else
tmp = x + ((-1.0d0) / ((t * 0.5d0) + (t_1 + ((t / y) * (-0.5d0)))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = t / (y * z);
double tmp;
if (y <= 7.5e-230) {
tmp = x + (-1.0 / ((t * 0.5) + t_1));
} else {
tmp = x + (-1.0 / ((t * 0.5) + (t_1 + ((t / y) * -0.5))));
}
return tmp;
}
def code(x, y, z, t): t_1 = t / (y * z) tmp = 0 if y <= 7.5e-230: tmp = x + (-1.0 / ((t * 0.5) + t_1)) else: tmp = x + (-1.0 / ((t * 0.5) + (t_1 + ((t / y) * -0.5)))) return tmp
function code(x, y, z, t) t_1 = Float64(t / Float64(y * z)) tmp = 0.0 if (y <= 7.5e-230) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + t_1))); else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t_1 + Float64(Float64(t / y) * -0.5))))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = t / (y * z); tmp = 0.0; if (y <= 7.5e-230) tmp = x + (-1.0 / ((t * 0.5) + t_1)); else tmp = x + (-1.0 / ((t * 0.5) + (t_1 + ((t / y) * -0.5)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 7.5e-230], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t$95$1 + N[(N[(t / y), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t}{y \cdot z}\\
\mathbf{if}\;y \leq 7.5 \cdot 10^{-230}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + t_1}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \left(t_1 + \frac{t}{y} \cdot -0.5\right)}\\
\end{array}
\end{array}
if y < 7.50000000000000006e-230Initial program 62.5%
sub-neg62.5%
associate-+l+79.6%
cancel-sign-sub79.6%
log1p-def86.3%
cancel-sign-sub86.3%
+-commutative86.3%
unsub-neg86.3%
*-rgt-identity86.3%
distribute-lft-out--86.3%
expm1-def99.5%
Simplified99.5%
clear-num99.5%
inv-pow99.5%
Applied egg-rr99.5%
unpow-199.5%
Applied egg-rr99.5%
Taylor expanded in y around 0 80.0%
Taylor expanded in z around 0 82.5%
*-commutative82.5%
Simplified82.5%
if 7.50000000000000006e-230 < y Initial program 32.3%
sub-neg32.3%
associate-+l+60.3%
cancel-sign-sub60.3%
log1p-def71.2%
cancel-sign-sub71.2%
+-commutative71.2%
unsub-neg71.2%
*-rgt-identity71.2%
distribute-lft-out--71.2%
expm1-def96.5%
Simplified96.5%
clear-num96.4%
inv-pow96.4%
Applied egg-rr96.4%
unpow-196.4%
Applied egg-rr96.4%
Taylor expanded in y around 0 70.8%
Taylor expanded in z around 0 81.3%
Final simplification82.1%
(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 52.6%
sub-neg52.6%
associate-+l+73.3%
cancel-sign-sub73.3%
log1p-def81.3%
cancel-sign-sub81.3%
+-commutative81.3%
unsub-neg81.3%
*-rgt-identity81.3%
distribute-lft-out--81.3%
expm1-def98.5%
Simplified98.5%
clear-num98.4%
inv-pow98.4%
Applied egg-rr98.4%
unpow-198.4%
Applied egg-rr98.4%
Taylor expanded in y around 0 77.0%
Taylor expanded in z around 0 80.3%
*-commutative80.3%
Simplified80.3%
Final simplification80.3%
(FPCore (x y z t) :precision binary64 (if (<= x -7.5e-196) x (if (<= x 2.4e-229) (/ y (/ t (- z))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.5e-196) {
tmp = x;
} else if (x <= 2.4e-229) {
tmp = y / (t / -z);
} 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 (x <= (-7.5d-196)) then
tmp = x
else if (x <= 2.4d-229) then
tmp = y / (t / -z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.5e-196) {
tmp = x;
} else if (x <= 2.4e-229) {
tmp = y / (t / -z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -7.5e-196: tmp = x elif x <= 2.4e-229: tmp = y / (t / -z) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -7.5e-196) tmp = x; elseif (x <= 2.4e-229) tmp = Float64(y / Float64(t / Float64(-z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -7.5e-196) tmp = x; elseif (x <= 2.4e-229) tmp = y / (t / -z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -7.5e-196], x, If[LessEqual[x, 2.4e-229], N[(y / N[(t / (-z)), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.5 \cdot 10^{-196}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{-229}:\\
\;\;\;\;\frac{y}{\frac{t}{-z}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -7.5e-196 or 2.4e-229 < x Initial program 57.3%
sub-neg57.3%
associate-+l+81.7%
cancel-sign-sub81.7%
log1p-def88.2%
cancel-sign-sub88.2%
+-commutative88.2%
unsub-neg88.2%
*-rgt-identity88.2%
distribute-lft-out--88.2%
expm1-def99.2%
Simplified99.2%
Taylor expanded in x around inf 77.9%
if -7.5e-196 < x < 2.4e-229Initial program 29.7%
sub-neg29.7%
associate-+l+32.5%
cancel-sign-sub32.5%
log1p-def48.2%
cancel-sign-sub48.2%
+-commutative48.2%
unsub-neg48.2%
*-rgt-identity48.2%
distribute-lft-out--48.2%
expm1-def95.5%
Simplified95.5%
Taylor expanded in z around 0 55.3%
associate-/l*57.4%
associate-/r/55.2%
Simplified55.2%
Taylor expanded in x around 0 38.4%
mul-1-neg38.4%
*-commutative38.4%
associate-*r/38.4%
distribute-lft-neg-in38.4%
Simplified38.4%
Taylor expanded in z around 0 38.4%
associate-*r/38.4%
neg-mul-138.4%
distribute-rgt-neg-in38.4%
associate-/l*40.5%
Simplified40.5%
Final simplification71.5%
(FPCore (x y z t) :precision binary64 (if (<= z -2.4e-41) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.4e-41) {
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 <= (-2.4d-41)) 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 <= -2.4e-41) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.4e-41: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.4e-41) 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 <= -2.4e-41) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.4e-41], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{-41}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -2.40000000000000022e-41Initial program 69.1%
sub-neg69.1%
associate-+l+73.1%
cancel-sign-sub73.1%
log1p-def98.6%
cancel-sign-sub98.6%
+-commutative98.6%
unsub-neg98.6%
*-rgt-identity98.6%
distribute-lft-out--98.6%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 55.9%
if -2.40000000000000022e-41 < z Initial program 46.0%
sub-neg46.0%
associate-+l+73.3%
cancel-sign-sub73.3%
log1p-def74.4%
cancel-sign-sub74.4%
+-commutative74.4%
unsub-neg74.4%
*-rgt-identity74.4%
distribute-lft-out--74.4%
expm1-def98.0%
Simplified98.0%
Taylor expanded in z around 0 87.4%
associate-/l*88.8%
associate-/r/84.3%
Simplified84.3%
Final simplification76.2%
(FPCore (x y z t) :precision binary64 (if (<= z -3.1e-41) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.1e-41) {
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 <= (-3.1d-41)) 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 <= -3.1e-41) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.1e-41: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.1e-41) 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 <= -3.1e-41) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.1e-41], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{-41}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -3.10000000000000001e-41Initial program 69.1%
sub-neg69.1%
associate-+l+73.1%
cancel-sign-sub73.1%
log1p-def98.6%
cancel-sign-sub98.6%
+-commutative98.6%
unsub-neg98.6%
*-rgt-identity98.6%
distribute-lft-out--98.6%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 55.9%
if -3.10000000000000001e-41 < z Initial program 46.0%
sub-neg46.0%
associate-+l+73.3%
cancel-sign-sub73.3%
log1p-def74.4%
cancel-sign-sub74.4%
+-commutative74.4%
unsub-neg74.4%
*-rgt-identity74.4%
distribute-lft-out--74.4%
expm1-def98.0%
Simplified98.0%
clear-num97.9%
associate-/r/97.9%
Applied egg-rr97.9%
Taylor expanded in z around 0 87.4%
associate-/l*88.8%
Simplified88.8%
Final simplification79.4%
(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 52.6%
sub-neg52.6%
associate-+l+73.3%
cancel-sign-sub73.3%
log1p-def81.3%
cancel-sign-sub81.3%
+-commutative81.3%
unsub-neg81.3%
*-rgt-identity81.3%
distribute-lft-out--81.3%
expm1-def98.5%
Simplified98.5%
Taylor expanded in x around inf 68.2%
Final simplification68.2%
(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 2023271
(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)))