Average Error: 0.0 → 0.0
Time: 5.1s
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 r477116 = x;
        double r477117 = r477116 * r477116;
        double r477118 = 2.0;
        double r477119 = r477116 * r477118;
        double r477120 = y;
        double r477121 = r477119 * r477120;
        double r477122 = r477117 + r477121;
        double r477123 = r477120 * r477120;
        double r477124 = r477122 + r477123;
        return r477124;
}

double f(double x, double y) {
        double r477125 = x;
        double r477126 = y;
        double r477127 = 2.0;
        double r477128 = fma(r477126, r477127, r477125);
        double r477129 = r477126 * r477126;
        double r477130 = fma(r477125, r477128, r477129);
        return r477130;
}

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. Simplified0.0

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

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

Reproduce

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