

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!


MATH 609-601 Numerical Analysis Programming assignment # Direct methods for linear system by LU -decomposition
Write a program for solving the system Ax = b with a banded martix A by using LU - decomposition. (1) Write your own routine for the LU -decomposition of a banded matrix with a bandwidth p (n integer number), such that n > p ≥ 1. For this write down the matrix as a rectangular (2p+1)×n-matrix, i.e. in R(2p+1)×n, that keeps the highest co-diagonal as first row and the lowest co-diagonal as the last row. In this way the matrix entry of position (i, j), i, j +1,... , n, |i−j| ≤ p in the original matrix will be in (k, j) = (i − j + p + 1, j) position in the new format with j = 1,... , n and k = 1,... , 2 p + 1. (2) use the corresponding simple driver routine DGBSV from LAPACK for banded matrices.
Note, that DGESV and DGESVX are the double precision variants of SGESV and SGESVX subroutines described in the LAPACK User’s Guide from the Internet (see the home page of the labs on: http://www.math.tamu.edu/ lsmith/math609/math609.html).
Solve the following linear systems:
x 0 = 0, ki− 1 (xi − xi− 1 ) + ki(xi − xi+1) + cixi = bi, i = 1, ..., n, xn+1 = 1,
which after the elimination of x 0 and xn+1 is written in the form Ax = b with x ∈ Rn. Solve for n = 20 , 40.
Introduce the following notations: h = 1/(n + 1), ki = k((i + 0.5)h), where k(t) is given below in two cases: (1) (constant k(t)): k(t) = 1, ci = 0, bi = 0, i = 1,... , n. (2) (jump in k(t)): K = 2, 100 and
k(t) = 1, for 0 < t < 0. 5 , and k(t) = K, for 0. 5 ≤ t < 1 , ci = 0, bi = 0.
Remark. Since the solution of this system represents an approximation of the solution of a boundary value problem on the interval t ∈ (0, 1), plot xi.
(4 + h^2 )xi,j − xi− 1 ,j − xi+1,j − xi,j− 1 − xi,j+1 = h^2 , x 0 ,j = xn+1,j = xi, 0 = xi,n+1 = 0.
Here h = 1/(n + 1) so that the system represents a finite difference approximation of the boundary value problem −∆u + u = 1 in Ω = (0, 1) × (0, 1) and u = 0 on the boundary of Ω. Solve for n = 20, 40. You need to represent this in the standard from Ax = b, where A is an Rn^2 ×n^2 matrix. If you use lexicographical enumeration of the unknowns then you will get a system with a banded matirx of bandwidth p = n. Remark. Again, since the solution xi,j of this system represents an approximation of the solution u(ih, jh) of a boundary value problem in Ω it makes sense to plot xi,j.