Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

The function \(f_{1}(x, \delta)=\cos (x+\delta)-\cos (x)\) can be transformed into another form, \(f_{2}(x, \delta)\), using the trigonometric formula $$ \cos (\phi)-\cos (\psi)=-2 \sin \left(\frac{\phi+\psi}{2}\right) \sin \left(\frac{\phi-\psi}{2}\right) . $$ Thus, \(f_{1}\) and \(f_{2}\) have the same values, in exact arithmetic, for any given argument values \(x\) and \(\delta\). (a) Show that, analytically, \(f_{1}(x, \delta) / \delta\) or \(f_{2}(x, \delta) / \delta\) are effective approximations of the function \(-\sin (x)\) for \(\delta\) sufficiently small. (b) Derive \(f_{2}(x, \delta)\). (c) Write a MATLAB script which will calculate \(g_{1}(x, \delta)=f_{1}(x, \delta) / \delta+\sin (x)\) and \(g_{2}(x, \delta)=\) \(f_{2}(x, \delta) / \delta+\sin (x)\) for \(x=3\) and \(\delta=1 . \mathrm{e}-11 .\) (d) Explain the difference in the results of the two calculations.

Short Answer

Expert verified
Question: Show that \(f_1(x, \delta) / \delta\) and \(f_2(x, \delta) / \delta\) are effective approximations of \(-\sin(x)\) for small \(\delta\), and explain the difference in results of \(g_1(x, \delta)\) and \(g_2(x, \delta)\) for \(x = 3\) and \(\delta = 1e-11\). Answer: Both \(f_1(x, \delta) / \delta\) and \(f_2(x, \delta) / \delta\) can effectively approximate \(-\sin(x)\) for small values of \(\delta\), as shown analytically. The difference in results of \(g_1(x, \delta)\) and \(g_2(x, \delta)\) arises from the limited precision of floating-point numbers in MATLAB. When \(\delta\) is very small, calculations involving \(f_1(x, \delta)\) suffer from catastrophic cancellation due to the subtraction of nearly equal numbers, resulting in a loss of precision. Conversely, \(f_2(x, \delta)\) does not involve such subtraction and provides more accurate results for small values of \(\delta\).

Step by step solution

01

(a) Showing effective approximation

Analytically, we want to show that \(f_1(x, \delta) / \delta\) and \(f_2(x, \delta) / \delta\) are effective approximations of \(-\sin(x)\) for \(\delta\) sufficiently small. Consider the function \(f_1(x, \delta)\), $$ f_1(x, \delta) = \cos(x+\delta) - \cos(x). $$ Now divide by \(\delta\): $$ \frac{f_1(x, \delta)}{\delta} = \frac{\cos(x+\delta) - \cos(x)}{\delta}. $$ As \(\delta \to 0\), the expression on the right side becomes the derivative of \(\cos(x)\) with respect to \(x\): $$ \lim_{\delta \to 0} \frac{\cos(x+\delta) - \cos(x)}{\delta} = -\sin(x). $$ So, \(f_1(x, \delta) / \delta\) can effectively approximate \(-\sin(x)\) for small values of \(\delta\). The same analysis applies to \(f_2(x, \delta)\).
02

(b) Deriving \(f_2(x, \delta)\)

Now we will derive \(f_2(x, \delta)\) by substituting \(\phi = x+\delta\) and \(\psi = x\) into the trigonometric formula: $$ \cos(\phi) - \cos(\psi) = -2 \sin\left(\frac{\phi+\psi}{2}\right) \sin\left(\frac{\phi-\psi}{2}\right). $$ Plugging in \(\phi = x+\delta\) and \(\psi = x\), we get: $$ f_2(x, \delta) = -2 \sin\left(\frac{x + \delta + x}{2}\right) \sin\left(\frac{x + \delta - x}{2}\right). $$ Simplify the expression: $$ f_2(x, \delta) = -2 \sin\left(\frac{2x + \delta}{2}\right) \sin\left(\frac{\delta}{2}\right) = -2 \sin(x + \frac{\delta}{2}) \sin\left(\frac{\delta}{2}\right). $$
03

(c) MATLAB script

Here is the requested MATLAB script to calculate \(g_1(x, \delta)\) and \(g_2(x, \delta)\) for \(x = 3\) and \(\delta = 1e-11\): ```MATLAB x = 3; delta = 1e-11; % Calculate f1(x, delta) and f2(x, delta) f1 = cos(x + delta) - cos(x); f2 = -2 * sin(x + delta / 2) * sin(delta / 2); % Calculate g1(x, delta) and g2(x, delta) g1 = f1 / delta + sin(x); g2 = f2 / delta + sin(x); % Display the results disp(['g1(x, delta) = ', num2str(g1)]); disp(['g2(x, delta) = ', num2str(g2)]); ```
04

(d) Explaining difference in results

