Average Error: 0.0 → 0.0
Time: 6.4s
Precision: 64
\[\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y\]
\[y \cdot y + \mathsf{fma}\left(y, 2, x\right) \cdot x\]
\left(x \cdot x + \left(x \cdot 2\right) \cdot y\right) + y \cdot y
y \cdot y + \mathsf{fma}\left(y, 2, x\right) \cdot x
double f(double x, double y) {
        double r24275852 = x;
        double r24275853 = r24275852 * r24275852;
        double r24275854 = 2.0;
        double r24275855 = r24275852 * r24275854;
        double r24275856 = y;
        double r24275857 = r24275855 * r24275856;
        double r24275858 = r24275853 + r24275857;
        double r24275859 = r24275856 * r24275856;
        double r24275860 = r24275858 + r24275859;
        return r24275860;
}

double f(double x, double y) {
        double r24275861 = y;
        double r24275862 = r24275861 * r24275861;
        double r24275863 = 2.0;
        double r24275864 = x;
        double r24275865 = fma(r24275861, r24275863, r24275864);
        double r24275866 = r24275865 * r24275864;
        double r24275867 = r24275862 + r24275866;
        return r24275867;
}

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

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

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

Reproduce

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