x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;y \leq 7.250583755579476 \cdot 10^{-37} \lor \neg \left(y \leq 5.5740362056955766 \cdot 10^{+222}\right):\\
\;\;\;\;x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(x \cdot z\right) \cdot \left(y - 1\right)\\
\end{array}(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z) :precision binary64 (if (or (<= y 7.250583755579476e-37) (not (<= y 5.5740362056955766e+222))) (* x (- 1.0 (* (- 1.0 y) z))) (+ x (* (* x z) (- y 1.0)))))
double code(double x, double y, double z) {
return x * (1.0 - ((1.0 - y) * z));
}
double code(double x, double y, double z) {
double tmp;
if ((y <= 7.250583755579476e-37) || !(y <= 5.5740362056955766e+222)) {
tmp = x * (1.0 - ((1.0 - y) * z));
} else {
tmp = x + ((x * z) * (y - 1.0));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 3.2 |
|---|---|
| Target | 0.3 |
| Herbie | 2.6 |
if y < 7.25058375557947622e-37 or 5.5740362056955766e222 < y Initial program 2.8
if 7.25058375557947622e-37 < y < 5.5740362056955766e222Initial program 4.6
rmApplied sub-neg_binary644.6
Applied distribute-rgt-in_binary644.6
Simplified4.6
Simplified4.6
rmApplied *-un-lft-identity_binary644.6
Applied distribute-rgt-out--_binary644.6
Applied associate-*r*_binary641.5
Final simplification2.6
herbie shell --seed 2020288
(FPCore (x y z)
:name "Data.Colour.RGBSpace.HSV:hsv from colour-2.3.3, J"
:precision binary64
:herbie-target
(if (< (* x (- 1.0 (* (- 1.0 y) z))) -1.618195973607049e+50) (+ x (* (- 1.0 y) (* (- z) x))) (if (< (* x (- 1.0 (* (- 1.0 y) z))) 3.892237649663903e+134) (- (* (* x y) z) (- (* x z) x)) (+ x (* (- 1.0 y) (* (- z) x)))))
(* x (- 1.0 (* (- 1.0 y) z))))