Programming Assignment 3: Solving a System of ODEs with Explicit and Implicit Methods - Pr, Study notes of Mathematical Methods for Numerical Analysis and Optimization

This programming assignment focuses on applying explicit and implicit methods to solve a system of ordinary differential equations (odes). Students will analyze the given system of odes, find eigenvectors and eigenvalues, and implement the forward and backward euler methods to approximate the solution. The assignment includes coding tasks and stability analysis.

Typology: Study notes

Pre 2010

Uploaded on 02/13/2009

koofers-user-16b
koofers-user-16b 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Programming assignment#3. (Due Nov 21.)
Math. 609
We consider applying explicit and implicit methods for solving a mildly stiff
system of ODE’s in this assignment. Specifically, we consider the system
Y=Y(t) : [0,1] Rnwhere Yis the solution to
(0.1) Yt+(n+ 1)2
5AY =0
Y(0) = Y0(1,1,...,1)t.
Here Ais the n×nmatrix given by
Aij =
2 if i=j,
1 if |ij|= 1,
0 otherwise.
Problem 1. Show that the set of vectors {φ1,...,φn} Rnwith compo-
nents given by
(φi)j= sin ijπ
n+ 1, i, j = 1,...,n
are eigenvectors for Aand compute the corresponding eigenvalues. Write
down the solution to (0.1) given the expansion of the initial data,
Y0=
n
X
i=1
ciφi.
You need not compute the coefficients {ci}above (and they will appear in
your expansion of the solution). Note that every component of the solution
decays exponentially as tincreases.
Problem 2. Given a time step size k, let Yidenote the sequence obtained
by applying the forward Euler method to (0.1). Give an expression for the
coefficients of Yiexpanded in the basis of eigenvectors. The forward Euler
method is considered stable for this problem provided that every component
of the solution decays. Find a “resonably sharp (see the next problem)”
condition on the time step size as a function of nwhich guarantees stability.
Problem 3. Code the forward Euler method applied to the ODE (0.1).
You can use CRS to store the matrix or simply store the diagonals in three
vectors. The forward Euler method only requires matrix evaluation and
is simple to code using either storage mode (note that the generation of
a full n×nmatrix is unacceptable). Apply your method to the cases of
1
pf2

Partial preview of the text

Download Programming Assignment 3: Solving a System of ODEs with Explicit and Implicit Methods - Pr and more Study notes Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Programming assignment#3. (Due Nov 21.)

Math. 609

We consider applying explicit and implicit methods for solving a mildly stiff system of ODE’s in this assignment. Specifically, we consider the system Y = Y (t) : [0, 1] → Rn^ where Y is the solution to

Yt +

(n + 1)^2 5

AY = 0

Y (0) = Y 0 ≡ (1, 1 ,... , 1)t.

Here A is the n × n matrix given by

Aij =

2 if i = j, − 1 if |i − j| = 1, 0 otherwise.

Problem 1. Show that the set of vectors {φ 1 ,... , φn} ⊂ Rn^ with compo- nents given by

(φi)j = sin

ijπ n + 1

, i, j = 1,... , n

are eigenvectors for A and compute the corresponding eigenvalues. Write down the solution to (0.1) given the expansion of the initial data,

Y 0 =

∑^ n

i=

ciφi.

You need not compute the coefficients {ci} above (and they will appear in your expansion of the solution). Note that every component of the solution decays exponentially as t increases.

Problem 2. Given a time step size k, let Yi denote the sequence obtained by applying the forward Euler method to (0.1). Give an expression for the coefficients of Yi expanded in the basis of eigenvectors. The forward Euler method is considered stable for this problem provided that every component of the solution decays. Find a “resonably sharp (see the next problem)” condition on the time step size as a function of n which guarantees stability.

Problem 3. Code the forward Euler method applied to the ODE (0.1). You can use CRS to store the matrix or simply store the diagonals in three vectors. The forward Euler method only requires matrix evaluation and is simple to code using either storage mode (note that the generation of a full n × n matrix is unacceptable). Apply your method to the cases of 1

2

n = 16, 32 , 64 , 128. First, use time step sizes which are twice as large as your condition in the previous problem. If your condition above is sharp enough, you will see blowup of the ODE approximation. Next, use time step sizes which are smaller than you condition by a factor of two. If your condition above is sharp enough, you will now see convergence at t = 1.

Problem 4. Code the backward Euler method applied to the ODE (0.1). As the matrix A is tri-diagonal, the matrix systems appearing are also tri- diagonal. These can be solved using a tri-diagonal solver as illustrated in the c-code http://www.math.tamu.edu/ pasciak/classes/609/trisol.c. This code is simply Gaussian elimination in a storage mode where calculations involving the zeroes of the matrix are avoided. As above, the construction of the full n × n matrix is not allowed. This method is stable for any time step size. Run the method for n = 16, 32 , 64 , 128 and, in each case, try to find a time step size where you observe two decimal places of accuracy in each component. This you can do by comparing the results of different (decreasing) time step sizes while observing the resulting changes in the solution (at t = 1). You should be able to get the desired accuracy with fewer time steps than necessary for stability of the forward Euler method above.