Average Error: 0.0 → 0.0
Time: 5.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 r536965 = x;
        double r536966 = 2.0;
        double r536967 = r536965 * r536966;
        double r536968 = r536965 * r536965;
        double r536969 = r536967 + r536968;
        double r536970 = y;
        double r536971 = r536970 * r536970;
        double r536972 = r536969 + r536971;
        return r536972;
}

double f(double x, double y) {
        double r536973 = y;
        double r536974 = x;
        double r536975 = 2.0;
        double r536976 = r536975 + r536974;
        double r536977 = r536974 * r536976;
        double r536978 = fma(r536973, r536973, r536977);
        return r536978;
}

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