This preview shows page 1. Sign up to view the full content.
Unformatted text preview: CS 111 - Introduction to Computational Science Homework 6
Consider the diﬀusion equation in the interval [0, 1]:
= D 2,
∂x (1) where D is the diﬀusion constant. Here, we will take D = .5. An exact solution for this equation is
u(x, t) = e−Dt cos(x) and a good approximation can be written as:
un+1 − 2un+1 + un+1
un+1 − un
= D i+1
∆x2 (2) 1. Write down the linear system corresponding to (2).
2. Write a code that solve the diﬀusion equation (1) using the scheme (2) for a ﬁnal time of
ttarget = 1. You can assume that the exact solution is given at the domain’s boundary, i.e. at
x = 0 and at x = 1. Take a time step of ∆t = .1 and discretize the interval [0, 1] with 100 points.
3. Use your code to make a movie showing the evolution of your numerical solution along with the
exact solution. What to turn in : the linear system from question 1, your code as well as your movie. This can be
emailed to the TAs. 1 ...
View Full Document
This note was uploaded on 12/29/2011 for the course CS 111 taught by Professor Staff during the Fall '08 term at UCSB.
- Fall '08