Average Error: 0.0 → 0.0
Time: 8.0s
Precision: 64
\[\left(x + y\right) \cdot \left(x + y\right)\]
\[\mathsf{fma}\left(y, 2 \cdot x, \mathsf{fma}\left(x, x, y \cdot y\right)\right)\]
\left(x + y\right) \cdot \left(x + y\right)
\mathsf{fma}\left(y, 2 \cdot x, \mathsf{fma}\left(x, x, y \cdot y\right)\right)
double f(double x, double y) {
        double r32537917 = x;
        double r32537918 = y;
        double r32537919 = r32537917 + r32537918;
        double r32537920 = r32537919 * r32537919;
        return r32537920;
}

double f(double x, double y) {
        double r32537921 = y;
        double r32537922 = 2.0;
        double r32537923 = x;
        double r32537924 = r32537922 * r32537923;
        double r32537925 = r32537921 * r32537921;
        double r32537926 = fma(r32537923, r32537923, r32537925);
        double r32537927 = fma(r32537921, r32537924, r32537926);
        return r32537927;
}

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}{{y}^{2} + \left({x}^{2} + 2 \cdot \left(x \cdot y\right)\right)}\]
  3. Simplified0.0

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

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

Reproduce

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

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

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