Laboratory Assignment 6 Problems - Numerical Analysis | MATH 4340, Lab Reports of Mathematical Methods for Numerical Analysis and Optimization

Material Type: Lab; Professor: Ginting; Class: Numerical Analysis; Subject: Mathematics; University: University of Wyoming; Term: Spring 2009;

Typology: Lab Reports

Pre 2010

Uploaded on 08/19/2009

koofers-user-ju0
koofers-user-ju0 🇺🇸

9 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CHE/COSC/MATH 4340-01 Numerical Analysis
Computer Laboratory Assignment 06
Due Date: Thursday, 04/21/09
Problem 1
Write a MATLAB function to implement the Gaussian Elimination for solving the linear system Ax =b
of size n, where Ais a triadiagonal matrix. Your function should be of the following form:
function x = GaussianElimination(n,d,ld,ud,b)
where the input argument nis the dimension of the system, dis a vector of size ncontaining 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 bis the right hand side vector with dimension n. The
output argument is xcontaining 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.
Problem 2
Consider the following linear system:
α1/2+α3/2x1α3/2x2=f1h2,
αi1/2xi1+αi1/2+αi+1/2xiαi+1/2xi+1=fih2for i=2,3,· · · ,n1,
αn1/2xn1+αn1/2+αn+1/2xn=fnh2+αn.
where h=1/(n+1). Let a function α(t)be given, and ti+1/2computed as
ti+1/2= (i+1
2)h,i=0,1,· · · ,n.
Then the coefficients αi±1/2are computed as
αi±1/2=α(ti±1/2),i=0,1,·· · ,n.
1
pf2

Partial preview of the text

Download Laboratory Assignment 6 Problems - Numerical Analysis | MATH 4340 and more Lab Reports Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

CHE/COSC/MATH 4340-01 Numerical Analysis

Computer Laboratory Assignment 06 Due Date: Thursday, 04/21/

Problem 1

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.

Problem 2

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:

  • α(t) = (^1) − 0 .8 sin^1 ( 20 πt), and fi = 0.
  • α(t) = 0 .01 for 0 < t ≤ 0 .5, α(t) = 10 for 0. 5 ≤ t < 1, and fi = 1.

For both cases use n = 10 and n = 200.

What you should do and report

  • For Problem 1, save your function in a file named GaussianElimination.m. Give appropri- ate comments on what the function does. After saving the file, print the file on a separate page.
  • What I need as the ouput in your report are the plot of the results, i.e, the vector x (do not print the vectors or matrix). To plot, use command plot(t,x), which basically plot (ti, xi) with ti = i ∗ h, for i = 1 , · · · , n.

Bonus Problem

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?