Average Error: 0.0 → 0.0
Time: 27.9s
Precision: 64
\[\left(x + y\right) \cdot \left(x + y\right)\]
\[\mathsf{fma}\left(x \cdot y, 2, \mathsf{fma}\left(y, y, x \cdot x\right)\right)\]
\left(x + y\right) \cdot \left(x + y\right)
\mathsf{fma}\left(x \cdot y, 2, \mathsf{fma}\left(y, y, x \cdot x\right)\right)
double f(double x, double y) {
        double r31736314 = x;
        double r31736315 = y;
        double r31736316 = r31736314 + r31736315;
        double r31736317 = r31736316 * r31736316;
        return r31736317;
}

double f(double x, double y) {
        double r31736318 = x;
        double r31736319 = y;
        double r31736320 = r31736318 * r31736319;
        double r31736321 = 2.0;
        double r31736322 = r31736318 * r31736318;
        double r31736323 = fma(r31736319, r31736319, r31736322);
        double r31736324 = fma(r31736320, r31736321, r31736323);
        return r31736324;
}

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 \cdot x, 2, \mathsf{fma}\left(y, y, x \cdot x\right)\right)}\]
  4. Final simplification0.0

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

Reproduce

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