Average Error: 0.0 → 0
Time: 4.7s
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 r220006282 = x;
        double r220006283 = r220006282 * r220006282;
        double r220006284 = y;
        double r220006285 = r220006283 + r220006284;
        double r220006286 = r220006285 + r220006284;
        return r220006286;
}

double f(double x, double y) {
        double r220006287 = x;
        double r220006288 = y;
        double r220006289 = r220006288 + r220006288;
        double r220006290 = fma(r220006287, r220006287, r220006289);
        return r220006290;
}

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