Average Error: 19.7 → 19.6
Time: 27.5s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \le 2.6546736668899873 \cdot 10^{+116}:\\ \;\;\;\;{x}^{\frac{-1}{2}} - \sqrt[3]{\frac{\frac{1}{1 + x}}{\sqrt{1 + x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{\sqrt{x}} - \frac{\frac{1}{\sqrt{1 + x}}}{1 + x}}{\left(\frac{1}{\sqrt{1 + x}} \cdot \frac{1}{\sqrt{1 + x}} + \frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{1 + x}}\right) + \frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}}}\\ \end{array}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
\mathbf{if}\;x \le 2.6546736668899873 \cdot 10^{+116}:\\
\;\;\;\;{x}^{\frac{-1}{2}} - \sqrt[3]{\frac{\frac{1}{1 + x}}{\sqrt{1 + x}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{\sqrt{x}} - \frac{\frac{1}{\sqrt{1 + x}}}{1 + x}}{\left(\frac{1}{\sqrt{1 + x}} \cdot \frac{1}{\sqrt{1 + x}} + \frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{1 + x}}\right) + \frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}}}\\

\end{array}
double f(double x) {
        double r2903105 = 1.0;
        double r2903106 = x;
        double r2903107 = sqrt(r2903106);
        double r2903108 = r2903105 / r2903107;
        double r2903109 = r2903106 + r2903105;
        double r2903110 = sqrt(r2903109);
        double r2903111 = r2903105 / r2903110;
        double r2903112 = r2903108 - r2903111;
        return r2903112;
}

double f(double x) {
        double r2903113 = x;
        double r2903114 = 2.6546736668899873e+116;
        bool r2903115 = r2903113 <= r2903114;
        double r2903116 = -0.5;
        double r2903117 = pow(r2903113, r2903116);
        double r2903118 = 1.0;
        double r2903119 = r2903118 + r2903113;
        double r2903120 = r2903118 / r2903119;
        double r2903121 = sqrt(r2903119);
        double r2903122 = r2903120 / r2903121;
        double r2903123 = cbrt(r2903122);
        double r2903124 = r2903117 - r2903123;
        double r2903125 = r2903118 / r2903113;
        double r2903126 = sqrt(r2903113);
        double r2903127 = r2903125 / r2903126;
        double r2903128 = r2903118 / r2903121;
        double r2903129 = r2903128 / r2903119;
        double r2903130 = r2903127 - r2903129;
        double r2903131 = r2903128 * r2903128;
        double r2903132 = r2903118 / r2903126;
        double r2903133 = r2903132 * r2903128;
        double r2903134 = r2903131 + r2903133;
        double r2903135 = r2903132 * r2903132;
        double r2903136 = r2903134 + r2903135;
        double r2903137 = r2903130 / r2903136;
        double r2903138 = r2903115 ? r2903124 : r2903137;
        return r2903138;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.7
Target0.8
Herbie19.6
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < 2.6546736668899873e+116

    1. Initial program 15.3

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
    2. Using strategy rm
    3. Applied pow1/215.3

      \[\leadsto \frac{1}{\color{blue}{{x}^{\frac{1}{2}}}} - \frac{1}{\sqrt{x + 1}}\]
    4. Applied pow-flip15.1

      \[\leadsto \color{blue}{{x}^{\left(-\frac{1}{2}\right)}} - \frac{1}{\sqrt{x + 1}}\]
    5. Simplified15.1

      \[\leadsto {x}^{\color{blue}{\frac{-1}{2}}} - \frac{1}{\sqrt{x + 1}}\]
    6. Using strategy rm
    7. Applied add-cbrt-cube14.9

      \[\leadsto {x}^{\frac{-1}{2}} - \color{blue}{\sqrt[3]{\left(\frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}\right) \cdot \frac{1}{\sqrt{x + 1}}}}\]
    8. Simplified14.9

      \[\leadsto {x}^{\frac{-1}{2}} - \sqrt[3]{\color{blue}{\frac{\frac{1}{x + 1}}{\sqrt{x + 1}}}}\]

    if 2.6546736668899873e+116 < x

    1. Initial program 29.4

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
    2. Using strategy rm
    3. Applied flip3--29.4

      \[\leadsto \color{blue}{\frac{{\left(\frac{1}{\sqrt{x}}\right)}^{3} - {\left(\frac{1}{\sqrt{x + 1}}\right)}^{3}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} + \left(\frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}} + \frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)}}\]
    4. Simplified29.8

      \[\leadsto \frac{\color{blue}{\frac{\frac{1}{x}}{\sqrt{x}} - \frac{\frac{1}{\sqrt{x + 1}}}{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} + \left(\frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}} + \frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification19.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 2.6546736668899873 \cdot 10^{+116}:\\ \;\;\;\;{x}^{\frac{-1}{2}} - \sqrt[3]{\frac{\frac{1}{1 + x}}{\sqrt{1 + x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{1}{x}}{\sqrt{x}} - \frac{\frac{1}{\sqrt{1 + x}}}{1 + x}}{\left(\frac{1}{\sqrt{1 + x}} \cdot \frac{1}{\sqrt{1 + x}} + \frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{1 + x}}\right) + \frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019144 
(FPCore (x)
  :name "2isqrt (example 3.6)"

  :herbie-target
  (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1)))))

  (- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))