Average Error: 0.0 → 0.0
Time: 13.8s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \mathsf{fma}\left(x, 2, y\right) \cdot y\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \mathsf{fma}\left(x, 2, y\right) \cdot y\right)
double f(double x, double y) {
        double r424197 = x;
        double r424198 = r424197 * r424197;
        double r424199 = 2.0;
        double r424200 = r424197 * r424199;
        double r424201 = y;
        double r424202 = r424200 * r424201;
        double r424203 = r424198 + r424202;
        double r424204 = r424201 * r424201;
        double r424205 = r424203 + r424204;
        return r424205;
}

double f(double x, double y) {
        double r424206 = x;
        double r424207 = 2.0;
        double r424208 = y;
        double r424209 = fma(r424206, r424207, r424208);
        double r424210 = r424209 * r424208;
        double r424211 = fma(r424206, r424206, r424210);
        return r424211;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.0
Target0.0
Herbie0.0
\[x \cdot x + \left(y \cdot y + \left(x \cdot y\right) \cdot 2\right)\]

Derivation

  1. Initial program 0.0

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

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

Reproduce

herbie shell --seed 2019304 +o rules:numerics
(FPCore (x y)
  :name "Examples.Basics.ProofTests:f4 from sbv-4.4"
  :precision binary64

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

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