Assignment given 24 March 2009


This assignment was given on 24 March 2009. The work is due 07 April 2009.


Question 1: BVP, a boundary value problem

Let us work in the interval 0 < X < 1.

Inside this interval, we are seeking the values of a solution function u(x).

We know that inside the interval, u(x) satisfies the following differential equation:

        - a(x) * u''(x) - a'(x) * u'(x) + c(x) * u(x) = f(x)
      
where a(x), c(x) and f(x) are functions that we know, and that, at the endpoints:
        u(0) = u(1) = 0.
      

We set up a grid of m equally spaced points between 0 and 1, which have spacing h = 1/(m-1), and replace the derivatives of u by finite difference approximations:

        u'(x) = approximately ( u(x) - u(x-h) ) / h

        u''(x) = approximately ( u(x+h) - 2 * u(x) + u(x-h)) / h^2
      

Now we can set up a linear system of equations, by writing the boundary conditions and the approximated differential equations. We assume we have formulas to evaluate a(x), a'(x), c(x) and f(x).

        #1: u(1) = 0

        #2: - a(x2) * ( u(3) - 2 * u(2) + u(1) ) / h^2
            - a'(x2) * ( u(2) - u(1) ) / h 
            + c(x2) * u(2)
            = f(x2)

        #3: - a(x3) * ( u(4) - 2 * u(3) + u(2) ) / h^2
            - a'(x2) * ( u(3) - u(2) ) / h 
            + c(x3) * u(3)
            = f(x3)

       ...

       #m: u(m) = 0
      

This system can be set up as a linear system A*x=b and solved easily with MATLAB.

1A: write a program that solves the BVP, assuming that the user specifies the value of m, and that functions a(x), aprime(x), c(x) and f(x) are supplied.

1B: use your program to solve the BVP with the following data: m = 101, a(x) = 1, aprime(x) = 0, c(x) = 2, and f(x)=x*(5-x)*e^x. Plot your solution versus the exact solution, which should be

        u(x) = x * ( 1 - x ) * e^x.
      

Question 2: BVP, a boundary value problem

Our finite difference estimate for u'(x) is less accurate than our estimate for u''(x). A more accurate estimate for u'(x) is

        u'(x) = approximately ( u(x+h) - u(x-h) ) / (2 * h )
      

2A: make a second version of your program which uses this more accurate estimate for u'(x).

2B: use your second program to solve the BVP again. Plot your solution versus the exact solution.

When you compare programs #1 and #2, do you see an improvement in the results?


Last revised on 31 March 2009.