(FPCore (x y z t) :precision binary64 (- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ (log1p (* y (expm1 z))) t))))
(if (<= z -6.255462246592998e-193)
t_1
(if (<= z 1.0409400238575313e-194) (- x (/ y (/ t z))) t_1))))double code(double x, double y, double z, double t) {
return x - (log(((1.0 - y) + (y * exp(z)))) / t);
}
double code(double x, double y, double z, double t) {
double t_1 = x - (log1p((y * expm1(z))) / t);
double tmp;
if (z <= -6.255462246592998e-193) {
tmp = t_1;
} else if (z <= 1.0409400238575313e-194) {
tmp = x - (y / (t / z));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
return x - (Math.log(((1.0 - y) + (y * Math.exp(z)))) / t);
}
public static double code(double x, double y, double z, double t) {
double t_1 = x - (Math.log1p((y * Math.expm1(z))) / t);
double tmp;
if (z <= -6.255462246592998e-193) {
tmp = t_1;
} else if (z <= 1.0409400238575313e-194) {
tmp = x - (y / (t / z));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): return x - (math.log(((1.0 - y) + (y * math.exp(z)))) / t)
def code(x, y, z, t): t_1 = x - (math.log1p((y * math.expm1(z))) / t) tmp = 0 if z <= -6.255462246592998e-193: tmp = t_1 elif z <= 1.0409400238575313e-194: tmp = x - (y / (t / z)) else: tmp = t_1 return tmp
function code(x, y, z, t) return Float64(x - Float64(log(Float64(Float64(1.0 - y) + Float64(y * exp(z)))) / t)) end
function code(x, y, z, t) t_1 = Float64(x - Float64(log1p(Float64(y * expm1(z))) / t)) tmp = 0.0 if (z <= -6.255462246592998e-193) tmp = t_1; elseif (z <= 1.0409400238575313e-194) tmp = Float64(x - Float64(y / Float64(t / z))); else tmp = t_1; end return tmp 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]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(N[Log[1 + N[(y * N[(Exp[z] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.255462246592998e-193], t$95$1, If[LessEqual[z, 1.0409400238575313e-194], N[(x - N[(y / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}
\begin{array}{l}
t_1 := x - \frac{\mathsf{log1p}\left(y \cdot \mathsf{expm1}\left(z\right)\right)}{t}\\
\mathbf{if}\;z \leq -6.255462246592998 \cdot 10^{-193}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 1.0409400238575313 \cdot 10^{-194}:\\
\;\;\;\;x - \frac{y}{\frac{t}{z}}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
Results
| Original | 24.6 |
|---|---|
| Target | 15.8 |
| Herbie | 1.4 |
if z < -6.255462246592998e-193 or 1.0409400238575313e-194 < z Initial program 22.4
Simplified0.9
if -6.255462246592998e-193 < z < 1.0409400238575313e-194Initial program 30.4
Simplified1.1
Applied egg-rr6.0
Taylor expanded in z around 0 3.1
Simplified2.6
Final simplification1.4
herbie shell --seed 2022150
(FPCore (x y z t)
:name "System.Random.MWC.Distributions:truncatedExp from mwc-random-0.13.3.2"
:precision binary64
:herbie-target
(if (< z -2.8874623088207947e+119) (- (- x (/ (/ (- 0.5) (* y t)) (* z z))) (* (/ (- 0.5) (* y t)) (/ (/ 2.0 z) (* z z)))) (- x (/ (log (+ 1.0 (* z y))) t)))
(- x (/ (log (+ (- 1.0 y) (* y (exp z)))) t)))