Average Error: 0.0 → 0
Time: 7.4s
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 r37580810 = x;
        double r37580811 = r37580810 * r37580810;
        double r37580812 = y;
        double r37580813 = r37580811 + r37580812;
        double r37580814 = r37580813 + r37580812;
        return r37580814;
}

double f(double x, double y) {
        double r37580815 = x;
        double r37580816 = y;
        double r37580817 = r37580816 + r37580816;
        double r37580818 = fma(r37580815, r37580815, r37580817);
        return r37580818;
}

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

    \[\leadsto \color{blue}{{x}^{2} + 2 \cdot y}\]
  4. Simplified0

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

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

Reproduce

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