
(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.8%
associate-+l-82.5%
sub-neg82.5%
log1p-define87.0%
neg-sub087.0%
associate-+l-87.0%
neg-sub087.0%
+-commutative87.0%
unsub-neg87.0%
*-rgt-identity87.0%
distribute-lft-out--87.0%
expm1-define99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z t)
:precision binary64
(if (<= (exp z) 1.0)
(+ x (/ -1.0 (/ (+ (* 0.5 (* y t)) (/ t (+ (exp z) -1.0))) y)))
(-
x
(/ (* z (+ y (* z (+ (* 0.16666666666666666 (* y z)) (* y 0.5))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 1.0) {
tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / (exp(z) + -1.0))) / y));
} else {
tmp = x - ((z * (y + (z * ((0.16666666666666666 * (y * z)) + (y * 0.5))))) / 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 (exp(z) <= 1.0d0) then
tmp = x + ((-1.0d0) / (((0.5d0 * (y * t)) + (t / (exp(z) + (-1.0d0)))) / y))
else
tmp = x - ((z * (y + (z * ((0.16666666666666666d0 * (y * z)) + (y * 0.5d0))))) / t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.exp(z) <= 1.0) {
tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / (Math.exp(z) + -1.0))) / y));
} else {
tmp = x - ((z * (y + (z * ((0.16666666666666666 * (y * z)) + (y * 0.5))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.exp(z) <= 1.0: tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / (math.exp(z) + -1.0))) / y)) else: tmp = x - ((z * (y + (z * ((0.16666666666666666 * (y * z)) + (y * 0.5))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 1.0) tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(0.5 * Float64(y * t)) + Float64(t / Float64(exp(z) + -1.0))) / y))); else tmp = Float64(x - Float64(Float64(z * Float64(y + Float64(z * Float64(Float64(0.16666666666666666 * Float64(y * z)) + Float64(y * 0.5))))) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (exp(z) <= 1.0) tmp = x + (-1.0 / (((0.5 * (y * t)) + (t / (exp(z) + -1.0))) / y)); else tmp = x - ((z * (y + (z * ((0.16666666666666666 * (y * z)) + (y * 0.5))))) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 1.0], N[(x + N[(-1.0 / N[(N[(N[(0.5 * N[(y * t), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[Exp[z], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[(z * N[(y + N[(z * N[(N[(0.16666666666666666 * N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 1:\\
\;\;\;\;x + \frac{-1}{\frac{0.5 \cdot \left(y \cdot t\right) + \frac{t}{e^{z} + -1}}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z \cdot \left(y + z \cdot \left(0.16666666666666666 \cdot \left(y \cdot z\right) + y \cdot 0.5\right)\right)}{t}\\
\end{array}
\end{array}
if (exp.f64 z) < 1Initial program 64.6%
associate-+l-82.6%
sub-neg82.6%
log1p-define87.1%
neg-sub087.1%
associate-+l-87.1%
neg-sub087.1%
+-commutative87.1%
unsub-neg87.1%
*-rgt-identity87.1%
distribute-lft-out--87.0%
expm1-define99.9%
Simplified99.9%
clear-num99.9%
associate-/r/99.8%
Applied egg-rr99.8%
associate-*l/99.9%
*-un-lft-identity99.9%
clear-num99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 77.3%
if 1 < (exp.f64 z) Initial program 75.7%
associate-+l-75.7%
sub-neg75.7%
log1p-define83.6%
neg-sub083.6%
associate-+l-83.6%
neg-sub083.6%
+-commutative83.6%
unsub-neg83.6%
*-rgt-identity83.6%
distribute-lft-out--82.9%
expm1-define100.0%
Simplified100.0%
Taylor expanded in y around 0 35.9%
associate-/l*35.9%
expm1-define53.0%
Simplified53.0%
Taylor expanded in z around 0 53.0%
Taylor expanded in t around 0 53.0%
Final simplification76.9%
(FPCore (x y z t) :precision binary64 (if (<= y -1e+125) x (- x (* y (/ (expm1 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1e+125) {
tmp = x;
} 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 <= -1e+125) {
tmp = x;
} else {
tmp = x - (y * (Math.expm1(z) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1e+125: tmp = x else: tmp = x - (y * (math.expm1(z) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1e+125) tmp = x; else tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1e+125], x, N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+125}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -9.9999999999999992e124Initial program 44.7%
associate-+l-78.3%
sub-neg78.3%
log1p-define78.3%
neg-sub078.3%
associate-+l-78.3%
neg-sub078.3%
+-commutative78.3%
unsub-neg78.3%
*-rgt-identity78.3%
distribute-lft-out--78.3%
expm1-define99.8%
Simplified99.8%
Taylor expanded in x around inf 63.4%
if -9.9999999999999992e124 < y Initial program 69.2%
associate-+l-83.4%
sub-neg83.4%
log1p-define88.9%
neg-sub088.9%
associate-+l-88.9%
neg-sub088.9%
+-commutative88.9%
unsub-neg88.9%
*-rgt-identity88.9%
distribute-lft-out--88.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in y around 0 84.1%
associate-/l*84.1%
expm1-define93.3%
Simplified93.3%
Final simplification87.9%
(FPCore (x y z t) :precision binary64 (if (<= y -1.82e+127) x (- x (/ (* y (expm1 z)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.82e+127) {
tmp = x;
} 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 <= -1.82e+127) {
tmp = x;
} else {
tmp = x - ((y * Math.expm1(z)) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.82e+127: tmp = x else: tmp = x - ((y * math.expm1(z)) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.82e+127) tmp = x; else tmp = Float64(x - Float64(Float64(y * expm1(z)) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.82e+127], x, N[(x - N[(N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.82 \cdot 10^{+127}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot \mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -1.82000000000000009e127Initial program 44.7%
associate-+l-78.3%
sub-neg78.3%
log1p-define78.3%
neg-sub078.3%
associate-+l-78.3%
neg-sub078.3%
+-commutative78.3%
unsub-neg78.3%
*-rgt-identity78.3%
distribute-lft-out--78.3%
expm1-define99.8%
Simplified99.8%
Taylor expanded in x around inf 63.4%
if -1.82000000000000009e127 < y Initial program 69.2%
associate-+l-83.4%
sub-neg83.4%
log1p-define88.9%
neg-sub088.9%
associate-+l-88.9%
neg-sub088.9%
+-commutative88.9%
unsub-neg88.9%
*-rgt-identity88.9%
distribute-lft-out--88.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in y around 0 84.1%
expm1-define93.7%
Simplified93.7%
Final simplification88.3%
(FPCore (x y z t)
:precision binary64
(if (<= z -3.2e-91)
x
(-
x
(/ (* z (+ y (* z (+ (* 0.16666666666666666 (* y z)) (* y 0.5))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.2e-91) {
tmp = x;
} else {
tmp = x - ((z * (y + (z * ((0.16666666666666666 * (y * z)) + (y * 0.5))))) / 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-91)) then
tmp = x
else
tmp = x - ((z * (y + (z * ((0.16666666666666666d0 * (y * z)) + (y * 0.5d0))))) / 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-91) {
tmp = x;
} else {
tmp = x - ((z * (y + (z * ((0.16666666666666666 * (y * z)) + (y * 0.5))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.2e-91: tmp = x else: tmp = x - ((z * (y + (z * ((0.16666666666666666 * (y * z)) + (y * 0.5))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.2e-91) tmp = x; else tmp = Float64(x - Float64(Float64(z * Float64(y + Float64(z * Float64(Float64(0.16666666666666666 * Float64(y * z)) + Float64(y * 0.5))))) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -3.2e-91) tmp = x; else tmp = x - ((z * (y + (z * ((0.16666666666666666 * (y * z)) + (y * 0.5))))) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.2e-91], x, N[(x - N[(N[(z * N[(y + N[(z * N[(N[(0.16666666666666666 * N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.2 \cdot 10^{-91}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{z \cdot \left(y + z \cdot \left(0.16666666666666666 \cdot \left(y \cdot z\right) + y \cdot 0.5\right)\right)}{t}\\
\end{array}
\end{array}
if z < -3.19999999999999996e-91Initial program 77.5%
associate-+l-83.3%
sub-neg83.3%
log1p-define95.1%
neg-sub095.1%
associate-+l-95.1%
neg-sub095.1%
+-commutative95.1%
unsub-neg95.1%
*-rgt-identity95.1%
distribute-lft-out--95.1%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 67.1%
if -3.19999999999999996e-91 < z Initial program 57.3%
associate-+l-82.0%
sub-neg82.0%
log1p-define82.2%
neg-sub082.2%
associate-+l-82.2%
neg-sub082.2%
+-commutative82.2%
unsub-neg82.2%
*-rgt-identity82.2%
distribute-lft-out--82.2%
expm1-define99.9%
Simplified99.9%
Taylor expanded in y around 0 81.0%
associate-/l*81.0%
expm1-define92.4%
Simplified92.4%
Taylor expanded in z around 0 88.7%
Taylor expanded in t around 0 93.1%
Final simplification83.5%
(FPCore (x y z t) :precision binary64 (if (<= z -3.1e-88) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -3.1e-88) {
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.1d-88)) 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.1e-88) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -3.1e-88: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -3.1e-88) 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.1e-88) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -3.1e-88], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{-88}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -3.0999999999999998e-88Initial program 77.5%
associate-+l-83.3%
sub-neg83.3%
log1p-define95.1%
neg-sub095.1%
associate-+l-95.1%
neg-sub095.1%
+-commutative95.1%
unsub-neg95.1%
*-rgt-identity95.1%
distribute-lft-out--95.1%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 67.1%
if -3.0999999999999998e-88 < z Initial program 57.3%
associate-+l-82.0%
sub-neg82.0%
log1p-define82.2%
neg-sub082.2%
associate-+l-82.2%
neg-sub082.2%
+-commutative82.2%
unsub-neg82.2%
*-rgt-identity82.2%
distribute-lft-out--82.2%
expm1-define99.9%
Simplified99.9%
Taylor expanded in z around 0 93.1%
associate-/l*92.3%
Simplified92.3%
Final simplification83.0%
(FPCore (x y z t) :precision binary64 (if (<= z -5.9e-89) x (- x (/ y (/ t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.9e-89) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-5.9d-89)) then
tmp = x
else
tmp = x - (y / (t / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5.9e-89) {
tmp = x;
} else {
tmp = x - (y / (t / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5.9e-89: tmp = x else: tmp = x - (y / (t / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5.9e-89) tmp = x; else tmp = Float64(x - Float64(y / Float64(t / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -5.9e-89) tmp = x; else tmp = x - (y / (t / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5.9e-89], x, N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.9 \cdot 10^{-89}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\end{array}
\end{array}
if z < -5.90000000000000021e-89Initial program 77.5%
associate-+l-83.3%
sub-neg83.3%
log1p-define95.1%
neg-sub095.1%
associate-+l-95.1%
neg-sub095.1%
+-commutative95.1%
unsub-neg95.1%
*-rgt-identity95.1%
distribute-lft-out--95.1%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 67.1%
if -5.90000000000000021e-89 < z Initial program 57.3%
associate-+l-82.0%
sub-neg82.0%
log1p-define82.2%
neg-sub082.2%
associate-+l-82.2%
neg-sub082.2%
+-commutative82.2%
unsub-neg82.2%
*-rgt-identity82.2%
distribute-lft-out--82.2%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 80.5%
mul-1-neg80.5%
unsub-neg80.5%
expm1-define82.5%
log1p-undefine91.6%
Simplified91.6%
Taylor expanded in z around 0 93.1%
mul-1-neg93.1%
associate-*r/92.3%
unsub-neg92.3%
associate-*r/93.1%
associate-*l/88.8%
associate-/r/92.3%
Simplified92.3%
Final simplification83.0%
(FPCore (x y z t) :precision binary64 (if (<= z -1.8e-93) x (- x (/ (* y z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.8e-93) {
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 <= (-1.8d-93)) 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 <= -1.8e-93) {
tmp = x;
} else {
tmp = x - ((y * z) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.8e-93: tmp = x else: tmp = x - ((y * z) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.8e-93) tmp = x; else tmp = Float64(x - Float64(Float64(y * z) / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.8e-93) tmp = x; else tmp = x - ((y * z) / t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.8e-93], x, N[(x - N[(N[(y * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{-93}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y \cdot z}{t}\\
\end{array}
\end{array}
if z < -1.8000000000000001e-93Initial program 77.5%
associate-+l-83.3%
sub-neg83.3%
log1p-define95.1%
neg-sub095.1%
associate-+l-95.1%
neg-sub095.1%
+-commutative95.1%
unsub-neg95.1%
*-rgt-identity95.1%
distribute-lft-out--95.1%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 67.1%
if -1.8000000000000001e-93 < z Initial program 57.3%
associate-+l-82.0%
sub-neg82.0%
log1p-define82.2%
neg-sub082.2%
associate-+l-82.2%
neg-sub082.2%
+-commutative82.2%
unsub-neg82.2%
*-rgt-identity82.2%
distribute-lft-out--82.2%
expm1-define99.9%
Simplified99.9%
Taylor expanded in z around 0 93.1%
Final simplification83.4%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 64.8%
associate-+l-82.5%
sub-neg82.5%
log1p-define87.0%
neg-sub087.0%
associate-+l-87.0%
neg-sub087.0%
+-commutative87.0%
unsub-neg87.0%
*-rgt-identity87.0%
distribute-lft-out--87.0%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 76.1%
Final simplification76.1%
(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 2024073
(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)))