1

Rewrite the following to avoid loss of significant

  1. $\ln(x+1)-\ln(x)$ where $x>>1$

  2. $\cos^2(x)-\sin^2(x)$ where $x\approx \frac{\pi}{4}$

  3. $\sqrt{x^2+1}-x$ where $x>>1$

  4. $\sqrt{\frac{1+\cos x}{2}}$

  1. Using taylor expansion we get $$x-\frac{x^2}{2}+\frac{x^3}{3}-[(x-1)-\frac{(x-1)^2}{2}+\frac{(x-1)^3}{3}]=1+\frac{(x-1)^2-x^2}{2}+\frac{x^3-(x-1)^3}{3}$$

  2. Using taylor expansion we get $$(1-\frac{x^2}{2!}+\frac{x^4}{4!})^2-(x-\frac{x^3}{3!}+\frac{x^5}{5!})^2$$

  3. $$\sqrt{x^2+1}-x=(\sqrt{x^2+1}-x)\cdot (\frac{\sqrt{x^2+1}+x}{\sqrt{x^2+1}+x})=\frac{1}{\sqrt{x^2+1}+x}$$

  4. $$\sqrt{\frac{1+\cos x}{x}}\approx \sqrt{\frac{1+1-\frac{x^2}{2!}+\frac{x^4}{4!}}{2}}$$

Is this valid?

gbox
  • 12,867

2 Answers2

1

You don't want to use the Taylor series when $x$ is large. Better to use the law of exponents to write $\log(x+1) - \log (x)=\log(1+\frac 1x)$ and use the Taylor series from there.

This is the usual approach. You want to analytically subtract the large parts of the two numbers, reducing the cancellation.

Ross Millikan
  • 374,822
1

You shouldn't use Taylor series for these.

  1. $\log(x+1)-\log(x) = \log(1+\frac{1}{x})$

  2. $\cos^2 x - \sin^2 x = \cos 2x$

  3. $\sqrt{x^2+1} - x = (\sqrt{x^2+1} - x) \frac{\sqrt{x^2+1}+x}{\sqrt{x^2+1}+x}$ and simplify.

  4. $1+\cos x = 2\cos^2 \frac{x}{2}$. This identity should help.

videlity
  • 908
  • 2
    On (2), I'd go a bit further and write $\cos(2x) = -\sin (2 (x - \frac{\pi}{4}))$ to make it as well-behaved as possible when $x$ is close to $\frac{\pi}{4}$. – Daniel Schepler Feb 01 '18 at 01:22
  • @DanielSchepler Why is $-sin(2(x-\frac{\pi}{4}))$ is better? as $x\to \frac{\pi}{4}$ we will get like the case in $cos(2x)$ the expression $-sin(y)$ where $y\to 0$ – gbox Feb 01 '18 at 09:10