Average Error: 0.0 → 0.0
Time: 8.0s
Precision: 64
\[\left(x + y\right) \cdot \left(x + y\right)\]
\[\mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), {x}^{2}\right)\]
\left(x + y\right) \cdot \left(x + y\right)
\mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), {x}^{2}\right)
double f(double x, double y) {
        double r732922 = x;
        double r732923 = y;
        double r732924 = r732922 + r732923;
        double r732925 = r732924 * r732924;
        return r732925;
}

double f(double x, double y) {
        double r732926 = y;
        double r732927 = 2.0;
        double r732928 = x;
        double r732929 = fma(r732927, r732928, r732926);
        double r732930 = pow(r732928, r732927);
        double r732931 = fma(r732926, r732929, r732930);
        return r732931;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.0
Target0.0
Herbie0.0
\[x \cdot x + \left(y \cdot y + 2 \cdot \left(y \cdot x\right)\right)\]

Derivation

  1. Initial program 0.0

    \[\left(x + y\right) \cdot \left(x + y\right)\]
  2. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{{x}^{2} + \left({y}^{2} + 2 \cdot \left(x \cdot y\right)\right)}\]
  3. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), {x}^{2}\right)}\]
  4. Final simplification0.0

    \[\leadsto \mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), {x}^{2}\right)\]

Reproduce

herbie shell --seed 2020042 +o rules:numerics
(FPCore (x y)
  :name "Examples.Basics.BasicTests:f3 from sbv-4.4"
  :precision binary64

  :herbie-target
  (+ (* x x) (+ (* y y) (* 2 (* y x))))

  (* (+ x y) (+ x y)))