>
BDH1-3.mws
Slope Fields
Section 1.3 - Blanchard, Devaney, Hall
26 January 1998
Matt Miller (with modifications by Douglas Meade)
Introduction
The purpose of this worksheet is to introduce you to the concept of slope fields (direction fields) of differential equations. This worksheet is intended to accompany reading section 1.3 of the text. The definitions are not repeated in this worksheet. There are a number of questions for you to answer as you work through this worksheet. Take the time to do what is asked, and be sure to ask questions as they arise.
Getting started
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);
> variables:= { P(t) };
> IC1:= P(0) = 2;
> domain:= t = 0 .. 10;
>
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);
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;
> IC3:= P(2) = 2;
> 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 );
> 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
>
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
> 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) };
> RATEa := 2/5 * P(t) * (1 - P(t)/30);
> RATEb := 2/5 * P(t) * (1 - P(t)/30) - 1/4 * P(t);
> MODEL4:= diff( P(t), t) = piecewise( t < 5, RATEa, RATEb );
> domain:= t = 0 .. 10 ;
> DEplot( MODEL4, variables, domain, P = 0 .. 30, arrows = MEDIUM );
> IC1:= P(0) = 20 ; # Your choice!
> IC2:= P(0) = 30 ; # Your choice!
> IC3:= P(0) = 40; # Your choice!
> IC4 := P(0) = 2; # Your choice!
> 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;
> ICa := P(0)=20;
> SOLa := dsolve( { MODEL4a, ICa }, P(t) );
>
The general solution for all other times is easily found by solving the corresponding (separable) differential equation.
> MODEL4b := diff( P(t), t ) = RATEb;
> dsolve( MODEL4b, P(t) );
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 := subs( t=5, SOLa );
> SOLb := dsolve( { MODEL4b, ICb }, P(t) );
>
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) );
> 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;