Average Error: 0.0 → 0.0
Time: 2.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 r474225 = x;
        double r474226 = 2.0;
        double r474227 = r474225 * r474226;
        double r474228 = r474225 * r474225;
        double r474229 = r474227 + r474228;
        double r474230 = y;
        double r474231 = r474230 * r474230;
        double r474232 = r474229 + r474231;
        return r474232;
}

double f(double x, double y) {
        double r474233 = x;
        double r474234 = 2.0;
        double r474235 = r474234 + r474233;
        double r474236 = y;
        double r474237 = r474236 * r474236;
        double r474238 = fma(r474233, r474235, r474237);
        return r474238;
}

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