Average Error: 0.0 → 0.0
Time: 3.1s
Precision: 64
\[\left(x \cdot 2.0 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, 2.0 \cdot x\right)\right)\]
\left(x \cdot 2.0 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, x, 2.0 \cdot x\right)\right)
double f(double x, double y) {
        double r7027658 = x;
        double r7027659 = 2.0;
        double r7027660 = r7027658 * r7027659;
        double r7027661 = r7027658 * r7027658;
        double r7027662 = r7027660 + r7027661;
        double r7027663 = y;
        double r7027664 = r7027663 * r7027663;
        double r7027665 = r7027662 + r7027664;
        return r7027665;
}

double f(double x, double y) {
        double r7027666 = y;
        double r7027667 = x;
        double r7027668 = 2.0;
        double r7027669 = r7027668 * r7027667;
        double r7027670 = fma(r7027667, r7027667, r7027669);
        double r7027671 = fma(r7027666, r7027666, r7027670);
        return r7027671;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.0

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

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

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

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

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

Reproduce

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