
(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 64.9%
remove-double-neg64.9%
neg-mul-164.9%
*-commutative64.9%
*-commutative64.9%
neg-mul-164.9%
remove-double-neg64.9%
sub-neg64.9%
associate-+l+75.5%
cancel-sign-sub75.5%
log1p-def82.2%
cancel-sign-sub82.2%
+-commutative82.2%
unsub-neg82.2%
*-rgt-identity82.2%
distribute-lft-out--82.2%
expm1-def98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (x y z t) :precision binary64 (if (<= (exp z) 0.99998) (+ 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.99998) {
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.99998) {
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.99998: 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.99998) 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.99998], 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.99998:\\
\;\;\;\;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.99997999999999998Initial program 77.5%
remove-double-neg77.5%
neg-mul-177.5%
*-commutative77.5%
*-commutative77.5%
neg-mul-177.5%
remove-double-neg77.5%
sub-neg77.5%
associate-+l+77.5%
cancel-sign-sub77.5%
log1p-def99.9%
cancel-sign-sub99.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.7%
expm1-def100.0%
Simplified100.0%
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 79.7%
if 0.99997999999999998 < (exp.f64 z) Initial program 59.8%
remove-double-neg59.8%
neg-mul-159.8%
*-commutative59.8%
*-commutative59.8%
neg-mul-159.8%
remove-double-neg59.8%
sub-neg59.8%
associate-+l+74.8%
cancel-sign-sub74.8%
log1p-def75.2%
cancel-sign-sub75.2%
+-commutative75.2%
unsub-neg75.2%
*-rgt-identity75.2%
distribute-lft-out--75.2%
expm1-def97.6%
Simplified97.6%
add-cbrt-cube83.3%
pow383.4%
Applied egg-rr83.4%
Taylor expanded in z around 0 97.8%
Final simplification92.7%
(FPCore (x y z t) :precision binary64 (if (<= y -1.8e-24) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (if (<= y 2e-7) (- x (/ y (/ t (expm1 z)))) (- x (/ (log1p (* y z)) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.8e-24) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else if (y <= 2e-7) {
tmp = x - (y / (t / expm1(z)));
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.8e-24) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else if (y <= 2e-7) {
tmp = x - (y / (t / Math.expm1(z)));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.8e-24: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) elif y <= 2e-7: tmp = x - (y / (t / math.expm1(z))) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.8e-24) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); elseif (y <= 2e-7) tmp = Float64(x - Float64(y / Float64(t / expm1(z)))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.8e-24], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2e-7], N[(x - N[(y / N[(t / N[(Exp[z] - 1), $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}\;y \leq -1.8 \cdot 10^{-24}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-7}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if y < -1.8e-24Initial program 54.6%
remove-double-neg54.6%
neg-mul-154.6%
*-commutative54.6%
*-commutative54.6%
neg-mul-154.6%
remove-double-neg54.6%
sub-neg54.6%
associate-+l+75.4%
cancel-sign-sub75.4%
log1p-def75.4%
cancel-sign-sub75.4%
+-commutative75.4%
unsub-neg75.4%
*-rgt-identity75.4%
distribute-lft-out--75.4%
expm1-def99.9%
Simplified99.9%
add-cbrt-cube55.5%
pow355.5%
Applied egg-rr55.5%
Taylor expanded in z around 0 72.3%
clear-num72.3%
inv-pow72.3%
Applied egg-rr72.3%
unpow-172.3%
Simplified72.3%
Taylor expanded in y around 0 75.6%
if -1.8e-24 < y < 1.9999999999999999e-7Initial program 81.5%
remove-double-neg81.5%
neg-mul-181.5%
*-commutative81.5%
*-commutative81.5%
neg-mul-181.5%
remove-double-neg81.5%
sub-neg81.5%
associate-+l+81.5%
cancel-sign-sub81.5%
log1p-def92.9%
cancel-sign-sub92.9%
+-commutative92.9%
unsub-neg92.9%
*-rgt-identity92.9%
distribute-lft-out--92.8%
expm1-def97.8%
Simplified97.8%
Taylor expanded in y around 0 92.8%
associate-/l*92.8%
expm1-def98.7%
Simplified98.7%
if 1.9999999999999999e-7 < y Initial program 13.6%
remove-double-neg13.6%
neg-mul-113.6%
*-commutative13.6%
*-commutative13.6%
neg-mul-113.6%
remove-double-neg13.6%
sub-neg13.6%
associate-+l+50.1%
cancel-sign-sub50.1%
log1p-def50.1%
cancel-sign-sub50.1%
+-commutative50.1%
unsub-neg50.1%
*-rgt-identity50.1%
distribute-lft-out--50.1%
expm1-def97.1%
Simplified97.1%
add-cbrt-cube77.6%
pow377.7%
Applied egg-rr77.7%
Taylor expanded in z around 0 97.4%
Final simplification92.2%
(FPCore (x y z t) :precision binary64 (if (<= y -1.8e-24) (+ 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 <= -1.8e-24) {
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 <= -1.8e-24) {
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 <= -1.8e-24: 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 <= -1.8e-24) 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, -1.8e-24], 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 -1.8 \cdot 10^{-24}:\\
\;\;\;\;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 < -1.8e-24Initial program 54.6%
remove-double-neg54.6%
neg-mul-154.6%
*-commutative54.6%
*-commutative54.6%
neg-mul-154.6%
remove-double-neg54.6%
sub-neg54.6%
associate-+l+75.4%
cancel-sign-sub75.4%
log1p-def75.4%
cancel-sign-sub75.4%
+-commutative75.4%
unsub-neg75.4%
*-rgt-identity75.4%
distribute-lft-out--75.4%
expm1-def99.9%
Simplified99.9%
add-cbrt-cube55.5%
pow355.5%
Applied egg-rr55.5%
Taylor expanded in z around 0 72.3%
clear-num72.3%
inv-pow72.3%
Applied egg-rr72.3%
unpow-172.3%
Simplified72.3%
Taylor expanded in y around 0 75.6%
if -1.8e-24 < y Initial program 68.7%
remove-double-neg68.7%
neg-mul-168.7%
*-commutative68.7%
*-commutative68.7%
neg-mul-168.7%
remove-double-neg68.7%
sub-neg68.7%
associate-+l+75.6%
cancel-sign-sub75.6%
log1p-def84.8%
cancel-sign-sub84.8%
+-commutative84.8%
unsub-neg84.8%
*-rgt-identity84.8%
distribute-lft-out--84.7%
expm1-def97.6%
Simplified97.6%
Taylor expanded in y around 0 84.7%
associate-/l*84.7%
expm1-def94.6%
Simplified94.6%
Final simplification89.4%
(FPCore (x y z t) :precision binary64 (if (<= y -9.2e+177) x (+ x (* (/ y (- (/ 1.0 z) 0.5)) (/ -1.0 t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9.2e+177) {
tmp = x;
} else {
tmp = x + ((y / ((1.0 / z) - 0.5)) * (-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 (y <= (-9.2d+177)) then
tmp = x
else
tmp = x + ((y / ((1.0d0 / z) - 0.5d0)) * ((-1.0d0) / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -9.2e+177) {
tmp = x;
} else {
tmp = x + ((y / ((1.0 / z) - 0.5)) * (-1.0 / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -9.2e+177: tmp = x else: tmp = x + ((y / ((1.0 / z) - 0.5)) * (-1.0 / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -9.2e+177) tmp = x; else tmp = Float64(x + Float64(Float64(y / Float64(Float64(1.0 / z) - 0.5)) * Float64(-1.0 / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -9.2e+177) tmp = x; else tmp = x + ((y / ((1.0 / z) - 0.5)) * (-1.0 / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -9.2e+177], x, N[(x + N[(N[(y / N[(N[(1.0 / z), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.2 \cdot 10^{+177}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{1}{z} - 0.5} \cdot \frac{-1}{t}\\
\end{array}
\end{array}
if y < -9.1999999999999996e177Initial program 60.5%
remove-double-neg60.5%
neg-mul-160.5%
*-commutative60.5%
*-commutative60.5%
neg-mul-160.5%
remove-double-neg60.5%
sub-neg60.5%
associate-+l+90.2%
cancel-sign-sub90.2%
log1p-def90.2%
cancel-sign-sub90.2%
+-commutative90.2%
unsub-neg90.2%
*-rgt-identity90.2%
distribute-lft-out--90.2%
expm1-def99.9%
Simplified99.9%
Taylor expanded in x around inf 57.1%
if -9.1999999999999996e177 < y Initial program 65.3%
remove-double-neg65.3%
neg-mul-165.3%
*-commutative65.3%
*-commutative65.3%
neg-mul-165.3%
remove-double-neg65.3%
sub-neg65.3%
associate-+l+74.3%
cancel-sign-sub74.3%
log1p-def81.6%
cancel-sign-sub81.6%
+-commutative81.6%
unsub-neg81.6%
*-rgt-identity81.6%
distribute-lft-out--81.5%
expm1-def98.1%
Simplified98.1%
Taylor expanded in y around 0 77.2%
associate-/l*77.2%
expm1-def90.4%
Simplified90.4%
*-un-lft-identity90.4%
div-inv90.4%
times-frac90.4%
Applied egg-rr90.4%
Taylor expanded in z around 0 85.0%
Final simplification82.9%
(FPCore (x y z t) :precision binary64 (if (<= y -1.0) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (+ x (* (/ y (- (/ 1.0 z) 0.5)) (/ -1.0 t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x + ((y / ((1.0 / z) - 0.5)) * (-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 (y <= (-1.0d0)) then
tmp = x + ((-1.0d0) / ((t * 0.5d0) + (t / (y * z))))
else
tmp = x + ((y / ((1.0d0 / z) - 0.5d0)) * ((-1.0d0) / t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.0) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x + ((y / ((1.0 / z) - 0.5)) * (-1.0 / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.0: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x + ((y / ((1.0 / z) - 0.5)) * (-1.0 / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x + Float64(Float64(y / Float64(Float64(1.0 / z) - 0.5)) * Float64(-1.0 / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.0) tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))); else tmp = x + ((y / ((1.0 / z) - 0.5)) * (-1.0 / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.0], 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 / N[(N[(1.0 / z), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{1}{z} - 0.5} \cdot \frac{-1}{t}\\
\end{array}
\end{array}
if y < -1Initial program 51.7%
remove-double-neg51.7%
neg-mul-151.7%
*-commutative51.7%
*-commutative51.7%
neg-mul-151.7%
remove-double-neg51.7%
sub-neg51.7%
associate-+l+76.3%
cancel-sign-sub76.3%
log1p-def76.3%
cancel-sign-sub76.3%
+-commutative76.3%
unsub-neg76.3%
*-rgt-identity76.3%
distribute-lft-out--76.3%
expm1-def99.9%
Simplified99.9%
add-cbrt-cube50.5%
pow350.5%
Applied egg-rr50.5%
Taylor expanded in z around 0 67.1%
clear-num67.1%
inv-pow67.1%
Applied egg-rr67.1%
unpow-167.1%
Simplified67.1%
Taylor expanded in y around 0 71.0%
if -1 < y Initial program 68.8%
remove-double-neg68.8%
neg-mul-168.8%
*-commutative68.8%
*-commutative68.8%
neg-mul-168.8%
remove-double-neg68.8%
sub-neg68.8%
associate-+l+75.3%
cancel-sign-sub75.3%
log1p-def84.0%
cancel-sign-sub84.0%
+-commutative84.0%
unsub-neg84.0%
*-rgt-identity84.0%
distribute-lft-out--83.9%
expm1-def97.8%
Simplified97.8%
Taylor expanded in y around 0 83.9%
associate-/l*83.9%
expm1-def94.9%
Simplified94.9%
*-un-lft-identity94.9%
div-inv94.9%
times-frac94.2%
Applied egg-rr94.2%
Taylor expanded in z around 0 87.7%
Final simplification83.9%
(FPCore (x y z t) :precision binary64 (if (<= z -3.2e+21) x (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.2e+21) {
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 <= (-3.2d+21)) 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 <= -3.2e+21) {
tmp = x;
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.2e+21: tmp = x else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.2e+21) 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 <= -3.2e+21) tmp = x; else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.2e+21], x, N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \cdot 10^{+21}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -3.2e21Initial program 78.4%
remove-double-neg78.4%
neg-mul-178.4%
*-commutative78.4%
*-commutative78.4%
neg-mul-178.4%
remove-double-neg78.4%
sub-neg78.4%
associate-+l+78.4%
cancel-sign-sub78.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 x around inf 56.8%
if -3.2e21 < z Initial program 60.1%
remove-double-neg60.1%
neg-mul-160.1%
*-commutative60.1%
*-commutative60.1%
neg-mul-160.1%
remove-double-neg60.1%
sub-neg60.1%
associate-+l+74.5%
cancel-sign-sub74.5%
log1p-def75.9%
cancel-sign-sub75.9%
+-commutative75.9%
unsub-neg75.9%
*-rgt-identity75.9%
distribute-lft-out--75.9%
expm1-def97.6%
Simplified97.6%
Taylor expanded in z around 0 88.5%
associate-/l*89.5%
associate-/r/86.1%
Simplified86.1%
Final simplification78.4%
(FPCore (x y z t) :precision binary64 (if (<= z -3.7e+21) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.7e+21) {
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 <= (-3.7d+21)) 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 <= -3.7e+21) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.7e+21: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.7e+21) 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 <= -3.7e+21) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.7e+21], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.7 \cdot 10^{+21}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -3.7e21Initial program 78.4%
remove-double-neg78.4%
neg-mul-178.4%
*-commutative78.4%
*-commutative78.4%
neg-mul-178.4%
remove-double-neg78.4%
sub-neg78.4%
associate-+l+78.4%
cancel-sign-sub78.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 x around inf 56.8%
if -3.7e21 < z Initial program 60.1%
remove-double-neg60.1%
neg-mul-160.1%
*-commutative60.1%
*-commutative60.1%
neg-mul-160.1%
remove-double-neg60.1%
sub-neg60.1%
associate-+l+74.5%
cancel-sign-sub74.5%
log1p-def75.9%
cancel-sign-sub75.9%
+-commutative75.9%
unsub-neg75.9%
*-rgt-identity75.9%
distribute-lft-out--75.9%
expm1-def97.6%
Simplified97.6%
Taylor expanded in z around 0 88.5%
associate-/l*89.5%
associate-/r/86.1%
Simplified86.1%
*-commutative86.1%
clear-num86.1%
un-div-inv86.5%
Applied egg-rr86.5%
associate-/r/89.5%
Simplified89.5%
Final simplification81.0%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 64.9%
remove-double-neg64.9%
neg-mul-164.9%
*-commutative64.9%
*-commutative64.9%
neg-mul-164.9%
remove-double-neg64.9%
sub-neg64.9%
associate-+l+75.5%
cancel-sign-sub75.5%
log1p-def82.2%
cancel-sign-sub82.2%
+-commutative82.2%
unsub-neg82.2%
*-rgt-identity82.2%
distribute-lft-out--82.2%
expm1-def98.3%
Simplified98.3%
Taylor expanded in x around inf 69.5%
Final simplification69.5%
(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 2024031
(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)))