Professional Documents
Culture Documents
0.1
f (x) = (x+1)3 (x1) obviously has roots at x = 1 and x = +1. Using starting
values that differ from the roots by 0.1, compare the number of iterations taken
when Newtons method computes both of the roots until they are within 0.0001
of the correct values.
0.2
1. Write a MATLAB user-defined function that solves for a root of a nonlinear equation f (x) = 0 using the bisection method. Name of the function
is: Xs = BisectionRoot(Fun,a,b)
The output argument Xs is the solution. The input argument Fun is a
name for the function that calculates f (x) for a given x (it is a dummy
name for the function that is imported into BisectionRoot); a and b are
two points that bracket the root. The iterations should stop when the
tolerance in f (x) is smaller than 0.000001. Note that is difference between true soluton f (XT S ) and numerical solution f (XN S ):
T oleranceInf = |f (XT S ) f (XN S )| = |0 | = ||
The program should check if points a and b are on opposite sides of the
solution. If not, the program should stop and display an error message.
2. Use the function BisectionRoot to determine the roots of
f (x) = x 2ex (start with a = 0 and b = 1). What is the result?