\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.7789192428595865 \cdot 10^{+287} \lor \neg \left(t_0 \leq 2.838894459478514 \cdot 10^{-52}\right)
\end{array}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, \frac{x}{z}\right) - x\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, 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.7789192428595865e+287)
(not (<= t_0 2.838894459478514e-52))))
(- (fma (/ x z) y (/ x z)) x)
(- (/ (fma x y 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.7789192428595865e+287) || !(t_0 <= 2.838894459478514e-52)) {
tmp = fma((x / z), y, (x / z)) - x;
} else {
tmp = (fma(x, y, x) / z) - x;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 10.1 |
|---|---|
| Target | 0.5 |
| Herbie | 0.2 |
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -4.77891924285958652e287 or 2.838894459478514e-52 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 23.3
Simplified23.3
Taylor expanded in y around 0 8.4
Simplified0.3
if -4.77891924285958652e287 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 2.838894459478514e-52Initial program 0.2
Simplified0.1
Taylor expanded in y around 0 0.1
Simplified3.1
Taylor expanded in x around 0 2.8
Applied pow1_binary642.8
Applied pow1_binary642.8
Applied pow-prod-down_binary642.8
Simplified0.1
Final simplification0.2
herbie shell --seed 2021274
(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))