Average Error: 0.0 → 0.0
Time: 9.1s
Precision: 64
\[\left(x + y\right) \cdot \left(x + y\right)\]
\[y \cdot \mathsf{fma}\left(x, 2, y\right) + x \cdot x\]
\left(x + y\right) \cdot \left(x + y\right)
y \cdot \mathsf{fma}\left(x, 2, y\right) + x \cdot x
double f(double x, double y) {
        double r352920 = x;
        double r352921 = y;
        double r352922 = r352920 + r352921;
        double r352923 = r352922 * r352922;
        return r352923;
}

double f(double x, double y) {
        double r352924 = y;
        double r352925 = x;
        double r352926 = 2.0;
        double r352927 = fma(r352925, r352926, r352924);
        double r352928 = r352924 * r352927;
        double r352929 = r352925 * r352925;
        double r352930 = r352928 + r352929;
        return r352930;
}

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(x, 2, y\right), x \cdot x\right)}\]
  4. Using strategy rm
  5. Applied fma-udef0.0

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

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

Reproduce

herbie shell --seed 2019304 +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)))