Average Error: 0.1 → 0.2
Time: 3.8s
Precision: 64
\[\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(\sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y}, 1 \cdot \mathsf{hypot}\left(x, \left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \left(\sqrt[3]{\sqrt{2}} \cdot y\right)\right), y \cdot y\right)\]
\left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right) + y \cdot y
\mathsf{fma}\left(\sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y}, 1 \cdot \mathsf{hypot}\left(x, \left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \left(\sqrt[3]{\sqrt{2}} \cdot y\right)\right), y \cdot y\right)
double f(double x, double y) {
        double r1219856 = x;
        double r1219857 = r1219856 * r1219856;
        double r1219858 = y;
        double r1219859 = r1219858 * r1219858;
        double r1219860 = r1219857 + r1219859;
        double r1219861 = r1219860 + r1219859;
        double r1219862 = r1219861 + r1219859;
        return r1219862;
}

double f(double x, double y) {
        double r1219863 = x;
        double r1219864 = r1219863 * r1219863;
        double r1219865 = y;
        double r1219866 = r1219865 * r1219865;
        double r1219867 = r1219864 + r1219866;
        double r1219868 = r1219867 + r1219866;
        double r1219869 = sqrt(r1219868);
        double r1219870 = 1.0;
        double r1219871 = 2.0;
        double r1219872 = sqrt(r1219871);
        double r1219873 = cbrt(r1219872);
        double r1219874 = r1219873 * r1219873;
        double r1219875 = r1219873 * r1219865;
        double r1219876 = r1219874 * r1219875;
        double r1219877 = hypot(r1219863, r1219876);
        double r1219878 = r1219870 * r1219877;
        double r1219879 = fma(r1219869, r1219878, r1219866);
        return r1219879;
}

Error

Bits error versus x

Bits error versus y

Target

Original0.1
Target0.1
Herbie0.2
\[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 *-un-lft-identity0.2

    \[\leadsto \mathsf{fma}\left(\sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y}, \sqrt{\color{blue}{1 \cdot \left(\left(x \cdot x + y \cdot y\right) + y \cdot y\right)}}, y \cdot y\right)\]
  7. Applied sqrt-prod0.2

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

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

    \[\leadsto \mathsf{fma}\left(\sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y}, 1 \cdot \color{blue}{\mathsf{hypot}\left(x, \sqrt{2} \cdot y\right)}, y \cdot y\right)\]
  10. Using strategy rm
  11. Applied add-cube-cbrt0.2

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

    \[\leadsto \mathsf{fma}\left(\sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y}, 1 \cdot \mathsf{hypot}\left(x, \color{blue}{\left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \left(\sqrt[3]{\sqrt{2}} \cdot y\right)}\right), y \cdot y\right)\]
  13. Final simplification0.2

    \[\leadsto \mathsf{fma}\left(\sqrt{\left(x \cdot x + y \cdot y\right) + y \cdot y}, 1 \cdot \mathsf{hypot}\left(x, \left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \left(\sqrt[3]{\sqrt{2}} \cdot y\right)\right), y \cdot y\right)\]

Reproduce

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