Average Error: 0.1 → 0.1
Time: 12.0s
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 \cdot y\right) \cdot 3\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, x, \left(y \cdot y\right) \cdot 3\right)
double f(double x, double y) {
        double r19394649 = x;
        double r19394650 = r19394649 * r19394649;
        double r19394651 = y;
        double r19394652 = r19394651 * r19394651;
        double r19394653 = r19394650 + r19394652;
        double r19394654 = r19394653 + r19394652;
        double r19394655 = r19394654 + r19394652;
        return r19394655;
}

double f(double x, double y) {
        double r19394656 = x;
        double r19394657 = y;
        double r19394658 = r19394657 * r19394657;
        double r19394659 = 3.0;
        double r19394660 = r19394658 * r19394659;
        double r19394661 = fma(r19394656, r19394656, r19394660);
        return r19394661;
}

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, \left(3 \cdot y\right) \cdot y\right)}\]
  3. Using strategy rm
  4. Applied associate-*l*0.1

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{3 \cdot \left(y \cdot y\right)}\right)\]
  5. Using strategy rm
  6. Applied add-cube-cbrt0.1

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}\right)} \cdot \left(y \cdot y\right)\right)\]
  7. Applied associate-*l*0.2

    \[\leadsto \mathsf{fma}\left(x, x, \color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \left(\sqrt[3]{3} \cdot \left(y \cdot y\right)\right)}\right)\]
  8. Using strategy rm
  9. Applied associate-*r*0.1

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

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

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

Reproduce

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

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

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