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
= the amount of pollutant in the tank at time
, we have
= rate coming in - rate going out
> DE1:= diff( y(t), t ) = 10*c(t) - 1/10*y(t);
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)});
Note that these solutions depend on the function c(t) as well as the initial value
.
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
> c := t->0.2 + 0.1*sin(t);
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)});
In the text, the authors use a value of
.
> Solution1 := subs(y[0]=15,GenSolution);
> plot(rhs(Solution1),t=0..60,range=0..21);
Look at hte differential equation corresponding to DE1 but which has no inflow term.
> DE2 := diff( y(t), t ) = -0.1*y(t);
We can solve it as well.
> Solution2 := dsolve({DE2, y(0)=15}, y(t));
We can also solve the original differential equation DE1 with initial equation
.
> Solution3 := dsolve({DE1,y(0)=0}, y(t));
Plotting the three solutions together, we get
> plot({rhs(Solution1), rhs(Solution2), rhs(Solution3)}, t=0..60);
>
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);
> DE2 := diff( y(t), t ) = 10*c - 1/10*y(t);
> GenSolution4 := dsolve({DE2,y(0)=y[0]}, {y(t)});
> Solution4 := subs(y[0]=15, GenSolution4);
>
plot( rhs(Solution4),t=0..60);
We can also use DEplot to get a similar result.
> DEplot(DE2, {y(t)}, t=0..60, [[0,15]]);
>
What are the differences between the two plots. Can you explain why they are different?-