Average Error: 0.0 → 0.0
Time: 1.9s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), {x}^{2}\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(y, \mathsf{fma}\left(2, x, y\right), {x}^{2}\right)
double f(double x, double y) {
        double r620009 = x;
        double r620010 = r620009 * r620009;
        double r620011 = 2.0;
        double r620012 = r620009 * r620011;
        double r620013 = y;
        double r620014 = r620012 * r620013;
        double r620015 = r620010 + r620014;
        double r620016 = r620013 * r620013;
        double r620017 = r620015 + r620016;
        return r620017;
}

double f(double x, double y) {
        double r620018 = y;
        double r620019 = 2.0;
        double r620020 = x;
        double r620021 = fma(r620019, r620020, r620018);
        double r620022 = 2.0;
        double r620023 = pow(r620020, r620022);
        double r620024 = fma(r620018, r620021, r620023);
        return r620024;
}

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

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

Reproduce

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