Average Error: 0.0 → 0
Time: 4.2s
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 r22184563 = x;
        double r22184564 = r22184563 * r22184563;
        double r22184565 = y;
        double r22184566 = r22184564 + r22184565;
        double r22184567 = r22184566 + r22184565;
        return r22184567;
}

double f(double x, double y) {
        double r22184568 = x;
        double r22184569 = y;
        double r22184570 = r22184569 + r22184569;
        double r22184571 = fma(r22184568, r22184568, r22184570);
        return r22184571;
}

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