MA/CS 371 - Lab 6
Even More Numerical Integration - Gaussian Quadrature


Section 1: Introduction

In this lab you will verify the convergence behavior of the Gaussian quadrature method by computing the integrals of a couple of functions.

If you have not already done so, create a directory for this lab and copy the lab 6 files into it. If you start off in your home directory you can do the following:

	mkdir ~/cs371/lab6
	cd ~/cs371/lab6
	cp ~cs371/lab6/* .
and (as always) don't forget to type that last period.

Section 2: Topics for Lecture

This week I'll talk about what happens when a function returns more than one variable and briefly about the nargin and nargout commands which count how many variables are actually being passed into and out of a function.

Section 3: The Gausspoints Function

This week I'm giving you a function which will give you the nodes and weights for the Nth order Gaussian quadrature method. The format of this subroutine is as follows:
	[x,a] = gausspoints(n);
The two variables on the left-hand side indicate that gausspoints will return two vectors when called. The first output variable will be a vector of the nodes, and the second output variable will be a vector of the weights. For example, if your program does
	[x,a] = gausspoints(2);
then the variable x will be set to the vector
	x = [ -0.7746 0.0000 0.7746 ]
and the variable a will be set to the vector
	a = [  0.5556 0.8889 0.5556 ]
as indicated in the table on page 213 of your book.

You should look through the code of gausspoints.m and make sure you understand what it's doing.

Section 4: Two Problems

Do Computer Problems 5.5.1 and 5.5.2 from the book. Approximate each function with a first-order through sixth-order polynomial. Format your output similarly to the way we did trap.m in previous labs.

Call the first program prob1.m and the second program prob2.m.

Section 5: Submitting Your Work

When you are ready, run
	~cs371/submit lab6
to submit your prob1.m and prob2.m files.

If you call them something else then submit won't find them.

This Week's Questions