\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\begin{array}{l}
\mathbf{if}\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \leq -\infty:\\
\;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\
\mathbf{elif}\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z} \leq 4.457413215179628 \cdot 10^{-99}:\\
\;\;\;\;\left(\frac{x}{z} + \frac{x \cdot y}{z}\right) - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right) - x\\
\end{array}(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
(FPCore (x y z)
:precision binary64
(if (<= (/ (* x (+ (- y z) 1.0)) z) (- INFINITY))
(* x (/ (+ (- y z) 1.0) z))
(if (<= (/ (* x (+ (- y z) 1.0)) z) 4.457413215179628e-99)
(- (+ (/ x z) (/ (* x y) z)) x)
(- (* (/ x z) (+ y 1.0)) 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 * ((y - z) + 1.0)) / z) <= -((double) INFINITY)) {
tmp = x * (((y - z) + 1.0) / z);
} else if (((x * ((y - z) + 1.0)) / z) <= 4.457413215179628e-99) {
tmp = ((x / z) + ((x * y) / z)) - x;
} else {
tmp = ((x / z) * (y + 1.0)) - x;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.2 |
|---|---|
| Target | 0.5 |
| Herbie | 0.3 |
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -inf.0Initial program 64.0
rmApplied *-un-lft-identity_binary64_1405964.0
Applied times-frac_binary64_140650.0
if -inf.0 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 4.4574132151796279e-99Initial program 0.1
Taylor expanded around 0 0.1
if 4.4574132151796279e-99 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 13.0
Taylor expanded around 0 4.6
Simplified0.7
Taylor expanded around 0 4.3
Simplified0.7
Final simplification0.3
herbie shell --seed 2021059
(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))