Topic 2 Introduction to Differential Equations
2.1 Basic concepts
2.1.1 How to define a differential equation in Maple
Depending on the differentiation command, there are three ways to define a differential equation in Maple.
Example 2.1 Assign the differential equation to a variable in Maple.
- Solution.
Method 1: Using the
diff
commandode111:=diff(y(x), x)=2*y(x)
Method 2: Using the the prime derivative notation
ode112:=y'=2y
Method 3: Using the command
D
ode113:=D(y)(x)=2*y(x)
Among the three methods, the one using diff
is the standard choice.
Exercise 2.1 Assign the differential equation to a variable in Maple.
2.1.2 How to check solutions
To check if a function (explicitly of implicitly defined) is a solution of a given differential equation, you may use the odetest(function, ODE, y(x))
command. If the output is 0, then the function is a solution.
Example 2.2 Verify that is a solution to the differential equation .
Solution. Run the following command, you will see that output is 0. So the function is a solution.
odetest(y(x)=c*exp(2*x), diff(y(x), x)=2*y(x), y(x))
Example 2.3 Verify that is a solution of the equation .
Solution. Again, running the following command returns the number 0. So the implicit function is a solution.
odetest(x^2+y(x)^2=1, diff(y(x),x)=-x/(y(x)), y(x));
When working with differential equations, we should always use instead of to indicate that is a function of .
Exercise 2.2 Verify that the function is a solution of the equation .
Exercise 2.3 Verify that is an implicit solution of the equation .
2.2 Solution curves vs Integral curves
A solution curve is the graph of a function that satisfies the given differential equation. An integral curves is a union of solution curves.
Example 2.4 Consider the differential equation . Verify that the graphs of the functions are solution curves of the equation, while the hyperbola defines an integral curve of the equation.
Solution. Let’s rename the function as and . In Maple, it means we y[1](x)
and y[2](x)
. We can check that they are solutions using the seq
loop.
ode121:=y(x)*diff(y(x), x)=4*x:
y[1](x):=sqrt(4*x^2-1);
y[2](x):=-sqrt(4*x^2-1);
seq(odetest(y(x)=y[i](x), ode121, y(x)), i = 1 .. 2);
The outputs show that and are solutions.
To see that hyperbola defines an integral curve, we solve for .
soly:=solve(4*x^2-y^2=1, y);
You will see that the solutions are exactly the functions and . So as an union of solution curves the hyperbola is an integral curve.
Plotting those curves will help use understand better.
solutioncurves := plot([y[1](x), y[2](x)],
x = -5 .. 5, y = -5 .. 5, color = [green, red]);
with(plots):
integralcurve := implicitplot(4*x^2 - y^2 = 1,
x = -5 .. 5, y = -5 .. 5, color = blue,
linestyle = dot);
To check the integral curve is the union of the two solution curve, we can use the display
command.
display(solutioncurves,integralcurve)
Exercise 2.4 Consider the differential equation . Verify that the graphs of the functions are solution curves of the equation, while the hyperbola defines an integral curve of the equation.
2.3 Direction fields
In Maple, the commands DEplot
, dfieldplot
, and phaseportrait
supported by the package DETools
can be used to plot the direction field and solution curves. The basic usage is as follows
DEplot(differential equation, function, ranges, options)
Again, using the command ?DEplot
, we can find details and examples on the command. In the following, I will use DEplot
as an example to show how they work.
Example 2.5 Plot the direction field for the differential equation . Can you guess what is a solution to this equation?
Solution. Let’s first define the differential equations and assign it to a variable.
ode131:=diff(y(x), x)=-x/(y(x));
Now load the package DETools
using the command with()
.
with(DETools):
With the package loaded, we can use DEplot
to plot the direction field for ode131
, say in the region and .
DEplot(ode131, y(x), x =-5..5, y =-5..5,
title = " Direction Field for y'=-x/y ")
Note that one may change the outlook by add options, such as color and arrows. Running the following command, you will see the difference.
DEplot(diff(y(x), x) = -(x - 1)/(y(x) + 1), y(x),
x = -5 .. 5, y = -5 .. 5,
title = "Direction Field for y'=2 y",
color = -(x - 1)/(y(x) + 1), arrows = line)
The direction field suggests that solutions are circles.
To display as in the output, you may run the following commands first.
with(PDEtools, declare):
declare(y(x), prime=x); # Turn ON the enhanced DEdisplay feature
You will see the following output
Exercise 2.5 Plot the direction field for the differential equation . Can you guess what is a solution to this equation?
Exercise 2.6 Plot the direction field for the differential equation . Can you guess what is a solution to this equation?