Average Error: 0.0 → 0.0
Time: 3.7s
Precision: 64
\[\left(x \cdot 2.0 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, 2.0, x \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, 2.0, x \cdot x\right)\right)
double f(double x, double y) {
        double r18501688 = x;
        double r18501689 = 2.0;
        double r18501690 = r18501688 * r18501689;
        double r18501691 = r18501688 * r18501688;
        double r18501692 = r18501690 + r18501691;
        double r18501693 = y;
        double r18501694 = r18501693 * r18501693;
        double r18501695 = r18501692 + r18501694;
        return r18501695;
}

double f(double x, double y) {
        double r18501696 = y;
        double r18501697 = x;
        double r18501698 = 2.0;
        double r18501699 = r18501697 * r18501697;
        double r18501700 = fma(r18501697, r18501698, r18501699);
        double r18501701 = fma(r18501696, r18501696, r18501700);
        return r18501701;
}

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, 2.0, x \cdot x\right)}\right)\]
  5. Final simplification0.0

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

Reproduce

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