a \cdot a - b \cdot b
\mathsf{fma}\left(a, a, -b \cdot b\right)double code(double a, double b) {
return ((a * a) - (b * b));
}
double code(double a, double b) {
return fma(a, a, -(b * b));
}




Bits error versus a




Bits error versus b
Results
| Original | 0.0 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 0.0
rmApplied fma-neg0.0
Final simplification0.0
herbie shell --seed 2020106 +o rules:numerics
(FPCore (a b)
:name "Difference of squares"
:precision binary64
:herbie-target
(* (+ a b) (- a b))
(- (* a a) (* b b)))