Learning Objectives
At the end of this class you should be able to
- Recognize a local function in a m-file
 - Write a local function in a m-file
 - Recognize an embedded function in an m-file
 - Write an embedded function in an m-file
 - Describe how the 
brackPlotfunction is used to bracket the roots of . - Describe how the 
bisectfunction is used to find the roots of , given a bracket. - Write an m-file function that uses 
brackPlotandbisectto find the roots of an function. 
Reading
The textbook discusses root-finding in two separate contexts. Newton's method is used as an example of a computational algorithm Chapter 2, section 2.7.1 and then again in Chapter 7, section 7.1 through 7.3 as a practical means of discussing function m-files. Please review those sections.
Root-finding as a generic numerical method is discussed Chapter 14, section 14.1.
Download
- Download slides on user-defined functions and study slides 19-24
 - Download Lecture slides on root-finding and study these slides:
    
- Slides 1 - 16 on the introduction and on bracketing
 - Slides 23 - 27 on bisection
 - Slides 28 - 31 on convergence criteria
 
 
Review of MATLAB Programming Techniques
As of last week, we have covered the basic MATLAB programming techniques that we need for the rest of this class. Of course, continued practice with those techniques is necessary and useful. However, there are only a few relatively specialized skills that we will need to add to your repertoire.
Here is a list of topics to review.
- Creating vectors and matrices
 - Vectorized statements
 - Creating and using functions
 forloopsifconstructswhileloops- plotting
 - printing with 
fprintf 
Please consult the reference pages of the class web site, and in particular the MATLAB Vocabulary reference document
Shifting Emphasis to Numerical Methods.
Having covered the basic programming techniques used in MATLAB, we now begin
applying MATLAB to a basic problem in numerical methods.  The first technique is
root-finding.  Since root-finding involves iteration, we also need to understand
how to check for convergence of a sequence.  This task requires combining
knowledge of how to implement loops, if constructs, along with a little
knowledge of floating point arithmetic.
Convergence of the Series Approximations to
In the Lab Exercise 03 the series approximation to 
was used to demonstrate a for loop.
- Review of series notation and convergence
 - Absolute and relative convergence tolerance
 - Formula for series evaluation of
 - Simplistic implementation: fixed number of terms
 
We want to avoid the simplistic implementation by using a termination criterion to automatically stop evaluating terms in the series. This leads us to consider the difference between an absolute criterion and a relative criterion.
Convergence of Newton's Method for Computing .
In an application of a while loop in Lab Exercise 04, we used
Newton's method to find the square root of a number.  This also
leads us to consider the difference between an absolute convergence
criterion and a relative convergence criterion
- Review of iterative formula
 - Three iterations by hand
 - implementation of absolute and relative convergence tolerance
 - Testing over large ranges of .