Average Error: 0.0 → 0.0
Time: 7.6s
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, 2, x \cdot x\right)\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, 2, x \cdot x\right)\right)
double f(double x, double y) {
        double r21532942 = x;
        double r21532943 = 2.0;
        double r21532944 = r21532942 * r21532943;
        double r21532945 = r21532942 * r21532942;
        double r21532946 = r21532944 + r21532945;
        double r21532947 = y;
        double r21532948 = r21532947 * r21532947;
        double r21532949 = r21532946 + r21532948;
        return r21532949;
}

double f(double x, double y) {
        double r21532950 = y;
        double r21532951 = x;
        double r21532952 = 2.0;
        double r21532953 = r21532951 * r21532951;
        double r21532954 = fma(r21532951, r21532952, r21532953);
        double r21532955 = fma(r21532950, r21532950, r21532954);
        return r21532955;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.0
Target0.0
Herbie0.0
\[y \cdot y + \left(2 \cdot x + x \cdot x\right)\]

Derivation

  1. Initial program 0.0

    \[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
  2. Simplified0.0

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

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

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

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

Reproduce

herbie shell --seed 2019168 +o rules:numerics
(FPCore (x y)
  :name "Numeric.Log:$clog1p from log-domain-0.10.2.1, A"

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

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