Gaussian elimination in MATLAB

  1. 1. The problem statement, all variables and given/known data

    The point of this homework is to experiment with Gaussian elimination, and to
    develop an appreciation for partial pivoting. Questions 1 & 2 can be done with a
    calculator (though a computer is preferred). Question 3 requires a computer – you
    do not necessarily have to write any programs: C++ examples are on the class
    web page, and Matlab examples are all over the web. Use whatever you like, but
    give credit to your sources.
    Q1)

    [2.0 1:0 1:0 [ x1 [2.0 + 10e-10
    1.0 10e-10 10e-10 x2 = -10e-10
    1.0 10e-10 10e-10] x3] 10e-10]

    Solve this equation for x using partial pivoting. Strive
    to achieve the most accurate results possible (e.g., double precision). First obtain
    the decomposition
    PA = LR
    then use this decomposition to determine x with two back substitution steps:
    Ly = (Pb)
    Rx = y

    Q2) The identity matrix I can be thought of as a collection of vectors:
    I = (e1e2...en)
    where ei is a vector of length n that is zero, except in the ith component which is 1.

    If one were to represent the inverse matrix A^-1 as a collection of vectors,
    A^-1 = (a1a2...an).

    Then the ith column of A^-1 can be determined by solving Aai = ei. Or, using our
    LR decomposition, LR(ai )= P(ei). Use this to find the inverse of the matrix in (1)
    with P,L,R from partial pivoting. Assess the quality of the result by computing
    (A^-1)A.

    Q3) For n = 60, solve
    Ax = b
    where n n matrix A is given by
    Ai j =r2n + 1sin2i j2n + 1
    i; j = 1 to n;

    and where b is given by the n-long vector of ones. With trivial pivoting, and with
    partial pivoting, calculate r = b-Ax. Present sqrt(r*r) (aka the L2 norm krk2), which
    should be zero with perfect math.


    2. Relevant equations

    I was able to do #1 with a calculator and by hand, and I understand the basic ideas of 2 and 3, but I dont know how to implement them in MATLAB.

    3. The attempt at a solution

    For #1, i get
    x = 4
    -2
    2
     
    Last edited: Apr 17, 2009
  2. jcsd
Know someone interested in this topic? Share this thead via email, Google+, Twitter, or Facebook

Have something to add?

0
Draft saved Draft deleted