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

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

\end{array}
double f(double x) {
        double r2696535 = 1.0;
        double r2696536 = x;
        double r2696537 = sqrt(r2696536);
        double r2696538 = r2696535 / r2696537;
        double r2696539 = r2696536 + r2696535;
        double r2696540 = sqrt(r2696539);
        double r2696541 = r2696535 / r2696540;
        double r2696542 = r2696538 - r2696541;
        return r2696542;
}

double f(double x) {
        double r2696543 = x;
        double r2696544 = 8764.773044208743;
        bool r2696545 = r2696543 <= r2696544;
        double r2696546 = -0.5;
        double r2696547 = pow(r2696543, r2696546);
        double r2696548 = 1.0;
        double r2696549 = r2696548 + r2696543;
        double r2696550 = r2696548 / r2696549;
        double r2696551 = sqrt(r2696549);
        double r2696552 = r2696550 / r2696551;
        double r2696553 = cbrt(r2696552);
        double r2696554 = r2696547 - r2696553;
        double r2696555 = r2696543 * r2696543;
        double r2696556 = r2696548 / r2696555;
        double r2696557 = r2696555 * r2696543;
        double r2696558 = r2696548 / r2696557;
        double r2696559 = r2696556 - r2696558;
        double r2696560 = r2696555 * r2696555;
        double r2696561 = r2696548 / r2696560;
        double r2696562 = r2696559 + r2696561;
        double r2696563 = r2696548 / r2696551;
        double r2696564 = r2696563 + r2696547;
        double r2696565 = r2696562 / r2696564;
        double r2696566 = r2696545 ? r2696554 : r2696565;
        return r2696566;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.9
Target0.7
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 < 8764.773044208743

    1. Initial program 0.3

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

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

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

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

      \[\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. Simplified0.1

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

    if 8764.773044208743 < x

    1. Initial program 39.6

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

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

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

      \[\leadsto {x}^{\color{blue}{\frac{-1}{2}}} - \frac{1}{\sqrt{x + 1}}\]
    6. Using strategy rm
    7. Applied flip--44.6

      \[\leadsto \color{blue}{\frac{{x}^{\frac{-1}{2}} \cdot {x}^{\frac{-1}{2}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{{x}^{\frac{-1}{2}} + \frac{1}{\sqrt{x + 1}}}}\]
    8. Taylor expanded around -inf 10.9

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

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

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

Reproduce

herbie shell --seed 2019152 
(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)))))