x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \leq -3.4347101080278726 \cdot 10^{+37}:\\
\;\;\;\;x + \left(y + -1\right) \cdot \left(z \cdot x\right)\\
\mathbf{elif}\;z \leq 9.036544996947276 \cdot 10^{-119}:\\
\;\;\;\;x + \left(x \cdot \left(z \cdot y\right) - z \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(x \cdot \left(y + -1\right)\right)\\
\end{array}(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
:precision binary64
(if (<= z -3.4347101080278726e+37)
(+ x (* (+ y -1.0) (* z x)))
(if (<= z 9.036544996947276e-119)
(+ x (- (* x (* z y)) (* z x)))
(+ x (* z (* x (+ 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 (z <= -3.4347101080278726e+37) {
tmp = x + ((y + -1.0) * (z * x));
} else if (z <= 9.036544996947276e-119) {
tmp = x + ((x * (z * y)) - (z * x));
} else {
tmp = x + (z * (x * (y + -1.0)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
Results
| Original | 3.7 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if z < -3.43471010802787256e37Initial program 11.3
Simplified0.1
if -3.43471010802787256e37 < z < 9.03654499694727634e-119Initial program 0.1
Simplified2.7
Taylor expanded around 0 0.1
if 9.03654499694727634e-119 < z Initial program 5.9
Simplified1.0
rmApplied associate-*r*_binary64_174090.7
Simplified0.7
Final simplification0.3
herbie shell --seed 2021176
(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))))