Average Error: 20.0 → 10.9
Time: 15.6s
Precision: 64
Internal Precision: 1088
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \le 1.26868933652928 \cdot 10^{-15}:\\ \;\;\;\;\left(\frac{1}{2} \cdot \sqrt{\frac{1}{{x}^{3}}} + \sqrt{\frac{1}{{x}^{7}}} \cdot \frac{5}{16}\right) - \sqrt{\frac{1}{{x}^{5}}} \cdot \frac{3}{8}\\ \mathbf{else}:\\ \;\;\;\;{x}^{\frac{-1}{2}} - \frac{1}{\sqrt{x + 1}}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.0
Target0.7
Herbie10.9
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Split input into 2 regimes
  2. if (- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))) < 1.26868933652928e-15

    1. Initial program 40.3

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt50.0

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\sqrt{\frac{1}{\sqrt{x + 1}}} \cdot \sqrt{\frac{1}{\sqrt{x + 1}}}}\]
    4. Applied add-sqr-sqrt40.4

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{x}}} \cdot \sqrt{\frac{1}{\sqrt{x}}}} - \sqrt{\frac{1}{\sqrt{x + 1}}} \cdot \sqrt{\frac{1}{\sqrt{x + 1}}}\]
    5. Applied difference-of-squares40.4

      \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{\sqrt{x}}} + \sqrt{\frac{1}{\sqrt{x + 1}}}\right) \cdot \left(\sqrt{\frac{1}{\sqrt{x}}} - \sqrt{\frac{1}{\sqrt{x + 1}}}\right)}\]
    6. Taylor expanded around inf 22.0

      \[\leadsto \color{blue}{\left(\frac{5}{16} \cdot \sqrt{\frac{1}{{x}^{7}}} + \frac{1}{2} \cdot \sqrt{\frac{1}{{x}^{3}}}\right) - \frac{3}{8} \cdot \sqrt{\frac{1}{{x}^{5}}}}\]

    if 1.26868933652928e-15 < (- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))

    1. Initial program 0.7

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

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

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

      \[\leadsto {x}^{\color{blue}{\frac{-1}{2}}} - \frac{1}{\sqrt{x + 1}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification10.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \le 1.26868933652928 \cdot 10^{-15}:\\ \;\;\;\;\left(\frac{1}{2} \cdot \sqrt{\frac{1}{{x}^{3}}} + \sqrt{\frac{1}{{x}^{7}}} \cdot \frac{5}{16}\right) - \sqrt{\frac{1}{{x}^{5}}} \cdot \frac{3}{8}\\ \mathbf{else}:\\ \;\;\;\;{x}^{\frac{-1}{2}} - \frac{1}{\sqrt{x + 1}}\\ \end{array}\]

Runtime

Time bar (total: 15.6s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes20.110.910.79.497.6%
herbie shell --seed 2018339 
(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)))))