a \cdot a - b \cdot b
\mathsf{fma}\left(a, a, -b \cdot b\right) + \mathsf{fma}\left(-b, b, b \cdot b\right)
(FPCore (a b) :precision binary64 (- (* a a) (* b b)))
(FPCore (a b) :precision binary64 (+ (fma a a (- (* b b))) (fma (- b) b (* b b))))
double code(double a, double b) {
return (a * a) - (b * b);
}
double code(double a, double b) {
return fma(a, a, -(b * b)) + fma(-b, b, (b * b));
}




Bits error versus a




Bits error versus b
| Original | 0.0 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 0.0
Applied prod-diff_binary640.0
Final simplification0.0
herbie shell --seed 2022076
(FPCore (a b)
:name "Difference of squares"
:precision binary64
:herbie-target
(* (+ a b) (- a b))
(- (* a a) (* b b)))