Transcribed TextTranscribed Text

Homework Problems for Chapter 5 1. Bisection method We consider the bisection method to find a root for f(x) = 0 where f is a continuous function. If f(0) < 0 and f(1) > 0, then there is a root on the interval [0, 1], and we take [0, 1] as the initial interval. How many steps of the bisection method are needed to obtain an approximation to the root, if the absolute error is guaranteed to be ≤ 10−8 ? (Note that your answer does not depend on the actual function!) 2. Fixed point iteration Given a function f(x) = e −x − cos(x). We want to find a root r such that f(r) = 0. (a). First show that there is a root inside the interval [1.1, 1.6]. (b). Next, we try to locate this root by a fixed point iteration. We observe that f(x) = 0 is equivalent to x = g1(x), where g1(x) = f(x) + x. Set up the corresponding fixed point iteration scheme. Then, choose the starting point x0 = 1.6, and perform 4 iterations to compute the values x1, x2, x3, x4. What do you observe? Does the method converge? Why? (c). We now observe that f(x) = 0 is also equivalent to x = g2(x), where g2(x) = x − f(x). Based on this new function, set up the corresponding fixed point iteration. Choose again x0 = 1.6 as your starting point , and perform 4 iterations to compute the values x1, x2, x3, x4. What is your result? How different is it from part (b)? Does the method converge? Why? 3. More on fixed point iteration. Consider the iteration scheme: xn+1 = 1 2 xn + 1 xn , x0 = 1 (a). If the iteration converges, what is limn→∞ xn? (b). Does the method converge? Why? 1 4. Newton’s method As you have seen in Example 5.7 in Section 5.4, the computation of √ R can be carried out by finding the root of f(x) = x 2 − R using Newton’s method. (a). Check that in this case Newton’s iteration scheme is xn+1 = 1 2  xn + R xn  . (b). Show that the sequence (xn)n≥1 satisfies x 2 n+1 − R =  x 2 n − R 2xn 2 . Interpret this equation in terms of quadratic convergence. The quantity x 2 n − R = f(xn) is also called the residual. It gives a measure of the error in the approximation xn. (c). Now we test the iterations for R = 10. Choose x0 = 3, and compute x1, x2 x3 and x4. Use 8 digits in your computation. Comment on your result. 5. When Newton’s Method Does not Work Well. (i). Let m be a positive integer and consider the function f(x) = (x − 1)m. It is clear that r = 1 is a root (indeed, it is a root with multiplicity m). We now try to find this root by Newton’s iteration, for m = 8. (a). Set up the iteration scheme. (b). Use x0 = 1.1 as your initial guess (note that this is very close to the root r = 1). Complete 4 iterations to compute the values x1, x2, x3, x4. (c). How does the method work for this problem? Do we still have quadratic convergence? Can you explain what is causing this? (d). If m = 20 (or with any large value of m), can you predict the behavior of Newton’s iteration? What type of convergence will you get? Explain in detail. (ii). Use Newton’s method to solve the equation 0 = 1 2 + 1 4 x 2 − x sin(x) − 1 2 cos(2x), with x0 = π 2 . Iterate using Newton’s method until an accuracy of 10−3 is obtained. Explain why the result seems unusual for Newton’s method. 2 6. Newton’s Method in Matlab Preparation: Use “help sprintf” and “help disp” in Matlab to understand how to use “sprintf” and “disp” to display the data. Here is an example: disp(sprintf(’I have n=%d and x=%g but f=%f.\n’,2,1.22, 1.22)) This will give the following result in Matlab: I have n=2 and x=1.22 but f=1.220000. The problem: Write a Matlab function for Newton’s method. Your file mynewton.m should start with: function x=mynewton(f,df,x0,tol,nmax) Among the input variables, f,df are the function f and its derivative f 0 , x0 is the initial guess, tol is the error tolerance, and nmax is the maximum number of iterations. The output variable x is the result of the Newton iterations. Use sprintf and “disp” to display your result in each iteration so you can check the convergence along the way. First, test your function with Example 5.7 in Section 5.4, computing √ 2. Then, use your Matlab function to find a root of f(x) = e −x − cos(x) on the interval [1.1, 1.6]. Use tol=1e-12 and nmax=10. You should choose an initial guess x0 on the interval [1.1, 1.6]. What is your answer? What to hand in: Print out your files mynewton.m, files for functions f(x) and f 0 (x), script file, test result for the example of √ 2 and for the root of f(x) = e −x − cos(x). 7. The secant method a). Calculate an approximate value for 43/5 using the secant method with x0 = 3 and x1 = 2. Make 3 steps, and compute the values x2, x3, x4. Comment on your result. b). Use secant method to find the root for f(x) = x 3 −2x+ 1 with x0 = 4 and x1 = 2. Compute the values x2, x3 and x4. Does the method converge? (You can easily check that x = 1 is a root.) c). Consider the iteration scheme xn+1 = xn + (2 − e xn )(xn − xn−1)/(e xn − e xn−1 ), x0 = 0, x1 = 1. If the iteration converges, what is limn→∞ xn ? 3 8. The Secant Method in Matlab Write a Matlab function to locate a root by the secant method. Your function should be put in the file mysecant.m, and should be called as x=mysecant(f,x0,x1,tol,nmax) Here f is the function f, x0,x1 are the initial guesses, tol is the error tolerance, nmax is the maximum number of iterations, and x is the output of your function. Test your function to find the value √ 2, as the root for f(x) = x 2 − 2, to see if it works. Use sprintf and “disp” to display your result in each iteration, so you can check the convergence. Then, use it to find a root for the function f(x) = e −x − cos(x) in the interval [1.1, 1.6]. Use tol=1e-12 and nmax=10. Your two initial guesses should be on the interval [1.1, 1.6]. How does the result compare to those with Newton’s method? Comment in detail. What to hand in: Your file mysecant.m, test result for f(x) = x 2 − 2, and the result for f(x) = e −x − cos(x).

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

    By purchasing this solution you'll be able to access the following files:
    Solution.docx, mynewton.m and mysecant.m.

    for this solution

    PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

    Find A Tutor

    View available MATLAB for Computer Science Tutors

    Get College Homework Help.

    Are you sure you don't want to upload any files?

    Fast tutor response requires as much info as possible.

    Upload a file
    Continue without uploading

    We couldn't find that subject.
    Please select the best match from the list below.

    We'll send you an email right away. If it's not in your inbox, check your spam folder.

    • 1
    • 2
    • 3
    Live Chats