
(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - (log(((1.0d0 - y) + (y * exp(z)))) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function tmp = code(x, y, z, t) tmp = x - (log(((1.0 - y) + (y * exp(z)))) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - (log(((1.0d0 - y) + (y * exp(z)))) / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function tmp = code(x, y, z, t) tmp = x - (log(((1.0 - y) + (y * exp(z)))) / t); end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[N[(N[(1.0 - y), $MachinePrecision] + N[(y * N[Exp[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\end{array}
(FPCore (x y z t) :precision binary64 (- x (/ (log1p (* y (expm1 z))) t)))
double code(double x, double y, double z, double t) {
return x - (log1p((y * expm1(z))) / t);
}
public static double code(double x, double y, double z, double t) {
return x - (Math.log1p((y * Math.expm1(z))) / t);
}
def code(x, y, z, t): return x - (math.log1p((y * math.expm1(z))) / t)
function code(x, y, z, t) return Float64(x - Float64(log1p(Float64(y * expm1(z))) / t)) end
code[x_, y_, z_, t_] := N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}
\end{array}
Initial program 61.7%
sub-neg61.7%
associate-+l+79.9%
cancel-sign-sub79.9%
log1p-def85.3%
cancel-sign-sub85.3%
+-commutative85.3%
unsub-neg85.3%
*-rgt-identity85.3%
distribute-lft-out--85.3%
expm1-def98.6%
Simplified98.6%
Final simplification98.6%
(FPCore (x y z t) :precision binary64 (if (<= (exp z) 0.0) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y (+ (exp z) -1.0)))))) (+ x (/ -1.0 (+ (* t 0.5) (/ (- (/ t z) (* t 0.5)) y))))))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 0.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (exp(z) + -1.0)))));
} else {
tmp = x + (-1.0 / ((t * 0.5) + (((t / z) - (t * 0.5)) / y)));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (exp(z) <= 0.0d0) then
tmp = x + ((-1.0d0) / ((t * 0.5d0) + (t / (y * (exp(z) + (-1.0d0))))))
else
tmp = x + ((-1.0d0) / ((t * 0.5d0) + (((t / z) - (t * 0.5d0)) / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.exp(z) <= 0.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (Math.exp(z) + -1.0)))));
} else {
tmp = x + (-1.0 / ((t * 0.5) + (((t / z) - (t * 0.5)) / y)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.exp(z) <= 0.0: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (math.exp(z) + -1.0))))) else: tmp = x + (-1.0 / ((t * 0.5) + (((t / z) - (t * 0.5)) / y))) return tmp
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 0.0) 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(-1.0 / Float64(Float64(t * 0.5) + Float64(Float64(Float64(t / z) - Float64(t * 0.5)) / y)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (exp(z) <= 0.0) tmp = x + (-1.0 / ((t * 0.5) + (t / (y * (exp(z) + -1.0))))); else tmp = x + (-1.0 / ((t * 0.5) + (((t / z) - (t * 0.5)) / y))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 0.0], 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[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(N[(N[(t / z), $MachinePrecision] - N[(t * 0.5), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 0:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot \left(e^{z} + -1\right)}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{\frac{t}{z} - t \cdot 0.5}{y}}\\
\end{array}
\end{array}
if (exp.f64 z) < 0.0Initial program 83.4%
sub-neg83.4%
associate-+l+83.4%
cancel-sign-sub83.4%
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.9%
associate-/r/99.9%
Applied egg-rr99.9%
associate-/r/99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 90.9%
if 0.0 < (exp.f64 z) Initial program 52.9%
sub-neg52.9%
associate-+l+78.5%
cancel-sign-sub78.5%
log1p-def79.4%
cancel-sign-sub79.4%
+-commutative79.4%
unsub-neg79.4%
*-rgt-identity79.4%
distribute-lft-out--79.4%
expm1-def98.0%
Simplified98.0%
clear-num97.9%
associate-/r/98.0%
Applied egg-rr98.0%
associate-/r/97.9%
Applied egg-rr97.9%
Taylor expanded in z around 0 59.0%
fma-def59.0%
associate-/l*65.2%
unpow265.2%
mul-1-neg65.2%
unpow265.2%
Simplified65.2%
Taylor expanded in y around -inf 90.8%
+-commutative90.8%
mul-1-neg90.8%
unsub-neg90.8%
*-commutative90.8%
+-commutative90.8%
mul-1-neg90.8%
unsub-neg90.8%
*-commutative90.8%
Simplified90.8%
Final simplification90.8%
(FPCore (x y z t) :precision binary64 (if (<= y -0.5) (+ x (/ -1.0 (+ (* -0.5 (/ t y)) (+ (* t 0.5) (/ t (* y z)))))) (+ x (* y (* (expm1 z) (/ -1.0 t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -0.5) {
tmp = x + (-1.0 / ((-0.5 * (t / y)) + ((t * 0.5) + (t / (y * z)))));
} else {
tmp = x + (y * (expm1(z) * (-1.0 / t)));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -0.5) {
tmp = x + (-1.0 / ((-0.5 * (t / y)) + ((t * 0.5) + (t / (y * z)))));
} else {
tmp = x + (y * (Math.expm1(z) * (-1.0 / t)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -0.5: tmp = x + (-1.0 / ((-0.5 * (t / y)) + ((t * 0.5) + (t / (y * z))))) else: tmp = x + (y * (math.expm1(z) * (-1.0 / t))) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -0.5) tmp = Float64(x + Float64(-1.0 / Float64(Float64(-0.5 * Float64(t / y)) + Float64(Float64(t * 0.5) + Float64(t / Float64(y * z)))))); else tmp = Float64(x + Float64(y * Float64(expm1(z) * Float64(-1.0 / t)))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -0.5], N[(x + N[(-1.0 / N[(N[(-0.5 * N[(t / y), $MachinePrecision]), $MachinePrecision] + N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] * N[(-1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -0.5:\\
\;\;\;\;x + \frac{-1}{-0.5 \cdot \frac{t}{y} + \left(t \cdot 0.5 + \frac{t}{y \cdot z}\right)}\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(\mathsf{expm1}\left(z\right) \cdot \frac{-1}{t}\right)\\
\end{array}
\end{array}
if y < -0.5Initial program 37.7%
sub-neg37.7%
associate-+l+77.1%
cancel-sign-sub77.1%
log1p-def77.1%
cancel-sign-sub77.1%
+-commutative77.1%
unsub-neg77.1%
*-rgt-identity77.1%
distribute-lft-out--77.1%
expm1-def99.9%
Simplified99.9%
clear-num99.7%
associate-/r/99.8%
Applied egg-rr99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 35.7%
fma-def35.7%
associate-/l*37.2%
unpow237.2%
mul-1-neg37.2%
unpow237.2%
Simplified37.2%
Taylor expanded in y around 0 78.4%
if -0.5 < y Initial program 70.1%
sub-neg70.1%
associate-+l+80.9%
cancel-sign-sub80.9%
log1p-def88.2%
cancel-sign-sub88.2%
+-commutative88.2%
unsub-neg88.2%
*-rgt-identity88.2%
distribute-lft-out--88.2%
expm1-def98.1%
Simplified98.1%
Taylor expanded in y around 0 86.7%
expm1-def93.4%
Simplified93.4%
div-inv93.4%
associate-*l*94.7%
Applied egg-rr94.7%
Final simplification90.5%
(FPCore (x y z t) :precision binary64 (if (<= y -0.98) (+ x (/ -1.0 (+ (* -0.5 (/ t y)) (+ (* 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 <= -0.98) {
tmp = x + (-1.0 / ((-0.5 * (t / y)) + ((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 <= -0.98) {
tmp = x + (-1.0 / ((-0.5 * (t / y)) + ((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 <= -0.98: tmp = x + (-1.0 / ((-0.5 * (t / y)) + ((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 <= -0.98) tmp = Float64(x + Float64(-1.0 / Float64(Float64(-0.5 * Float64(t / y)) + 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, -0.98], N[(x + N[(-1.0 / N[(N[(-0.5 * N[(t / y), $MachinePrecision]), $MachinePrecision] + N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $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 -0.98:\\
\;\;\;\;x + \frac{-1}{-0.5 \cdot \frac{t}{y} + \left(t \cdot 0.5 + \frac{t}{y \cdot z}\right)}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\end{array}
\end{array}
if y < -0.97999999999999998Initial program 37.7%
sub-neg37.7%
associate-+l+77.1%
cancel-sign-sub77.1%
log1p-def77.1%
cancel-sign-sub77.1%
+-commutative77.1%
unsub-neg77.1%
*-rgt-identity77.1%
distribute-lft-out--77.1%
expm1-def99.9%
Simplified99.9%
clear-num99.7%
associate-/r/99.8%
Applied egg-rr99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 35.7%
fma-def35.7%
associate-/l*37.2%
unpow237.2%
mul-1-neg37.2%
unpow237.2%
Simplified37.2%
Taylor expanded in y around 0 78.4%
if -0.97999999999999998 < y Initial program 70.1%
sub-neg70.1%
associate-+l+80.9%
cancel-sign-sub80.9%
log1p-def88.2%
cancel-sign-sub88.2%
+-commutative88.2%
unsub-neg88.2%
*-rgt-identity88.2%
distribute-lft-out--88.2%
expm1-def98.1%
Simplified98.1%
Taylor expanded in y around 0 86.7%
associate-/l*86.7%
expm1-def94.7%
Simplified94.7%
Final simplification90.5%
(FPCore (x y z t) :precision binary64 (+ x (/ -1.0 (+ (* t 0.5) (/ (- (/ t z) (* t 0.5)) y)))))
double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t * 0.5) + (((t / z) - (t * 0.5)) / 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 + ((-1.0d0) / ((t * 0.5d0) + (((t / z) - (t * 0.5d0)) / y)))
end function
public static double code(double x, double y, double z, double t) {
return x + (-1.0 / ((t * 0.5) + (((t / z) - (t * 0.5)) / y)));
}
def code(x, y, z, t): return x + (-1.0 / ((t * 0.5) + (((t / z) - (t * 0.5)) / y)))
function code(x, y, z, t) return Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(Float64(Float64(t / z) - Float64(t * 0.5)) / y)))) end
function tmp = code(x, y, z, t) tmp = x + (-1.0 / ((t * 0.5) + (((t / z) - (t * 0.5)) / y))); end
code[x_, y_, z_, t_] := N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(N[(N[(t / z), $MachinePrecision] - N[(t * 0.5), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{-1}{t \cdot 0.5 + \frac{\frac{t}{z} - t \cdot 0.5}{y}}
\end{array}
Initial program 61.7%
sub-neg61.7%
associate-+l+79.9%
cancel-sign-sub79.9%
log1p-def85.3%
cancel-sign-sub85.3%
+-commutative85.3%
unsub-neg85.3%
*-rgt-identity85.3%
distribute-lft-out--85.3%
expm1-def98.6%
Simplified98.6%
clear-num98.5%
associate-/r/98.5%
Applied egg-rr98.5%
associate-/r/98.5%
Applied egg-rr98.5%
Taylor expanded in z around 0 56.4%
fma-def56.4%
associate-/l*64.1%
unpow264.1%
mul-1-neg64.1%
unpow264.1%
Simplified64.1%
Taylor expanded in y around -inf 86.2%
+-commutative86.2%
mul-1-neg86.2%
unsub-neg86.2%
*-commutative86.2%
+-commutative86.2%
mul-1-neg86.2%
unsub-neg86.2%
*-commutative86.2%
Simplified86.2%
Final simplification86.2%
(FPCore (x y z t) :precision binary64 (if (<= y -1.05e+187) (- x (/ 2.0 t)) (- x (/ y (+ (/ t z) (* t -0.5))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.05e+187) {
tmp = x - (2.0 / t);
} else {
tmp = x - (y / ((t / z) + (t * -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) :: tmp
if (y <= (-1.05d+187)) then
tmp = x - (2.0d0 / t)
else
tmp = x - (y / ((t / z) + (t * (-0.5d0))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.05e+187) {
tmp = x - (2.0 / t);
} else {
tmp = x - (y / ((t / z) + (t * -0.5)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.05e+187: tmp = x - (2.0 / t) else: tmp = x - (y / ((t / z) + (t * -0.5))) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.05e+187) tmp = Float64(x - Float64(2.0 / t)); else tmp = Float64(x - Float64(y / Float64(Float64(t / z) + Float64(t * -0.5)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.05e+187) tmp = x - (2.0 / t); else tmp = x - (y / ((t / z) + (t * -0.5))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.05e+187], N[(x - N[(2.0 / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(y / N[(N[(t / z), $MachinePrecision] + N[(t * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+187}:\\
\;\;\;\;x - \frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z} + t \cdot -0.5}\\
\end{array}
\end{array}
if y < -1.05e187Initial program 41.0%
sub-neg41.0%
associate-+l+68.0%
cancel-sign-sub68.0%
log1p-def68.0%
cancel-sign-sub68.0%
+-commutative68.0%
unsub-neg68.0%
*-rgt-identity68.0%
distribute-lft-out--68.0%
expm1-def99.9%
Simplified99.9%
clear-num99.7%
associate-/r/99.8%
Applied egg-rr99.8%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in z around 0 0.0%
fma-def0.0%
associate-/l*0.0%
unpow20.0%
mul-1-neg0.0%
unpow20.0%
Simplified0.0%
Taylor expanded in y around inf 59.6%
if -1.05e187 < y Initial program 64.5%
sub-neg64.5%
associate-+l+81.5%
cancel-sign-sub81.5%
log1p-def87.6%
cancel-sign-sub87.6%
+-commutative87.6%
unsub-neg87.6%
*-rgt-identity87.6%
distribute-lft-out--87.6%
expm1-def98.4%
Simplified98.4%
Taylor expanded in y around 0 84.8%
associate-/l*84.8%
expm1-def93.1%
Simplified93.1%
Taylor expanded in z around 0 87.9%
Final simplification84.6%
(FPCore (x y z t) :precision binary64 (if (<= z -100000000000.0) x (+ x (* y (* z (/ -1.0 t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -100000000000.0) {
tmp = x;
} else {
tmp = x + (y * (z * (-1.0 / 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 <= (-100000000000.0d0)) then
tmp = x
else
tmp = x + (y * (z * ((-1.0d0) / t)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -100000000000.0) {
tmp = x;
} else {
tmp = x + (y * (z * (-1.0 / t)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -100000000000.0: tmp = x else: tmp = x + (y * (z * (-1.0 / t))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -100000000000.0) tmp = x; else tmp = Float64(x + Float64(y * Float64(z * Float64(-1.0 / t)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -100000000000.0) tmp = x; else tmp = x + (y * (z * (-1.0 / t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -100000000000.0], x, N[(x + N[(y * N[(z * N[(-1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -100000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot \frac{-1}{t}\right)\\
\end{array}
\end{array}
if z < -1e11Initial program 82.9%
sub-neg82.9%
associate-+l+82.9%
cancel-sign-sub82.9%
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 69.7%
if -1e11 < z Initial program 53.4%
sub-neg53.4%
associate-+l+78.7%
cancel-sign-sub78.7%
log1p-def79.6%
cancel-sign-sub79.6%
+-commutative79.6%
unsub-neg79.6%
*-rgt-identity79.6%
distribute-lft-out--79.6%
expm1-def98.1%
Simplified98.1%
Taylor expanded in z around 0 87.6%
associate-/l*88.3%
associate-/r/86.9%
Simplified86.9%
associate-*l/87.6%
clear-num87.5%
Applied egg-rr87.5%
associate-/r/87.6%
*-commutative87.6%
associate-*r*88.3%
Applied egg-rr88.3%
Final simplification83.1%
(FPCore (x y z t) :precision binary64 (if (<= z -66000000000.0) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -66000000000.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 <= (-66000000000.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 <= -66000000000.0) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -66000000000.0: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -66000000000.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 <= -66000000000.0) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -66000000000.0], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -66000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -6.6e10Initial program 82.9%
sub-neg82.9%
associate-+l+82.9%
cancel-sign-sub82.9%
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 69.7%
if -6.6e10 < z Initial program 53.4%
sub-neg53.4%
associate-+l+78.7%
cancel-sign-sub78.7%
log1p-def79.6%
cancel-sign-sub79.6%
+-commutative79.6%
unsub-neg79.6%
*-rgt-identity79.6%
distribute-lft-out--79.6%
expm1-def98.1%
Simplified98.1%
*-un-lft-identity98.1%
add-cube-cbrt97.6%
times-frac97.6%
pow297.6%
Applied egg-rr97.6%
associate-*l/97.6%
*-lft-identity97.6%
Simplified97.6%
Taylor expanded in z around 0 87.6%
associate-*r/88.3%
Simplified88.3%
Final simplification83.1%
(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 61.7%
sub-neg61.7%
associate-+l+79.9%
cancel-sign-sub79.9%
log1p-def85.3%
cancel-sign-sub85.3%
+-commutative85.3%
unsub-neg85.3%
*-rgt-identity85.3%
distribute-lft-out--85.3%
expm1-def98.6%
Simplified98.6%
Taylor expanded in x around inf 75.4%
Final simplification75.4%
(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 2023293
(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)))