Average Error: 0.0 → 0.0
Time: 12.5s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, \mathsf{fma}\left(y, 2, x\right), y \cdot y\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, \mathsf{fma}\left(y, 2, x\right), y \cdot y\right)
double f(double x, double y) {
        double r443963 = x;
        double r443964 = r443963 * r443963;
        double r443965 = 2.0;
        double r443966 = r443963 * r443965;
        double r443967 = y;
        double r443968 = r443966 * r443967;
        double r443969 = r443964 + r443968;
        double r443970 = r443967 * r443967;
        double r443971 = r443969 + r443970;
        return r443971;
}

double f(double x, double y) {
        double r443972 = x;
        double r443973 = y;
        double r443974 = 2.0;
        double r443975 = fma(r443973, r443974, r443972);
        double r443976 = r443973 * r443973;
        double r443977 = fma(r443972, r443975, r443976);
        return r443977;
}

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}{{y}^{2} + \left({x}^{2} + 2 \cdot \left(x \cdot y\right)\right)}\]
  3. Simplified0.0

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

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

Reproduce

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

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

  (+ (+ (* x x) (* (* x 2.0) y)) (* y y)))