x \cdot \left(1 - \left(1 - y\right) \cdot z\right)
\begin{array}{l}
\mathbf{if}\;\begin{array}{l}
t_0 := x \cdot \left(1 - \left(1 - y\right) \cdot z\right)\\
t_0 \leq -2.6255077649920472 \cdot 10^{+213} \lor \neg \left(t_0 \leq 6.795679507506787 \cdot 10^{-67}\right)
\end{array}:\\
\;\;\;\;\mathsf{fma}\left(x \cdot z, y, x\right) - x \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\left(1 + y \cdot z\right) - z\right)\\
\end{array}
(FPCore (x y z) :precision binary64 (* x (- 1.0 (* (- 1.0 y) z))))
(FPCore (x y z)
:precision binary64
(if (let* ((t_0 (* x (- 1.0 (* (- 1.0 y) z)))))
(or (<= t_0 -2.6255077649920472e+213)
(not (<= t_0 6.795679507506787e-67))))
(- (fma (* x z) y x) (* x z))
(* x (- (+ 1.0 (* y z)) z))))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 = x * (1.0 - ((1.0 - y) * z));
double tmp;
if ((t_0 <= -2.6255077649920472e+213) || !(t_0 <= 6.795679507506787e-67)) {
tmp = fma((x * z), y, x) - (x * z);
} else {
tmp = x * ((1.0 + (y * z)) - z);
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 3.5 |
|---|---|
| Target | 0.3 |
| Herbie | 0.2 |
if (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < -2.6255077649920472e213 or 6.79567950750678696e-67 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) Initial program 7.3
Simplified7.3
Taylor expanded in y around 0 0.2
Taylor expanded in y around inf 0.2
Simplified0.3
if -2.6255077649920472e213 < (*.f64 x (-.f64 1 (*.f64 (-.f64 1 y) z))) < 6.79567950750678696e-67Initial program 0.1
Simplified0.1
Taylor expanded in y around 0 2.8
Taylor expanded in x around -inf 0.1
Final simplification0.2
herbie shell --seed 2021280
(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))))