Average Error: 0.0 → 0.0
Time: 1.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 r420790 = x;
        double r420791 = 2.0;
        double r420792 = r420790 * r420791;
        double r420793 = r420790 * r420790;
        double r420794 = r420792 + r420793;
        double r420795 = y;
        double r420796 = r420795 * r420795;
        double r420797 = r420794 + r420796;
        return r420797;
}

double f(double x, double y) {
        double r420798 = x;
        double r420799 = 2.0;
        double r420800 = r420799 + r420798;
        double r420801 = y;
        double r420802 = r420801 * r420801;
        double r420803 = fma(r420798, r420800, r420802);
        return r420803;
}

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