Modeling with Linear ODEs

Section 1.4 in Borrelli-Coleman

January 27, 1998

Richard Hitt

Getting started

Every Maple worksheet should begin by re-initializing the Maple "kernel" and loading the additional packages that we are most likely to use.

> restart;

> with( plots ):

> with( DEtools ):

Example 1.4.1 - Accumulation of a Pollutant

You can see the text for a discussion of the problem.

If [Maple Math] = the amount of pollutant in the tank at time [Maple Math] , we have

[Maple Math] = rate coming in - rate going out

[Maple Math]

> DE1:= diff( y(t), t ) = 10*c(t) - 1/10*y(t);

[Maple Math]

We can use the dsolve procedure in Maple to find the complete family of the solutions of this first order linear differential equation.

> Solution := dsolve({DE1,y(0)=y[0]}, {y(t)});

[Maple Math]

Note that these solutions depend on the function c(t) as well as the initial value [Maple Math] .

Important: Note that the first term on the rhs of the solution is due to the inflow of pollutant while the second term is due to the initial amount of pollutant. Over time, the second term will approach zero.

If we use the function in the text for [Maple Math]

> c := t->0.2 + 0.1*sin(t);

[Maple Math]

we can then use dsolve again to produce the 1-parameter family of solutions to the DE

> GenSolution := dsolve({DE1,y(0)=y[0]}, {y(t)});

[Maple Math]

In the text, the authors use a value of [Maple Math] .

> Solution1 := subs(y[0]=15,GenSolution);

[Maple Math]

> plot(rhs(Solution1),t=0..60,range=0..21);

[Maple Plot]

Look at hte differential equation corresponding to DE1 but which has no inflow term.

> DE2 := diff( y(t), t ) = -0.1*y(t);

[Maple Math]

We can solve it as well.

> Solution2 := dsolve({DE2, y(0)=15}, y(t));

[Maple Math]

We can also solve the original differential equation DE1 with initial equation [Maple Math] .

> Solution3 := dsolve({DE1,y(0)=0}, y(t));

[Maple Math]

Plotting the three solutions together, we get

> plot({rhs(Solution1), rhs(Solution2), rhs(Solution3)}, t=0..60);

[Maple Plot]

>

Example 1.4.3

In this example we change the function c(t) so that it is 0.2 for the first 20 minutes and 0 thereafter. This is done with step functions (see the text). In Maple, the syntax is as follows.

> c := piecewise(t<20,1);

[Maple Math]

> DE2 := diff( y(t), t ) = 10*c - 1/10*y(t);

[Maple Math]

> GenSolution4 := dsolve({DE2,y(0)=y[0]}, {y(t)});

[Maple Math]

> Solution4 := subs(y[0]=15, GenSolution4);

[Maple Math]

> plot( rhs(Solution4),t=0..60);

[Maple Plot]

We can also use DEplot to get a similar result.

> DEplot(DE2, {y(t)}, t=0..60, [[0,15]]);

[Maple Plot]

>

What are the differences between the two plots. Can you explain why they are different?-