Average Error: 0.0 → 0.0
Time: 8.1s
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 r253140 = x;
        double r253141 = 2.0;
        double r253142 = r253140 * r253141;
        double r253143 = r253140 * r253140;
        double r253144 = r253142 + r253143;
        double r253145 = y;
        double r253146 = r253145 * r253145;
        double r253147 = r253144 + r253146;
        return r253147;
}

double f(double x, double y) {
        double r253148 = y;
        double r253149 = x;
        double r253150 = 2.0;
        double r253151 = r253150 + r253149;
        double r253152 = r253149 * r253151;
        double r253153 = fma(r253148, r253148, r253152);
        return r253153;
}

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 2019304 +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)))