MCS 471 Computer Project 2

Problems turned in late (i.e. not in class) will be penalized 10% per day.


Write a well-documented Matlab function (m-file), called mybrent, that implements a hybrid root finding algorithm based on bisection and the secant method as described in class and in the supplement. The inputs should be: The outputs should be the approximation to the root and the last bracket. By including print statements in your function, you should display the following table including the starting point:

K   X(K)     ABS(X(K)-X(K-1))      F(X(K))

Here X(K) is either m or s, based on which is closest to b.
Test Examples: For each of the examples, use (1,2) as the initial sign change interval (double check this of course). You should compare your answers with the roots found using Matlab's root finder fzero.
  1. F1(X) = exp(-4.5*X) -X/200.
  2. F2(X) = X^8 - 8*X^7 + 28*X^6 - 56*X^5 + 70*X^4 - 56*X^3 + 28*X^2 - 8*X + 1 - 1e-14 Note: you should know in advance from computer project 1 that you can not do this problem. Use fplot over the interval [.99,1.03] to illustrate the problem. After you have determined that, please do the problem (x-1)^8 - 1e-14
  3. p(x) = 170.4*x^3 - 356.41*x^2 + 168.97*x + 18.601 has three real zeros. The two positive zeros lie in the interval [1.091607 , 1.091608 ] can you find them with any accuracy? You may want to try using some of the techniques mentioned in class for finding zeros located near each other. Note that these are simple zeros, but are close together.

You should submit your Matlab function m-file along with a separate sheets for each of the above examples. For the examples, you should use your function and Matlab's fzero as a comparison. Use diary command or cut/paste to capture the command window use of your function.


by Charles Tier

©2002 Charles Tier