Average Error: 0.1 → 0.1
Time: 46.4s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, x, y \cdot \left(3 \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, y \cdot \left(3 \cdot y\right)\right)
double f(double x, double y) {
        double r526802 = x;
        double r526803 = r526802 * r526802;
        double r526804 = y;
        double r526805 = r526804 * r526804;
        double r526806 = r526803 + r526805;
        double r526807 = r526806 + r526805;
        double r526808 = r526807 + r526805;
        return r526808;
}

double f(double x, double y) {
        double r526809 = x;
        double r526810 = y;
        double r526811 = 3.0;
        double r526812 = r526811 * r526810;
        double r526813 = r526810 * r526812;
        double r526814 = fma(r526809, r526809, r526813);
        return r526814;
}

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

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{3 \cdot {y}^{2}}\right)\]
  4. Simplified0.1

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

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

Reproduce

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