Average Error: 0.1 → 0.1
Time: 24.4s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, \left(y + y\right) \cdot y\right) + y \cdot y\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \left(y + y\right) \cdot y\right) + y \cdot y
double f(double x, double y) {
        double r427595 = x;
        double r427596 = r427595 * r427595;
        double r427597 = y;
        double r427598 = r427597 * r427597;
        double r427599 = r427596 + r427598;
        double r427600 = r427599 + r427598;
        double r427601 = r427600 + r427598;
        return r427601;
}

double f(double x, double y) {
        double r427602 = x;
        double r427603 = y;
        double r427604 = r427603 + r427603;
        double r427605 = r427604 * r427603;
        double r427606 = fma(r427602, r427602, r427605);
        double r427607 = r427603 * r427603;
        double r427608 = r427606 + r427607;
        return r427608;
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.1

    \[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt0.2

    \[\leadsto \color{blue}{\sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y}} + y \cdot y\]
  4. Applied fma-def0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y}, \sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y}, y \cdot y\right)}\]
  5. Using strategy rm
  6. Applied fma-udef0.2

    \[\leadsto \color{blue}{\sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y} \cdot \sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y} + y \cdot y}\]
  7. Simplified0.1

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

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

Reproduce

herbie shell --seed 2019209 +o rules:numerics
(FPCore (x y)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, E"
  :precision binary64

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

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