Consider the problem of finding the zeros of the function

1. Are there any ? How many ? How do you know ?

2. Name at least five methods one could use to find the roots.

3. Is there a root in the interval [1,2] ?

Estimate how many iterations would the Bisection algorithm need to find such a root accurate to 12 decimals.

4. Write a code

Evaluation of F(x) should be done in a subprogram

The code should ask for input of

At each iteration n, should print out (nicely, in columns, use fprintf):

(with appropriate format, like '%d %f %e %e \n' )

Upon convergence, it should print out:

Debug on a simple problem, like 1.3-x on [1,2].

5. Use your

Output your final approximate root (with all appropriate digits), the residual, and how many iterations it took.

6. Write another code

(copy your Bisect code and modify).

Evaluation of F(x) and F'(x) should be done in a subprogram

The code should ask for input of:

Debug on a simple problem, like x

Then use it to find root of F(x) in [1,2] with TOL=1.e-12.

Now consider the problem of finding zeros of

7. Are there any ? How many ? How do you know ?

8. Use your Newton code to find the zero of G(x) closest to x=99 (radians) to 9 decimals ( use

Output your final approximate root, the residual, and how many iterations it took.

Note: Extremely accurate starting values are needed for this function. Plot it using gnuplot or Matlab or... or produce values of G(x) around x=99 to see the nature of the function. Simplest is gnuplot:plot [98.9:99] x-tan(x)then adjust the range [98.9:99] to zoom in further.

9. Matlab (and Maple, and ...) have built-in programs to solve nonlinear (systems of) equations, among which

This rootfinder needs an interval [a,b] on which the function changes sign;

it performs bisection and then inverse quadratic interpolation.

Try fzero on the function F(x) and on G(x).

In a single plain text file "lab2.txt", submit (on Canvas):

Lab2 , Name, Date

===================================================

a. Answers to each of 1, 2, 3, 5 (show ONLY final result).

===================================================

b. Answers to 7, 8 (show ONLY final result).

===================================================

c. Answers to 9.

Compare with yours from 5 and 8 on accuracy, efficiency (# of itereations).

===================================================

d. Your bisection code, CLEANED UP, and FCN function.

===================================================

e. Your Newton-Raphson code, CLEANED UP, and FCN function.