\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\begin{array}{l}
t_0 := \frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\sqrt{x} \cdot \left(\frac{y + 1}{z} \cdot \sqrt{x}\right) - x\\
\mathbf{elif}\;t_0 \leq 4.83290050337353 \cdot 10^{-84}:\\
\;\;\;\;\left(\frac{x \cdot y}{z} + \frac{x}{z}\right) - x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, \frac{x}{z}\right) - x\\
\end{array}
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x (+ (- y z) 1.0)) z)))
(if (<= t_0 (- INFINITY))
(- (* (sqrt x) (* (/ (+ y 1.0) z) (sqrt x))) x)
(if (<= t_0 4.83290050337353e-84)
(- (+ (/ (* x y) z) (/ x z)) x)
(- (fma (/ x z) 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 <= -((double) INFINITY)) {
tmp = (sqrt(x) * (((y + 1.0) / z) * sqrt(x))) - x;
} else if (t_0 <= 4.83290050337353e-84) {
tmp = (((x * y) / z) + (x / z)) - x;
} else {
tmp = fma((x / z), 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.5 |
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -inf.0Initial program 64.0
Simplified64.0
Taylor expanded in y around 0 22.2
Simplified0.1
Taylor expanded in x around 0 0.1
Applied add-sqr-sqrt_binary644.0
Applied associate-*r*_binary644.0
Simplified4.0
if -inf.0 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 4.83290050337353e-84Initial program 0.1
Simplified0.1
Taylor expanded in y around 0 0.1
if 4.83290050337353e-84 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 13.9
Simplified13.9
Taylor expanded in y around 0 4.7
Simplified0.5
Final simplification0.5
herbie shell --seed 2022039
(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))