Average Error: 0.1 → 0.1
Time: 26.8s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(3, y \cdot y, x \cdot x\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(3, y \cdot y, x \cdot x\right)
double f(double x, double y) {
        double r287734 = x;
        double r287735 = r287734 * r287734;
        double r287736 = y;
        double r287737 = r287736 * r287736;
        double r287738 = r287735 + r287737;
        double r287739 = r287738 + r287737;
        double r287740 = r287739 + r287737;
        return r287740;
}

double f(double x, double y) {
        double r287741 = 3.0;
        double r287742 = y;
        double r287743 = r287742 * r287742;
        double r287744 = x;
        double r287745 = r287744 * r287744;
        double r287746 = fma(r287741, r287743, r287745);
        return r287746;
}

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

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

    \[\leadsto {\left(\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)\right)}^{1}\]
  7. Applied associate-*l*0.2

    \[\leadsto {\left(\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)\right)}^{1}\]
  8. Taylor expanded around 0 0.1

    \[\leadsto {\color{blue}{\left({x}^{2} + 3 \cdot {y}^{2}\right)}}^{1}\]
  9. Simplified0.1

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

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

Reproduce

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