\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\begin{array}{l}
\mathbf{if}\;y \leq 1.63726535631151 \cdot 10^{+93}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z} - x\\
\mathbf{elif}\;y \leq 4.786042295204834 \cdot 10^{+237}:\\
\;\;\;\;y \cdot \frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, y - z, x\right) \cdot \frac{1}{z}\\
\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z)
:precision binary64
(if (<= y 1.63726535631151e+93)
(- (/ (fma y x x) z) x)
(if (<= y 4.786042295204834e+237)
(- (* y (/ x z)) x)
(* (fma x (- y z) x) (/ 1.0 z)))))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 (y <= 1.63726535631151e+93) {
tmp = (fma(y, x, x) / z) - x;
} else if (y <= 4.786042295204834e+237) {
tmp = (y * (x / z)) - x;
} else {
tmp = fma(x, (y - z), x) * (1.0 / z);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.2 |
|---|---|
| Target | 0.5 |
| Herbie | 3.0 |
if y < 1.63726535631151e93Initial program 9.9
Simplified9.8
Applied egg-rr10.0
Taylor expanded in x around 0 9.9
Simplified2.3
if 1.63726535631151e93 < y < 4.78604229520483372e237Initial program 11.5
Simplified11.5
Applied egg-rr11.6
Taylor expanded in z around 0 8.8
Simplified8.7
Taylor expanded in y around inf 8.8
Simplified4.6
if 4.78604229520483372e237 < y Initial program 13.6
Simplified13.6
Applied egg-rr13.7
Final simplification3.0
herbie shell --seed 2022125
(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))