\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\begin{array}{l}
\mathbf{if}\;x \le -1.863929268284692307003518013897528112257 \cdot 10^{-90}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, 1, \frac{y}{z} \cdot x\right) - x\\
\mathbf{elif}\;x \le 1.076984167266228777802393156484664836043 \cdot 10^{-131}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, 1, \left(x \cdot y\right) \cdot \frac{1}{z}\right) - x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, 1, \frac{y}{z} \cdot x\right) - x\\
\end{array}double f(double x, double y, double z) {
double r25804363 = x;
double r25804364 = y;
double r25804365 = z;
double r25804366 = r25804364 - r25804365;
double r25804367 = 1.0;
double r25804368 = r25804366 + r25804367;
double r25804369 = r25804363 * r25804368;
double r25804370 = r25804369 / r25804365;
return r25804370;
}
double f(double x, double y, double z) {
double r25804371 = x;
double r25804372 = -1.8639292682846923e-90;
bool r25804373 = r25804371 <= r25804372;
double r25804374 = z;
double r25804375 = r25804371 / r25804374;
double r25804376 = 1.0;
double r25804377 = y;
double r25804378 = r25804377 / r25804374;
double r25804379 = r25804378 * r25804371;
double r25804380 = fma(r25804375, r25804376, r25804379);
double r25804381 = r25804380 - r25804371;
double r25804382 = 1.0769841672662288e-131;
bool r25804383 = r25804371 <= r25804382;
double r25804384 = r25804371 * r25804377;
double r25804385 = 1.0;
double r25804386 = r25804385 / r25804374;
double r25804387 = r25804384 * r25804386;
double r25804388 = fma(r25804375, r25804376, r25804387);
double r25804389 = r25804388 - r25804371;
double r25804390 = r25804383 ? r25804389 : r25804381;
double r25804391 = r25804373 ? r25804381 : r25804390;
return r25804391;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.2 |
|---|---|
| Target | 0.5 |
| Herbie | 0.6 |
if x < -1.8639292682846923e-90 or 1.0769841672662288e-131 < x Initial program 17.0
Taylor expanded around 0 5.9
Simplified0.2
rmApplied div-inv0.2
Applied associate-*l*1.0
Simplified1.0
if -1.8639292682846923e-90 < x < 1.0769841672662288e-131Initial program 0.2
Taylor expanded around 0 0.1
Simplified4.0
rmApplied div-inv4.0
Applied associate-*l*7.2
Simplified7.2
rmApplied div-inv7.2
Applied associate-*r*0.1
Final simplification0.6
herbie shell --seed 2019172 +o rules:numerics
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:herbie-target
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))