Average Error: 0.0 → 0.0
Time: 12.8s
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x + 2, y \cdot y\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(x, x + 2, y \cdot y\right)
double f(double x, double y) {
        double r66615115 = x;
        double r66615116 = 2.0;
        double r66615117 = r66615115 * r66615116;
        double r66615118 = r66615115 * r66615115;
        double r66615119 = r66615117 + r66615118;
        double r66615120 = y;
        double r66615121 = r66615120 * r66615120;
        double r66615122 = r66615119 + r66615121;
        return r66615122;
}

double f(double x, double y) {
        double r66615123 = x;
        double r66615124 = 2.0;
        double r66615125 = r66615123 + r66615124;
        double r66615126 = y;
        double r66615127 = r66615126 * r66615126;
        double r66615128 = fma(r66615123, r66615125, r66615127);
        return r66615128;
}

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(y, y, x \cdot \left(2 + x\right)\right)}\]
  3. Taylor expanded around 0 0.0

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

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

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

Reproduce

herbie shell --seed 2019173 +o rules:numerics
(FPCore (x y)
  :name "Numeric.Log:$clog1p from log-domain-0.10.2.1, A"

  :herbie-target
  (+ (* y y) (+ (* 2.0 x) (* x x)))

  (+ (+ (* x 2.0) (* x x)) (* y y)))