MAE 107 – Computational Methods
Summer Session II 2009
Homework # 2
due on Wednesday, August 19 in class
4 problems – 20 points
Guidelines
: Please turn in a neat homework that gives all the formulae that you have used and all the
necessary information for the grader to understand your solution. Also, if the problem requires you to write
a MATLAB code, please turn in a copy of the code you used, carefully documented with comments and
using proper indentation, as well as the requested ouputs and graphs, along with the written explanation
of your solution.
Problem 1 – 8 points
LU decomposition
1. Create a Matlab function
ludec.m
that implements the LU decomposition of a square matrix
A
using Gauss elimination without pivoting as presented in class.
Your function should take
A
as
input, and should return an error message (i) if
A
is not square and (ii) if pivoting is necessary
(that is, if one of the pivot elements is equal to zero). The outputs of the function should be two
matrices
L
and
U
where
L
is lower triangular with diagonal coefficients equal to 1, and
U
is an
upper triangular matrix.
2. Use this function to compute the LU decomposition of the following matrices:
A
1
=
3
9

1

3

11
8
6
24

24
,
A
2
=
4
2
0
0
1
2
20
10
4
Check your answers by computing the product
L*U
of the two matrices obtained (you should find
that it is equal to
A
).
3. Create a second function
linsys_lu
that solves the linear system
A
.
x
=
b
using the LU decomposi
tion obtained with Gauss elimination without pivoting. Your function should take as input a square
matrix
A
and a column vector
b
and return the answer
x
when it exists. You should compute the
LU decomposition of
A
using the function
ludec.m
you have created. Then compute the solution
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Summer '08
 Rottman
 Triangular matrix

Click to edit the document details