CS368 Homework 7
| ||
AnnouncementsCheck here periodically.
| ||
ProblemsYou can get started with this homework by downloading this MATLAB script: Complete ALL your work in MATLAB (in your homework7.m script and any functions you write. And, as with all homework assignments, your solution must use techniques discussed and covered in lecture and the on-line readings. You may not use MATLAB commands or constructs that have not been covered in lecture prior to the date of the release of the homework (or in the corresponding on-line readings). Problem 1: (12 points) The Secant MethodIn MATLAB, roots of functions are determined numerically (i.e., rather than symbolically) using numeric approximation algorithms. The Successive Numeric Approximation module describes Newton's Method for finding roots and you saw an implementation of the Bisection Method and Newton's Method in the Finding Roots example from the Successive Numeric Approximation handout. In this problem, you will implement a different numeric approximation algorithm for finding roots, the Secant Method. For the purposes of this problem, the function whose roots you will be finding is This function is defined for you already (as a function handle named fctn) inside the provided homework7.m script.
A function which implements Newton's Method for finding roots has been implemented for you. Download the file Newton's Method uses the first derivative of the function in its computation. In order for the newton function to work, it requires that 3 arguments be given to it: a function handle for the function for which we wish to find the root, a function handle for the function that computes the derivative of the function, and an initial guess for the location of the root.
The Secant Method takes two initial guesses (x0 and x1), which must be distinct. It is very similar to Newton's method except that instead of using the derivative to find the slope of the tangent line at a point on the function, it estimates the slope of the tangent line by using the slope of the line between two nearby points on the function (i.e., the secant line). The formula for determining the next guess (based on the two previous guesses) is: Starting with the initial guesses, x0 and x1, a new guess, x2, is then obtained by finding where the line between the function values at the initial guesses intersects the x-axis; x1 and x2 are then used to compute a new guess, x3, and the process repeats until the desired precision is reached (or two guesses in succession are identical).
We now wish to compare the results we get using fzero, Newton's method, and the secant method for our function f(x).
Problem 2: (8 points) Area between two curvesThis problem deals with the two curves: and These curves are displayed in the next figure: For this problem, you will need to make appropriate use of MATLAB's built-in fzero and integral functions. These MATLAB functions each take a function handle as one of their parameters. To receive full credit for this problem, you must use anonymous functions to represent the functions being passed as parameters (i.e., you may not define any functions in separate m-files). You will also need to add code to your homework7.m script which runs everything and displays the appropriate output.
| ||
Handing inUpload your m-files to your Dropbox in Learn@UW. See these instructions for uploading files to a Learn@UW Dropbox. The files you should upload are:
In order for your work to be considered to have been turned in on-time, you must upload your files to your Learn@UW Dropbox by 11:59 pm Friday, May 6. | ||
Last Updated: 4/26/2016 © 2016 Beck Hasti, hasti@cs.wisc.edu |