Average Error: 0.1 → 0.1
Time: 21.5s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, 3 \cdot \left(y \cdot y\right)\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, 3 \cdot \left(y \cdot y\right)\right)
double f(double x, double y) {
        double r378588 = x;
        double r378589 = r378588 * r378588;
        double r378590 = y;
        double r378591 = r378590 * r378590;
        double r378592 = r378589 + r378591;
        double r378593 = r378592 + r378591;
        double r378594 = r378593 + r378591;
        return r378594;
}

double f(double x, double y) {
        double r378595 = x;
        double r378596 = 3.0;
        double r378597 = y;
        double r378598 = r378597 * r378597;
        double r378599 = r378596 * r378598;
        double r378600 = fma(r378595, r378595, r378599);
        return r378600;
}

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. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 3 \cdot \left(y \cdot y\right)\right)}\]
  3. Using strategy rm
  4. Applied *-un-lft-identity0.1

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

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

Reproduce

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