233k views
1 vote
No simple formulae exist to compute the zeros of a general function f(x) (i.e, the values of x for which f(x) = 0). This includes even polynomial functions of degree greater than 4. Instead, numerical methods must be used to find these zeros. We have previously considered a "brute force" approach to this problem: compute f(x) on a large range of values for x, and look for the one which results in f(x) being close to zero. In addition to being inelegant, this approach requires a large amount unnecessary computation (and hence time). It is far more efficient, and elegant to use a more sophisticated "guess and check" algorithm to "home in" on a value of x for which f(x) = 0, using as few computations as possible. One common algorithm is known as Newton's method, which can be summarized as follows: Start with an (essentially arbitrary) initial guess z for one of the zeros of the function f(x). Compute f(2). Iff(2)=0 then z is a zero and we are done. Of course, it is unlikely that the initial guess for z really is a zero, so generally A(z) +0. In this case, Newton's method generates a new, "improved" guess for the zero z according to the formula (+) 1'(). In this formula the "old" guess for z is used on the right-hand side of the equation, and the result is used to define the new guess for z. We then check this new z to see if f(x) = 0, and if not repeat the above calculation with the new z to generate yet another new z, continuing in this fashion as long as necessary until f(z) = 0. Of course, the finite precision of the computer means that we can't really continue the process of generating better and better guesses until f(z) is exactly zero, as this would require essentially infinite time. Rather, we must settle for zeros which satisfy||() < € where is some small "tolerance" level near to, but not exactly equal to zero. For this assignment, you can take e = 10-10 (1e-10 in Matlab). Write a Matlab function called polyroot such that the command z-polyroot(p), where p is a vector defining the coefficients of a polynomial, will use Newton's method to find one of the zeros of this polynomial. Hints: Use the function polyval to compute f(z). Use the function polyder together with polyval to compute the derivative f '(z). Since you don't know ahead of time how many iterations will be required to reach the desired accuracy, use a while loop to keep generating new guesses until the tolerance is met. Use z = 0 as your initial guess.

User Bmjohns
by
7.7k points

1 Answer

6 votes

Final answer:

Newton's method is a numerical method used to find the zeros of a polynomial function. It involves iteratively improving an initial guess until the polynomial approaches zero within a specified tolerance level. In MATLAB, you can implement this method using the polyval and polyder functions.

Step-by-step explanation:

Newton's method is a numerical method used to find the zeros of a general function. It involves iteratively improving an initial guess until the function approaches zero within a specified tolerance level. In this case, the tolerance level is set to 10-10.

To implement Newton's method for finding the zero of a polynomial, you can use the polyval function to compute the value of the polynomial at a given point, and the polyder function to compute the derivative of the polynomial. You can then use these to iteratively improve the initial guess until the polynomial function is close to zero within the specified tolerance level.

To implement this in MATLAB, you can define a function called polyroot that takes a vector of coefficients representing the polynomial. The function can use a while loop to iteratively compute the new guess for the zero using the formula z - polyval(p, z) / polyval(polyder(p), z), and continue iterating until the polynomial function evaluated at the new guess is within the specified tolerance level.

User Phindmarsh
by
8.4k points