\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(x \cdot y + z\right)\right)\begin{array}{l}
\mathbf{if}\;\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(z + x \cdot y\right)\right) \leq -1:\\
\;\;\;\;\mathsf{fma}\left(x, y, z\right) - \left(1 + \left(z + x \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(\mathsf{fma}\left(x, y, z\right) + z \cdot \sqrt[3]{-1}\right)\\
\end{array}(FPCore (x y z) :precision binary64 (- (fma x y z) (+ 1.0 (+ (* x y) z))))
(FPCore (x y z) :precision binary64 (if (<= (- (fma x y z) (+ 1.0 (+ z (* x y)))) -1.0) (- (fma x y z) (+ 1.0 (+ z (* x y)))) (+ -1.0 (+ (fma x y z) (* z (cbrt -1.0))))))
double code(double x, double y, double z) {
return fma(x, y, z) - (1.0 + ((x * y) + z));
}
double code(double x, double y, double z) {
double tmp;
if ((fma(x, y, z) - (1.0 + (z + (x * y)))) <= -1.0) {
tmp = fma(x, y, z) - (1.0 + (z + (x * y)));
} else {
tmp = -1.0 + (fma(x, y, z) + (z * cbrt(-1.0)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z
| Original | 45.3 |
|---|---|
| Target | 0 |
| Herbie | 24.5 |
if (-.f64 (fma.f64 x y z) (+.f64 1 (+.f64 (*.f64 x y) z))) < -1Initial program 0.3
if -1 < (-.f64 (fma.f64 x y z) (+.f64 1 (+.f64 (*.f64 x y) z))) Initial program 62.1
rmApplied add-cube-cbrt_binary64_250062.1
Simplified62.1
Simplified62.1
Taylor expanded around inf 63.3
Simplified62.2
Taylor expanded around -inf 33.5
Final simplification24.5
herbie shell --seed 2021098
(FPCore (x y z)
:name "simple fma test"
:precision binary64
:herbie-target
-1.0
(- (fma x y z) (+ 1.0 (+ (* x y) z))))