\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 -1.396857832934799 \cdot 10^{+108}:\\
\;\;\;\;\left(y + 1\right) \cdot \frac{x}{z} - x\\
\mathbf{elif}\;t_0 \leq 8.285899374516599 \cdot 10^{+269}:\\
\;\;\;\;\left(\frac{x}{z} + \frac{x \cdot y}{z}\right) - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\left(y + 1\right) - z}{z}\\
\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 -1.396857832934799e+108)
(- (* (+ y 1.0) (/ x z)) x)
(if (<= t_0 8.285899374516599e+269)
(- (+ (/ x z) (/ (* x y) z)) x)
(* x (/ (- (+ y 1.0) z) 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 t_0 = (x * ((y - z) + 1.0)) / z;
double tmp;
if (t_0 <= -1.396857832934799e+108) {
tmp = ((y + 1.0) * (x / z)) - x;
} else if (t_0 <= 8.285899374516599e+269) {
tmp = ((x / z) + ((x * y) / z)) - x;
} else {
tmp = x * (((y + 1.0) - z) / z);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 10.1 |
|---|---|
| Target | 0.4 |
| Herbie | 0.4 |
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < -1.3968578329347991e108Initial program 23.2
Taylor expanded in y around 0 8.2
Applied *-un-lft-identity_binary648.2
Applied times-frac_binary640.1
Applied distribute-lft1-in_binary640.1
Simplified0.1
if -1.3968578329347991e108 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 8.28589937451659909e269Initial program 0.1
Taylor expanded in y around 0 0.1
if 8.28589937451659909e269 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 51.7
Applied *-un-lft-identity_binary6451.7
Applied times-frac_binary643.7
Simplified3.7
Simplified3.7
Final simplification0.4
herbie shell --seed 2022081
(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))