Question: (Pencil-and-paper and MATLAB) Consider the function f(x) = e^sin x + x^6 - 2x^4 -1 on the interval [-2, 2]. (a) Plot a graph of
(Pencil-and-paper and MATLAB) Consider the function f(x) = e^sin x + x^6 - 2x^4 -1 on the interval [-2, 2]. (a) Plot a graph of the function to obtain a rough estimate of where the zeros are. (b) Use Newtons method to find all the zeros in the interval. Proceed as follows. i. Create a MATLAB function [y, yp] = f(x) which accepts input and generates outputs y = f(x) and yp = f(x) where f is the function defined above. The function should reside in a file called f.m. ii. Create a MATLAB function [x, n] = myNewton (x0, tol) which accepts an initial guess x0 and a tolerance tol, and returns the root x of f(x) = 0 computed by Newtons method to the specified tolerance. Choose whether to apply the tolerance to x_n = x_n - 1, the difference between successive iterates, to f(x_n), or to a combination thereof. The second output argument is the number of iterations n needed to achieve the tolerance. You may use, as a starting point, the script Newton discussed in class and supplied in the notes for Lesson 2. iii. Create a MATLAB script callNewton.m that calls myNewton (x0, tol) to compute all the zeros of f. This script should supply the tolerance as well as a guess for each zero of f to the function myNewton (x0,tol). The numerical output should be a suitably headed table of three columns displaying the computed solution a, the value f(x), and the number of iterations. Print out the solutions to seven places after the decimal. iv. For each zero analyze the data to determine whether the convergence is quadratic or linear
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
