Matematik och Datavetenskap, Chalmers Tekniska Högskola och Göteborgs Universitet

ALA-B, 2003, studio 2.2

Home, w 1, w 2, w 3, w 4, w 5, w 6, w 7. Matlab: analysis, linear algebra, facit.

The exponential function

Do not print this file!! Read it from the computer screen.

1. Write a program that computes an approximate solution of the initial value problem

u'(x) =cu(x), a<x<b,
u(a)=ua,

using the algorithm in Chapter 31 with stepsize h. Use the template my_exp.m. This program is a simple modification of the program my_int that you have already written.

2. Experiment with various values of the constant c, the initial value ua, and the interval [a,b]. Plot the solutions using the command plot(x,U,'.'). In each case write down the solution formula by hand in terms of the function exp. Matlab has a built in function exp.m for computing the exponential function. Use it to plot the solution formula in the same figure as your own plot. For example:

plot(x,U,'.')
hold on
fplot('exp(-3*x)',[0 2])

3. Modify the program so that it computes an approximate solution of the initial value problem

u'(x) =cu(x)+f, a<x<b,
u(a)=ua,

where f is a constant. Experiment with various values of c, ua, and f, plot the solutions, in each case solve the equation by hand.

a. Show that the solution formula is (when a=0)

u(x)=ua exp(cx) + f (exp(cx)-1)/c

b. Compute solutions with c=-3, f=6, over the interval [0,10] and several initial values ua. What do you observe? Explain it by letting x tend to infinity in the solution formula.

4. Voluntary: modify the program so that it takes variable coefficients c(x) and f(x).

/stig


Last modified: Thu Oct 23 15:09:26 MEST 2003