Average Error: 0.0 → 0.0
Time: 956.0ms
Precision: 64
\[a \cdot a - b \cdot b\]
\[\mathsf{fma}\left(a \cdot 1, a, -b \cdot b\right)\]
a \cdot a - b \cdot b
\mathsf{fma}\left(a \cdot 1, 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 * 1.0), a, -(b * b));
}

Error

Bits error versus a

Bits error versus b

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.0
Target0.0
Herbie0.0
\[\left(a + b\right) \cdot \left(a - b\right)\]

Derivation

  1. Initial program 0.0

    \[a \cdot a - b \cdot b\]
  2. Using strategy rm
  3. Applied *-un-lft-identity0.0

    \[\leadsto a \cdot \color{blue}{\left(1 \cdot a\right)} - b \cdot b\]
  4. Applied associate-*r*0.0

    \[\leadsto \color{blue}{\left(a \cdot 1\right) \cdot a} - b \cdot b\]
  5. Applied fma-neg0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(a \cdot 1, a, -b \cdot b\right)}\]
  6. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(a \cdot 1, a, -b \cdot b\right)\]

Reproduce

herbie shell --seed 2020066 +o rules:numerics
(FPCore (a b)
  :name "Difference of squares"
  :precision binary64

  :herbie-target
  (* (+ a b) (- a b))

  (- (* a a) (* b b)))