AMATH 352
Summer Quarter, 2008

Applied Linear Algebra and Numerical Analysis



Homework #5 Supplement Page

Note: Using backslash to solve a system (e.g. A\b) is off-limits for this assignment. Use Gauss-Jordan elimination in Problem #1 whenever you need to solve a system. In later problems, you'll use forwardsubstitute.m and backsubstitute.m, as indicated in the assignment.

Problem #1

Here are the programs from Homework #4:
issolvable.m
pivotfree.m
findrange.m
jordanelim.m
findnull.m

And here's a starter for the code for fullsolve.m

function [x,N] = fullsolve(A,b)

% Reduce [A b] using gausselim2.
  [Aech, bech] = gausselim2(A,b);
I can't say much more without giving away the good parts. However, it's worth mentioning that the command isempty will check whether an array is empty.

In particular, if there are no free variables, then freevars is an empty array, and isempty(freevars)=1. Otherwise, isempty(freevars)=0. This will probably be useful for an if statement somewhere along the way.

Problem #3

Note: If you want to run a for loop with the index decreasing, here's how to do it:
for i = 10:-1:1
  disp(i)
end
This loop will display numbers counting down from 10 to 1. The expression 10:-1:1 represents the list of numbers from 10 to 1, changing by -1 each time.



Here's the program forwardsubstitute.m.

The expression L(i, 1:i-1) * x(1:i-1) on line 34 is a shortcut that calculates the sum by using matrix multiplication. This avoids using a for loop, as these aren't exactly one of Matlab's strengths.


Trump Problems

Each of these problems may be substituted for any one problem in the homework assignment.

Problem 1.   Basic LU factorization: Write a Matlab program that will take an invertible matrix A as input, and return the factors L and U in a basic LU factorization.

You can assume the user has entered a matrix with a basic LU factorization, but if you'd rather, you can also have it return an error if there is no such factorization.


Problem 2.   LUP factorization: Write a Matlab program that will take an invertible matrix A as input, and return the factors L, U, and P in an LUP factorization.