>

BDH1-3.mws

Slope Fields

Section 1.3 - Blanchard, Devaney, Hall

26 January 1998

Matt Miller (with modifications by Douglas Meade)

Introduction

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 ):

>

Unlimited population growth

A model for unlimited population growth is represented by the following first-order ordinary differential equation.

> MODEL1:= diff( P(t), t ) = 2/5 * P(t);

[Maple Math]

> variables:= { P(t) };

[Maple Math]

> IC1:= P(0) = 2;

[Maple Math]

> domain:= t = 0 .. 10;

[Maple Math]

>

The next command will exhibit the slope field for this model, and the following command superimposes the solution of the DE with the given initial condition.

> DEplot( MODEL1, variables, domain, P = 0 .. 30, arrows = MEDIUM );

> DEplot( MODEL1, variables, domain, P = 0 .. 30, [ [IC1] ], linecolor = BLUE, arrows = MEDIUM );

>

Logistic population growth

Let's compare the logistic model. Notice that to get a plot Maple needs to have specific numerical values for the parameters.

> MODEL2 := diff( P(t), t ) = 2/5 * ( 1 - P(t)/30 ) * P(t);

[Maple Math]

Let's use the same initial condition and domain as before.

> DEplot( MODEL2, variables, domain, P = 0 .. 40, [ [IC1] ], linecolor = BLUE, arrows = MEDIUM );

>

Questions

What happens if we use different initial conditions, say by changing the value of t at which P = 2?

How does this affect the solution curves?

How does the fact that the logistic model is an autonomous DE come into your answer?

> IC2:= P(-2) = 2;

[Maple Math]

> IC3:= P(2) = 2;

[Maple Math]

> DEplot( MODEL2, variables, t = -2 .. 12, P = 0 .. 30, [[IC1], [IC2], [IC3]], linecolor = [BLUE, GREEN, BLACK], arrows = MEDIUM );

Observe how multiple initial conditions are specified in the DEplot command. Note also how the colors of the solution curves are controlled via the linecolor option.

>

A non-autonomous model

Let's see what a non-autonomous model's slope field looks like.

> MODEL3:= diff( P(t), t) = exp( -0.25 * t );

[Maple Math]

> DEplot( MODEL3, variables, domain, P = 0 .. 15, arrows = MEDIUM );

> DEplot( MODEL3, variables, t = -2 .. 8, P = 0 .. 15, [ [IC1], [IC2], [IC3] ], linecolor = [BLUE, GREEN, BLACK], arrows = MEDIUM );

>

Questions

What is the relationship between the solution curves for this example?

What property of the differential equation is the source of this property between solution curves?

>

>

Testing Your Understanding - Mixing in a Vat

Replace the question marks ( ? ) in the following input regions to create the slope fiield for the mixing problem discussed in Section 1.2 of the text. Be sure to choose an appropriate range for the amount of sugar in the tank. Choose initial conditions that are both above and below the equilibrium solution.

> MODEL := diff( %?, %? ) = %? - %? ; # define the differential equation model

[Maple Math]

> variables:= { %? }; # specify the variables in the model

> IC1:= S(0) = %?; # choose 4 initial conditions

> IC2:= S(0) = %?;

> IC3:= S(0) = %?;

> IC4:= S(0) = %?;

> domain:= t = 0 .. %?; # specify a reasonable time interval

>

> DEplot( MODEL, variables, domain, S = %? .. %?, arrows = MEDIUM );

> DEplot( MODEL, variables, domain, S = %? .. %?,
[ [IC1], [IC2], [IC3], [IC4] ],
linecolor = [ BLUE, GREEN, BLACK, ORANGE ],
arrows = MEDIUM );

>

Analytic solutions

All three of the models givcen here are solvable by separation of vartiables and explicit integration--so do this now by hand! Then use Maple to check your work. The Maple command for finding explicit solutions to differential equations is dsolve . The arguments are the initial value problem (a set containing the differential equation and the initial condition) and the function for which we are trying to solve.

> SOLN1 := dsolve( {MODEL1, IC1}, P(t) );

> SOLN3 := dsolve( {MODEL3, IC1}, P(t) );

> SOLN2 := dsolve( {MODEL2, IC1}, P(t) );

>

Problem 24, section 1-3 -- Piecewise-defined slope fields

In this problem the right hand side of the model equation changes at t = 5. It is easy to instruct Maple to do this, and quite interesting to investigate the result.

> variables := { P(t) };

[Maple Math]

> RATEa := 0.4 * P(t) * (1 - P(t)/30);

[Maple Math]

> RATEb := 0.4 * P(t) * (1 - P(t)/30) - 1/4 * P(t);

[Maple Math]

> MODEL4:= diff( P(t), t) = piecewise( t < 5, RATEa, RATEb );

[Maple Math]

> domain:= t = 0 .. 10 ;

[Maple Math]

> DEplot( MODEL4, variables, domain, P = 0 .. 30, arrows = MEDIUM );

> IC1:= P(0) = 20 ; # Your choice!

[Maple Math]

> IC2:= P(0) = 30 ; # Your choice!

[Maple Math]

> IC3:= P(0) = 40; # Your choice!

[Maple Math]

> IC4 := P(0) = 2; # Your choice!

[Maple Math]

> DEplot( MODEL4, variables, domain, P = 0 .. 40, [ [IC1], [IC2], [IC3], [IC4] ], linecolor = [BLUE, GREEN, BLACK, ORANGE], arrows = MEDIUM );

>

Analytic solution for a piecewise-defined ODE -- advanced mathematical and Maple content

Since the differential equation is defined differently for different time intervals, the analytic solution must be determined separately for each part of the definition. The solution for the first part ( t < 5 ) proceeds exactly as for any other initial value problem. Assuming the initial condition is P(0) = 20

> MODEL4a := diff( P(t), t ) = RATEa;

[Maple Math]

> ICa := P(0)=20;

[Maple Math]

> SOLa := dsolve( { MODEL4a, ICa }, P(t) );

[Maple Math]

>

The general solution for all other times is easily found by solving the corresponding (separable) differential equation.

> MODEL4b := diff( P(t), t ) = RATEb;

[Maple Math]

> dsolve( MODEL4b, P(t) );

[Maple Math]

The particular solution that is needed, however, is the one that matches up with the solution from the first part of the model. That is, the ``initial condition'' for t > 5 must be chosen to be

> ICb := eval( SOLa, t=5 );

[Maple Math]

> SOLb := dsolve( { MODEL4b, ICb }, P(t) );

[Maple Math]

>

The two parts of the analytic solution can be pieced together (with piecewise) to form the complete solution as follows:

> SOLpw := piecewise( t<5, rhs(SOLa), rhs(SOLb) );

[Maple Math]

> plot( SOLpw, t=0..10, P=0 .. 30 );

Compare this plot with the slope field produced earlier. How can you convince yourself that these represent the same solution?

>

>

>

> restart;