Average Error: 0.0 → 0
Time: 4.9s
Precision: 64
\[\left(x \cdot x + y\right) + y\]
\[\mathsf{fma}\left(x, x, y + y\right)\]
\left(x \cdot x + y\right) + y
\mathsf{fma}\left(x, x, y + y\right)
double f(double x, double y) {
        double r48060656 = x;
        double r48060657 = r48060656 * r48060656;
        double r48060658 = y;
        double r48060659 = r48060657 + r48060658;
        double r48060660 = r48060659 + r48060658;
        return r48060660;
}

double f(double x, double y) {
        double r48060661 = x;
        double r48060662 = y;
        double r48060663 = r48060662 + r48060662;
        double r48060664 = fma(r48060661, r48060661, r48060663);
        return r48060664;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, y\right) + y}\]
  3. Using strategy rm
  4. Applied fma-udef0.0

    \[\leadsto \color{blue}{\left(x \cdot x + y\right)} + y\]
  5. Applied associate-+l+0.0

    \[\leadsto \color{blue}{x \cdot x + \left(y + y\right)}\]
  6. Using strategy rm
  7. Applied fma-def0

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

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x y)
  :name "Data.Random.Distribution.Normal:normalTail from random-fu-0.2.6.2"

  :herbie-target
  (+ (+ y y) (* x x))

  (+ (+ (* x x) y) y))