# Fall 2012 MATH 151-8xx MATLAB Project 2

Introduction:

Today in lab, you will learn a formula for the equation of the line tangent to f at the point where x=a. Suppose there is a solution to the equation f(x)=0 near a (which we will now call x0 to avoid confusion below). In most cases, we can get an approximate solution (x1) by setting the tangent line equal to 0 and solving, then finding the tangent line at x1 and solving (=0) to create x2, and so on. To illustrate this, open the file EngrMath/Stewart/c03/sc/s230X01.m in Matlab and examine the 3 graphs produced.

Rather than re-calculating the equation of the tangent line each time, we can instead relabel the solution by letting a be xn and calling the solution xn+1. The resulting formula is called Newton's Method for solving equations:
xn+1 = xn - f(xn) / f '(xn)

Description
1. Students will work in their assigned teams on this assignment.
2. Assignment Objectives:
• Creating Functions in Matlab (Gilat pp220-226)
• Anonymous Functions (Gilat pp230-232)
• While Loops (Gilat pp195-198)
• Approximating Solutions to Equations in Matlab (Gilat pp 295-298)***NOTE: This should ONLY be used if you want to check your answers!
3. ALSO RECALL:
• Plotting Graphs (Gilat pp134-148)
5. For this assignment, you'll work out of the MATLAB Editor. You'll create a script file which runs the Newton program, plus two function files for f and f '. Files should be named so as to easily recognize the contents.
6. Your TA will give you 2 equations (f(x)=0) to solve. After entering your function and derivative as function files, you are to plot f to determine a starting guess, then run your program to find the solution to within .001 and publish your results.
7. This assignment is due 22-23 Oct, at the START of your computer lab. Be sure to manage your time according to your schedule. Do NOT put things off! It is highly advisable that you use the remaining time in lab to complete as much of the assignment as possible while your TA is available to help.
8. When you finish, you will turn in the printout of your published PDF file to your TA. Print a copy of the assignment page linked above, fill it out, and use it as a cover sheet.
Notes
• Your program should be able to solve any equation given the function and its derivative. To test your program, use an odd-numbered problem in Stewart 3.12 (pp232-233) and compare your final answer with the answer in the back of the book.
• There are samples of the types of problems you have to do in Sections 6.7 and 7.12 of your lab manual. (Not all sample problems apply to this assignment.) Watch the Streaming Videos linked on the Index page if you have not already done so.