\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\begin{array}{l}
t_0 := \left(\frac{x}{z} + x \cdot \frac{y}{z}\right) - x\\
\mathbf{if}\;z \leq -1.3894035698836182 \cdot 10^{-28}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.1269081990223642 \cdot 10^{+44}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z} - x\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (+ (/ x z) (* x (/ y z))) x)))
(if (<= z -1.3894035698836182e-28)
t_0
(if (<= z 1.1269081990223642e+44) (- (/ (fma y x x) z) x) t_0))))double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
double code(double x, double y, double z) {
double t_0 = ((x / z) + (x * (y / z))) - x;
double tmp;
if (z <= -1.3894035698836182e-28) {
tmp = t_0;
} else if (z <= 1.1269081990223642e+44) {
tmp = (fma(y, x, x) / z) - x;
} else {
tmp = t_0;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.2 |
|---|---|
| Target | 0.4 |
| Herbie | 0.2 |
if z < -1.38940356988361817e-28 or 1.12690819902236419e44 < z Initial program 17.1
Simplified17.1
Taylor expanded in x around 0 17.1
Simplified5.5
Taylor expanded in x around 0 0.1
Applied add-cube-cbrt_binary641.4
Taylor expanded in y around 0 5.5
Simplified0.1
if -1.38940356988361817e-28 < z < 1.12690819902236419e44Initial program 0.4
Simplified0.4
Taylor expanded in x around 0 0.4
Simplified0.2
Final simplification0.2
herbie shell --seed 2022077
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
: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))