2
$\begingroup$

I'm working through a numerical analysis text and came across this question.

The function $f_{1}(x,\delta) = \cos(x + \delta) - \cos(x)$ can be transformed into another form, $f_{2}(x,\delta)$, using the formula $$ \cos(\phi) - \cos(\varphi) = -2\sin\bigg(\frac{\phi + \varphi}{2}\bigg)\sin\bigg(\frac{\phi - \varphi}{2}\bigg) $$ Thus, $f_{1}$ and $f_{2}$ have the same values, in exact arithmetic, for any given argument values $x$ and $\delta$.

(1) Show that, analytically, $f_{1}/\delta$ and $f_{2}/\delta$ are effective approximations.

This is very vague. How might this be accomplished?

(2) Explain the difference in the computed results (in MATLAB or a similar software) for $$\frac{f_{1}}{\delta} + \sin(x) \hspace{5mm} \text{ and } \hspace{5mm} \frac{f_{2}}{\delta} + \sin(x)$$

using $x = 3$ and $\delta = 1\times10^{-11}$.

I made a table of the computed values:

enter image description here

and I thus have $$\frac{f_{1}}{\delta} + sin(x) = -4.4060023643433\times 10^{-07}$$ $$\frac{f_{2}}{\delta} + sin(x) = 4.94995711086688\times 10^{-12}$$

How do I explanation these differences? I want to say that the division by $\delta$, which is arbitrarily small, amplifies the roundoff error in the calculations for $f_{1}$ and $f_{2}$. Then, the addition of $\sin(x)$ results in cancellation of significant digits since the two numbers are nearly equal. I am new to this new terminology so I want to get it straight. May you comment on my explanation?

$\endgroup$
1
  • 1
    $\begingroup$ I agree that the wording "effective approximations" in the first part seems vague or unclear. Are we asked to show the two expressions approximate each other? We've just been told that they are equal in exact arithmetic. Perhaps if you cited the numerical analysis text at issue it might clear up the author's meaning. $\endgroup$ – hardmath Jan 24 '16 at 4:24
3
$\begingroup$

Perhaps you lost some words and the first part is (1) Show that, analytically, $f_{1}/\delta$ and $f_{2}/\delta$ are effective approximations to $\frac {d\cos x}{dx}$ I suggest this because it looks like the thing you take the limit (as $\delta \to 0$) of to get the derivative. Then $\frac {f_1(x,\delta)}\delta \approx -\sin x$ and you might expect the addition of $\sin x$ to result in cancellation.

To explain the difference in $f_1$ and $f_2$ as computed, note that the numerator in $f_1$ has two nearly equal quantities being subtracted so you will get cancellation. In $f_2$ the subtraction is handled analytically because the second term is $\sin \frac \delta 2$ and no cancellation occurs at this step.

$\endgroup$
2
  • $\begingroup$ You're correct. I did overlook the $-\sin x$ portion. $f_{1}/\delta$ as the limit of $\cos(x)$ is exceedingly clear, but not so much for $f_{2}$. Do you have any comments there? $\endgroup$ – clocktower Jan 24 '16 at 16:34
  • 1
    $\begingroup$ As $f_2=f_1$ analytically, they are the same approximation until you do the numerics as it says in the problem statement. The advantage in the second is the point of my second paragraph $\endgroup$ – Ross Millikan Jan 24 '16 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.