Average Error: 0.0 → 0.0
Time: 8.9s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, y \cdot \mathsf{fma}\left(2, x, y\right)\right)\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, y \cdot \mathsf{fma}\left(2, x, y\right)\right)
double f(double x, double y) {
        double r23197163 = x;
        double r23197164 = r23197163 * r23197163;
        double r23197165 = 2.0;
        double r23197166 = r23197163 * r23197165;
        double r23197167 = y;
        double r23197168 = r23197166 * r23197167;
        double r23197169 = r23197164 + r23197168;
        double r23197170 = r23197167 * r23197167;
        double r23197171 = r23197169 + r23197170;
        return r23197171;
}

double f(double x, double y) {
        double r23197172 = x;
        double r23197173 = y;
        double r23197174 = 2.0;
        double r23197175 = fma(r23197174, r23197172, r23197173);
        double r23197176 = r23197173 * r23197175;
        double r23197177 = fma(r23197172, r23197172, r23197176);
        return r23197177;
}

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

    \[\leadsto \color{blue}{y \cdot \mathsf{fma}\left(2, x, y\right) + x \cdot x}\]
  5. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{{y}^{2} + \left({x}^{2} + 2 \cdot \left(x \cdot y\right)\right)}\]
  6. Simplified0.0

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

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

Reproduce

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