\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\begin{array}{l}
\mathbf{if}\;\begin{array}{l}
t_0 := \frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\
t_0 \leq -4.083961478419301 \cdot 10^{-70} \lor \neg \left(t_0 \leq 1.5305641720450072 \cdot 10^{+32}\right)
\end{array}:\\
\;\;\;\;\left(y + 1\right) \cdot \frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, x, x\right)}{z} - x\\
\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z)
:precision binary64
(if (let* ((t_0 (/ (* x (+ (- y z) 1.0)) z)))
(or (<= t_0 -4.083961478419301e-70)
(not (<= t_0 1.5305641720450072e+32))))
(- (* (+ y 1.0) (/ x z)) x)
(- (/ (fma y x x) 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 t_0 = (x * ((y - z) + 1.0)) / z;
double tmp;
if ((t_0 <= -4.083961478419301e-70) || !(t_0 <= 1.5305641720450072e+32)) {
tmp = ((y + 1.0) * (x / z)) - x;
} else {
tmp = (fma(y, x, x) / z) - x;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.0 |
|---|---|
| Target | 0.5 |
| Herbie | 0.2 |
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -4.08396147841930076e-70 or 1.5305641720450072e32 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 15.6
Simplified15.6
Taylor expanded in y around 0 5.5
Simplified0.2
Applied add-cube-cbrt_binary640.9
Taylor expanded in y around 0 5.5
Simplified0.2
if -4.08396147841930076e-70 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 1.5305641720450072e32Initial program 0.1
Simplified0.1
Taylor expanded in y around 0 0.1
Simplified3.7
Applied add-cube-cbrt_binary644.6
Applied add-cube-cbrt_binary645.0
Applied prod-diff_binary645.0
Simplified0.1
Simplified0.1
Final simplification0.2
herbie shell --seed 2022068
(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))