

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Lab; Professor: Ginting; Class: Numerical Analysis; Subject: Mathematics; University: University of Wyoming; Term: Spring 2009;
Typology: Lab Reports
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Computer Laboratory Assignment 06 Due Date: Thursday, 04/21/
Write a MATLAB function to implement the Gaussian Elimination for solving the linear system Ax = b of size n, where A is a triadiagonal matrix. Your function should be of the following form:
function x = GaussianElimination(n,d,ld,ud,b)
where the input argument n is the dimension of the system, d is a vector of size n containing the diagonal entries of A, ld is a vector of size n-1 containing the lower diagonal entries of A, ud is a vector of size n-1 containing the upper diagonal entries of A, and b is the right hand side vector with dimension n. The output argument is x containing the solution of the linear system. Recall that the Gaussian Elimination consists of transforming the original system into an upper triangular system followed by back substitution to solve for x.
Consider the following linear system:
(α 1 / 2 +^ α 3 / 2
) (^) x 1 −^ α 3 / 2 x 2 =^ f 1 h^2 , −αi− 1 / 2 xi− 1 + (αi− 1 / 2 + αi+ 1 / 2 )^ xi − αi+ 1 / 2 xi+ 1 = fih^2 for i = 2 , 3 , · · · , n − 1 , −αn− 1 / 2 xn− 1 + (αn− 1 / 2 + αn+ 1 / 2 )^ xn = fnh^2 + αn.
where h = 1 /(n + 1 ). Let a function α(t) be given, and ti+ 1 / 2 computed as
ti+ 1 / 2 = (i + 12 )h, i = 0 , 1 , · · · , n.
Then the coefficients αi± 1 / 2 are computed as
αi± 1 / 2 = α(ti± 1 / 2 ), i = 0 , 1 , · · · , n.
Solve the system above using the Gaussian Elimination that you have written in Problem 1. Use the following two cases:
For both cases use n = 10 and n = 200.
The linear system that you solve is actually the numerical solution of the following two-point boundary value problem:
− (^) dtd
α(t)dudt
= f , t ∈ ( 0 , 1 ) u( 0 ) = 0 u( 1 ) = 1
where f = 0 for the first case and f = 1 for the second case. Can you find the analytical solution of the two cases above?