Computational Methods: Explain how to evaluate the following functions accurately for small |x|

66 Views Asked by At

Please help me solve this problem. I have a difficult time understanding my professor and need assistance on my homework assignment so I can be prepared when the exam comes. The question is as follows-

Explain how to evaluate the following functions accurately for small $x$

a) $\left[{1\over(1+2x)}\right]+\left[{(1-x)\over(1+x)}\right]$

b) $\sqrt{({1\over x})+x}−\sqrt{({1\over x})-x}$

c) $\operatorname{sinh}(x) = [e^x−e^{-x}]/2$

1

There are 1 best solutions below

0
On

The basic idea is to avoid loss of precision when subtracting two nearly equal quantities. This should be a major theme of your course. A simple example is computing $1-(1-x)$ for small $x$. If you compute it as written you will lose many bits of $x$ from the first subtraction. Try it in your environment for $x=10^{-10}, 10^{-20}, 10^{-30}$. In my Excel I get zero for $1-(1-x)$ at $x=10^{-10}$. The fix is to analytically cancel the large term, replacing $1-(1-x)$ with $x$. You can use Taylor series, because when $x$ is small they converge very rapidly.