x - \frac{\log \left(\left(1 - y\right) + y \cdot e^{z}\right)}{t}\begin{array}{l}
\mathbf{if}\;z \le -6.310119903545574434291526250400899439411 \cdot 10^{-134}:\\
\;\;\;\;\mathsf{fma}\left(1, x, -\frac{\log \left(\mathsf{fma}\left(\mathsf{expm1}\left(z\right), y, 1\right)\right)}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1, x, -\frac{\mathsf{fma}\left(y, z \cdot \left(0.5 \cdot z + 1\right), \log 1\right)}{t}\right)\\
\end{array}double f(double x, double y, double z, double t) {
double r182778 = x;
double r182779 = 1.0;
double r182780 = y;
double r182781 = r182779 - r182780;
double r182782 = z;
double r182783 = exp(r182782);
double r182784 = r182780 * r182783;
double r182785 = r182781 + r182784;
double r182786 = log(r182785);
double r182787 = t;
double r182788 = r182786 / r182787;
double r182789 = r182778 - r182788;
return r182789;
}
double f(double x, double y, double z, double t) {
double r182790 = z;
double r182791 = -6.310119903545574e-134;
bool r182792 = r182790 <= r182791;
double r182793 = 1.0;
double r182794 = x;
double r182795 = expm1(r182790);
double r182796 = y;
double r182797 = 1.0;
double r182798 = fma(r182795, r182796, r182797);
double r182799 = log(r182798);
double r182800 = t;
double r182801 = r182799 / r182800;
double r182802 = -r182801;
double r182803 = fma(r182793, r182794, r182802);
double r182804 = 0.5;
double r182805 = r182804 * r182790;
double r182806 = r182805 + r182797;
double r182807 = r182790 * r182806;
double r182808 = log(r182797);
double r182809 = fma(r182796, r182807, r182808);
double r182810 = r182809 / r182800;
double r182811 = -r182810;
double r182812 = fma(r182793, r182794, r182811);
double r182813 = r182792 ? r182803 : r182812;
return r182813;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t
| Original | 24.6 |
|---|---|
| Target | 16.1 |
| Herbie | 8.4 |
if z < -6.310119903545574e-134Initial program 16.9
Simplified11.6
rmApplied div-inv11.6
rmApplied *-un-lft-identity11.6
Applied fma-neg11.6
Simplified11.6
if -6.310119903545574e-134 < z Initial program 30.4
Simplified11.2
rmApplied div-inv11.2
rmApplied *-un-lft-identity11.2
Applied fma-neg11.2
Simplified11.2
Taylor expanded around 0 6.0
Simplified6.0
Final simplification8.4
herbie shell --seed 2019323 +o rules:numerics
(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 z) (* z z)))) (- x (/ (log (+ 1 (* z y))) t)))
(- x (/ (log (+ (- 1 y) (* y (exp z)))) t)))