Average Error: 0.0 → 0.0
Time: 6.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 r306948 = x;
        double r306949 = 2.0;
        double r306950 = r306948 * r306949;
        double r306951 = r306948 * r306948;
        double r306952 = r306950 + r306951;
        double r306953 = y;
        double r306954 = r306953 * r306953;
        double r306955 = r306952 + r306954;
        return r306955;
}

double f(double x, double y) {
        double r306956 = y;
        double r306957 = x;
        double r306958 = 2.0;
        double r306959 = r306958 + r306957;
        double r306960 = r306957 * r306959;
        double r306961 = fma(r306956, r306956, r306960);
        return r306961;
}

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

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

Reproduce

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