Average Error: 0.0 → 0.0
Time: 3.1s
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 r236646 = x;
        double r236647 = 2.0;
        double r236648 = r236646 * r236647;
        double r236649 = r236646 * r236646;
        double r236650 = r236648 + r236649;
        double r236651 = y;
        double r236652 = r236651 * r236651;
        double r236653 = r236650 + r236652;
        return r236653;
}

double f(double x, double y) {
        double r236654 = x;
        double r236655 = 2.0;
        double r236656 = r236655 + r236654;
        double r236657 = y;
        double r236658 = r236657 * r236657;
        double r236659 = fma(r236654, r236656, r236658);
        return r236659;
}

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