MatchDemo.m

Contents

Overview

This script illustrates the solution of the burning match problem

$$ y'(t) = y^2(t) - y^3(t), \quad  0 \le t \le \frac{2}{\delta}$$

$$ y(0) = \delta $$

along with the fact that this becomes a stiff problem when the initial radius of the flame, $$\delta$, becomes very small.

Beginning of code

Initialize

clear all
close all

f = @(t,y) y^2-y^3;
t0 = 0;
tol = 1e-4;
opts = odeset('RelTol',tol);

Example 1

Use ode23tx to solve the problem with

$$ \delta = 0.01,\ 0.0001,\ 0.000001 $$

and note how ode23tx takes forever toadvance the solution for $$ \delta = 0.000001 $$

dvalues = [0.01 0.0001 0.000001];
for delta=dvalues
    tmax=2/delta;
    y0=delta;    % initial condition
    ode23tx(f,[t0 tmax],y0,opts);
    title(sprintf('ode23tx with delta=%f',delta))
    pause
end

Example 2

Now use the stiff solver ode23s to solve the same problem.

for delta=dvalues
    tmax=2/delta;
    y0=delta;    % initial condition
    ode23s(f,[t0 tmax],y0,opts);
    title(sprintf('ode23s with delta=%f',delta))
    pause
end