Department of Mathematics

Math 300: Mathematical Computing

Assignment 9

For this assignment you will write a Matlab function called trapplot that computes and plots a given function and its 'trapezoid' approximate. The function will take four arguments: a function handle, the left endpoint of the interval, the right endpoint, and the number of subintervals. You should also make Matlab functions to evaluate the following mathematical functions. Use them to test your plotting function.

Figure 1. A sample plot
Each of those functions takes only one argument: a vector x containing the points where it should be evaluated. Make sure you use e.g. '.*' and '.^' notation to create your functions so they can take vector arguments. We emphasize that your functions must accept vector arguments, and produce vectors that can be plotted from those. An example of a plot trapplot will produce is shown in Figure 1. Observe the following.

The assignment is turned in when the three .m files containing the scripts are received as an attachment to an email message in the instructor's inbox. If your function uses any other function file, be sure that is also attached to your message. The assignment is worth 40 points, and is due at 9:00 on Tuesday, 6 November.

Hint: The limit of \(x\sin\frac{1}{x}\) at 0 exists. We can evaluate the function there by a clever use of boolean vectors.

Assignment C is posted.

The test solution is available.

Department of Mathematics, PO Box 643113, Neill Hall 103, Washington State University, Pullman WA 99164-3113, 509-335-3926, Contact Us
Copyright © 1996-2015 Kevin Cooper