Initial Value Problems

The files below were used in lectures on September 26th and 28th to demonstrate some properties of the MATLAB ODE solvers. Each "example" file is intended to be run simply from the command window by typing the name of the file. MATLAB is an interpretative language, meaning that it will run the commands in the example files one-by-one, and you could have obtained similar results by typing things in (or cutting and pasting) yourself. Note that you must save these files to the working directory where you operate MATLAB (presumably the MATLAB folder in your My Documents on a Windows machine). Note also that we could have completely avoided the "func" files altogether by writing our functions as anonymous functions, as described in Sections 7.2 and 7.7 of Moler's ODE chapter.

Two-Point Boundary Value Problems

The files below were used in lectures on October 1st and 3rd to demonstrate shooting and the MATLAB bvp4c function for solving BVPs.

Calculating Pi by Polynomial Extrapolation

This example isn't actually an ODE; but it includes some nice, simple use of MATLAB's polynomial fitting. The calcpi.m script contains the calculation described in lecture on Friday October 8th, with the constant coefficient giving the polynomial extrapolation as x = 1/n2 goes to zero.

Spectral Method Solutions on Periodic Boundary Conditions.

We cobbled together the pbcsolve.m file together in lecture (November 5th diary file) to solve the ODE u''(x)-c^2u(x)=f(x) for two different forcing functions. The first function is the numerical delta function on our discrete grid. The second function, a Gaussian, is much smoother and therefore numerically converges much faster with increasing N (because the forcing function and the resulting solution are both naturally band-limited and therefore have much faster decay of their Fourier coefficients).

Plotting Power Series Solutions

In lecture on November 14th we made use of the commands in powerseries.m (which called optapprox.m).