
(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 11 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 57.3%
associate-+l-75.1%
sub-neg75.1%
log1p-define82.6%
neg-sub082.6%
associate-+l-82.6%
neg-sub082.6%
+-commutative82.6%
unsub-neg82.6%
*-rgt-identity82.6%
distribute-lft-out--82.6%
expm1-define98.7%
Simplified98.7%
Final simplification98.7%
(FPCore (x y z t) :precision binary64 (if (<= (exp z) 0.0002) (- x (/ y (/ t (expm1 z)))) (- 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.0002) {
tmp = x - (y / (t / expm1(z)));
} 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.0002) {
tmp = x - (y / (t / Math.expm1(z)));
} 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.0002: tmp = x - (y / (t / math.expm1(z))) 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.0002) tmp = Float64(x - Float64(y / Float64(t / expm1(z)))); 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.0002], N[(x - N[(y / N[(t / N[(Exp[z] - 1), $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.0002:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\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) < 2.0000000000000001e-4Initial program 76.2%
Taylor expanded in y around 0 77.5%
associate-/l*77.4%
expm1-define77.4%
Simplified77.4%
clear-num77.4%
un-div-inv77.5%
Applied egg-rr77.5%
if 2.0000000000000001e-4 < (exp.f64 z) Initial program 48.5%
associate-+l-74.5%
sub-neg74.5%
log1p-define74.5%
neg-sub074.5%
associate-+l-74.5%
neg-sub074.5%
+-commutative74.5%
unsub-neg74.5%
*-rgt-identity74.5%
distribute-lft-out--74.5%
expm1-define98.1%
Simplified98.1%
Taylor expanded in z around 0 98.7%
Final simplification92.0%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2.1e+213) (not (<= y 1.3e+113))) (- x (/ (log (+ (* y z) 1.0)) t)) (- x (/ y (/ t (expm1 z))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2.1e+213) || !(y <= 1.3e+113)) {
tmp = x - (log(((y * z) + 1.0)) / t);
} 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.1e+213) || !(y <= 1.3e+113)) {
tmp = x - (Math.log(((y * z) + 1.0)) / t);
} else {
tmp = x - (y / (t / Math.expm1(z)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2.1e+213) or not (y <= 1.3e+113): tmp = x - (math.log(((y * z) + 1.0)) / t) else: tmp = x - (y / (t / math.expm1(z))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2.1e+213) || !(y <= 1.3e+113)) tmp = Float64(x - Float64(log(Float64(Float64(y * z) + 1.0)) / t)); else tmp = Float64(x - Float64(y / Float64(t / expm1(z)))); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2.1e+213], N[Not[LessEqual[y, 1.3e+113]], $MachinePrecision]], N[(x - N[(N[Log[N[(N[(y * z), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision] / t), $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.1 \cdot 10^{+213} \lor \neg \left(y \leq 1.3 \cdot 10^{+113}\right):\\
\;\;\;\;x - \frac{\log \left(y \cdot z + 1\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}\\
\end{array}
\end{array}
if y < -2.1000000000000001e213 or 1.3e113 < y Initial program 15.2%
Taylor expanded in z around 0 81.3%
if -2.1000000000000001e213 < y < 1.3e113Initial program 66.0%
Taylor expanded in y around 0 80.9%
associate-/l*80.9%
expm1-define92.1%
Simplified92.1%
clear-num92.1%
un-div-inv92.1%
Applied egg-rr92.1%
Final simplification90.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (/ -1.0 (/ (+ (* -0.5 (/ (* z t) y)) (/ t y)) z)))))
(if (<= z -9.2e+254)
t_1
(if (<= z -3.7e+198)
(* y (/ (expm1 z) (- t)))
(if (<= z -5e-211) t_1 (+ x (* (* y z) (/ -1.0 t))))))))
double code(double x, double y, double z, double t) {
double t_1 = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z));
double tmp;
if (z <= -9.2e+254) {
tmp = t_1;
} else if (z <= -3.7e+198) {
tmp = y * (expm1(z) / -t);
} else if (z <= -5e-211) {
tmp = t_1;
} else {
tmp = x + ((y * z) * (-1.0 / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z));
double tmp;
if (z <= -9.2e+254) {
tmp = t_1;
} else if (z <= -3.7e+198) {
tmp = y * (Math.expm1(z) / -t);
} else if (z <= -5e-211) {
tmp = t_1;
} else {
tmp = x + ((y * z) * (-1.0 / t));
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z)) tmp = 0 if z <= -9.2e+254: tmp = t_1 elif z <= -3.7e+198: tmp = y * (math.expm1(z) / -t) elif z <= -5e-211: tmp = t_1 else: tmp = x + ((y * z) * (-1.0 / t)) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(-1.0 / Float64(Float64(Float64(-0.5 * Float64(Float64(z * t) / y)) + Float64(t / y)) / z))) tmp = 0.0 if (z <= -9.2e+254) tmp = t_1; elseif (z <= -3.7e+198) tmp = Float64(y * Float64(expm1(z) / Float64(-t))); elseif (z <= -5e-211) tmp = t_1; else tmp = Float64(x + Float64(Float64(y * z) * Float64(-1.0 / t))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(-1.0 / N[(N[(N[(-0.5 * N[(N[(z * t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(t / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9.2e+254], t$95$1, If[LessEqual[z, -3.7e+198], N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / (-t)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -5e-211], t$95$1, N[(x + N[(N[(y * z), $MachinePrecision] * N[(-1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{-1}{\frac{-0.5 \cdot \frac{z \cdot t}{y} + \frac{t}{y}}{z}}\\
\mathbf{if}\;z \leq -9.2 \cdot 10^{+254}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -3.7 \cdot 10^{+198}:\\
\;\;\;\;y \cdot \frac{\mathsf{expm1}\left(z\right)}{-t}\\
\mathbf{elif}\;z \leq -5 \cdot 10^{-211}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \frac{-1}{t}\\
\end{array}
\end{array}
if z < -9.19999999999999994e254 or -3.6999999999999998e198 < z < -5.0000000000000002e-211Initial program 63.1%
Taylor expanded in y around 0 74.8%
associate-/l*74.8%
expm1-define84.5%
Simplified84.5%
associate-*r/84.2%
clear-num84.2%
Applied egg-rr84.2%
Taylor expanded in z around 0 76.0%
if -9.19999999999999994e254 < z < -3.6999999999999998e198Initial program 51.8%
Taylor expanded in y around 0 66.6%
associate-/l*66.4%
expm1-define66.4%
Simplified66.4%
Taylor expanded in x around 0 60.0%
associate-*r/60.0%
expm1-define60.0%
neg-mul-160.0%
distribute-rgt-neg-in60.0%
associate-/l*59.8%
distribute-neg-frac59.8%
distribute-neg-frac259.8%
Simplified59.8%
if -5.0000000000000002e-211 < z Initial program 51.6%
associate-+l-77.2%
sub-neg77.2%
log1p-define77.2%
neg-sub077.2%
associate-+l-77.2%
neg-sub077.2%
+-commutative77.2%
unsub-neg77.2%
*-rgt-identity77.2%
distribute-lft-out--77.2%
expm1-define97.6%
Simplified97.6%
clear-num97.6%
associate-/r/97.6%
Applied egg-rr97.6%
add-cube-cbrt97.3%
pow397.3%
Applied egg-rr97.3%
Taylor expanded in z around 0 89.3%
Final simplification81.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (/ -1.0 (/ (+ (* -0.5 (/ (* z t) y)) (/ t y)) z)))))
(if (<= z -9.2e+254)
t_1
(if (<= z -3.7e+198)
(* (expm1 z) (/ y (- t)))
(if (<= z -4.7e-211) t_1 (+ x (* (* y z) (/ -1.0 t))))))))
double code(double x, double y, double z, double t) {
double t_1 = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z));
double tmp;
if (z <= -9.2e+254) {
tmp = t_1;
} else if (z <= -3.7e+198) {
tmp = expm1(z) * (y / -t);
} else if (z <= -4.7e-211) {
tmp = t_1;
} else {
tmp = x + ((y * z) * (-1.0 / t));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z));
double tmp;
if (z <= -9.2e+254) {
tmp = t_1;
} else if (z <= -3.7e+198) {
tmp = Math.expm1(z) * (y / -t);
} else if (z <= -4.7e-211) {
tmp = t_1;
} else {
tmp = x + ((y * z) * (-1.0 / t));
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z)) tmp = 0 if z <= -9.2e+254: tmp = t_1 elif z <= -3.7e+198: tmp = math.expm1(z) * (y / -t) elif z <= -4.7e-211: tmp = t_1 else: tmp = x + ((y * z) * (-1.0 / t)) return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(-1.0 / Float64(Float64(Float64(-0.5 * Float64(Float64(z * t) / y)) + Float64(t / y)) / z))) tmp = 0.0 if (z <= -9.2e+254) tmp = t_1; elseif (z <= -3.7e+198) tmp = Float64(expm1(z) * Float64(y / Float64(-t))); elseif (z <= -4.7e-211) tmp = t_1; else tmp = Float64(x + Float64(Float64(y * z) * Float64(-1.0 / t))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(-1.0 / N[(N[(N[(-0.5 * N[(N[(z * t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(t / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -9.2e+254], t$95$1, If[LessEqual[z, -3.7e+198], N[(N[(Exp[z] - 1), $MachinePrecision] * N[(y / (-t)), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -4.7e-211], t$95$1, N[(x + N[(N[(y * z), $MachinePrecision] * N[(-1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \frac{-1}{\frac{-0.5 \cdot \frac{z \cdot t}{y} + \frac{t}{y}}{z}}\\
\mathbf{if}\;z \leq -9.2 \cdot 10^{+254}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -3.7 \cdot 10^{+198}:\\
\;\;\;\;\mathsf{expm1}\left(z\right) \cdot \frac{y}{-t}\\
\mathbf{elif}\;z \leq -4.7 \cdot 10^{-211}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \frac{-1}{t}\\
\end{array}
\end{array}
if z < -9.19999999999999994e254 or -3.6999999999999998e198 < z < -4.6999999999999997e-211Initial program 63.1%
Taylor expanded in y around 0 74.8%
associate-/l*74.8%
expm1-define84.5%
Simplified84.5%
associate-*r/84.2%
clear-num84.2%
Applied egg-rr84.2%
Taylor expanded in z around 0 76.0%
if -9.19999999999999994e254 < z < -3.6999999999999998e198Initial program 51.8%
Taylor expanded in y around 0 66.6%
associate-/l*66.4%
expm1-define66.4%
Simplified66.4%
Taylor expanded in x around 0 60.0%
associate-*r/60.0%
expm1-define60.0%
neg-mul-160.0%
distribute-frac-neg60.0%
*-commutative60.0%
associate-*r/60.0%
distribute-rgt-neg-in60.0%
Simplified60.0%
if -4.6999999999999997e-211 < z Initial program 51.6%
associate-+l-77.2%
sub-neg77.2%
log1p-define77.2%
neg-sub077.2%
associate-+l-77.2%
neg-sub077.2%
+-commutative77.2%
unsub-neg77.2%
*-rgt-identity77.2%
distribute-lft-out--77.2%
expm1-define97.6%
Simplified97.6%
clear-num97.6%
associate-/r/97.6%
Applied egg-rr97.6%
add-cube-cbrt97.3%
pow397.3%
Applied egg-rr97.3%
Taylor expanded in z around 0 89.3%
Final simplification81.2%
(FPCore (x y z t) :precision binary64 (- x (* y (/ (expm1 z) t))))
double code(double x, double y, double z, double t) {
return x - (y * (expm1(z) / t));
}
public static double code(double x, double y, double z, double t) {
return x - (y * (Math.expm1(z) / t));
}
def code(x, y, z, t): return x - (y * (math.expm1(z) / t))
function code(x, y, z, t) return Float64(x - Float64(y * Float64(expm1(z) / t))) end
code[x_, y_, z_, t_] := N[(x - N[(y * N[(N[(Exp[z] - 1), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - y \cdot \frac{\mathsf{expm1}\left(z\right)}{t}
\end{array}
Initial program 57.3%
Taylor expanded in y around 0 75.5%
associate-/l*75.4%
expm1-define85.6%
Simplified85.6%
Final simplification85.6%
(FPCore (x y z t) :precision binary64 (- x (/ y (/ t (expm1 z)))))
double code(double x, double y, double z, double t) {
return x - (y / (t / expm1(z)));
}
public static double code(double x, double y, double z, double t) {
return x - (y / (t / Math.expm1(z)));
}
def code(x, y, z, t): return x - (y / (t / math.expm1(z)))
function code(x, y, z, t) return Float64(x - Float64(y / Float64(t / expm1(z)))) end
code[x_, y_, z_, t_] := N[(x - N[(y / N[(t / N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y}{\frac{t}{\mathsf{expm1}\left(z\right)}}
\end{array}
Initial program 57.3%
Taylor expanded in y around 0 75.5%
associate-/l*75.4%
expm1-define85.6%
Simplified85.6%
clear-num85.6%
un-div-inv85.7%
Applied egg-rr85.7%
Final simplification85.7%
(FPCore (x y z t) :precision binary64 (if (<= z -5e-211) (+ x (/ -1.0 (/ (+ (* -0.5 (/ (* z t) y)) (/ t y)) z))) (+ x (* (* y z) (/ -1.0 t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -5e-211) {
tmp = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z));
} else {
tmp = x + ((y * z) * (-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 <= (-5d-211)) then
tmp = x + ((-1.0d0) / ((((-0.5d0) * ((z * t) / y)) + (t / y)) / z))
else
tmp = x + ((y * z) * ((-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 <= -5e-211) {
tmp = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z));
} else {
tmp = x + ((y * z) * (-1.0 / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -5e-211: tmp = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z)) else: tmp = x + ((y * z) * (-1.0 / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -5e-211) tmp = Float64(x + Float64(-1.0 / Float64(Float64(Float64(-0.5 * Float64(Float64(z * t) / y)) + Float64(t / y)) / z))); else tmp = Float64(x + Float64(Float64(y * z) * Float64(-1.0 / t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -5e-211) tmp = x + (-1.0 / (((-0.5 * ((z * t) / y)) + (t / y)) / z)); else tmp = x + ((y * z) * (-1.0 / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -5e-211], N[(x + N[(-1.0 / N[(N[(N[(-0.5 * N[(N[(z * t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(t / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * z), $MachinePrecision] * N[(-1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-211}:\\
\;\;\;\;x + \frac{-1}{\frac{-0.5 \cdot \frac{z \cdot t}{y} + \frac{t}{y}}{z}}\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \frac{-1}{t}\\
\end{array}
\end{array}
if z < -5.0000000000000002e-211Initial program 62.0%
Taylor expanded in y around 0 74.0%
associate-/l*73.9%
expm1-define82.7%
Simplified82.7%
associate-*r/82.5%
clear-num82.4%
Applied egg-rr82.4%
Taylor expanded in z around 0 70.8%
if -5.0000000000000002e-211 < z Initial program 51.6%
associate-+l-77.2%
sub-neg77.2%
log1p-define77.2%
neg-sub077.2%
associate-+l-77.2%
neg-sub077.2%
+-commutative77.2%
unsub-neg77.2%
*-rgt-identity77.2%
distribute-lft-out--77.2%
expm1-define97.6%
Simplified97.6%
clear-num97.6%
associate-/r/97.6%
Applied egg-rr97.6%
add-cube-cbrt97.3%
pow397.3%
Applied egg-rr97.3%
Taylor expanded in z around 0 89.3%
Final simplification79.2%
(FPCore (x y z t) :precision binary64 (if (<= t -1.7e-249) x (if (<= t 6.4e-261) (* (/ z t) (- y)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.7e-249) {
tmp = x;
} else if (t <= 6.4e-261) {
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.7d-249)) then
tmp = x
else if (t <= 6.4d-261) 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.7e-249) {
tmp = x;
} else if (t <= 6.4e-261) {
tmp = (z / t) * -y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.7e-249: tmp = x elif t <= 6.4e-261: tmp = (z / t) * -y else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.7e-249) tmp = x; elseif (t <= 6.4e-261) 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.7e-249) tmp = x; elseif (t <= 6.4e-261) tmp = (z / t) * -y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.7e-249], x, If[LessEqual[t, 6.4e-261], N[(N[(z / t), $MachinePrecision] * (-y)), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.7 \cdot 10^{-249}:\\
\;\;\;\;x\\
\mathbf{elif}\;t \leq 6.4 \cdot 10^{-261}:\\
\;\;\;\;\frac{z}{t} \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if t < -1.6999999999999999e-249 or 6.40000000000000008e-261 < t Initial program 59.7%
associate-+l-78.9%
sub-neg78.9%
log1p-define86.1%
neg-sub086.1%
associate-+l-86.1%
neg-sub086.1%
+-commutative86.1%
unsub-neg86.1%
*-rgt-identity86.1%
distribute-lft-out--86.1%
expm1-define98.9%
Simplified98.9%
Taylor expanded in x around inf 73.2%
if -1.6999999999999999e-249 < t < 6.40000000000000008e-261Initial program 24.5%
associate-+l-24.3%
sub-neg24.3%
log1p-define35.2%
neg-sub035.2%
associate-+l-35.2%
neg-sub035.2%
+-commutative35.2%
unsub-neg35.2%
*-rgt-identity35.2%
distribute-lft-out--35.2%
expm1-define95.6%
Simplified95.6%
Taylor expanded in x around 0 18.7%
mul-1-neg18.7%
log1p-define29.5%
expm1-define90.2%
distribute-frac-neg290.2%
Simplified90.2%
Taylor expanded in z around 0 59.4%
mul-1-neg59.4%
associate-/l*63.5%
distribute-rgt-neg-in63.5%
Simplified63.5%
Final simplification72.5%
(FPCore (x y z t) :precision binary64 (if (<= z -2.85e+86) x (- x (* y (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.85e+86) {
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.85d+86)) 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.85e+86) {
tmp = x;
} else {
tmp = x - (y * (z / t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.85e+86: tmp = x else: tmp = x - (y * (z / t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.85e+86) 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.85e+86) tmp = x; else tmp = x - (y * (z / t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.85e+86], x, N[(x - N[(y * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.85 \cdot 10^{+86}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{z}{t}\\
\end{array}
\end{array}
if z < -2.85e86Initial program 72.2%
associate-+l-72.2%
sub-neg72.2%
log1p-define99.9%
neg-sub099.9%
associate-+l-99.9%
neg-sub099.9%
+-commutative99.9%
unsub-neg99.9%
*-rgt-identity99.9%
distribute-lft-out--99.9%
expm1-define99.9%
Simplified99.9%
Taylor expanded in x around inf 49.4%
if -2.85e86 < z Initial program 53.5%
Taylor expanded in z around 0 85.8%
associate-/l*85.9%
Simplified85.9%
Final simplification78.5%
(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 57.3%
associate-+l-75.1%
sub-neg75.1%
log1p-define82.6%
neg-sub082.6%
associate-+l-82.6%
neg-sub082.6%
+-commutative82.6%
unsub-neg82.6%
*-rgt-identity82.6%
distribute-lft-out--82.6%
expm1-define98.7%
Simplified98.7%
Taylor expanded in x around inf 68.6%
Final simplification68.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 2024078
(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)))