Average Error: 0.0 → 0.0
Time: 809.0ms
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 r398836 = x;
        double r398837 = 2.0;
        double r398838 = r398836 * r398837;
        double r398839 = r398836 * r398836;
        double r398840 = r398838 + r398839;
        double r398841 = y;
        double r398842 = r398841 * r398841;
        double r398843 = r398840 + r398842;
        return r398843;
}

double f(double x, double y) {
        double r398844 = x;
        double r398845 = 2.0;
        double r398846 = r398845 + r398844;
        double r398847 = y;
        double r398848 = r398847 * r398847;
        double r398849 = fma(r398844, r398846, r398848);
        return r398849;
}

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