Docsity

MATH 609-601 Assignment: Solving Linear Systems with LU-decomposition of Banded Matrices -, Assignments of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
MATH 609-601 Numerical Analysis
Programming assignment #1
Direct methods for linear system by LU-decomposition
1 Problem Formulation
Write a program for solving the system Ax =bwith a banded martix Aby 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| ≤
pin 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,...,2p+ 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).
2 Specifications
1. The program should use double precision and should be well documented.
2. Report the computed solution and compare the results obtained by different methods. For
the report use the provided template on
http://www.math.tamu.edu/ lsmith/math609/math609.html.
3. First test your program on the following simple example of a diagonally dominant penta-
diagonal matrix: aii = 10, aij = 1, aij = 0,|i−j|>2, i, j = 1, ..., n, n = 10,20 and
b1=bn= 12, b2=bn−1= 13 and bj= 14,for j= 3,4, . . . , n −2. (This problem is just to
test your program, the solution is x1=x2=... =xn= 1; do not report the results).
3 Computational examples
Solve the following linear systems:
1. Consider the following linear system:
x0= 0, ki−1(xi−xi−1) + ki(xi−xi+1) + cixi=bi, i = 1, ..., n, xn+1 = 1,
which after the elimination of x0and xn+1 is written in the form Ax =bwith x∈Rn.
Solve for n= 20,40.
1
pf2

Partial preview of the text

Download MATH 609-601 Assignment: Solving Linear Systems with LU-decomposition of Banded Matrices - and more Assignments Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

MATH 609-601 Numerical Analysis Programming assignment # Direct methods for linear system by LU -decomposition

1 Problem Formulation

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).

2 Specifications

  1. The program should use double precision and should be well documented.
  2. Report the computed solution and compare the results obtained by different methods. For the report use the provided template on http://www.math.tamu.edu/ lsmith/math609/math609.html.
  3. First test your program on the following simple example of a diagonally dominant penta- diagonal matrix: aii = 10, aij = 1, aij = 0, |i − j| > 2 , i, j = 1, ..., n, n = 10, 20 and b 1 = bn = 12, b 2 = bn− 1 = 13 and bj = 14, for j = 3, 4 ,... , n − 2. (This problem is just to test your program, the solution is x 1 = x 2 = ... = xn = 1; do not report the results).

3 Computational examples

Solve the following linear systems:

  1. Consider the following linear system:

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.

  1. Now the unknowns are given as a two dimensional array xij , i, j = 0,... , n + 1 that satisfy the system

(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.