PHYCS 3730/6720 Lab Exercise

Reading and references:

Exercise 1. STL vector class exercise

The infinity norm of a vector is the largest magnitude of any element. So, for example, the infinity norm of the vector (-4, 1, 3) is 4. Write a short program for computing the infinity norm of a vector of arbitrary length. For practice, design the program so it uses the STL vector class, obtained by #include <vector>. Your code should first read in the entire vector, storing it in single precision. It should read only the vector components without knowing or specifying in advance how many of them there are. After that it should compute the infinity norm and write the result. The example code in the notes should give you most of what you need for this exercise. And if your code practice.cc from Exercise 1 of Assignment 3 worked with an array, it should have most of the logic you need to find the infinity norm.

Put your code in the answer file lab13.


Exercise 2. Solving using Gaussian elimination

Solve the linear system Ax = b
 Eqn (1)   2*x1 -   x2 +   x3 =  -1
 Eqn (2)   3*x1 + 3*x2 + 9*x3 =   0
 Eqn (3)   3*x1 + 3*x2 + 5*x3 =   4
using Gaussian elimination without row interchange. Do it by hand, but you may use Maple to help with the arithmetic and check your intermediate steps.

Give your solution in the answer file. Do it by showing the result of each step on the augmented matrix (matrix plus the right-hand-side column vector), with a couple of words explaining what the step did.


Exercise 3. Check your solution with Maple

Learn about matrices, vectors, and linsolve for solving a linear system. To use linsolve, you must first load the linear algebra and linear solution packages with the command with(linalg,linsolve). Then run the command ?linsolve to see some examples. Pay particular attention to the way vectors and matrices are defined in Maple.

Then use Maple to solve the linear system of Exercise 2.

Copy your Maple session in text format to your answer file.