Average Error: 0.0 → 0.0
Time: 4.3s
Precision: 64
\[\left(x \cdot 2.0 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, 2.0, x \cdot x\right)\right)\]
\left(x \cdot 2.0 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(y, y, \mathsf{fma}\left(x, 2.0, x \cdot x\right)\right)
double f(double x, double y) {
        double r20163948 = x;
        double r20163949 = 2.0;
        double r20163950 = r20163948 * r20163949;
        double r20163951 = r20163948 * r20163948;
        double r20163952 = r20163950 + r20163951;
        double r20163953 = y;
        double r20163954 = r20163953 * r20163953;
        double r20163955 = r20163952 + r20163954;
        return r20163955;
}

double f(double x, double y) {
        double r20163956 = y;
        double r20163957 = x;
        double r20163958 = 2.0;
        double r20163959 = r20163957 * r20163957;
        double r20163960 = fma(r20163957, r20163958, r20163959);
        double r20163961 = fma(r20163956, r20163956, r20163960);
        return r20163961;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.0
Target0.0
Herbie0.0
\[y \cdot y + \left(2.0 \cdot x + x \cdot x\right)\]

Derivation

  1. Initial program 0.0

    \[\left(x \cdot 2.0 + x \cdot x\right) + y \cdot y\]
  2. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, \left(2.0 + x\right) \cdot x\right)}\]
  3. Taylor expanded around 0 0.0

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

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

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

Reproduce

herbie shell --seed 2019163 +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)))