Average Error: 0.0 → 0.0
Time: 3.4s
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 r495097 = x;
        double r495098 = 2.0;
        double r495099 = r495097 * r495098;
        double r495100 = r495097 * r495097;
        double r495101 = r495099 + r495100;
        double r495102 = y;
        double r495103 = r495102 * r495102;
        double r495104 = r495101 + r495103;
        return r495104;
}

double f(double x, double y) {
        double r495105 = x;
        double r495106 = 2.0;
        double r495107 = r495106 + r495105;
        double r495108 = y;
        double r495109 = r495108 * r495108;
        double r495110 = fma(r495105, r495107, r495109);
        return r495110;
}

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