
(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 10 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 59.4%
associate-+l-71.8%
sub-neg71.8%
log1p-define78.9%
neg-sub078.9%
associate-+l-78.9%
neg-sub078.9%
+-commutative78.9%
unsub-neg78.9%
*-rgt-identity78.9%
distribute-lft-out--78.9%
expm1-define98.6%
Simplified98.6%
Final simplification98.6%
(FPCore (x y z t) :precision binary64 (if (<= z -1.7e-7) (- x (/ (* y (expm1 z)) t)) (- x (/ (log1p (* z (+ y (* z (* y 0.5))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.7e-7) {
tmp = x - ((y * expm1(z)) / t);
} else {
tmp = x - (log1p((z * (y + (z * (y * 0.5))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.7e-7) {
tmp = x - ((y * Math.expm1(z)) / t);
} else {
tmp = x - (Math.log1p((z * (y + (z * (y * 0.5))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.7e-7: tmp = x - ((y * math.expm1(z)) / t) else: tmp = x - (math.log1p((z * (y + (z * (y * 0.5))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.7e-7) tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(z * Float64(y * 0.5))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.7e-7], N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(z * N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{-7}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + z \cdot \left(y \cdot 0.5\right)\right)\right)}{t}\\
\end{array}
\end{array}
if z < -1.69999999999999987e-7Initial program 75.3%
associate-+l-75.3%
sub-neg75.3%
log1p-define99.6%
neg-sub099.6%
associate-+l-99.6%
neg-sub099.6%
+-commutative99.6%
unsub-neg99.6%
*-rgt-identity99.6%
distribute-lft-out--99.5%
expm1-define100.0%
Simplified100.0%
Taylor expanded in y around 0 81.6%
expm1-define82.1%
Simplified82.1%
if -1.69999999999999987e-7 < z Initial program 52.8%
associate-+l-70.4%
sub-neg70.4%
log1p-define70.4%
neg-sub070.4%
associate-+l-70.4%
neg-sub070.4%
+-commutative70.4%
unsub-neg70.4%
*-rgt-identity70.4%
distribute-lft-out--70.4%
expm1-define98.1%
Simplified98.1%
Taylor expanded in z around 0 98.1%
associate-*r*98.1%
*-commutative98.1%
Simplified98.1%
Final simplification93.4%
(FPCore (x y z t) :precision binary64 (if (<= y -7.5e+253) (/ (log1p (* y z)) (- t)) (- x (* y (/ (expm1 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -7.5e+253) {
tmp = log1p((y * z)) / -t;
} 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 <= -7.5e+253) {
tmp = Math.log1p((y * z)) / -t;
} else {
tmp = x - (y * (Math.expm1(z) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -7.5e+253: tmp = math.log1p((y * z)) / -t else: tmp = x - (y * (math.expm1(z) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -7.5e+253) tmp = Float64(log1p(Float64(y * z)) / Float64(-t)); else tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -7.5e+253], N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] / (-t)), $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 -7.5 \cdot 10^{+253}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(y \cdot z\right)}{-t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -7.50000000000000017e253Initial program 34.9%
associate-+l-51.6%
sub-neg51.6%
log1p-define51.6%
neg-sub051.6%
associate-+l-51.6%
neg-sub051.6%
+-commutative51.6%
unsub-neg51.6%
*-rgt-identity51.6%
distribute-lft-out--51.5%
expm1-define99.4%
Simplified99.4%
Taylor expanded in z around 0 69.0%
Taylor expanded in x around 0 54.2%
mul-1-neg54.2%
log1p-define54.2%
distribute-frac-neg254.2%
Simplified54.2%
if -7.50000000000000017e253 < y Initial program 60.7%
associate-+l-72.9%
sub-neg72.9%
log1p-define80.4%
neg-sub080.4%
associate-+l-80.4%
neg-sub080.4%
+-commutative80.4%
unsub-neg80.4%
*-rgt-identity80.4%
distribute-lft-out--80.4%
expm1-define98.6%
Simplified98.6%
Taylor expanded in y around 0 76.1%
associate-/l*76.0%
expm1-define91.8%
Simplified91.8%
Final simplification89.9%
(FPCore (x y z t) :precision binary64 (if (<= z -1.32e-8) (- x (* y (/ (expm1 z) t))) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.32e-8) {
tmp = x - (y * (expm1(z) / t));
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.32e-8) {
tmp = x - (y * (Math.expm1(z) / t));
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.32e-8: tmp = x - (y * (math.expm1(z) / t)) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.32e-8) tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.32e-8], N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $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}\;z \leq -1.32 \cdot 10^{-8}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -1.32000000000000007e-8Initial program 75.3%
associate-+l-75.3%
sub-neg75.3%
log1p-define99.6%
neg-sub099.6%
associate-+l-99.6%
neg-sub099.6%
+-commutative99.6%
unsub-neg99.6%
*-rgt-identity99.6%
distribute-lft-out--99.5%
expm1-define100.0%
Simplified100.0%
Taylor expanded in y around 0 81.6%
associate-/l*81.5%
expm1-define82.0%
Simplified82.0%
if -1.32000000000000007e-8 < z Initial program 52.8%
associate-+l-70.4%
sub-neg70.4%
log1p-define70.4%
neg-sub070.4%
associate-+l-70.4%
neg-sub070.4%
+-commutative70.4%
unsub-neg70.4%
*-rgt-identity70.4%
distribute-lft-out--70.4%
expm1-define98.1%
Simplified98.1%
Taylor expanded in z around 0 98.1%
Final simplification93.3%
(FPCore (x y z t) :precision binary64 (if (<= z -6.5e-12) (- x (/ (* y (expm1 z)) t)) (- x (/ (log1p (* y z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.5e-12) {
tmp = x - ((y * expm1(z)) / t);
} else {
tmp = x - (log1p((y * z)) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.5e-12) {
tmp = x - ((y * Math.expm1(z)) / t);
} else {
tmp = x - (Math.log1p((y * z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -6.5e-12: tmp = x - ((y * math.expm1(z)) / t) else: tmp = x - (math.log1p((y * z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -6.5e-12) tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); else tmp = Float64(x - Float64(log1p(Float64(y * z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -6.5e-12], N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(y * z), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{-12}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(y \cdot z\right)}{t}\\
\end{array}
\end{array}
if z < -6.5000000000000002e-12Initial program 75.3%
associate-+l-75.3%
sub-neg75.3%
log1p-define99.6%
neg-sub099.6%
associate-+l-99.6%
neg-sub099.6%
+-commutative99.6%
unsub-neg99.6%
*-rgt-identity99.6%
distribute-lft-out--99.5%
expm1-define100.0%
Simplified100.0%
Taylor expanded in y around 0 81.6%
expm1-define82.1%
Simplified82.1%
if -6.5000000000000002e-12 < z Initial program 52.8%
associate-+l-70.4%
sub-neg70.4%
log1p-define70.4%
neg-sub070.4%
associate-+l-70.4%
neg-sub070.4%
+-commutative70.4%
unsub-neg70.4%
*-rgt-identity70.4%
distribute-lft-out--70.4%
expm1-define98.1%
Simplified98.1%
Taylor expanded in z around 0 98.1%
Final simplification93.4%
(FPCore (x y z t) :precision binary64 (if (<= z -8000000000000.0) x (- x (* y (* z (+ (* 0.5 (/ z t)) (/ 1.0 t)))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8000000000000.0) {
tmp = x;
} else {
tmp = x - (y * (z * ((0.5 * (z / t)) + (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 <= (-8000000000000.0d0)) then
tmp = x
else
tmp = x - (y * (z * ((0.5d0 * (z / t)) + (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 <= -8000000000000.0) {
tmp = x;
} else {
tmp = x - (y * (z * ((0.5 * (z / t)) + (1.0 / t))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8000000000000.0: tmp = x else: tmp = x - (y * (z * ((0.5 * (z / t)) + (1.0 / t)))) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8000000000000.0) tmp = x; else tmp = Float64(x - Float64(y * Float64(z * Float64(Float64(0.5 * Float64(z / t)) + Float64(1.0 / t))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -8000000000000.0) tmp = x; else tmp = x - (y * (z * ((0.5 * (z / t)) + (1.0 / t)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8000000000000.0], x, N[(x - N[(y * N[(z * N[(N[(0.5 * N[(z / t), $MachinePrecision]), $MachinePrecision] + N[(1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8000000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \left(z \cdot \left(0.5 \cdot \frac{z}{t} + \frac{1}{t}\right)\right)\\
\end{array}
\end{array}
if z < -8e12Initial program 74.5%
associate-+l-74.5%
sub-neg74.5%
log1p-define100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
*-rgt-identity100.0%
distribute-lft-out--100.0%
expm1-define100.0%
Simplified100.0%
Taylor expanded in x around inf 57.8%
if -8e12 < z Initial program 53.8%
associate-+l-70.8%
sub-neg70.8%
log1p-define71.2%
neg-sub071.2%
associate-+l-71.2%
neg-sub071.2%
+-commutative71.2%
unsub-neg71.2%
*-rgt-identity71.2%
distribute-lft-out--71.2%
expm1-define98.1%
Simplified98.1%
Taylor expanded in z around 0 77.6%
Taylor expanded in y around 0 90.4%
Final simplification81.6%
(FPCore (x y z t) :precision binary64 (if (<= z -3.9e+63) x (+ x (/ -1.0 (/ (+ (* 0.5 (* y t)) (/ t z)) y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.9e+63) {
tmp = x;
} else {
tmp = x + (-1.0 / (((0.5 * (y * t)) + (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 <= (-3.9d+63)) then
tmp = x
else
tmp = x + ((-1.0d0) / (((0.5d0 * (y * t)) + (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 <= -3.9e+63) {
tmp = x;
} else {
tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.9e+63: tmp = x else: tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.9e+63) tmp = x; else tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(0.5 * Float64(y * t)) + Float64(t / z)) / y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.9e+63) tmp = x; else tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / z)) / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.9e+63], x, N[(x + N[(-1.0 / N[(N[(N[(0.5 * N[(y * t), $MachinePrecision]), $MachinePrecision] + N[(t / z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{+63}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + \frac{-1}{\frac{0.5 \cdot \left(y \cdot t\right) + \frac{t}{z}}{y}}\\
\end{array}
\end{array}
if z < -3.9e63Initial program 73.9%
associate-+l-73.9%
sub-neg73.9%
log1p-define100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
*-rgt-identity100.0%
distribute-lft-out--100.0%
expm1-define100.0%
Simplified100.0%
Taylor expanded in x around inf 58.0%
if -3.9e63 < z Initial program 54.9%
associate-+l-71.2%
sub-neg71.2%
log1p-define72.5%
neg-sub072.5%
associate-+l-72.5%
neg-sub072.5%
+-commutative72.5%
unsub-neg72.5%
*-rgt-identity72.5%
distribute-lft-out--72.5%
expm1-define98.2%
Simplified98.2%
Taylor expanded in z around 0 96.3%
clear-num96.2%
inv-pow96.2%
Applied egg-rr96.2%
unpow-196.2%
Simplified96.2%
Taylor expanded in y around 0 89.6%
Final simplification82.2%
(FPCore (x y z t) :precision binary64 (if (<= t -1.9e-197) x (if (<= t 5e-253) (* (/ z t) (- y)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.9e-197) {
tmp = x;
} else if (t <= 5e-253) {
tmp = (z / t) * -y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-1.9d-197)) then
tmp = x
else if (t <= 5d-253) then
tmp = (z / t) * -y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.9e-197) {
tmp = x;
} else if (t <= 5e-253) {
tmp = (z / t) * -y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.9e-197: tmp = x elif t <= 5e-253: tmp = (z / t) * -y else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.9e-197) tmp = x; elseif (t <= 5e-253) tmp = Float64(Float64(z / t) * Float64(-y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.9e-197) tmp = x; elseif (t <= 5e-253) tmp = (z / t) * -y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.9e-197], x, If[LessEqual[t, 5e-253], N[(N[(z / t), $MachinePrecision] * (-y)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.9 \cdot 10^{-197}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 5 \cdot 10^{-253}:\\
\;\;\;\;\frac{z}{t} \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.8999999999999999e-197 or 4.99999999999999971e-253 < t Initial program 66.6%
associate-+l-81.2%
sub-neg81.2%
log1p-define87.5%
neg-sub087.5%
associate-+l-87.5%
neg-sub087.5%
+-commutative87.5%
unsub-neg87.5%
*-rgt-identity87.5%
distribute-lft-out--87.5%
expm1-define99.5%
Simplified99.5%
Taylor expanded in x around inf 76.7%
if -1.8999999999999999e-197 < t < 4.99999999999999971e-253Initial program 25.2%
associate-+l-27.7%
sub-neg27.7%
log1p-define39.0%
neg-sub039.0%
associate-+l-39.0%
neg-sub039.0%
+-commutative39.0%
unsub-neg39.0%
*-rgt-identity39.0%
distribute-lft-out--38.9%
expm1-define94.7%
Simplified94.7%
Taylor expanded in z around 0 68.8%
associate-/l*73.6%
Simplified73.6%
Taylor expanded in x around 0 49.5%
neg-mul-149.5%
associate-/l*53.5%
distribute-rgt-neg-in53.5%
distribute-frac-neg53.5%
Simplified53.5%
Final simplification72.6%
(FPCore (x y z t) :precision binary64 (if (<= z -2.7e+63) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.7e+63) {
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 <= (-2.7d+63)) 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 <= -2.7e+63) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.7e+63: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.7e+63) 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 <= -2.7e+63) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.7e+63], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+63}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -2.70000000000000017e63Initial program 73.9%
associate-+l-73.9%
sub-neg73.9%
log1p-define100.0%
neg-sub0100.0%
associate-+l-100.0%
neg-sub0100.0%
+-commutative100.0%
unsub-neg100.0%
*-rgt-identity100.0%
distribute-lft-out--100.0%
expm1-define100.0%
Simplified100.0%
Taylor expanded in x around inf 58.0%
if -2.70000000000000017e63 < z Initial program 54.9%
associate-+l-71.2%
sub-neg71.2%
log1p-define72.5%
neg-sub072.5%
associate-+l-72.5%
neg-sub072.5%
+-commutative72.5%
unsub-neg72.5%
*-rgt-identity72.5%
distribute-lft-out--72.5%
expm1-define98.2%
Simplified98.2%
Taylor expanded in z around 0 87.4%
associate-/l*88.8%
Simplified88.8%
Final simplification81.6%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 59.4%
associate-+l-71.8%
sub-neg71.8%
log1p-define78.9%
neg-sub078.9%
associate-+l-78.9%
neg-sub078.9%
+-commutative78.9%
unsub-neg78.9%
*-rgt-identity78.9%
distribute-lft-out--78.9%
expm1-define98.6%
Simplified98.6%
Taylor expanded in x around inf 67.2%
Final simplification67.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 2024055
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:precision binary64
:alt
(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)))