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

double f(double x, double y) {
        double r615170 = x;
        double r615171 = 2.0;
        double r615172 = r615170 * r615171;
        double r615173 = y;
        double r615174 = r615172 * r615173;
        double r615175 = r615173 * r615173;
        double r615176 = r615174 + r615175;
        double r615177 = fma(r615170, r615170, r615176);
        return r615177;
}

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

    \[\leadsto \mathsf{fma}\left(x, x, y \cdot \color{blue}{\left(x \cdot 2 + y\right)}\right)\]
  6. Applied distribute-rgt-in0.0

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

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

Reproduce

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