
(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.2%
sub-neg64.2%
associate-+l+79.1%
cancel-sign-sub79.1%
log1p-def86.0%
cancel-sign-sub86.0%
+-commutative86.0%
unsub-neg86.0%
*-rgt-identity86.0%
distribute-lft-out--86.1%
expm1-def98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x y z t) :precision binary64 (+ x (/ (/ -1.0 t) (+ 0.5 (/ 1.0 (* y (expm1 z)))))))
double code(double x, double y, double z, double t) {
return x + ((-1.0 / t) / (0.5 + (1.0 / (y * expm1(z)))));
}
public static double code(double x, double y, double z, double t) {
return x + ((-1.0 / t) / (0.5 + (1.0 / (y * Math.expm1(z)))));
}
def code(x, y, z, t): return x + ((-1.0 / t) / (0.5 + (1.0 / (y * math.expm1(z)))))
function code(x, y, z, t) return Float64(x + Float64(Float64(-1.0 / t) / Float64(0.5 + Float64(1.0 / Float64(y * expm1(z)))))) end
code[x_, y_, z_, t_] := N[(x + N[(N[(-1.0 / t), $MachinePrecision] / N[(0.5 + N[(1.0 / N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\frac{-1}{t}}{0.5 + \frac{1}{y \cdot \mathsf{expm1}\left(z\right)}}
\end{array}
Initial program 64.2%
sub-neg64.2%
associate-+l+79.1%
cancel-sign-sub79.1%
log1p-def86.0%
cancel-sign-sub86.0%
+-commutative86.0%
unsub-neg86.0%
*-rgt-identity86.0%
distribute-lft-out--86.1%
expm1-def98.9%
Simplified98.9%
clear-num98.9%
inv-pow98.9%
Applied egg-rr98.9%
unpow-198.9%
div-inv98.8%
associate-/r*98.5%
Applied egg-rr98.5%
Taylor expanded in y around 0 81.0%
expm1-def90.2%
Simplified90.2%
Final simplification90.2%
(FPCore (x y z t) :precision binary64 (if (<= y -3.2e+18) (+ x (/ -1.0 (+ (* t 0.5) (/ t (* y z))))) (- x (* y (/ (expm1 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.2e+18) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (y * (expm1(z) / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.2e+18) {
tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z))));
} else {
tmp = x - (y * (Math.expm1(z) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.2e+18: tmp = x + (-1.0 / ((t * 0.5) + (t / (y * z)))) else: tmp = x - (y * (math.expm1(z) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.2e+18) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(t / Float64(y * z))))); else tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.2e+18], 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[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{+18}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \frac{t}{y \cdot z}}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -3.2e18Initial program 47.3%
sub-neg47.3%
associate-+l+72.8%
cancel-sign-sub72.8%
log1p-def72.8%
cancel-sign-sub72.8%
+-commutative72.8%
unsub-neg72.8%
*-rgt-identity72.8%
distribute-lft-out--73.0%
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 57.0%
Taylor expanded in z around 0 73.9%
if -3.2e18 < y Initial program 69.2%
sub-neg69.2%
associate-+l+80.9%
cancel-sign-sub80.9%
log1p-def89.9%
cancel-sign-sub89.9%
+-commutative89.9%
unsub-neg89.9%
*-rgt-identity89.9%
distribute-lft-out--89.9%
expm1-def98.7%
Simplified98.7%
clear-num98.6%
inv-pow98.6%
Applied egg-rr98.6%
Taylor expanded in y around 0 88.7%
expm1-def94.7%
associate-*r/95.0%
Simplified95.0%
Final simplification90.2%
(FPCore (x y z t) :precision binary64 (if (<= y -2.6e+18) (+ 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.6e+18) {
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.6e+18) {
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.6e+18: 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.6e+18) 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.6e+18], 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.6 \cdot 10^{+18}:\\
\;\;\;\;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.6e18Initial program 47.3%
sub-neg47.3%
associate-+l+72.8%
cancel-sign-sub72.8%
log1p-def72.8%
cancel-sign-sub72.8%
+-commutative72.8%
unsub-neg72.8%
*-rgt-identity72.8%
distribute-lft-out--73.0%
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 57.0%
Taylor expanded in z around 0 73.9%
if -2.6e18 < y Initial program 69.2%
sub-neg69.2%
associate-+l+80.9%
cancel-sign-sub80.9%
log1p-def89.9%
cancel-sign-sub89.9%
+-commutative89.9%
unsub-neg89.9%
*-rgt-identity89.9%
distribute-lft-out--89.9%
expm1-def98.7%
Simplified98.7%
clear-num98.6%
inv-pow98.6%
Applied egg-rr98.6%
unpow-198.6%
div-inv98.6%
associate-/r*98.1%
Applied egg-rr98.1%
Taylor expanded in y around 0 88.7%
associate-/l*88.7%
expm1-def95.4%
Simplified95.4%
Final simplification90.6%
(FPCore (x y z t) :precision binary64 (if (<= z -3e-189) (+ x (/ -1.0 (+ (* t 0.5) (+ (/ t (* y z)) (* -0.5 (/ t y)))))) (+ x (/ -1.0 (/ (/ t z) y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3e-189) {
tmp = x + (-1.0 / ((t * 0.5) + ((t / (y * z)) + (-0.5 * (t / y)))));
} else {
tmp = x + (-1.0 / ((t / z) / 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 (z <= (-3d-189)) then
tmp = x + ((-1.0d0) / ((t * 0.5d0) + ((t / (y * z)) + ((-0.5d0) * (t / y)))))
else
tmp = x + ((-1.0d0) / ((t / z) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3e-189) {
tmp = x + (-1.0 / ((t * 0.5) + ((t / (y * z)) + (-0.5 * (t / y)))));
} else {
tmp = x + (-1.0 / ((t / z) / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3e-189: tmp = x + (-1.0 / ((t * 0.5) + ((t / (y * z)) + (-0.5 * (t / y))))) else: tmp = x + (-1.0 / ((t / z) / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3e-189) tmp = Float64(x + Float64(-1.0 / Float64(Float64(t * 0.5) + Float64(Float64(t / Float64(y * z)) + Float64(-0.5 * Float64(t / y)))))); else tmp = Float64(x + Float64(-1.0 / Float64(Float64(t / z) / y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3e-189) tmp = x + (-1.0 / ((t * 0.5) + ((t / (y * z)) + (-0.5 * (t / y))))); else tmp = x + (-1.0 / ((t / z) / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3e-189], N[(x + N[(-1.0 / N[(N[(t * 0.5), $MachinePrecision] + N[(N[(t / N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(-1.0 / N[(N[(t / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3 \cdot 10^{-189}:\\
\;\;\;\;x + \frac{-1}{t \cdot 0.5 + \left(\frac{t}{y \cdot z} + -0.5 \cdot \frac{t}{y}\right)}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{\frac{\frac{t}{z}}{y}}\\
\end{array}
\end{array}
if z < -3e-189Initial program 69.3%
sub-neg69.3%
associate-+l+78.5%
cancel-sign-sub78.5%
log1p-def91.2%
cancel-sign-sub91.2%
+-commutative91.2%
unsub-neg91.2%
*-rgt-identity91.2%
distribute-lft-out--91.3%
expm1-def99.9%
Simplified99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr99.9%
unpow-199.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 83.7%
Taylor expanded in z around 0 78.2%
if -3e-189 < z Initial program 59.1%
sub-neg59.1%
associate-+l+79.6%
cancel-sign-sub79.6%
log1p-def80.8%
cancel-sign-sub80.8%
+-commutative80.8%
unsub-neg80.8%
*-rgt-identity80.8%
distribute-lft-out--80.8%
expm1-def97.9%
Simplified97.9%
Taylor expanded in z around 0 90.8%
associate-/l*92.0%
associate-/r/90.4%
Simplified90.4%
associate-/r/92.0%
clear-num92.0%
Applied egg-rr92.0%
Final simplification85.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 64.2%
sub-neg64.2%
associate-+l+79.1%
cancel-sign-sub79.1%
log1p-def86.0%
cancel-sign-sub86.0%
+-commutative86.0%
unsub-neg86.0%
*-rgt-identity86.0%
distribute-lft-out--86.1%
expm1-def98.9%
Simplified98.9%
clear-num98.9%
inv-pow98.9%
Applied egg-rr98.9%
unpow-198.9%
Applied egg-rr98.9%
Taylor expanded in y around 0 81.3%
Taylor expanded in z around 0 82.1%
Final simplification82.1%
(FPCore (x y z t) :precision binary64 (if (<= z -5.2e+113) (- x (/ 2.0 t)) (- x (* z (/ y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.2e+113) {
tmp = x - (2.0 / t);
} 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 <= (-5.2d+113)) then
tmp = x - (2.0d0 / t)
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 <= -5.2e+113) {
tmp = x - (2.0 / t);
} else {
tmp = x - (z * (y / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5.2e+113: tmp = x - (2.0 / t) else: tmp = x - (z * (y / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5.2e+113) tmp = Float64(x - Float64(2.0 / t)); 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 <= -5.2e+113) tmp = x - (2.0 / t); else tmp = x - (z * (y / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.2e+113], N[(x - N[(2.0 / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+113}:\\
\;\;\;\;x - \frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -5.1999999999999998e113Initial program 79.6%
sub-neg79.6%
associate-+l+79.6%
cancel-sign-sub79.6%
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.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 86.4%
Taylor expanded in y around inf 58.0%
if -5.1999999999999998e113 < z Initial program 60.7%
sub-neg60.7%
associate-+l+78.9%
cancel-sign-sub78.9%
log1p-def82.8%
cancel-sign-sub82.8%
+-commutative82.8%
unsub-neg82.8%
*-rgt-identity82.8%
distribute-lft-out--82.9%
expm1-def98.7%
Simplified98.7%
Taylor expanded in z around 0 84.6%
associate-/l*85.8%
associate-/r/84.3%
Simplified84.3%
Final simplification79.4%
(FPCore (x y z t) :precision binary64 (if (<= z -5.2e+113) (- x (/ 2.0 t)) (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.2e+113) {
tmp = x - (2.0 / t);
} 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 <= (-5.2d+113)) then
tmp = x - (2.0d0 / t)
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 <= -5.2e+113) {
tmp = x - (2.0 / t);
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5.2e+113: tmp = x - (2.0 / t) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5.2e+113) tmp = Float64(x - Float64(2.0 / t)); 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 <= -5.2e+113) tmp = x - (2.0 / t); else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.2e+113], N[(x - N[(2.0 / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+113}:\\
\;\;\;\;x - \frac{2}{t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -5.1999999999999998e113Initial program 79.6%
sub-neg79.6%
associate-+l+79.6%
cancel-sign-sub79.6%
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.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 86.4%
Taylor expanded in y around inf 58.0%
if -5.1999999999999998e113 < z Initial program 60.7%
sub-neg60.7%
associate-+l+78.9%
cancel-sign-sub78.9%
log1p-def82.8%
cancel-sign-sub82.8%
+-commutative82.8%
unsub-neg82.8%
*-rgt-identity82.8%
distribute-lft-out--82.9%
expm1-def98.7%
Simplified98.7%
Taylor expanded in z around 0 84.6%
associate-/l*85.8%
Simplified85.8%
*-un-lft-identity85.8%
associate-*l/85.8%
clear-num85.8%
Applied egg-rr85.8%
Final simplification80.6%
(FPCore (x y z t) :precision binary64 (- x (/ 2.0 t)))
double code(double x, double y, double z, double t) {
return x - (2.0 / 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 - (2.0d0 / t)
end function
public static double code(double x, double y, double z, double t) {
return x - (2.0 / t);
}
def code(x, y, z, t): return x - (2.0 / t)
function code(x, y, z, t) return Float64(x - Float64(2.0 / t)) end
function tmp = code(x, y, z, t) tmp = x - (2.0 / t); end
code[x_, y_, z_, t_] := N[(x - N[(2.0 / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{2}{t}
\end{array}
Initial program 64.2%
sub-neg64.2%
associate-+l+79.1%
cancel-sign-sub79.1%
log1p-def86.0%
cancel-sign-sub86.0%
+-commutative86.0%
unsub-neg86.0%
*-rgt-identity86.0%
distribute-lft-out--86.1%
expm1-def98.9%
Simplified98.9%
clear-num98.9%
inv-pow98.9%
Applied egg-rr98.9%
unpow-198.9%
Applied egg-rr98.9%
Taylor expanded in y around 0 81.3%
Taylor expanded in y around inf 48.6%
Final simplification48.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 2023275
(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)))