
(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 13 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 (<= (exp z) 0.9999999) (- x (/ y (* t (- (/ 1.0 (expm1 z)) (* y -0.5))))) (- x (/ (log1p (* z (+ y (* 0.5 (* y z))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (exp(z) <= 0.9999999) {
tmp = x - (y / (t * ((1.0 / expm1(z)) - (y * -0.5))));
} else {
tmp = x - (log1p((z * (y + (0.5 * (y * z))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (Math.exp(z) <= 0.9999999) {
tmp = x - (y / (t * ((1.0 / Math.expm1(z)) - (y * -0.5))));
} else {
tmp = x - (Math.log1p((z * (y + (0.5 * (y * z))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if math.exp(z) <= 0.9999999: tmp = x - (y / (t * ((1.0 / math.expm1(z)) - (y * -0.5)))) else: tmp = x - (math.log1p((z * (y + (0.5 * (y * z))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (exp(z) <= 0.9999999) tmp = Float64(x - Float64(y / Float64(t * Float64(Float64(1.0 / expm1(z)) - Float64(y * -0.5))))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(0.5 * Float64(y * z))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[Exp[z], $MachinePrecision], 0.9999999], N[(x - N[(y / N[(t * N[(N[(1.0 / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision] - N[(y * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(0.5 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{z} \leq 0.9999999:\\
\;\;\;\;x - \frac{y}{t \cdot \left(\frac{1}{\mathsf{expm1}\left(z\right)} - y \cdot -0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + 0.5 \cdot \left(y \cdot z\right)\right)\right)}{t}\\
\end{array}
\end{array}
if (exp.f64 z) < 0.999999900000000053Initial 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%
clear-num99.3%
associate-/r/99.8%
Applied egg-rr99.8%
associate-/r/99.3%
Applied egg-rr99.3%
Taylor expanded in y around 0 85.2%
Taylor expanded in t around -inf 85.9%
associate-*r/85.9%
neg-mul-185.9%
*-commutative85.9%
expm1-define86.3%
Simplified86.3%
if 0.999999900000000053 < (exp.f64 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 simplification94.6%
(FPCore (x y z t) :precision binary64 (if (<= z -1.7e-7) (- x (* (expm1 z) (/ y t))) (- x (/ (log1p (* z (+ y (* 0.5 (* y z))))) t))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.7e-7) {
tmp = x - (expm1(z) * (y / t));
} else {
tmp = x - (log1p((z * (y + (0.5 * (y * z))))) / t);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.7e-7) {
tmp = x - (Math.expm1(z) * (y / t));
} else {
tmp = x - (Math.log1p((z * (y + (0.5 * (y * z))))) / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.7e-7: tmp = x - (math.expm1(z) * (y / t)) else: tmp = x - (math.log1p((z * (y + (0.5 * (y * z))))) / t) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.7e-7) tmp = Float64(x - Float64(expm1(z) * Float64(y / t))); else tmp = Float64(x - Float64(log1p(Float64(z * Float64(y + Float64(0.5 * Float64(y * z))))) / t)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.7e-7], N[(x - N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(N[Log[1 + N[(z * N[(y + N[(0.5 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{-7}:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{\mathsf{log1p}\left(z \cdot \left(y + 0.5 \cdot \left(y \cdot z\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%
*-commutative81.6%
associate-/l*81.6%
expm1-define82.0%
Simplified82.0%
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%
Final simplification93.4%
(FPCore (x y z t) :precision binary64 (if (<= y -4.2e+20) (- x (/ -1.0 (/ (/ (- (* z (* 0.5 (- t (* y t)))) t) z) y))) (- x (* y (/ (expm1 z) t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.2e+20) {
tmp = x - (-1.0 / ((((z * (0.5 * (t - (y * t)))) - t) / z) / y));
} 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 <= -4.2e+20) {
tmp = x - (-1.0 / ((((z * (0.5 * (t - (y * t)))) - t) / z) / y));
} else {
tmp = x - (y * (Math.expm1(z) / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.2e+20: tmp = x - (-1.0 / ((((z * (0.5 * (t - (y * t)))) - t) / z) / y)) else: tmp = x - (y * (math.expm1(z) / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.2e+20) tmp = Float64(x - Float64(-1.0 / Float64(Float64(Float64(Float64(z * Float64(0.5 * Float64(t - Float64(y * t)))) - t) / z) / y))); else tmp = Float64(x - Float64(y * Float64(expm1(z) / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.2e+20], N[(x - N[(-1.0 / N[(N[(N[(N[(z * N[(0.5 * N[(t - N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] / z), $MachinePrecision] / y), $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 -4.2 \cdot 10^{+20}:\\
\;\;\;\;x - \frac{-1}{\frac{\frac{z \cdot \left(0.5 \cdot \left(t - y \cdot t\right)\right) - t}{z}}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}\\
\end{array}
\end{array}
if y < -4.2e20Initial program 34.1%
associate-+l-66.9%
sub-neg66.9%
log1p-define66.9%
neg-sub066.9%
associate-+l-66.9%
neg-sub066.9%
+-commutative66.9%
unsub-neg66.9%
*-rgt-identity66.9%
distribute-lft-out--66.8%
expm1-define99.8%
Simplified99.8%
clear-num99.7%
associate-/r/99.6%
Applied egg-rr99.6%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 35.3%
Taylor expanded in z around 0 63.2%
distribute-lft-out--63.2%
Simplified63.2%
if -4.2e20 < y Initial program 66.4%
associate-+l-73.2%
sub-neg73.2%
log1p-define82.3%
neg-sub082.3%
associate-+l-82.3%
neg-sub082.3%
+-commutative82.3%
unsub-neg82.3%
*-rgt-identity82.3%
distribute-lft-out--82.3%
expm1-define98.3%
Simplified98.3%
Taylor expanded in y around 0 82.2%
associate-/l*82.2%
expm1-define97.5%
Simplified97.5%
Final simplification90.0%
(FPCore (x y z t) :precision binary64 (if (<= y -4.2e+20) (- x (/ -1.0 (/ (/ (- (* z (* 0.5 (- t (* y t)))) t) z) y))) (- x (/ y (/ t (expm1 z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.2e+20) {
tmp = x - (-1.0 / ((((z * (0.5 * (t - (y * t)))) - t) / z) / y));
} 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 <= -4.2e+20) {
tmp = x - (-1.0 / ((((z * (0.5 * (t - (y * t)))) - t) / z) / y));
} else {
tmp = x - (y / (t / Math.expm1(z)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.2e+20: tmp = x - (-1.0 / ((((z * (0.5 * (t - (y * t)))) - t) / z) / y)) else: tmp = x - (y / (t / math.expm1(z))) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.2e+20) tmp = Float64(x - Float64(-1.0 / Float64(Float64(Float64(Float64(z * Float64(0.5 * Float64(t - Float64(y * t)))) - t) / z) / y))); else tmp = Float64(x - Float64(y / Float64(t / expm1(z)))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.2e+20], N[(x - N[(-1.0 / N[(N[(N[(N[(z * N[(0.5 * N[(t - N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] / z), $MachinePrecision] / y), $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 -4.2 \cdot 10^{+20}:\\
\;\;\;\;x - \frac{-1}{\frac{\frac{z \cdot \left(0.5 \cdot \left(t - y \cdot t\right)\right) - t}{z}}{y}}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\end{array}
\end{array}
if y < -4.2e20Initial program 34.1%
associate-+l-66.9%
sub-neg66.9%
log1p-define66.9%
neg-sub066.9%
associate-+l-66.9%
neg-sub066.9%
+-commutative66.9%
unsub-neg66.9%
*-rgt-identity66.9%
distribute-lft-out--66.8%
expm1-define99.8%
Simplified99.8%
clear-num99.7%
associate-/r/99.6%
Applied egg-rr99.6%
associate-/r/99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 35.3%
Taylor expanded in z around 0 63.2%
distribute-lft-out--63.2%
Simplified63.2%
if -4.2e20 < y Initial program 66.4%
associate-+l-73.2%
sub-neg73.2%
log1p-define82.3%
neg-sub082.3%
associate-+l-82.3%
neg-sub082.3%
+-commutative82.3%
unsub-neg82.3%
*-rgt-identity82.3%
distribute-lft-out--82.3%
expm1-define98.3%
Simplified98.3%
Taylor expanded in y around 0 82.2%
associate-/l*82.2%
expm1-define97.5%
Simplified97.5%
clear-num97.5%
un-div-inv97.6%
Applied egg-rr97.6%
Final simplification90.0%
(FPCore (x y z t) :precision binary64 (if (<= z -6.5e-12) (- x (* (expm1 z) (/ y 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 - (expm1(z) * (y / 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 - (Math.expm1(z) * (y / 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 - (math.expm1(z) * (y / 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(expm1(z) * Float64(y / 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[(Exp[z] - 1), $MachinePrecision] * N[(y / 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 -6.5 \cdot 10^{-12}:\\
\;\;\;\;x - \mathsf{expm1}\left(z\right) \cdot \frac{y}{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%
*-commutative81.6%
associate-/l*81.6%
expm1-define82.0%
Simplified82.0%
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 (- x (/ -1.0 (/ (/ (- (* z (* 0.5 (- t (* y t)))) t) z) y))))
double code(double x, double y, double z, double t) {
return x - (-1.0 / ((((z * (0.5 * (t - (y * t)))) - t) / z) / y));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x - ((-1.0d0) / ((((z * (0.5d0 * (t - (y * t)))) - t) / z) / y))
end function
public static double code(double x, double y, double z, double t) {
return x - (-1.0 / ((((z * (0.5 * (t - (y * t)))) - t) / z) / y));
}
def code(x, y, z, t): return x - (-1.0 / ((((z * (0.5 * (t - (y * t)))) - t) / z) / y))
function code(x, y, z, t) return Float64(x - Float64(-1.0 / Float64(Float64(Float64(Float64(z * Float64(0.5 * Float64(t - Float64(y * t)))) - t) / z) / y))) end
function tmp = code(x, y, z, t) tmp = x - (-1.0 / ((((z * (0.5 * (t - (y * t)))) - t) / z) / y)); end
code[x_, y_, z_, t_] := N[(x - N[(-1.0 / N[(N[(N[(N[(z * N[(0.5 * N[(t - N[(y * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t), $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{-1}{\frac{\frac{z \cdot \left(0.5 \cdot \left(t - y \cdot t\right)\right) - t}{z}}{y}}
\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%
clear-num98.4%
associate-/r/98.6%
Applied egg-rr98.6%
associate-/r/98.4%
Applied egg-rr98.4%
Taylor expanded in y around 0 71.8%
Taylor expanded in z around 0 84.3%
distribute-lft-out--84.3%
Simplified84.3%
Final simplification84.3%
(FPCore (x y z t) :precision binary64 (if (<= t -1.7e-196) x (if (<= t 7e-254) (* y (/ (- z) t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.7e-196) {
tmp = x;
} else if (t <= 7e-254) {
tmp = y * (-z / t);
} 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.7d-196)) then
tmp = x
else if (t <= 7d-254) then
tmp = y * (-z / t)
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.7e-196) {
tmp = x;
} else if (t <= 7e-254) {
tmp = y * (-z / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.7e-196: tmp = x elif t <= 7e-254: tmp = y * (-z / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.7e-196) tmp = x; elseif (t <= 7e-254) tmp = Float64(y * Float64(Float64(-z) / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.7e-196) tmp = x; elseif (t <= 7e-254) tmp = y * (-z / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.7e-196], x, If[LessEqual[t, 7e-254], N[(y * N[((-z) / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.7 \cdot 10^{-196}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 7 \cdot 10^{-254}:\\
\;\;\;\;y \cdot \frac{-z}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.7e-196 or 7.00000000000000014e-254 < 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.7e-196 < t < 7.00000000000000014e-254Initial 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 x around 0 8.1%
mul-1-neg8.1%
log1p-define19.2%
expm1-define75.4%
distribute-frac-neg275.4%
Simplified75.4%
Taylor expanded in z around 0 49.5%
mul-1-neg49.5%
associate-/l*53.5%
distribute-rgt-neg-in53.5%
Simplified53.5%
Final simplification72.6%
(FPCore (x y z t) :precision binary64 (- x (/ y (/ (+ t (* -0.5 (* z t))) z))))
double code(double x, double y, double z, double t) {
return x - (y / ((t + (-0.5 * (z * t))) / 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 - (y / ((t + ((-0.5d0) * (z * t))) / z))
end function
public static double code(double x, double y, double z, double t) {
return x - (y / ((t + (-0.5 * (z * t))) / z));
}
def code(x, y, z, t): return x - (y / ((t + (-0.5 * (z * t))) / z))
function code(x, y, z, t) return Float64(x - Float64(y / Float64(Float64(t + Float64(-0.5 * Float64(z * t))) / z))) end
function tmp = code(x, y, z, t) tmp = x - (y / ((t + (-0.5 * (z * t))) / z)); end
code[x_, y_, z_, t_] := N[(x - N[(y / N[(N[(t + N[(-0.5 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y}{\frac{t + -0.5 \cdot \left(z \cdot t\right)}{z}}
\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 y around 0 73.5%
associate-/l*73.5%
expm1-define87.8%
Simplified87.8%
clear-num87.5%
un-div-inv87.6%
Applied egg-rr87.6%
Taylor expanded in z around 0 82.2%
Final simplification82.2%
(FPCore (x y z t) :precision binary64 (if (<= z -2.5e+63) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.5e+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.5d+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.5e+63) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.5e+63: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.5e+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.5e+63) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.5e+63], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.5 \cdot 10^{+63}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -2.50000000000000005e63Initial 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.50000000000000005e63 < 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 (if (<= z -8000000000000.0) (- x (/ y (* t -0.5))) (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8000000000000.0) {
tmp = x - (y / (t * -0.5));
} 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 <= (-8000000000000.0d0)) then
tmp = x - (y / (t * (-0.5d0)))
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 <= -8000000000000.0) {
tmp = x - (y / (t * -0.5));
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8000000000000.0: tmp = x - (y / (t * -0.5)) else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8000000000000.0) tmp = Float64(x - Float64(y / Float64(t * -0.5))); 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 <= -8000000000000.0) tmp = x - (y / (t * -0.5)); else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8000000000000.0], N[(x - N[(y / N[(t * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8000000000000:\\
\;\;\;\;x - \frac{y}{t \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\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 y around 0 80.5%
associate-/l*80.4%
expm1-define80.4%
Simplified80.4%
clear-num80.4%
un-div-inv80.5%
Applied egg-rr80.5%
Taylor expanded in z around 0 60.5%
Taylor expanded in z around inf 58.6%
*-commutative58.6%
Simplified58.6%
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 88.8%
associate-/l*90.2%
Simplified90.2%
Final simplification81.7%
(FPCore (x y z t) :precision binary64 (- x (/ y (+ (* t -0.5) (/ t z)))))
double code(double x, double y, double z, double t) {
return x - (y / ((t * -0.5) + (t / 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 - (y / ((t * (-0.5d0)) + (t / z)))
end function
public static double code(double x, double y, double z, double t) {
return x - (y / ((t * -0.5) + (t / z)));
}
def code(x, y, z, t): return x - (y / ((t * -0.5) + (t / z)))
function code(x, y, z, t) return Float64(x - Float64(y / Float64(Float64(t * -0.5) + Float64(t / z)))) end
function tmp = code(x, y, z, t) tmp = x - (y / ((t * -0.5) + (t / z))); end
code[x_, y_, z_, t_] := N[(x - N[(y / N[(N[(t * -0.5), $MachinePrecision] + N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y}{t \cdot -0.5 + \frac{t}{z}}
\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 y around 0 73.5%
associate-/l*73.5%
expm1-define87.8%
Simplified87.8%
clear-num87.5%
un-div-inv87.6%
Applied egg-rr87.6%
Taylor expanded in z around 0 82.2%
Taylor expanded in z around inf 81.7%
Final simplification81.7%
(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)))