

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due date: Monday, February 13th, 2006 at the beginning of the lecture.
Develop, debug, and test a program (MATLAB m-file) that solves a system of linear equations Ax = b using Doolittle LU decomposition with partial pivoting (on columns). (Important: do not perform Crout LU decomposition, you will be given no credits for it.) The code should be able to solve for an arbitrary square m Ć m matrix A.
You should provide 2 different functions:
[P,L,U,flag] = LUDecompose(A);
and
[x] = LUBacksub(P,L,U,b);
The first function would compute the LU decomposition while the second one would take care of solving the problem LU x = b given L,U , b and the per- mutation vector P. The f lag is an error variable to use before entering the substitution code. Consider the possibility that matrix A is not invertible. This will happen dur- ing the LU decomposition process: you will encounter a zero diagonal element. This can only happen if the rows or columns are linearly dependent. If this happens, your program should display an error message before stopping like: āerror: matrix is rank deficientā.
If possible, solve the following systems of linear equations with your own pro- gram: A) (^) 

x 1 x 2 x 3
x 1 x 2 x 3
x 1 x 2 x 3 x 4
Check you results by substituting x into Ax and compare it with b. If your code is correct, Ax should be identical to b. If your code can not solve
the problem, see whether you can invert the matrix using MATLAB internal procedure, inv(A). If you can, then the problem definitely has a solution and something is wrong with your code. Email your code (m-file). The program that you send should be a working program. All the codes will be checked whether they run or not. If they are erroneous, but run, points will be taken for the errors. If the code is not running (it has some syntax errors), an additional 25% will be taken out.
Given a set of points (xi, yi) ā R^2 , j = 1, ..., N that comes from some experiment and that we believe would either lie on some curve if it were not from experi- mental error, what would be the curve that best approximate these points? Suppose that the data behaves like a line yi = bxi + c and that we seek b, c that works for all xi and yi. The resulting system describing the problem would be :
    
x 1 1 x 2 1 .. .
xN 1
b c
y 1 y 2 .. . yN
If the curve sought was a parabola then the system
   
x^21 x 1 1 x^22 x 2 1 .. .
x^2 N xN 1
a b c
y 1 y 2 .. . yN
would describe the (over-determined) problem. These problems written as Ax = b have no unique solutions. This unsolvable problem can be replaced by the solvable one AxĖ = Ėb where Ėb is as close as possible to b and yet does lie in the column space of A. Thus, the best Ėb will be the one orthogonal to the column space of A namely
AT^ (Ėb ā b) = AT^ (AĖx ā b) = 0
or equivalently (AT^ A)Ėx = AT^ b.
Download from the MCEN3030 website
http://scales.colorado.edu/classes/MCEN3030_S2006/assignments.html
the file xyexperiment.mat is under the link Data for this homework. Place the file where matlab can read it (ie check your path settings). Load the data in matlab using the load command. Now if you type xy you will see that it contains an array of data with two columns: one for xi the other for yi.