Average Error: 0.0 → 0.0
Time: 1.8s
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(x, 2 + x, y \cdot y\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(x, 2 + x, y \cdot y\right)
double f(double x, double y) {
        double r440279 = x;
        double r440280 = 2.0;
        double r440281 = r440279 * r440280;
        double r440282 = r440279 * r440279;
        double r440283 = r440281 + r440282;
        double r440284 = y;
        double r440285 = r440284 * r440284;
        double r440286 = r440283 + r440285;
        return r440286;
}

double f(double x, double y) {
        double r440287 = x;
        double r440288 = 2.0;
        double r440289 = r440288 + r440287;
        double r440290 = y;
        double r440291 = r440290 * r440290;
        double r440292 = fma(r440287, r440289, r440291);
        return r440292;
}

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(x, 2 + x, y \cdot y\right)}\]
  3. Final simplification0.0

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

Reproduce

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