Project1-7

advertisement
MA 282-Assignment #1: First Order Differential Equations -Part-1
The standard form for a first-order differential equation is
𝑑𝑦
𝑑𝑑
= 𝑓(𝑑, 𝑦) . A solution to this equation is a
differentiable function 𝑦(𝑑)of the independent variable 𝑑 that satisfies 𝑦 ′ (𝑑) = 𝑓(𝑑, 𝑦(𝑑)).
Analytic Techniques
MATLAB can solve most of the differential equations that can be solved with the standard techniques
encountered in this course. MATLAB's differential equations solver dsolve provides symbolic solutions to
first-order differential equations although they not always explicit solutions.
Example
Find the general solution to the differential equation
𝑑𝑦
𝑑𝑑
= 𝑑 3 + 𝑦.
Notice that MATLAB produces the answer with an arbitrary constant 𝐢𝑖 ; in this example with a constant
𝐢2 .
To solve the initial value problem
𝑑𝑦
𝑑𝑑
= 𝑑 3 + 𝑦, 𝑦(0) = 7:
The solution S is a symbolic expression that is, you cannot evaluate S at 𝑑0 by typing 𝑆(𝑑0 ); use the subs
command to display the values of S at certain times 𝑑. For instance the value of S at 𝑑 = 0.5 is
If you wish to evaluate S at several values of 𝑑, then use vector notation. As an example we evaluate S at
𝑑 = 0.5, 0.6, 0.7:
To plot the solution S on the interval [0, 1]
In practice, the goal is to study a family of solutions at various initial conditions. One way to do this is to
solve the
IVP:
𝑑𝑦
𝑑𝑑
= 𝑑 3 + 𝑦, 𝑦(0) = 𝑐
If we wish to plot the solutions curves with initial values 𝑦(0) = 7, 7.5, 8, 8.5 on the interval [0, 1]:
Exercise MA282-1 (B. Hunt) (Solution at the end of document)
Consider the initial value problem:
𝑑𝑦 ′ + 3𝑦 = 5𝑑 2 , 𝑦(2) = 5
a. Solve using the MATLAB function dsolve
b. Plot the solution 𝑦(𝑑) on the intervals 0.5 ≤ 𝑑 ≤ 5 and 0.2 ≤ 𝑑 ≤ 20. Determine the behavior of
𝑦(𝑑) as 𝑑 approaches 0 from the right and as 𝑑 becomes large.
c. Change the initial condition to 𝑦(2) = 3 and determine the behaviour of this solution, again by
plotting on intervals such as 0.2 ≤ 𝑑 ≤ 20 and 0.5 ≤ 𝑑 ≤ 5.
Exercise 282-2 (B. Hunt) (Solution at the end of document)
a. Solve the initial value problem:
𝑦 ′ − 2𝑦 = 𝑠𝑖𝑛2𝑑, 𝑦(0) = 𝑐
b. Use MATLAB to graph solutions for 𝑐 = −0.5, −0.45, … , −0.05, 0 on the interval [0, 1]. Use axis
tight.
c. Use MATLAB to graph solutions for 𝑐 = −0.5, −0.45, … , −0.05, 0 on the interval [0, 2.5]
d. What happens to the solution curves as t increases?
e. What effect small changes in initial data can have on the global behavior of solutions curves?
MA 282-Assignment #2: First Order Differential Equations -Part-2
Qualitative Techniques
1. Understanding the quiver command
The quiver command allows us to draw vectors in the plane 𝑅 2 :
For instance, if we wish to draw the two vectors a = < 2,3 > and 𝑏 = < 1,4 > and place them at the
points (0, 0) and (0, 1) in 𝑅 2 , then we form the following four matrices:
1.
2.
3.
4.
The x-positions matrix: [0,0]
The y-positions matrix: [0,1]
The x-components matrix: [2,1]
The y-components matrix: [3,4]
If we type "quiver([0 0],[0 1],[2 1],[3 4])" in the command window, we see
Note that MATLAB automatically scales vectors so that they do not overlap. To prevent MATLAB from
scaling vectors we add a zero to the script:
We can use the command axis to request that MATLAB draw the vectors and display them on a specific
window.
In this example we draw the vectors A and B and display them on the window 0 ≤ π‘₯ ≤ 10, 0 ≤ 𝑦 ≤ 10:
To display a grid, simply type "grid on":
We can use the command "linewidth" to change the width of the vectors; in this example we multiply the
original length by 1.5:
Important Remark
To draw a single vector π‘Ž =< π‘Ž1 , π‘Ž2 > and place it at the point π‘₯ = (π‘₯1 , π‘₯2 ), type
π‘žπ‘’π‘–π‘£π‘’π‘Ÿ([π‘₯1 , π‘₯1 ], [π‘₯2 , π‘₯2 ], [π‘Ž1 , π‘Ž1 ], [π‘Ž2 , π‘Ž2 ]); that is we draw the vector π‘Ž =< π‘Ž1 , π‘Ž2 > twice.
2. Slope Fields
𝑑𝑦
Consider the equation 𝑑𝑑 = 𝑦 − 𝑑. If 𝑦(𝑑) is a solution of the equation, then 𝑓(𝑑, 𝑦) = 𝑦 − 𝑑 represents the
slope of the tangent line to the graph of 𝑦(𝑑) at the point (𝑑, 𝑦). The following table gives the slopes of the
tangent lines at three different points.
(𝑑, 𝑦)
𝑓(𝑑, 𝑦)
(-1, 1)
2
(-1, 0)
1
(1, 4)
3
Think of the vector < π‘Ž, 𝑏 > as the position vector of the point (π‘Ž, 𝑏) that is, the vector whose tail is the
origin and tip the point (π‘Ž, 𝑏). In other words, < π‘Ž, 𝑏 > is the vector that joins the points (0, 0) and (π‘Ž, 𝑏).
The vectors < 1, 2 >, < 1, 1 >, and < 1, 3 > are parallel to the tangent lines to the graph of 𝑓(𝑑, 𝑦) at the
points (−1, 1), (-1, 0), and (1, 4).
We can use the quiver command to plot the vectors < 1, 2 >, < 1, 1 >, and < 1, 3 >:
We observe that the vectors have the desired slopes but have different lengths at different points. We can
scale the vectors by dividing each one of them by its length 𝐿𝑖 :
The slope field of our differential equation can be obtained by repeating the same procedure for a large
number of points. To do this we use the MATLAB commend meshgrid.
In this example we plot the slope field of the above equation on the domain −4 ≤ 𝑑 ≤ 4, −3 ≤ 𝑦 ≤ 3.
We can obtain a better picture by reducing the length of the vectors by half:
Using the dsolve command, we see that the general solution of our equation consists of the family of
functions 𝑦(𝑑) = 𝑑 + 1 + 𝑐𝑒 𝑑 . The following figure shows the solutions for 𝑐 = −2, −1, 0, 1, 2
superimposed on the slope field.
Example
Plot the slop field:
𝑦 ′ = −𝑑𝑦 2 .
A special attention should be directed to the second line and the way S was written. Make sure that use
".*" and ".^"
Exercise MA282-3 (B. Hunt) (Solution at the end of document)
Consider the critical threshold model for population growth
𝑦 ′ = −(2 − 𝑦)𝑦.
a. Find the equilibrium solutions of the differential equation.
b. Draw the slop field and use it to decide which equilibrium solutions are stable and which are
unstable (𝑦(𝑑) is stable if solutions that start near 𝑦(𝑑) converge to 𝑦(𝑑)). Hint: modify
[T,Y]=meshgrid(-4:0.2:4, -4:0.2:4)until you obtain a desirable slope field.
c. What is the limiting behavior of the solution if the initial population is between 0 and 2? Greater
than 2?
d. Use dsolve to find the solutions with initial values 1.5, 0.3, and 2.1.
e. Plot the three solutions of part (d) together with the slop field on the same graph. Do the solutions
follow the slope field as you expect it to?
Exercise MA282-4 (Solution at the end of document)
Consider 𝑦 ′ = (𝛼 − 1)𝑦 − 𝑦 3 .
a. Use solve to find the roots of (𝛼 − 1)𝑦 − 𝑦 3. Explain why 𝑦 = 0 is the only real root when 𝛼 ≤ 1,
and why there are three distinct roots when 𝛼 > 1.
b. For 𝛼 = −2, −1, π‘Žπ‘›π‘‘ 2, draw a direction field for the differential equation and deduce there is only
one equilibrium solution. Is it stable?
c. Do the same for 𝛼 = 1.
d. For 𝛼 = 1.5, 2, draw the direction field . Identify the equilibrium solutions and explain their
stability.
e. Explain: "As 𝛼 increase through 1, the stable solution π‘₯ = 0 bifurcates into two stable solutions"
MA 282-Assignment #3: Numerical Solutions-the MATLAB Command ode45
So far we have been using examples where the command dsolve was capable of producing explicit
solutions of the differential equations.
Now consider the IVP: 𝑦 ′ = 𝑦 − 𝑦 2 − 0.2 sin(𝑑) , 𝑦(0) = 2.
If we type:
In this situation we use the numerical solver ode45 to find and plot approximate solutions for the
equation.
First we define an anonymous function (we could use an inline function):
We will use the notation yap instead of y just to emphasis that the solution is an approximation one:
We solved the IVP over the interval [0, 15] with initial condition 𝑦(0) = 2. Notice the way the second and
third arguments were used with the command ode45. In particular, 0 must be one of end points of the
interval over which we wish to obtain a solution.
If we wish to plot the same solution solution on the interval [-2 , 15], then we plot forwards i.e. over [0,
15] and backwards i.e. over [0, -2]:
Now suppose we want to plot a family of solutions with initial values 𝑦(0) = 0.1, 0.3, 0.5, 1, 2 over the
interval [0, 15], then:
Similarly, we can plot the entire family on the interval [-2, 15] by solving forwards and backwards:
Remark
The choice of axis is very important in producing a complete graph.
Example
Consider the initial value problem 𝑦 ′ = 𝑦 − 𝑦 2 − 0.2 sin(𝑑) , 𝑦(7) = 0.5. Use ode45 to find an
approximate solution over the interval [0, 15]. Plot the approximate solution together with an
appropriate slope field.
Exercise MA282-5 (Solution at the end of document)
𝑑
Consider the differential equation 𝑦 ′ = 𝑦 .
a. Use ode45 to calculate and plot an approximate solution to the initial value problem: 𝑦 ′ =
𝑑
𝑦
, 𝑦(0) = 1 for 0 ≤ 𝑑 ≤ 2
b. Use dsolve to find an exact solution of the IVP
c. Plot the exact and the approximate solution on the same graph. Can you distinguish between the
two curves?
d. Plot a family of solutions with initial values 𝑦(0) = 1.2, 1.4, 1.6, 1.8 over the interval [-1, 2]
MA 282-Assignment #4: First-Order Systems
Example1 The predator-prey model
𝑑𝑅
= 2𝑅 − 1.2𝑅𝐹
𝑑𝑑
𝑑𝐹
= −𝐹 + 0.9 𝑅𝐹
𝑑𝑑
predicts cyclic population behavior for both the predator population described by F(t) and the prey
population described by R(t). See Blanchard for more details.
Equilibrium Solutions
2𝑅 − 1.2𝑅𝐹 = 0
The solutions of the system {
are pairs of constant functions called equilibrium solutions
−𝐹 + 0.9𝑅𝐹 = 0
to the system.
We can use the solve command to find the equilibrium points of the above system by typing:
10
5
That is the equilibrium solutions are (𝑅, 𝐹) = (0, 0) and (𝑅, 𝐹) = ( 9 , 3).
R(t)- and F(t)-graphs
If we specify the initial conditions 𝑅0 = 1 and 𝐹0 = 0.5 we can use the MATLAB function ode45 to obtain
approximate solutions to the system.
Let 𝑃 = (𝑅(𝑑), 𝐹(𝑑)) ; we think of 𝑃 as a vector whose components are 𝑅(𝑑) and F(t). For MATLAB, 𝑅(𝑑)
is 𝑃(1) and 𝐹(𝑑) is 𝑃(2). With this in mind, we begin by defining an anonymous function f whose
components are the right hand side of the system:
Let us denote by π‘†π‘Žπ‘ the approximate solution to the IVP; that is π‘†π‘Žπ‘ = (𝑅(𝑑), 𝐹(𝑑)) is an approximation
to the actual solution of the system with the indicated initial conditions. If we wish to plot the first
component of π‘†π‘Žπ‘ i.e. 𝑅(𝑑) over the interval 0 ≤ 𝑑 ≤ 15 then:
Similarly we can plot the component 𝐹(𝑑) for 0 ≤ 𝑑 ≤ 15:
We can plot the two solutions on the same graph as follows:
Phase Portrait
The plot of a solution (𝐹(𝑑), 𝑅(𝑑)) as a function of 𝑑 would be a curve in the (𝑑, 𝐹, 𝑅) − π‘ π‘π‘Žπ‘π‘’. The
projection of this curve into the (𝐹, 𝑅) − π‘π‘™π‘Žπ‘›π‘’ is called a trajectory or a solution curve. A trajectory is an
example of a parameterized curve and is drawn by plotting (𝐹(𝑑), 𝑅(𝑑)) as 𝑑 varies. A plot of a family of
trajectories is called a phase portrait of the system.
The solution curve for the predator-prey system
𝑑𝑅
= 2𝑅 − 1.2𝑅𝐹
𝑑𝑑
𝑑𝐹
= −𝐹 + 0.9 𝑅𝐹
𝑑𝑑
corresponding to the initial condition (𝑅0 , 𝐹0 ) = (1, 0.5) is
Making a phase portrait requires some planning. The best approach is to start by plotting the equilibrium
solutions:
Next use a loop to add extra curves:
Remark
The above phase portrait corresponds to the curves where (𝑅(0), 𝐹(0)) = (π‘Ž, 𝑏) for several values of π‘Ž
and 𝑏. Moreover we solved forwards from 𝑑 = 0 to 𝑑 = 6.
If we change the initial conditions to (𝑅(2), 𝐹(2)) = (π‘Ž, 𝑏) then it is necessary that we plot forwards and
backwards otherwise we do not obtain complete curves.
Exercise MA282-6 (Solution at the end of document)
𝑑𝑅
Consider the predator-prey system {
𝑑𝑑
𝑑𝐹
𝑑𝑑
𝑅
= 2 (1 − 3 ) 𝑅 − 𝑅𝐹
. (See Blanchard section 2.1)
= −2𝐹 + 4𝑅𝐹
a. Use solve to find all the equilibrium solutions
b. Plot the solution curve corresponding to the initial conditions 𝑅(1) = 1, π‘Žπ‘›π‘‘ 𝐹(1) = 3.7 over the
interval 0 ≤ 𝑑 ≤ 30. For axis, use [0, 2, 0, 6].
c. Describe the fate of the prey and predator populations based on the solution curve.
d. Display graphs of the solutions 𝑅(𝑑) and 𝐹(𝑑) corresponding to the initial conditions 𝑅(1) =
1, π‘Žπ‘›π‘‘ 𝐹(1) = 3.7 over the interval 0 ≤ 𝑑 ≤ 30. Compare with part (c).
MA 282-Assignment #5: Vector Fields
Once again consider the predator-prey system
𝑑𝑅
= 2𝑅 − 1.2𝑅𝐹
𝑑𝑑
𝑑𝐹
= −𝐹 + 0.9 𝑅𝐹
𝑑𝑑
If we let 𝑃(𝑑) = (𝑅(𝑑), 𝐹(𝑑)), then the system can be written in the form
𝑑𝑃
𝑑𝑑
= (2𝑅 − 1.2𝑅𝐹, −𝐹 + 0.9𝑅𝐹).
For each point (𝑅, 𝐹) in the RF-plane we assign a vector whose components are given by (2𝑅 −
1.2𝑅𝐹, −𝐹 + 0.9𝑅𝐹). The assignment: (𝑅, 𝐹) ⟢ (2𝑅 − 1.2𝑅𝐹, −𝐹 + 0.9𝑅𝐹) is an example of a vector field.
We visualize this vector field as a set of arrows based at points in the RF-plane.
As an example, let us draw some selected vectors:
The lengths of vectors are important however to avoid overlapping, we often scale the vectors so they all
have the same length; the result is called a direction field.
The following few commands produce a vector field of the predator-prey system:
We can get a better picture by selecting smaller vectors; this can be done by scaling the vectors by a
factor of 0.5:
Now we plot the direction field together with the solution curve corresponding to the initial condition
(𝑅(0), 𝐹(0)) = (1, 0.5).
Exercise MA282-7 (Blanchard) (Solution at the end of document)
𝑑2 π‘₯
𝑑π‘₯
a. Convert the second-order differential equation 𝑑𝑑 2 + 2 𝑑𝑑 − 3π‘₯ + π‘₯ 3 = 0 into a first-order system
in terms of π‘₯ and 𝑣, where 𝑣 =
𝑑π‘₯
𝑑𝑑
b. Find all equilibrium points
c. Use MATLAB to sketch the associated direction field. Hint: use meshgrid(-5:.4:5,5:.4:5)and axis tight
d. The following script plots several solution curves over the interval −3 ≤ 𝑑 ≤ 3
f=@(t,P) [P(2);3*P(1)-P(1)^3-2*P(2)];
a=-2:0.2:2;
b=-2:0.2:2;
for k=1:length(a)
[t,Pap]=ode45(f, [0,3],[a(k),b(k)]);
plot(Pap(:,1),Pap(:,2),'linewidth',2)
hold on
[t,Pap]=ode45(f, [0,-3],[a(k),b(k)]);
plot(Pap(:,1),Pap(:,2),'linewidth',2)
end
hold off
axis([-5,5,-5,5])
What are the initial conditions?
e. Use the above script to plot a phase portrait together with the direction field of part c.
f. Describe the behavior of the solutions?
MA 282-Assignment #6: Linear Systems
We restrict our discussion to systems of the form
𝑑π‘₯
= π‘Žπ‘₯ + 𝑏𝑦
𝑑𝑑
𝑑𝑦
= 𝑐π‘₯ + 𝑑𝑦
𝑑𝑑
where π‘Ž, 𝑏, 𝑐, 𝑑 are constants.
We let = (
π‘Ž
𝑐
π‘‘π‘Œ
π‘₯(𝑑)
𝑏
) , π‘Œ(𝑑) = (
), and we write the system in the form
= π΄π‘Œ.
𝑦(𝑑)
𝑑𝑑
𝑑
1. Strait -Line Solutions
π‘‘π‘Œ
Recall, if the matrix 𝐴 has a real eigenvalue πœ† with associated eigenvector 𝑣, then the linear system 𝑑𝑑 =
π΄π‘Œ has the straight line solution π‘Œ(𝑑) = 𝑒 πœ†π‘‘ 𝑣.
Example
π‘‘π‘Œ
Consider the system 𝑑𝑑 = (
2 2
) π‘Œ.
1 3
We use the MATLAB command eig to calculate the eigenvalues and their associated eigenvectors as
follows.
The eigenpairs of the system are: πœ†1 = 1, 𝑣1 = [
−2
1
] and πœ†2 = 4, 𝑣2 = [ ].
1
1
So the system has two straight- line solutions namely, π‘Œ1 (𝑑) = 𝑒 𝑑 [
𝑑
4𝑑
−2
] = [−2𝑒
] and π‘Œ2 (𝑑) = [𝑒 4𝑑 ].
𝑑
1
𝑒
𝑒
We can plot the direction field of the system exactly as we did for non-linear systems:
To plot half of the straight line solution, we type
Any multiple of the vector 𝑣1 is also an eigeinvector of πœ†1 . In particular – 𝑣1 is an eigenvector and the
lower half of the line is obtained by plotting the solution – 𝑒 𝑑 𝑣1 .
Similarly we can plot the second straight solution as folows.
Please consult the textbook for detailed analysis of the importance of straight line solutions.
Next we use MATLAB to solve linear systems in two different ways. We will focus on the technical parts;
students should consult their textbooks to learn about the valuable information that eigenpairs pairs
contain.
2. Solving Systems in Terms of Eigenpairs
Case I: two distinct real eigenvalues
Example
As an example we solve the system
π‘‘π‘Œ
𝑑𝑑
−3 1
2
=(
) π‘Œ, π‘Œ(0) = [ ].
0 2
5
−3 1
We enter the coefficient matrix 𝐴 = (
) in MATLAB:
0 2
Next we use the command eig to calculate the eigenpairs of 𝐴:
1 1/5
) provides the eigenvectors associated to the distinct
0
1
eigenvalues πœ†1 = −3 and πœ†2 = 2 found along the diagonal of the matrix Evl.
Note that the columns of the matrix πΈπ‘£π‘Ÿ = (
Therefore the general solution is
1
1/5
π‘Œ(𝑑) = 𝑐1 𝑒 −3𝑑 [ ] + 𝑐2 𝑒 2𝑑 [
].
0
1
2
Substituting for the initial condition π‘Œ(0) = [ ]:
5
1
1/5
2
𝑐1 [ ] + 𝑐2 [
]=[ ]
0
5
1
which can be written in the form:
1 1/5 𝑐1
2
(
) [𝑐 ] = [ ]
5
2
0
1
1 1/5
Observe that πΈπ‘£π‘Ÿ = (
), hence we obtain:
0
1
𝑐1
2
πΈπ‘£π‘Ÿ [𝑐 ] = [ ].
5
2
Now we use MATLAB to solve for 𝑐1 and 𝑐2 as follows:
that is 𝑐1=1, 𝑐2 = 5, and the solution to our initial value problem is
1
1/5
π‘Œ(𝑑) = 𝑒 −3𝑑 [ ] + 5𝑒 2𝑑 [
]
0
1
or
1
1
π‘Œ(𝑑) = [ ] 𝑒 −3𝑑 + [ ] 𝑒 2𝑑
0
5
Case II: two complex eigenvalues
As an example we find the general solution of the system
So the eigenpairs are
π‘‘π‘Œ
𝑑𝑑
=(
−2 −3
) π‘Œ.
3 −2
−𝑖
πœ†1 = −2 − 3𝑖,
𝑣1 = [
]
1
and
𝑖
πœ†2 = −2 + 3𝑖,
𝑣2 = [ ].
1
Consider the second pair and let us calculate the real and imaginary parts of the complex solution:
𝑖
π‘Œ(𝑑) = [ ] 𝑒 (−2+3𝑖)𝑑
1
𝑖
𝑖𝑒 −2𝑑 π‘π‘œπ‘ 3𝑑 − 𝑒 −2𝑑 𝑠𝑖𝑛3𝑑
−𝑒 −2𝑑 𝑠𝑖𝑛3𝑑
𝑒 −2𝑑 π‘π‘œπ‘ 3𝑑
π‘Œ(𝑑) = [ ] 𝑒 −2𝑑 (π‘π‘œπ‘ 3𝑑 + 𝑖𝑠𝑖𝑛3𝑑) = [
]=[
]+[
]𝑖
−2𝑑
−2𝑑
−2𝑑
−2𝑑
1
𝑒 π‘π‘œπ‘ 3𝑑 + 𝑖𝑒 𝑠𝑖𝑛3𝑑
𝑒 π‘π‘œπ‘ 3𝑑
𝑒 𝑠𝑖𝑛3𝑑
Consequently the general solution of this system is
−𝑒 −2𝑑 𝑠𝑖𝑛3𝑑
π‘Œ(𝑑) = 𝐢1 [
𝑒 −2𝑑 π‘π‘œπ‘ 3𝑑
] + 𝐢2 [
𝑒
−2𝑑
π‘π‘œπ‘ 3𝑑
]
𝑒
−2𝑑
𝑠𝑖𝑛3𝑑
Case III: The eigenvalue πœ† has multiplicity 2
i.
π‘‘π‘Œ
3 0
)π‘Œ
0 3
There are two independent eigenvectors associated with πœ† : 𝑑𝑑 = (
1
0
In this case the general solution is π‘Œ(𝑑) = 𝑐1 𝑒 3𝑑 [ ] + 𝑐2 𝑒 3𝑑 [ ]
0
1
ii.
π‘‘π‘Œ
3
1
There is only one linearly independent vector associated with πœ†: 𝑑𝑑 = (
0
)π‘Œ
3
0
So there is one vector, 𝑣 = [ ], associated with πœ† = 3.
1
0
A particular solution is given by π‘Œ1 = 𝑒 πœ† 𝑑 𝑣 = 𝑒 3𝑑 [ ].
1
A second solution is π‘Œ2 = 𝑑𝑒 πœ† 𝑑 𝑣 + 𝑀𝑒 πœ†π‘‘ , where (𝐴 − πœ†πΌ)𝑀 = 𝑣.
Note that Evr is just the vector 𝑣 hence we can easily solve for 𝑀:
1
0
Therefore, π‘Œ2 = 𝑑𝑒 πœ† 𝑑 𝑣 + 𝑀𝑒 πœ†π‘‘ = 𝑑𝑒 3 𝑑 [ ] + [ ] 𝑒 3𝑑 and the general solution is 𝑇(𝑑) = 𝐢1 π‘Œ1 (𝑑) + 𝐢2 π‘Œ2 (𝑑).
0
1
3. Solving Systems using the command dsolve
Let us consider the system discussed in Case III (ii):
π‘‘π‘Œ
𝑑𝑑
That is the system
𝑑π‘₯
= 3π‘₯
𝑑𝑑
𝑑𝑦
= π‘₯ + 3𝑦
𝑑𝑑
To find the general solution, we type
3
1
=(
0
) π‘Œ.
3
To solve the same system but with the initial conditions π‘₯(0) = 2, 𝑦(0) = 5:
Exercise MA282-8 (Solution at the end of document)
Let π‘Ž be a real number different from 0 and consider the system
𝑑π‘₯
= π‘Žπ‘₯ + 4𝑦
𝑑𝑑
𝑑𝑦
= π‘Žπ‘¦
𝑑𝑑
1.
2.
3.
4.
Use MATLAB to verify that the system has a double eigenvalue πœ†
Use MATLAB to verify that there is only one eigenvector associated with πœ†
Write a script that calculates the general solution of the system
Verify your script by using dsolve to solve the system
MA 282-Assignment #7: Phase Portraits and Direction Fields
Consider the initial value problem
𝑑π‘₯
= 2π‘₯ + 2𝑦
𝑑𝑑
, π‘₯(0) = π‘š, 𝑦(0) = 𝑛.
𝑑𝑦
= π‘₯ + 3𝑦
𝑑𝑑
We can use desolve to solve this IVP problem in terms of π‘š and 𝑛:
As we have indicated before the outputs of the desolve command are symbolic expressions. We can
use MATLAB to change those symbolic expressions into functions π‘₯𝑓(𝑑, π‘š, 𝑛) and 𝑦𝑓(𝑑, π‘š, 𝑛). This can
be done using the MATLAB command eval.
Finally since we intend to plot solutions curves, we need to make sure that all expressions are
vectorized ; has dots before * and /; otherwise 𝑑 will be interpreted as a matrix and multiplications
and divisions will not make any sense.
The following script should plot the straight-line solutions:
Let us plot the straight-line solutions together with some solutions curves:
Putting everything together by adding a direction field:
Exercise MA282-9 (Blanchard Ex 19, 3.3)
Consider the initial value problem
𝑑π‘₯
1
= −2π‘₯ + 𝑦
𝑑𝑑
2 , π‘₯(0) = π‘š, 𝑦(0) = 𝑛.
𝑑𝑦
= −𝑦
𝑑𝑑
1.
2.
3.
4.
5.
Draw a direction field for the system.
Determine the type of the equilibrium point at the origin.
Use dsolve to solve the IVP in terms of m and n
Find all straight-line solutions
Plot the straight-line solutions together with the solutions with initial conditions (π‘š, 𝑛) =
(2, 1), (1, −2), (−2, 2), (−2, 0)
Download