Average Error: 0.0 → 0.0
Time: 16.5s
Precision: 64
\[\left(x \cdot x + y\right) + y\]
\[\mathsf{fma}\left(y, 2, x \cdot x\right)\]
\left(x \cdot x + y\right) + y
\mathsf{fma}\left(y, 2, x \cdot x\right)
double f(double x, double y) {
        double r532679 = x;
        double r532680 = r532679 * r532679;
        double r532681 = y;
        double r532682 = r532680 + r532681;
        double r532683 = r532682 + r532681;
        return r532683;
}

double f(double x, double y) {
        double r532684 = y;
        double r532685 = 2.0;
        double r532686 = x;
        double r532687 = r532686 * r532686;
        double r532688 = fma(r532684, r532685, r532687);
        return r532688;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.0
Target0.0
Herbie0.0
\[\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}{y + \mathsf{fma}\left(x, x, y\right)}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt21.6

    \[\leadsto \color{blue}{\sqrt{y + \mathsf{fma}\left(x, x, y\right)} \cdot \sqrt{y + \mathsf{fma}\left(x, x, y\right)}}\]
  5. Taylor expanded around 0 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, 2, x \cdot x\right)}\]
  7. Final simplification0.0

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

Reproduce

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