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 r170913 = x;
        double r170914 = 2.0;
        double r170915 = r170913 * r170914;
        double r170916 = r170913 * r170913;
        double r170917 = r170915 + r170916;
        double r170918 = y;
        double r170919 = r170918 * r170918;
        double r170920 = r170917 + r170919;
        return r170920;
}

double f(double x, double y) {
        double r170921 = x;
        double r170922 = 2.0;
        double r170923 = r170922 + r170921;
        double r170924 = y;
        double r170925 = r170924 * r170924;
        double r170926 = fma(r170921, r170923, r170925);
        return r170926;
}

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