x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;z \leq -8.392853027253622 \cdot 10^{+35}:\\
\;\;\;\;\left(z \cdot x\right) \cdot \left(y - 1\right)\\
\mathbf{elif}\;z \leq 5.443626847987299 \cdot 10^{-37}:\\
\;\;\;\;x + x \cdot \left(z \cdot y - z\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(z \cdot x\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 (<= z -8.392853027253622e+35)
(* (* z x) (- y 1.0))
(if (<= z 5.443626847987299e-37)
(+ x (* x (- (* z y) z)))
(+ 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 <= -8.392853027253622e+35) {
tmp = (z * x) * (y - 1.0);
} else if (z <= 5.443626847987299e-37) {
tmp = x + (x * ((z * y) - z));
} 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.5 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
| Alternative 1 | |
|---|---|
| Error | 0.3 |
| Cost | 1346 |
| Alternative 2 | |
|---|---|
| Error | 0.1 |
| Cost | 904 |
| Alternative 3 | |
|---|---|
| Error | 0.9 |
| Cost | 776 |
| Alternative 4 | |
|---|---|
| Error | 4.8 |
| Cost | 1097 |
| Alternative 5 | |
|---|---|
| Error | 12.2 |
| Cost | 913 |
| Alternative 6 | |
|---|---|
| Error | 19.1 |
| Cost | 320 |
| Alternative 7 | |
|---|---|
| Error | 33.4 |
| Cost | 64 |
| Alternative 8 | |
|---|---|
| Error | 61.8 |
| Cost | 64 |
| Alternative 9 | |
|---|---|
| Error | 61.9 |
| Cost | 64 |
| Alternative 10 | |
|---|---|
| Error | 61.8 |
| Cost | 64 |

if z < -8.3928530272536224e35Initial program 10.1
rmApplied sub-neg_binary64_2360010.1
Applied distribute-rgt-in_binary64_2355710.1
Simplified10.1
Simplified10.1
rmApplied *-un-lft-identity_binary64_2360710.1
Applied distribute-rgt-out--_binary64_2356110.1
Applied associate-*r*_binary64_235470.1
Taylor expanded around inf 0.1
Simplified0.1
Simplified0.1
if -8.3928530272536224e35 < z < 5.4436268479872988e-37Initial program 0.2
rmApplied sub-neg_binary64_236000.2
Applied distribute-rgt-in_binary64_235570.2
Simplified0.2
Simplified0.2
Simplified0.2
if 5.4436268479872988e-37 < z Initial program 7.6
rmApplied sub-neg_binary64_236007.6
Applied distribute-rgt-in_binary64_235577.6
Simplified7.6
Simplified7.6
rmApplied *-un-lft-identity_binary64_236077.6
Applied distribute-rgt-out--_binary64_235617.6
Applied associate-*r*_binary64_235470.2
Simplified0.2
Final simplification0.2
herbie shell --seed 2021044
(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))))