Average Error: 0.0 → 0.0
Time: 5.5s
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 r308089 = x;
        double r308090 = 2.0;
        double r308091 = r308089 * r308090;
        double r308092 = r308089 * r308089;
        double r308093 = r308091 + r308092;
        double r308094 = y;
        double r308095 = r308094 * r308094;
        double r308096 = r308093 + r308095;
        return r308096;
}

double f(double x, double y) {
        double r308097 = x;
        double r308098 = 2.0;
        double r308099 = r308098 + r308097;
        double r308100 = y;
        double r308101 = r308100 * r308100;
        double r308102 = fma(r308097, r308099, r308101);
        return r308102;
}

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