Average Error: 0.0 → 0.0
Time: 9.6s
Precision: 64
\[\left(x + y\right) \cdot \left(x + y\right)\]
\[\mathsf{fma}\left(y, y, x \cdot \left(x + y \cdot 2\right)\right)\]
\left(x + y\right) \cdot \left(x + y\right)
\mathsf{fma}\left(y, y, x \cdot \left(x + y \cdot 2\right)\right)
double f(double x, double y) {
        double r27832501 = x;
        double r27832502 = y;
        double r27832503 = r27832501 + r27832502;
        double r27832504 = r27832503 * r27832503;
        return r27832504;
}

double f(double x, double y) {
        double r27832505 = y;
        double r27832506 = x;
        double r27832507 = 2.0;
        double r27832508 = r27832505 * r27832507;
        double r27832509 = r27832506 + r27832508;
        double r27832510 = r27832506 * r27832509;
        double r27832511 = fma(r27832505, r27832505, r27832510);
        return r27832511;
}

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. Taylor expanded around 0 0.0

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

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

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

Reproduce

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