Average Error: 5.8 → 0.1
Time: 8.2s
Precision: 64
\[x \cdot \left(1 + y \cdot y\right)\]
\[\begin{array}{l} \mathbf{if}\;y \le -6.68515282831365304 \cdot 10^{28}:\\ \;\;\;\;\sqrt{\left(\frac{0.125}{{y}^{3}} - y\right) - \frac{0.5}{y}} \cdot \left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)\\ \mathbf{elif}\;y \le 4.4508025748694133 \cdot 10^{153}:\\ \;\;\;\;\mathsf{fma}\left(y, y, 1\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\sqrt{y + \left(\frac{0.5}{y} - \frac{0.125}{{y}^{3}}\right)} \cdot \left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)\\ \end{array}\]
x \cdot \left(1 + y \cdot y\right)
\begin{array}{l}
\mathbf{if}\;y \le -6.68515282831365304 \cdot 10^{28}:\\
\;\;\;\;\sqrt{\left(\frac{0.125}{{y}^{3}} - y\right) - \frac{0.5}{y}} \cdot \left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)\\

\mathbf{elif}\;y \le 4.4508025748694133 \cdot 10^{153}:\\
\;\;\;\;\mathsf{fma}\left(y, y, 1\right) \cdot x\\

\mathbf{else}:\\
\;\;\;\;\sqrt{y + \left(\frac{0.5}{y} - \frac{0.125}{{y}^{3}}\right)} \cdot \left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)\\

\end{array}
double f(double x, double y) {
        double r465828 = x;
        double r465829 = 1.0;
        double r465830 = y;
        double r465831 = r465830 * r465830;
        double r465832 = r465829 + r465831;
        double r465833 = r465828 * r465832;
        return r465833;
}

double f(double x, double y) {
        double r465834 = y;
        double r465835 = -6.685152828313653e+28;
        bool r465836 = r465834 <= r465835;
        double r465837 = 0.125;
        double r465838 = 3.0;
        double r465839 = pow(r465834, r465838);
        double r465840 = r465837 / r465839;
        double r465841 = r465840 - r465834;
        double r465842 = 0.5;
        double r465843 = r465842 / r465834;
        double r465844 = r465841 - r465843;
        double r465845 = sqrt(r465844);
        double r465846 = 1.0;
        double r465847 = sqrt(r465846);
        double r465848 = hypot(r465834, r465847);
        double r465849 = sqrt(r465848);
        double r465850 = x;
        double r465851 = r465848 * r465850;
        double r465852 = r465849 * r465851;
        double r465853 = r465845 * r465852;
        double r465854 = 4.450802574869413e+153;
        bool r465855 = r465834 <= r465854;
        double r465856 = fma(r465834, r465834, r465846);
        double r465857 = r465856 * r465850;
        double r465858 = r465843 - r465840;
        double r465859 = r465834 + r465858;
        double r465860 = sqrt(r465859);
        double r465861 = r465860 * r465852;
        double r465862 = r465855 ? r465857 : r465861;
        double r465863 = r465836 ? r465853 : r465862;
        return r465863;
}

Error

Bits error versus x

Bits error versus y

Target

Original5.8
Target0.1
Herbie0.1
\[x + \left(x \cdot y\right) \cdot y\]

Derivation

  1. Split input into 3 regimes
  2. if y < -6.685152828313653e+28

    1. Initial program 21.1

      \[x \cdot \left(1 + y \cdot y\right)\]
    2. Simplified21.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, 1\right) \cdot x}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt21.1

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

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot \left(\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot x\right)}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt21.1

      \[\leadsto \sqrt{\color{blue}{\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot \sqrt{\mathsf{fma}\left(y, y, 1\right)}}} \cdot \left(\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot x\right)\]
    8. Applied sqrt-prod21.3

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

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

      \[\leadsto \sqrt{\sqrt{\mathsf{fma}\left(y, y, 1\right)}} \cdot \color{blue}{\left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)}\]
    11. Taylor expanded around -inf 0.6

      \[\leadsto \sqrt{\color{blue}{0.125 \cdot \frac{1}{{y}^{3}} - \left(y + 0.5 \cdot \frac{1}{y}\right)}} \cdot \left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)\]
    12. Simplified0.6

      \[\leadsto \sqrt{\color{blue}{\left(\frac{0.125}{{y}^{3}} - y\right) - \frac{0.5}{y}}} \cdot \left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)\]

    if -6.685152828313653e+28 < y < 4.450802574869413e+153

    1. Initial program 0.1

      \[x \cdot \left(1 + y \cdot y\right)\]
    2. Simplified0.1

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

    if 4.450802574869413e+153 < y

    1. Initial program 63.8

      \[x \cdot \left(1 + y \cdot y\right)\]
    2. Simplified63.8

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, y, 1\right) \cdot x}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt63.8

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

      \[\leadsto \color{blue}{\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot \left(\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot x\right)}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt63.8

      \[\leadsto \sqrt{\color{blue}{\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot \sqrt{\mathsf{fma}\left(y, y, 1\right)}}} \cdot \left(\sqrt{\mathsf{fma}\left(y, y, 1\right)} \cdot x\right)\]
    8. Applied sqrt-prod63.8

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

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

      \[\leadsto \sqrt{\sqrt{\mathsf{fma}\left(y, y, 1\right)}} \cdot \color{blue}{\left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)}\]
    11. Taylor expanded around inf 0.6

      \[\leadsto \sqrt{\color{blue}{\left(y + 0.5 \cdot \frac{1}{y}\right) - 0.125 \cdot \frac{1}{{y}^{3}}}} \cdot \left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)\]
    12. Simplified0.6

      \[\leadsto \sqrt{\color{blue}{y + \left(\frac{0.5}{y} - \frac{0.125}{{y}^{3}}\right)}} \cdot \left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -6.68515282831365304 \cdot 10^{28}:\\ \;\;\;\;\sqrt{\left(\frac{0.125}{{y}^{3}} - y\right) - \frac{0.5}{y}} \cdot \left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)\\ \mathbf{elif}\;y \le 4.4508025748694133 \cdot 10^{153}:\\ \;\;\;\;\mathsf{fma}\left(y, y, 1\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;\sqrt{y + \left(\frac{0.5}{y} - \frac{0.125}{{y}^{3}}\right)} \cdot \left(\sqrt{\mathsf{hypot}\left(y, \sqrt{1}\right)} \cdot \left(\mathsf{hypot}\left(y, \sqrt{1}\right) \cdot x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020046 +o rules:numerics
(FPCore (x y)
  :name "Numeric.Integration.TanhSinh:everywhere from integration-0.2.1"
  :precision binary64

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

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