Average Error: 20.2 → 5.5
Time: 9.5s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \le 138832.0855285687721334397792816162109375:\\ \;\;\;\;\sqrt{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\left(x + 1\right) \cdot x}} \cdot \frac{\sqrt{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\left(x + 1\right) \cdot x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 \cdot \left(\left(\frac{1}{{x}^{2}} + \frac{1}{{x}^{4}}\right) - \frac{1}{{x}^{3}}\right)}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\\ \end{array}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
\mathbf{if}\;x \le 138832.0855285687721334397792816162109375:\\
\;\;\;\;\sqrt{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\left(x + 1\right) \cdot x}} \cdot \frac{\sqrt{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\left(x + 1\right) \cdot x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\\

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

\end{array}
double f(double x) {
        double r131847 = 1.0;
        double r131848 = x;
        double r131849 = sqrt(r131848);
        double r131850 = r131847 / r131849;
        double r131851 = r131848 + r131847;
        double r131852 = sqrt(r131851);
        double r131853 = r131847 / r131852;
        double r131854 = r131850 - r131853;
        return r131854;
}

double f(double x) {
        double r131855 = x;
        double r131856 = 138832.08552856877;
        bool r131857 = r131855 <= r131856;
        double r131858 = 1.0;
        double r131859 = r131858 * r131858;
        double r131860 = r131855 + r131858;
        double r131861 = r131860 - r131855;
        double r131862 = r131859 * r131861;
        double r131863 = r131860 * r131855;
        double r131864 = r131862 / r131863;
        double r131865 = sqrt(r131864);
        double r131866 = sqrt(r131855);
        double r131867 = r131858 / r131866;
        double r131868 = sqrt(r131860);
        double r131869 = r131858 / r131868;
        double r131870 = r131867 + r131869;
        double r131871 = r131865 / r131870;
        double r131872 = r131865 * r131871;
        double r131873 = 1.0;
        double r131874 = 2.0;
        double r131875 = pow(r131855, r131874);
        double r131876 = r131873 / r131875;
        double r131877 = 4.0;
        double r131878 = pow(r131855, r131877);
        double r131879 = r131873 / r131878;
        double r131880 = r131876 + r131879;
        double r131881 = 3.0;
        double r131882 = pow(r131855, r131881);
        double r131883 = r131873 / r131882;
        double r131884 = r131880 - r131883;
        double r131885 = r131858 * r131884;
        double r131886 = r131885 / r131870;
        double r131887 = r131857 ? r131872 : r131886;
        return r131887;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.2
Target0.6
Herbie5.5
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < 138832.08552856877

    1. Initial program 0.4

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}\]
    4. Using strategy rm
    5. Applied frac-times0.5

      \[\leadsto \frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1 \cdot 1}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
    6. Applied frac-times0.7

      \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1}{\sqrt{x} \cdot \sqrt{x}}} - \frac{1 \cdot 1}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
    7. Applied frac-sub0.6

      \[\leadsto \frac{\color{blue}{\frac{\left(1 \cdot 1\right) \cdot \left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right) - \left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(1 \cdot 1\right)}{\left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
    8. Simplified0.5

      \[\leadsto \frac{\frac{\color{blue}{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}}{\left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
    9. Simplified0.4

      \[\leadsto \frac{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\color{blue}{\left(x + 1\right) \cdot x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity0.4

      \[\leadsto \frac{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\left(x + 1\right) \cdot x}}{\color{blue}{1 \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right)}}\]
    12. Applied add-sqr-sqrt0.5

      \[\leadsto \frac{\color{blue}{\sqrt{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\left(x + 1\right) \cdot x}} \cdot \sqrt{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\left(x + 1\right) \cdot x}}}}{1 \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right)}\]
    13. Applied times-frac0.4

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\left(x + 1\right) \cdot x}}}{1} \cdot \frac{\sqrt{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\left(x + 1\right) \cdot x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}\]
    14. Simplified0.4

      \[\leadsto \color{blue}{\sqrt{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\left(x + 1\right) \cdot x}}} \cdot \frac{\sqrt{\frac{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\right)}{\left(x + 1\right) \cdot x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]

    if 138832.08552856877 < x

    1. Initial program 40.1

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}\]
    4. Taylor expanded around inf 10.5

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

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

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

Reproduce

herbie shell --seed 2019308 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64

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

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