Average Error: 0.0 → 0.0
Time: 8.1s
Precision: 64
\[\left(x \cdot 2 + x \cdot x\right) + y \cdot y\]
\[\mathsf{fma}\left(y, y, x \cdot \left(2 + x\right)\right)\]
\left(x \cdot 2 + x \cdot x\right) + y \cdot y
\mathsf{fma}\left(y, y, x \cdot \left(2 + x\right)\right)
double f(double x, double y) {
        double r420914 = x;
        double r420915 = 2.0;
        double r420916 = r420914 * r420915;
        double r420917 = r420914 * r420914;
        double r420918 = r420916 + r420917;
        double r420919 = y;
        double r420920 = r420919 * r420919;
        double r420921 = r420918 + r420920;
        return r420921;
}

double f(double x, double y) {
        double r420922 = y;
        double r420923 = x;
        double r420924 = 2.0;
        double r420925 = r420924 + r420923;
        double r420926 = r420923 * r420925;
        double r420927 = fma(r420922, r420922, r420926);
        return r420927;
}

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. Taylor expanded around 0 0.0

    \[\leadsto \color{blue}{{x}^{2} + \left(2 \cdot x + {y}^{2}\right)}\]
  3. Simplified0.0

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

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

Reproduce

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