Important Note: If you see funny characters in your display, and if you are using Xwindows (for instance, under linux), please see the following file for information on configuring your browser: Xfonts (unfortunately, printing will still give funny fonts - you will need to use a different format of this document, such as pdf or postscript, for printing).

Differential Equations

Differential Equations

1  Maple Assignment 1

In this lab we use Maple to:

  • find exact solutions of differential equations and initial value problems,
  • help visualize solutions,

  • approximate the solution of differential equations by numerical methods.

When preparing the material to be handed-in, be sure to include explicit answers to all questions asked, using the text feature of Maple to insert them in the worksheet (don't write them by hand). Insert graphs directly into your worksheet and use the editing capabilities of Maple to remove from the worksheet any extraneous material such as any errors you have made.

Please make sure to read, or at least quickly go over, the instructions on using Maple.

Remember that you can learn more about the relevant Maple commands by using the Help feature of Maple, especially looking at examples.

In order to use some of the special commands Maple has for producing plots and solving differential equations, you must first type:

with(plots):  with(DEtools):

1.1  Part 1

1a. Execute the following commands which show how Maple solves the first order equation dy/dt + y(t) = 1/(1 + et) (note that Maple uses _C1 to denote an arbitrary constant), evaluates this solution at t = 0, and then determines the constant _C1 so that y(0) = 8. In this problem, the solution y is given explicitly as a function of t. Note that the commands with(plots): with(DEtools): must be entered to allow you to use the Maple commands which are part of these special Maple packages.

with(plots): with(DEtools): 
de1:= diff(y(t),t) + y(t) = 1/(1 + exp(t)); 
s1:=dsolve(de1,y(t));
y0:=simplify(subs(t=0,rhs(s1)));
c1:=solve(y0=8,_C1);
s2:= rhs(subs(_C1=c1,s1));

Note: the ``rhs'' may be a litle confusing. What happens is that the result of the dsolve command is an equation: try just typing ``s1;'' and you'll see what Maple has as the value of the variale s1. Therefore, we must use the rhs command to define the solution as the right hand side of the equation produced by the dsolve command.

We first found the general solution, and then fit the constant. Execute next the following command, which shows how Maple can solve the initial value problem more simply and directly (note the use of braces {}).

s3:=dsolve({de1,y(0)=8},y(t));
Execute the following sequence of commands which defines particular solutions corresponding to the choices y(0) = -2,-1,0,1,2, and plots all the solutions on the same set of axes.
t1:=rhs(dsolve({de1,y(0)=-2},y(t)));
t2:=rhs(dsolve({de1,y(0)=-1},y(t)));
t3:=rhs(dsolve({de1,y(0)=0},y(t)));
t4:=rhs(dsolve({de1,y(0)=1},y(t)));
t5:=rhs(dsolve({de1,y(0)=2},y(t)));
plot({t1,t2,t3,t4,t5},t=-1..5);
Incidentally, if you are interested in evaluating the solution t1 at the point t = 1.2, type subs(t=1.2,t1); or to get a numerical value for this quantity type evalf(subs(t=1.2,t1));

1b. Note that in this case, no matter what initial condition we start with, all solutions tend to the same value as t . What value is this?

1c. The qualitative behavior of the differential equation can also be determined by looking at a plot of its direction field. Execute the following statements which show the use of Maple's dfieldplot command to plot direction fields. This can also be combined with the display command to plot the direction field and solutions of the differential equation on the same set of axes. Note that the dfieldplot command assumes the differential equation is written in the form dy/dt = f(t,y). Also note that when naming the output of a plot, changing the ending semicolon to a colon will suppress unwanted output.

de1m:= diff(y(t),t) = - y(t) + 1/(1 + exp(t));
dfieldplot(de1m,y(t), t=-1..5,y= -6..4,color=black);
df:= dfieldplot(de1m,y(t), t=-1..5,y= -6..4,color=black):
ds:= plot({t1,t2,t3,t4,t5},t=-1..5):
display({df,ds});

1.2  Part 2

2a. Use Maple to find the general solution of the differential equation

t dy
dt
+ t y = 1 - y
and then the solution of the initial value problem consisting of this equation and the initial condition y(1) = 1/2. Plot the solution of the initial value problem over the interval 0 t 5.

2b. Plot the direction field for the equation in part (a) over the range 0.1 t 5, -2 y 1 and then plot the direction field and the solution found in part (a) on the same set of axes. Note: the differential equation must be rewritten in the form dy/dt = f(t,y) for the correct use of dfieldplot.

In cases where the exact solution of an initial value problem can be obtained, this solution may be plotted together with the direction field by combining the dfieldplot, plot and display commands. A more direct method, which gives results even in cases in which an exact solution of the differential equation can not be found, is to use the command DEplot. This command computes a numerical solution to a differential equation and then plots the resulting solution curve together with the direction field of the differential equation.

1.3  Part 3

3a. Execute these commands to see how Maple can be used to plot the direction field of the equation y = 1+2ty and then the direction field along with the particular solution satisfying this differential equation and the initial condition y(-1) = -2.

with(plots): with(DEtools): 
de:= diff(y(t),t) = 1 + 2*t*y(t);
dfieldplot(de, y(t), t=-3..3, y=-3..3);
DEplot(de, y(t), t=-3..3, y=-3..3);
initval:={[y(-1)=-2]};
DEplot(de, y(t), t=-3..3, initval,y=-3..3);
The DEplot command has many options which you can read about by typing ?DEplot. In particular, it is possible to specify the color of the solution curve by using linecolor, the color of the direction field by using color, and to make the gridwork of lines in the direction field finer by using the dirgrid option. For example, try:
DEplot(de, y(t), t=-3..3, initval, y=-3..3, linecolor = black,
color = green, dirgrid= [30,30]);
It is also possible to plot several solution curves on the same graph. For example, type
initval:= {[y(-3)=-2],[y(-1)=-2],[y(1)=-2]};
DEplot(de, y(t), t=-3..3, initval, y=-3..3);


3b. By trial and error, find a number t0 with -1 t0 0 such that the solution curve through [t0,-2] passes (approximately) through [2,1]. To determine a value of t0 more precisely, use dirgrid=[30,30] and change the t and y ranges in DEplot. Check your result by plotting the solution curves for the initial values [t0,-2] and [2,1] on the same graph for the value of t0 that you found.


3c. Does there exist a number t1 with the property that the solution curve through the point [t1,2] also passes through the point [1,-2]? If so, find it, and if not, use the plot of the direction field to explain why.


3d. The solution y(t) of the differential equation y = 1+2ty satisfies at each t, y(t) = 1 + 2 t y(t). Therefore, at points where y(t) = 0, y(t) = -1/(2 t). On the same set of axes, plot the function y = -1/(2 t), the direction field for the equation y = 1+2ty, and the solutions of this equation corresponding to the initial conditions y(-1) = 2, y(-1) = -1, and y(0) = - 2 over the interval -3 t 3.

(Note: to place these on the same graph, first plot the function y = -1/(2t), and give the output a name, say q1. Next, plot the direction field and solutions of the differential equation, giving the output the name q2. When giving a name to the output of a plot, you can avoid unwanted output by ending the command with a colon, rather than a semicolon. The command display(q1,q2); will then display both plots together.)


3e. What do you notice about the direction of the arrows along the curve y = -1/(2 t)?

1.4  Part 4

Consider the differential equation

dy
dt
= y ln(1/y) (2-y)
which is sometimes used to model population growth.


4a. To get a rough idea about the behavior of this model, plot on the same set of axes the direction field and solutions corresponding to the initial conditions y(0) = 0.2, y(0) = 0.8, y(0) = 1, y(0) = 1.2, y(0) = 1.8, y(0) = 2, y(0) = 2.2. Use the ranges 0 t 5 and 0 y 2.5.


4b. Based on the graph of part (a), determine the equilibrium solutions and state which are stable (sinks) and which unstable (sources).


4c. Although DEplot can be used to obtain qualitative information about the solution of a differential equation by plotting its direction field and some of the solution curves, it does not give quantitative information. To obtain quantitative information about the solution of an initial value problem for which we have no exact solution, we use the numeric option of the dsolve command. To use this command to obtain a numerical solution of the differential equation given above (named let us say de), with the initial condition y(0) = 1.2, giving the result the name sol, type:

sol:=dsolve({de,y(0)=1.2},y(t),numeric);
The result of this Maple command is a Maple procedure, which acts like a function. Evaluate the numerical solution at t = 2 by typing sol(2);


4d. Find the time t, correct to one decimal place, at which y(t) = 1.5. This can be done by using the numerical solution obtained above in sol and trial and error to evaluate it at various points. The plot in part (a) should give you a rough idea of the correct value.


4e. Note that when you type sol(2), Maple does not just return the value, but instead returns a list of equations. The practical effect of this is that one cannot get a graph of the solution by just typing plot(sol,t=0..5);. Try this to see that the plot Maple gives is clearly wrong. Instead, the numerical solution obtained by using dsolve[numeric] can by plotted by using the Maple command odeplot. In this case, type odeplot(sol,[t,y(t)],0..5); to obtain a plot.

This page was last updated on September 05, 2006 at 10:28 am and is maintained by webmaster@math.rutgers.edu.
For questions regarding courses and/or special permission, please contact ugoffice@math.rutgers.edu.
For questions or comments about this site, please contact help@math.rutgers.edu.
© 2014 Rutgers, The State University of New Jersey. All rights reserved.