Average Error: 0.0 → 0.0
Time: 3.7s
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 r399125 = x;
        double r399126 = 2.0;
        double r399127 = r399125 * r399126;
        double r399128 = r399125 * r399125;
        double r399129 = r399127 + r399128;
        double r399130 = y;
        double r399131 = r399130 * r399130;
        double r399132 = r399129 + r399131;
        return r399132;
}

double f(double x, double y) {
        double r399133 = x;
        double r399134 = 2.0;
        double r399135 = r399134 + r399133;
        double r399136 = y;
        double r399137 = r399136 * r399136;
        double r399138 = fma(r399133, r399135, r399137);
        return r399138;
}

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