x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
t_0 := \mathsf{fma}\left(y, z \cdot x, x\right) - z \cdot x\\
\mathbf{if}\;z \leq -8.795145312110055 \cdot 10^{+83}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.599520831582608 \cdot 10^{-73}:\\
\;\;\;\;x \cdot \left(\mathsf{fma}\left(y, z, 1\right) - z\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (fma y (* z x) x) (* z x))))
(if (<= z -8.795145312110055e+83)
t_0
(if (<= z 1.599520831582608e-73) (* x (- (fma y z 1.0) z)) t_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 t_0 = fma(y, (z * x), x) - (z * x);
double tmp;
if (z <= -8.795145312110055e+83) {
tmp = t_0;
} else if (z <= 1.599520831582608e-73) {
tmp = x * (fma(y, z, 1.0) - z);
} else {
tmp = t_0;
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 3.7 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if z < -8.7951453121100549e83 or 1.5995208315826081e-73 < z Initial program 9.0
Simplified9.0
Taylor expanded in y around 0 0.3
Applied fma-def_binary640.3
if -8.7951453121100549e83 < z < 1.5995208315826081e-73Initial program 0.3
Simplified0.3
Final simplification0.3
herbie shell --seed 2022088
(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))))