Average Error: 3.8 → 0.1
Time: 29.5s
Precision: 64
Internal Precision: 320
\[\sqrt{1 + x \cdot x} - \sqrt{1 + x} \cdot x\]
\[\begin{array}{l} \mathbf{if}\;\sqrt{1 + x \cdot x} - \sqrt{1 + x} \cdot x \le 2.6007018313976645 \cdot 10^{+269}:\\ \;\;\;\;\sqrt{\sqrt{1 + x \cdot x}} \cdot \sqrt{\sqrt{1 + x \cdot x}} - \sqrt{1 + x} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x + \frac{\frac{1}{2}}{x}\right) - \frac{\frac{\frac{1}{8}}{x}}{x \cdot x}\right) - \sqrt{1 + x} \cdot x\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (- (sqrt (+ 1 (* x x))) (* (sqrt (+ 1 x)) x)) < 2.6007018313976645e+269

    1. Initial program 0.1

      \[\sqrt{1 + x \cdot x} - \sqrt{1 + x} \cdot x\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.1

      \[\leadsto \sqrt{\color{blue}{\sqrt{1 + x \cdot x} \cdot \sqrt{1 + x \cdot x}}} - \sqrt{1 + x} \cdot x\]
    4. Applied sqrt-prod0.1

      \[\leadsto \color{blue}{\sqrt{\sqrt{1 + x \cdot x}} \cdot \sqrt{\sqrt{1 + x \cdot x}}} - \sqrt{1 + x} \cdot x\]

    if 2.6007018313976645e+269 < (- (sqrt (+ 1 (* x x))) (* (sqrt (+ 1 x)) x))

    1. Initial program 64.0

      \[\sqrt{1 + x \cdot x} - \sqrt{1 + x} \cdot x\]
    2. Taylor expanded around inf 0.3

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

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

Runtime

Time bar (total: 29.5s)Debug log

herbie shell --seed '#(2775764126 3555076145 3898259844 1891440260 2599947619 1948460636)' 
(FPCore (x)
  :name "sqrt(1+x*x)-sqrt(1+x)*x"
  (- (sqrt (+ 1 (* x x))) (* (sqrt (+ 1 x)) x)))