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




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.3 |
|---|---|
| Target | 0.4 |
| Herbie | 0.2 |
if x < -3.1371785873879285e55Initial program 31.8
Simplified31.8
Taylor expanded in y around 0 9.6
Simplified0.1
Taylor expanded in x around 0 0.1
Applied *-un-lft-identity_binary640.1
Applied distribute-rgt-out--_binary640.1
Simplified0.1
if -3.1371785873879285e55 < x < 1.92496341874612876e-34Initial program 0.5
Simplified0.5
Taylor expanded in x around 0 0.5
Simplified0.2
if 1.92496341874612876e-34 < x Initial program 23.4
Simplified23.4
Taylor expanded in y around 0 7.6
Simplified0.1
Taylor expanded in x around 0 0.2
Final simplification0.2
herbie shell --seed 2021275
(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))