The difference in the results of the two calculations can be attributed to the limited precision of floating-point numbers in MATLAB. When \(\delta\) is very small, the calculations involving \(f_1(x, \delta)\) can suffer from catastrophic cancellation due to the subtraction of nearly equal numbers, leading to a loss of precision. On the other hand, \(f_2(x, \delta)\) does not involve such subtraction, so its results tend to be more accurate for small values of \(\delta\).

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

Key Concepts

These are the key concepts you need to understand to accurately answer the question.

Trigonometric Identities
Trigonometric identities are mathematical relationships involving trigonometric functions like sine, cosine, and tangent. These identities allow us to simplify expressions and solve equations involving these functions. A key identity used in this exercise is:
  • \( \cos(\phi) - \cos(\psi) = -2 \sin\left(\frac{\phi+\psi}{2}\right) \sin\left(\frac{\phi-\psi}{2}\right) \).
This identity transforms the difference of two cosines into a product of sines.
In this particular problem, it helps in deriving the expression for \(f_2(x, \delta)\) from \(f_1(x, \delta)\) by substituting \(\phi = x + \delta\) and \(\psi = x\). This transformation makes the function easier to analyze, especially when using it for numerical computations.
Floating Point Precision
Floating point numbers are used in computers to represent real numbers. They have a fixed precision determined by the number of bits used to store them. Floating point precision becomes crucial in calculations where very small or very large numbers are involved.

In our problem, we deal with very small \(\delta\). When calculating using formulas like \(f_1(x, \delta) = \cos(x+\delta) - \cos(x)\), the limited precision of floating point numbers can affect the accuracy of results.
  • Small changes in values can be lost due to rounding errors.
  • Precision error increases when small differences of large numbers are computed, i.e., \(\cos(x+\delta) - \cos(x)\).
Understanding and considering floating point precision is essential when writing programs or scripts that require high numerical accuracy. MATLAB, like other computing environments, provides functions and quirks that can mitigate these limitations.
Catastrophic Cancellation
Catastrophic cancellation occurs when subtracting two nearly equal numbers. It causes significant loss of precision because the significant digits cancel each other out, leaving behind only the insignificant ones.

This is particularly relevant in the exercise at hand. Calculating \(f_1(x, \delta)\) involves subtracting two similar cosine values, especially for small \(\delta\). This subtraction can lead to catastrophic cancellation, creating inaccurate results.
  • The subtraction in \(f_1(x, \delta)\) leads to a precision loss since \(\delta\) is very small.
  • The alternate formulation, \(f_2(x, \delta)\), avoids direct subtraction of similar values, thus providing a more stable and accurate result.
Recognizing when catastrophic cancellation might occur helps in choosing appropriate mathematical formulations to avoid significant computation errors. This highlights the importance of exploring multiple representations and understanding the underlying numerical algorithms in scientific computations.

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

The fraction in a single precision word has 23 bits (alas, less than half the length of the double precision word). Show that the corresponding rounding unit is approximately \(6 \times 10^{-8}\).

Suppose a computer company is developing a new floating point system for use with their machines. They need your help in answering a few questions regarding their system. Following the terminology of Section \(2.2\), the company's floating point system is specified by \((\beta, t, L, U) .\) Assume the following: \- All floating point values are normalized (except the floating point representation of zero). \- All digits in the mantissa (i.e., fraction) of a floating point value are explicitly stored. \- The number 0 is represented by a float with a mantissa and an exponent of zeros. (Don't worry about special bit patterns for \(\pm \infty\) and NaN.) Here is your part: (a) How many different nonnegative floating point values can be represented by this floating point system? (b) Same question for the actual choice \((\beta, t, L, U)=(8,5,-100,100)\) (in decimal) which the company is contemplating in particular. (c) What is the approximate value (in decimal) of the largest and smallest positive numbers that can be represented by this floating point system? (d) What is the rounding unit?

Write a quadratic equation solver. Your MATLAB script should get \(a, b, c\) as input, and accurately compute the roots of the corresponding quadratic equation. Make sure to check end cases such as \(a=0\), and consider ways to avoid an overflow and cancellation errors. Implement your algorithm and demonstrate its performance on a few cases (for example, the cases mentioned in Exercise 15). Show that your algorithm produces better results than the standard formula for computing roots of a quadratic equation.

Write a MATLAB program that receives as input a number \(x\) and a parameter \(n\) and returns \(x\) rounded to \(n\) decimal digits. Write your program so that it can handle an array as input, returning an array of the same size in this case. Use your program to generate numbers for Example \(2.2\), demonstrating the phenomenon depicted there without use of single precision.

Suggest a way to determine approximately the rounding unit of your calculator. State the type of calculator you have and the rounding unit you have come up with. If you do not have a calculator, write a short MATLAB script to show that your algorithm works well on the standard IEEE floating point system.

See all solutions

Recommended explanations on Math Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free