Average Error: 0.0 → 0.0
Time: 1.4s
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \mathsf{fma}\left(2, x, {y}^{2}\right)\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(x, x, \mathsf{fma}\left(2, x, {y}^{2}\right)\right)
double f(double x, double y) {
        double r388719 = x;
        double r388720 = 2.0;
        double r388721 = r388719 * r388720;
        double r388722 = r388719 * r388719;
        double r388723 = r388721 + r388722;
        double r388724 = y;
        double r388725 = r388724 * r388724;
        double r388726 = r388723 + r388725;
        return r388726;
}

double f(double x, double y) {
        double r388727 = x;
        double r388728 = 2.0;
        double r388729 = y;
        double r388730 = 2.0;
        double r388731 = pow(r388729, r388730);
        double r388732 = fma(r388728, r388727, r388731);
        double r388733 = fma(r388727, r388727, r388732);
        return r388733;
}

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. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{{x}^{2} + \left(2 \cdot x + {y}^{2}\right)}\]
  4. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, \mathsf{fma}\left(2, x, {y}^{2}\right)\right)}\]
  5. Final simplification0.0

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

Reproduce

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