Average Error: 0.0 → 0.0
Time: 7.0s
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, x \cdot \left(2 + x\right)\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(y, y, x \cdot \left(2 + x\right)\right)
double f(double x, double y) {
        double r282121 = x;
        double r282122 = 2.0;
        double r282123 = r282121 * r282122;
        double r282124 = r282121 * r282121;
        double r282125 = r282123 + r282124;
        double r282126 = y;
        double r282127 = r282126 * r282126;
        double r282128 = r282125 + r282127;
        return r282128;
}

double f(double x, double y) {
        double r282129 = y;
        double r282130 = x;
        double r282131 = 2.0;
        double r282132 = r282131 + r282130;
        double r282133 = r282130 * r282132;
        double r282134 = fma(r282129, r282129, r282133);
        return r282134;
}

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. Taylor expanded around 0 0.0

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

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

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

Reproduce

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

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

  (+ (+ (* x 2) (* x x)) (* y y)))