Average Error: 5.8 → 0.1
Time: 7.7s
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 r491081 = x;
        double r491082 = 1.0;
        double r491083 = y;
        double r491084 = r491083 * r491083;
        double r491085 = r491082 + r491084;
        double r491086 = r491081 * r491085;
        return r491086;
}

double f(double x, double y) {
        double r491087 = y;
        double r491088 = -6.685152828313653e+28;
        bool r491089 = r491087 <= r491088;
        double r491090 = 0.125;
        double r491091 = 3.0;
        double r491092 = pow(r491087, r491091);
        double r491093 = r491090 / r491092;
        double r491094 = r491093 - r491087;
        double r491095 = 0.5;
        double r491096 = r491095 / r491087;
        double r491097 = r491094 - r491096;
        double r491098 = sqrt(r491097);
        double r491099 = 1.0;
        double r491100 = sqrt(r491099);
        double r491101 = hypot(r491087, r491100);
        double r491102 = sqrt(r491101);
        double r491103 = x;
        double r491104 = r491101 * r491103;
        double r491105 = r491102 * r491104;
        double r491106 = r491098 * r491105;
        double r491107 = 4.450802574869413e+153;
        bool r491108 = r491087 <= r491107;
        double r491109 = fma(r491087, r491087, r491099);
        double r491110 = r491109 * r491103;
        double r491111 = r491096 - r491093;
        double r491112 = r491087 + r491111;
        double r491113 = sqrt(r491112);
        double r491114 = r491113 * r491105;
        double r491115 = r491108 ? r491110 : r491114;
        double r491116 = r491089 ? r491106 : r491115;
        return r491116;
}

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))))