Differential Equations A Problem Solving Approach Based On MATLAB by P. Mohana Shankar
Differential Equations A Problem Solving Approach Based On MATLAB by P. Mohana Shankar
www.TechnicalBooksPDF.com
www.TechnicalBooksPDF.com
Differential Equations
A Problem Solving Approach Based on MATLAB®
P. Mohana Shankar
Drexel University
Department of Electrical & Computer Engineering
Philadelphia, Pennsylvania, USA
p,
p,
A SCIENCE PUBLISHERS BOOK
A SCIENCE PUBLISHERS BOOK
www.TechnicalBooksPDF.com
MATLAB® and Simulink® are trademarks of The MathWorks, Inc. and are used with permission. The
MathWorks does not warrant the accuracy of the text or exercises in this book. This book’s use or
discussion of MATLAB® and Simulink® software or related products does not constitute endorsement or
sponsorship by The MathWorks of a particular pedagogical approach or particular use of the MATLAB®
and Simulink® software.
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
© 2018
2017 by Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, an Informa business
978-1-1385-0160-7 (Hardback)
International Standard Book Number-13: 978-1-4987-4799-8
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been
made to publish reliable data and information, but the author and publisher cannot assume responsibility for the
validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the
copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to
publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let
us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted,
or utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, includ-
ing photocopying, microfilming, and recording, or in any information storage or retrieval system, without written
permission from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com
(http://www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers,
MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety
of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment
has been arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for
identification and explanation without intent to infringe.
www.TechnicalBooksPDF.com
Dedicated to my parents, Padmanabharao and
Kanakabai, who were school teachers
www.TechnicalBooksPDF.com
www.TechnicalBooksPDF.com
Preface
This book grew out of instructional material and notes the author created while teaching
courses in Linear Algebra and Differential Equations to undergraduate engineering
students. Starting from simple demos prepared for instructing students, all aspects
associated with the first order differential equations, linear second and higher order
differential equations with constant coefficients and coupled first order differential
equations were incorporated into several modules for obtaining solutions to any
exercise. Taking the pulse of the students to determine what they felt was essential
for their understanding, these modules were constantly updated and put in to a final
from where they display solutions to differential equations with a simple input in
textual form. The solutions are displayed as figures such that they provide theoretical
aspects, explanations, step-by-step generation of solutions, solutions using multiple
approaches, including verification through numerical techniques. The examples in the
book capture this holistic approach to problem solving. MATLAB® (version 2016a)
with its symbolic toolbox provided the appropriate software for the creation of the
solutions in this format.
The book provides theoretical background containing a large number of examples,
far exceeding what is seen in typical textbooks and a substantial number of exercises.
The goal of the book has been the creation of materials that provide the theory, ample
examples to cover the diverse theoretical concepts in each chapter, and multiple ways
of solving problems providing the pedagogy in terms of verification of solutions, etc.
The solutions manual is available separately.
This book has been a family project with the support and encouragement from
my wife Raja and daughter Raji. Their assistance in the preparation of materials was
crucial to the timely completion of the project. I want to thank my editor Mr. Vijay
Primlani for his support during this endeavor. The support provided by the staff at
CRC press is also greatly appreciated.
www.TechnicalBooksPDF.com
www.TechnicalBooksPDF.com
Contents
Dedication v
Preface vii
1. Introduction 1
2. First Order Differential Equations 5
3. Linear Second Order Differential Equations with Constant Coefficients 81
4. Linear Higher Order Differential Equations with Constant Coefficients 181
5. First Order Coupled Differential Equations with Constant Coefficients 236
Appendices 383
Suggested Readings 445
Index 447
www.TechnicalBooksPDF.com
www.TechnicalBooksPDF.com
CHAPTER 1
Introduction
In the sciences, engineering, social sciences, business and other areas that impact
our lives, changes take place continuously. This dynamic behavior can be easily
demonstrated, studied and critically analyzed through modeling carried out by
examining how changes take place in time. This time dependent or temporal behavior
leads us to the notion of derivatives and differential equations. Therefore, a study of
differential equations, their solutions, and interpretation of the solutions is essential
for the proper understanding of systems operating in all walks of life.
Consider a phenomenon where the observable quantity is identified by y. If changes
are taking place in time, it is obvious that y will be a function of time t, expressed as
y(t). If we take the first order derivative of y (differentiation once with respect to the
independent variable t) and equate it to another function f(y,t), we obtain a first order
differential equation expressed as
dy
= f ( y, t ) . (1.1)
dt
It should be noted that f(y,t) may be a constant, a function of time, a function of y
(implicit dependence on t) or a function of y and t. For example, we may have
dy
= f ( y, t ) = y + y 2 t + t 2 + 2. (1.2)
dt
If f(y,t) only depends on y, the first order differential equation is an autonomous one
as in the case of
dy
= f= ( y, t ) h ( y ) . (1.3)
dt
In eqn. (1.3) h(y) is a linear or nonlinear function of y only.
It is possible to take the derivative of eqn. (1.1) once more. In this case, we get
a second order differential equation. We may also take higher order derivatives. The
order of the differential equation is determined by the highest order derivative existing
in the equation. In addition to differential equations in a single variable of the first or
higher orders, it is also possible that there may be two or more observables such as y1(t),
y2(t),.., in which case, we may have interconnected or coupled differential equations.
www.TechnicalBooksPDF.com
2 Differential Equations: A Problem Solving Approach Based on MATLAB
In this book, we study all these differential equations starting from a single first
order differential equation, followed by second order and higher order differential
equations and culminating in coupled first order differential equations. If the differential
dy dy n
equations only contain terms in y, , ,…, or d y , the differential equations are
dt dt dt n
linear. An example of a 4th order linear differential equation is
d4y d2y
a (t ) 4
+ b (t ) 2 + c (t ) y =h ( t ). (1.4)
dt dt
If a(t), b(t) and c(t) in eqn. (1.4) are constants (no dependence on t), the differential
equation is identified as a linear differential equation with constant coefficients.
An example of a second order linear differential equation with constant coefficients
(A, B, and, C) is
d2y dy
A h ( t ). (1.5)
+ B + Cy =
dt 2 dt
Additionally, if h(t)=0, eqn. (1.5) will be a homogeneous differential equation
while a non-homogeneous differential equation will have h(t)≠0. Note that h(t) may
be number (not equal to zero) in a non-homogeneous differential equation.
Chapter 2 is devoted to the study of first order differential equations with special
emphasis on autonomous systems to develop an appreciation and understanding of the
equilibrium conditions of associated systems. The chapter starts with the method of
integrating factors and the method of separable functions for obtaining the solution of
first order differential equations. A description of D-fields is provided to offer a pictorial
description of the behavior of the system. All aspects necessary to understand an
autonomous system are presented and well supported by an extensive set of examples.
The examples are annotated to provide insights into the form of the solution, type
of equilibrium as well as verification of the solution through additional approaches
including use of dsolve(.) in MATLAB®, along with plots if and when necessary.
The second order differential equations are studied in Chapter 3. The differential
equations are limited to linear ones with constant coefficients. Starting with the
homogeneous differential equations, the concept of the characteristic equation or
polynomial is introduced and the evolution of the solution from the roots of the
characteristic equation is described. Solutions are also obtained using Laplace
transforms and the state of the system is examined using the phase portraits to ensure
that the analytical solution and their properties match the conclusions that can be
drawn from phase portraits. An additional approach for obtaining the solution based
on converting the second order equation into a pair of coupled first order differential
equations is also offered as yet another level of verification of the solutions along
with numerical solution obtained using Runge-Kutta methods. Finally, examples are
provided which encompass every aspect of the solution with necessary equations,
annotations, explanations and verification. Non-homogeneous differential equations
are studied next in Chapter 3 by offering two methods for obtaining the particular
solutions, namely the method of undetermined coefficients and the method of variation
of parameters. The particular solutions obtained using both methods are compared
offering a comprehensive view of the solutions to the non-homogeneous differential
www.TechnicalBooksPDF.com
Introduction 3
equations. The Laplace transform based approach and Runge-Kutta method are used
to provide verification. Numerous examples are provided to cover diverse forcing
functions and annotations in figures that clearly illustrate steps in the generation of the
particular solutions, e.g., the need to scale the initial guess by t or t2 as the case may be.
The examples are fully annotated including steps taken to evaluate unknown constants
when the initial conditions are given along with the background theoretical aspects.
Higher order differential equations are studied in Chapter 4. The solution to the
homogeneous differential equation is obtained using the roots of the characteristic
polynomial and issues with the diversity of relationships among the multiple roots are
discussed. Based on this, the characteristic polynomial is used only for differential
equations up to the 4th order. The Laplace transform method is used for all orders.
The particular solution is obtained using the method of variation of parameters (up
to the 4th order). The Runge-Kutta method is used as a means to verify the results.
Once again, the examples are annotated with theoretical aspects, relationships among
the roots (if they exist), formulation of the solution, determination of the unknown
constants (initial conditions given), and, plots of the theoretical and numerical solutions.
Chapter 5 is devoted to coupled first order systems. A pair of coupled equations
is studied first. The use of eigenvectors and eigenvalues in obtaining the solution to
the homogeneous set is presented. The notion of defective matrices and the need for
generalized eigenvectors is described. Another method based on the conversion of a
pair of first order equations into a single second order equation is also presented along
with the method based on Laplace transforms, as additional means for verification.
The Runge-Kutta method is used as an extra step of verification. Phase portraits are
used to justify conclusions about the stability of the system based on the solution
obtained analytically. The concept of the fundamental matrix is invoked to obtain
the particular solution when forcing functions are present. The fundamental matrix
is used to obtain solutions when multiple coupled differential equations are present.
Taking note of the existence of defective matrices, the analysis is limited to coefficient
matrices of size [4 x 4] for the use of eigenvalues and eigenvectors. For larger matrices,
only the Laplace transform based method (which is used throughout regardless of the
size of the coefficient matrix) and the Runge-Kutta method are used for verification.
The examples are annotated by displaying eigenvalues and eigenvectors, identifying
defective matrices (algebraic and geometric multiplicities), degenerate eigenvalues,
generalized eigenvectors, etc.
Appendices provide in depth coverage of topics such as numerical methods for
solving differential equations (Euler’s and Runge-Kutta methods), theory of Laplace
transforms and applications to differential equations and phase plane analysis. In all
cases, theoretical aspects are enunciated with appropriate examples to demonstrate
the relevance to the issues presented in the main body of the book. The final appendix
(Appendix D) is devoted to concepts of linear algebra that are absolutely essential for
gaining a better understanding of the methods employed to find solutions to differential
equations. These include properties of matrices, solution of a set of equations using
row reduced echelon forms, Cramer’s rule if applicable, matrix inversion if permitted
and most importantly, the topic of eigenvalues and eigenvectors of square matrices.
An expanded view of defective matrices and generalized eigenvectors is presented to
www.TechnicalBooksPDF.com
4 Differential Equations: A Problem Solving Approach Based on MATLAB
illustrate how they play an important role in obtaining solutions to a set of first order
coupled differential equations.
A common thread throughout this book is the use of MATLAB (version 2016a)
for the creation of the displays associated with every example. In every chapter,
MATLAB scripts for solving example problems, creating phase plots, obtaining
Laplace transforms, etc. are given for the benefit of the reader. Through the use of
LaTex conversion and extensive use of symbolic toolbox, the displays of the examples
and solutions provide equations, explanations, sketches, plots, etc. reproducing the
class room work by an instructor. MATLAB is used not merely as a means to verify
the solution. It is also used to create a step-by-step solution matching the theory in
every respect and thus providing a pedagogical element which is a unique feature of
this book. Even though it is not possible to assure the absolute accuracies, every effort
has been made to ensure that the MATLAB scripts (written in version 2016a) and the
results provided are correct.
As indicated in the preface, the book is the culmination of the author’s participation
in teaching courses in Linear Algebra and Differential Equations to engineering
students. The books used during that period of instruction and a number of journal
publications by the author that came out of the preliminary work are listed below.
Bibliography
Books
Brannan, J. R. and W. E. Boyce. Differential Equations: An Introduction to Modern Methods and
Applications, 2nd Edition, John Wiley, NJ. 2011.
Farlow, J., J. E. Hall, J. M. McDill and B. H. West. Differential Equations and Linear Algebra, 2nd Edition,
Pearson, NY, 2007.
Lay, D. C. Linear Algebra and Its Applications, 5th Edition, Pearson, NY, 2015.
Nagle, R. K., E. B. Saff and A. D. Snider. Fundamentals of Differential Equations, 8th Edition, Person,
NY 2012.
Publications
Shankar, P. M. A MATLAB workbook on the pedagogy of generalized eigenvectors. Computer Applications
in Engineering Education, Vol. 25, No. 3, pp. 411–419, March 2017. doi:10.1002/cae.21808
Shankar, P. M. Pedagogy of Cramer’s Rule and beyond: A MATLAB workbook. Mathematics & Computer
Education, Fall 2016, Vol. 50 Issue 3, pp. 207–215, December 2016.
Shankar, P. M. Pedagogy of autonomous differential equations and equilibria using a MATLAB workbook.
Mathematics & Computer Education. Winter 2016, Vol. 50 Issue 1, pp. 57–72.
Shankar, P. M. Pedagogy of second order homogeneous differential equations: A holistic approach using
a MATLAB workbook. Computer Applications in Engineering Education, Vol. 24, No. 1, January
2016, pp. 114–121.
Shankar, P. M. Pedagogy of solutions to a set of linear equations using a MATLAB workbook. Computer
Applications in Engineering Education, Vol. 25, No. 3, pp. 345–351, March 2017. doi:10.1002/
cae.21803
www.TechnicalBooksPDF.com
CHAPTER 2
2.1 Introduction 5
2.2 D-field Plots 6
2.3 Methods of Solving First Order Differential Equations 9
2.3.1 Method of integrating factors 9
2.3.2 Separable differential equations 17
2.4 Additional Examples on D-field Plots 26
2.5 Autonomous Differential Equations 31
2.5.1 A general example 35
2.5.2 An example using MATLAB® and the script 44
2.5.3 Additional examples 46
2.6 Summary 77
2.7 Exercises 77
2.1 Introduction
Most physical and chemical phenomena involve changes taking place with respect to
one or more parameters. This means that in its simplest form, systems responsible for
these phenomena can be modeled in terms of an independent parameter (or variable)
and a dependent parameter (or variable). Since changes take place over time, the
easiest way to represent the system is through an expression describing the variation
of a parameter (temperature, pressure, concentration of a chemical, force, pressure,
etc.) in time. Variations are often represented in terms of derivatives resulting in first
and higher order differential equations to model these systems.
Differential equations of first order are characterized by the existence of the
derivative of the first order in an equation containing an independent variable (t) and
a dependent variable (y) such as
dy
= f ( t , y ). (2.1)
dt
In eqn. (2.1), f(.) is generally taken to be a function of two variables, even though
f(.) may be a function of y or t alone. It is also possible that f(.) is a constant. If
f(t,y) does not depend on t, the differential equation in eqn. (2.1) is identified as an
autonomous differential equation. If f(t,y) only contains terms that are linear in y,
www.TechnicalBooksPDF.com
6 Differential Equations: A Problem Solving Approach Based on MATLAB
eqn. (2.1) becomes a first order linear differential equation. If f(t,y) can be separable
and written as the product of two functions h(t) and g(y), a function of t and a function
of y, the differential equation is a separable one.
2.2 D-field Plots
Considerable insight into the systems described through eqn. (2.1) can be gained by
examining the behavior of the differential equation through the use of plots known as
directional field plots or D-field plots. They rely on the fact that eqn. (2.1) also is the
slope of y, describing how y varies with time t. Consider a simple differential equation
dy
= 6 − y . (2.2)
dt
If a value of y=6 is chosen, the slope is 0. For y=0, the slope is 6. If there is a way
to indicate the values of the slope at various values of y by short arrows on a plot of
t vs. y, the pattern created will provide information on how the solution varies with
time and what is likely to happen when t goes up or down. The plot so generated is
called the directional field or D-field plot. The plot can be generated with MATLAB
using the quiver(.) command which draws small arrows. The simple code is given
below and the resulting display is shown in Figure 2.1.
clear;clc
y=0:10; % pick values of y
t=0:.4:8; % pick values of t
[tt,yt]=meshgrid(t,y); % create a 2-d array of samples of t and y
dy=6-yt; % create dy/dt
dt=ones(size(dy)); % create corresponding time coordinates
figure, quiver(tt,yt,dt,dy,1.,‘b’) % quiver displays the directional arrows
xlabel(‘time’),ylabel(‘y(t)’), axis tight
title(‘dy/dt=6-y’)
hold on
plot(t,6*ones(length(t)),‘-r’,’linewidth’,2)
CC=[-5:5];% values of C
% now plot the solution
tt=t;
clear t
syms y(t) C
ys=dsolve(diff(y,t)==6-y); % get the symbolic solution
vars=symvar(ys);% find the symbolic variables
ys=subs(ys,vars(1),C); % replace the unknown constant with C
yss=MATLABFunction(ys); % create in-line function for plotting the solution
for k=1:length(CC)
C=CC(k);
ysS=yss(C,tt);
plot(tt,ysS)
end;
A solution to eqn. (2.2) can easily be found by rewriting it as
dy
= dt (2.3)
( − y)
6
www.TechnicalBooksPDF.com
First Order Differential Equations 7
Regardless of the value of the unknown constant C, it can be seen that as t→∞,
the solution approaches a stable value of 6. This can be observed from the plot. If a
second step is undertaken to plot the solution for several values of C [for example,
ranging from 0 to 5] and displayed on the same D-field plot, the solutions (shown by
continuous lines) will follow the field directions arrows as shown in Figure 2.1. If an
analytical solution is unavailable, numerical techniques (Appendix A) can be used to
superimpose the samples of solutions as shown.
While eqn. (2.2) was autonomous, a slightly different case is that of a non-
autonomous linear differential equation
dy
= y + 5 − 3t . (2.5)
dt
Proceeding as before and taking an additional note of the existence of t by choosing
values of t along with values of y, the D-field can be plotted. The MATLAB script
appears below and results are shown in Figure 2.2.
clear;clc;close all
y=-5:.5:5; % pick values of y
t=0:.25:5; % pick values of t
[tt,yt]=meshgrid(t,y); % create a 2-d array of samples of t and y
dy=yt+5-3*tt; % create dy/dt
dt=ones(size(dy)); % create corresponding time coordinates
figure,
quiver(tt,yt,dt,dy,1.5,‘b’) % quiver displays the directional arrows
www.TechnicalBooksPDF.com
8 Differential Equations: A Problem Solving Approach Based on MATLAB
Unlike the example in eqn. (2.2), the contours seem to diverge indicating that
the system represented in eqn. (2.5) is unstable. This can be established by getting
the solution of eqn. (2.5) as (methods of obtaining solutions are discussed in the next
section)
y ( t ) = 3t − 2 + Cet. (2.6)
The theoretical plots are superimposed (continuous lines). The benefits of D-field
patterns are clearly evident in terms of the directional arrows providing information on
whether the system is likely to attain a stable value once the system starts functioning
and how the behavior is likely to change with time, without actually knowing the
solution.
Additional examples of D-field plots are given in Section 2.4 following the
discussion of methods for finding solutions of first order differential equations.
www.TechnicalBooksPDF.com
First Order Differential Equations 9
In eqn. (2.7), a(t), p(t) and g(t) are either constants or functions of time and
dy
Dy = . (2.8)
dt
Equation (2.7) is rewritten as
p (t ) g (t )
Dy + y= . (2.9)
a (t ) a (t )
It is understood from eqn. (2.9) that
a ( t ) ≠ 0 . (2.10)
The integrating factor µ(t) is a function of time that satisfies the following relationship
d
µ (=
t ) y ( t ) µ ( t ) Dy + q ( t ) y ( t ) (2.12)
dt
Multiplying eqn. (2.11) by µ(t) leads to
µ ( t ) Dy + µ ( t ) q ( t ) y ( t ) =
µ ( t ) h ( t ). (2.13)
Comparing eqns. (2.12) and (2.13), the second term on the left hand side of eqn.
(2.13) yields
d
µ ( t ) = µ ( t ) q ( t ). (2.14)
dt
www.TechnicalBooksPDF.com
10 Differential Equations: A Problem Solving Approach Based on MATLAB
µ (t ) y (t )
= ∫ µ ( z ) h ( z )dz + C (2.18)
t0
If the initial conditions are given, the unknown constant C can be determined and an
exact solution can be obtained.
MATLAB is a perfect vehicle to solve these problems through the use of the
Symbolic Toolbox. A few examples (including one where no analytical solution exists
appear below). All these were done in MATLAB to incorporate appropriate theory
and results as well as explanations if necessary such as the case where no analytical
solutions exist. The results are verified using dsolve(.) in MATLAB. It is noted that
the constants created with the integrating factor based approach will be different from
the unknown constants displayed in the solution obtained using dsolve(.). If the initial
condition y(t0)=y0 with t0=0 or the boundary condition with y(t0)=y0, t0≠0, the unknown
coefficients can be evaluated and an exact solution can be obtained. If the analytical
solution to the differential equation is available, the implicit solution in eqn. (2.19)
can be plotted by choosing a few values of C.
If the example falls in a special category such as the availability of the exact or
particular solution, unavailability of analytical solution, etc. these are indicated in the
displays created in MATLAB.
www.TechnicalBooksPDF.com
First Order Differential Equations 11
Example # 2.1
www.TechnicalBooksPDF.com
12 Differential Equations: A Problem Solving Approach Based on MATLAB
www.TechnicalBooksPDF.com
First Order Differential Equations 13
Example # 2.3
•
•,.
o ••••••• ------------- --- ---
.,.
..:.-----;.:.------:-----:,.:-----~,:-----,~.;-----!,
,
www.TechnicalBooksPDF.com
14 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 2.4
," ",do r dm.r.n~" eq ... , Ion: 601_ ",1"11 ""-IIr.~"9 F. cto<
' ..... ~~Iion . Dy _ 2y + tt,{l '
TIle Different ial Eiluation =- Q(t)Dy + p(t)y _ get )
In~ating factor .... I,(t ) ,. tf $i.
General Solution .... y(t) ,. M • [1'.. ~. ) + C1
"($)~ds
a(t).... 1 p(!).... -2
">' ("+~c)
11 1" ,. ,
!IO , _________-J""""~-;;.~'I~~~~~"~'~c_------_,
I'
1"It,
.','.
, "
• "
',"', , ", , ", ,
. ',,, • , I'
. """'"
_"""',It,, ',
~';""
" ,
.. '- ," " , ,""' ,
~""'",
, ,
" I
• I IllI- ==::
--_
~~ -, - ""- " I
, ,".. , ,' ,
www.TechnicalBooksPDF.com
First Order Differential Equations 15
Example # 2.5
1" ....... , d_ntlal '"'!uallon: Solution u.lng ..,..Un" Factor
I..... OiI......IaIE_ _ .. Th.
~,
= ~
, _ ,
11
".
y( t)
'.
".
"',.
",.-
", ...
,,,",
,"'''
tI,"''''
..
.. , ,
www.TechnicalBooksPDF.com
16 Differential Equations: A Problem Solving Approach Based on MATLAB
.., , ,
www.TechnicalBooksPDF.com
First Order Differential Equations 17
Example # 2.7 In this case, the analytical solution is not available for plotting because
it is given in terms of the error function of a complex input. The MATLAB script
displays this information.
www.TechnicalBooksPDF.com
18 Differential Equations: A Problem Solving Approach Based on MATLAB
In other words, it is easy to get an implicit solution of the form in eqn. (2.28) and
it may or may not be possible to get a solution in explicit form as in eqn. (2.29) where
G(.) is only a function of x and C. The implicit solutions can be plotted by choosing
a range of values of the unknown constant C. The plotting can be done using the
ezplot(.) command available in the symbolic toolbox in MATLAB. It should be noted
that the method based on separable functions will provide an implicit solution, while
the use of dsolve(.) in MATLAB leads to explicit solutions and these may involve
complex functions. Use of dsolve(.) may also lead to implicit solutions expressed in
the form containing phrases ‘RootOf’, suggesting that a simple representation of the
solution is not possible.
A few examples are given below demonstrating the various aspects of the approach
described above. All these were created in MATLAB and keeping up with the theme
of the book, the displays provide the theoretical aspects, steps involved, solution
obtained using the approach and the solution (if it exists) using dsolve(.). Note that the
unknown constants in the solutions obtained using the method of separable differential
equations and dsolve(.) in MATLAB may be different.
www.TechnicalBooksPDF.com
First Order Differential Equations 19
Example # 2.8 Explicit solution available using dsolve(.) as seen by the three separate
solutions for y, with two of them being complex.
/ ht,j dP " Ii
$oIutioo ... / ht,) <41 - f /(z)dz + C• 0
SoUiOn~ r';
S-_E~ + i'.! + C = 0
-"3
y(Z) = 31 (if + B) l
• . ' _ __ ;~"d
.,;;;"1'
, ----, ',',
, I,i,-, ,- -- _"I,','.'
II. , _',
" I " I ,
• I" I ",
y
",,'
I,.
I
", " ,
".'
,.,'
""
- ;, 1
" ' -.-_.'
I.,' ,
........
"II " , ' _ ___ '
"'" 1,- '
.:"1 2 J!I
001-3·2 •
.~--~--~--~--~--~--~
~ 0 2 •
~ $ ~
www.TechnicalBooksPDF.com
20 Differential Equations: A Problem Solving Approach Based on MATLAB
www.TechnicalBooksPDF.com
First Order Differential Equations 21
www.TechnicalBooksPDF.com
22 Differential Equations: A Problem Solving Approach Based on MATLAB
C-("I·2·' 0 , 2 31
."-~----~--------------~
~ 0 2
~ 4 8 ~
www.TechnicalBooksPDF.com
First Order Differential Equations 23
Example # 2.12 Explicit solution unavailable using dsolve(.) as seen by the presence
of the phrase ‘RootOf’ in the MATLAB generated solution.
~_ !(x)= 4x-x 3
' ''''''- ~ h(y ) = rh
jf(Z)iU" _ :r'(~-3) jh~)4" '(",,+32)
--.
.. ~-...~ lI(r) "" RootOf(zl ' + 32z1 -
Roo .. camot be found
4B + il (z2 - 8), zl )
____~c:.~·~(=yi,=":I~='=(]':-:.I~-:~~----1
+ + 4 4 -
•r
•
,
• •
Co("l_i!-1 0 , 2 JI
' L-~~~~~~~~~~~~
~ ~ ~ 0 2 • 6
•
www.TechnicalBooksPDF.com
24 Differential Equations: A Problem Solving Approach Based on MATLAB
j h(~) d~ - Jf(z)<h: + C -
--
Solution ... 0
5, _E __ C+c-z+dI-t= O
,--
"""'" dooI¥O(.) 11(2:) - log(B - e- ' + f)
C+e-"+~-;' = o
.r-----~~~~~~----~
•
,
-
~ ~~-::~~ ~
--"',,,
,-,-", ",
>, ,',','""
"",,,
" , ,,", ' "
"
•, , , "
"
•
•• C-l"~·'
" ", , ,
• • •
•
www.TechnicalBooksPDF.com
First Order Differential Equations 25
Example # 2.14 Explicit solution unavailable using dsolve(.) as seen by the presence
of the phrase ‘RootOf’ in the MATLAB generated solution.
,--
..... dooI¥o(.) ~(%) _ RootO£(zl~ - 3z1 + h
Rootl camot t. found
(:.2 + 12) - 3B, zl)
www.TechnicalBooksPDF.com
26 Differential Equations: A Problem Solving Approach Based on MATLAB
www.TechnicalBooksPDF.com
First Order Differential Equations 27
xlim([0,5]),ylim([-5,5])
title(‘Directional Field of dy/dt=1-y: Numerical solution’)
figure
quiver(tt,yt,dtn,dyn,1,‘b’)
xlabel(‘time’),ylabel(‘y(t)’), axis tight, hold on
yy=dsolve(ff); % get the symbolic solution
vr=symvar(yy); % determine the existing symbolic variable
yy=subs(yy,vr(1),C); % replace the constant MATLAB outputs to C
CC=[-20:2:20]; % choose a number of unknown constants
for k=1:length(CC)
ffr=subs(yy,C,sym(CC(k)));
p1 = ezplot(ffr);
set(p1,‘Color’,‘red’, ‘LineWidth’, 2)
hold on
end;
title(‘Directional Field of dy/dt=1-y: Analytical solution’)
ylim([-5,5]),xlim([0,5])
hold off
www.TechnicalBooksPDF.com
28 Differential Equations: A Problem Solving Approach Based on MATLAB
www.TechnicalBooksPDF.com
First Order Differential Equations 29
plot(T,yode,‘color’,‘r’,‘linewidth’,2)
end;
xlim([1,3]),ylim([-5,5])
tit1=‘$$ \frac{dy}{dt}=\frac{3t^2+4t}{y-1} $$’;
title(tit1,‘interpreter’,‘latex’,‘color’,‘b’)
text(2.2,1,‘[numerical solution]’,‘color’,‘r’,‘fontweight’,‘bold’)
%title(‘dy/dt=(3t^2+4t)/(y-1): Numerical solution’)
figure
quiver(tt,yt,dtn,dyn,1,‘b’)
xlabel(‘time’),ylabel(‘y(t)’), axis tight, hold on
yy=dsolve(ff); % get the symbolic solution
vr=symvar(yy); % determine the existing symbolic variable
yy=subs(yy,vr(1),C); % replace the unknown constant to C
% use of dsolve leads to two separate solutions and they need to be
% plotted separately. See the next cell on how to avoid this issue by
% seeking the implicit solution
yy1=yy(1);
yy2=yy(2);
CC=[-20:4:16]; % choose a number of unknown constants
for k=1:length(CC)
ffr=subs(yy1,C,sym(CC(k)));
p1 = ezplot(ffr);
set(p1,‘Color’,‘red’, ‘LineWidth’, 2)
hold on
end;
xlim([1,3])
for k=1:length(CC)
ffr=subs(yy2,C,sym(CC(k)));
p1 = ezplot(ffr);
set(p1,‘Color’,‘black’,‘Linestyle’,‘--’, ‘LineWidth’, 2)
hold on
end;
tit2=’$$ \frac{dy}{dt}=\frac{3t^2+4t}{y-1} $$’;
title(tit2,‘interpreter’,‘latex’,‘color’,‘b’)
text(1.8,1,{‘[explicit solution # 1 (continuous lines)]’;‘[explicit solution # 2 (dotted
lines)]’},...
‘color’,‘r’,‘fontweight’,‘bold’)
xlim([1,3]),ylim([-5,5])
figure
quiver(tt,yt,dtn,dyn,1,‘b’)
xlabel(‘time’),ylabel(‘y(t)’), axis tight, hold on
% in this case, the method of separable equations is used.
clear y(t)
syms y t % define y and t as symbolic variables
fy=int(y-1,y);
fx=int((3*t*t+4*t),t);
fq=[fy-fx+B==0]; % create an implicit solution B is the unknown constant
CC=[4:2:16]; % choose a number of unknown constants
for k=1:length(CC)
ffr=subs(fq,B,sym(CC(k)));
www.TechnicalBooksPDF.com
30 Differential Equations: A Problem Solving Approach Based on MATLAB
p1 = ezplot(ffr);
set(p1,‘Color’,‘red’, ‘LineWidth’, 2)
hold on
end;
tit3=’$$ \frac{dy}{dt}=\frac{3t^2+4t}{y-1} $$’;
title(tit3,‘interpreter’,‘latex’,‘color’,‘b’)
xlim([1,3]),ylim([-5,5])
ylabel(‘y(t)’),xlabel(‘time t’)
text(2.2,1,‘[implicit solution]’,‘color’,‘r’,‘fontweight’,‘bold’)
www.TechnicalBooksPDF.com
First Order Differential Equations 31
www.TechnicalBooksPDF.com
32 Differential Equations: A Problem Solving Approach Based on MATLAB
dy K
= ry log e . (2.32)
dt y
Because the quantity modeled is growth, the function y is always positive. The
two constants r and K are also positive. To understand the stability of the system
described through the differential equation in eqn. (2.32), the first step is to examine
a plot of the differential equation expressed as
dy
f ( y) = . (2.33)
dt
The function f(y) is plotted in Figure 2.15 for K=4 and r=2.
The plot of f(y) in Figure 2.15 shows two critical points, one at y=0 and the other
one at y=4 (value of K). These critical points can be obtained by solving f(y)=0 and
invoking L’Hospital’s rule for limits if necessary. Figure 2.15 also shows the plots of
df/dy. The value of df/dy at y=0 is positive while the value of df/dy at y=4 is negative.
The reasons for this classification of the two critical points become obvious if one
examines the direction fields given in Figure 2.16.
It can be seen that around y=4, the solutions are converging while around
y=0 the solutions are diverging, justifying the classification of the critical points as
asymptotically stable (y=K=4) and unstable (y=0).
Critical points may also be classified as semi-stable. Consider the system described
in terms of the following autonomous differential equation,
dy
f ( y) = = ( y − 1) ( y + 1)
2
(2.34)
dt
Figure 2.17 shows the plot containing f(y) and df/dy. There are two critical points,
one at y=–1 and the other one at y=1. Notice that df/dy is positive at y=–1 making
the EQM at y =–1 an example of the unstable equilibrium. On the other hand, df/dy
is exactly equal to 0 at y=1 and it goes from positive to negative on either side of the
equilibrium. This equilibrium point at y=1 is identified as semi-stable and the reasons
for this classification are seen in Figure 2.18 containing the directional field. While
fields move away from y=–1 indicating unstable conditions, the field shows unique
characteristics around y=1. On one side of y=1, field moves towards the equilibrium
point while on the other side, they move away from the equilibrium point. This is the
characteristic property that separates the semi-stable equilibrium from the stable and
unstable equilibrium conditions.
One can now state the rules for classifying the critical points, y=y0, as the following:
If df/dy at y=y0 is positive, the equilibrium point y0 is unstable.
If df/dy at y=y0 is negative, the equilibrium point y0 is asymptotically stable.
If df/dy at y=y0 is zero and df/dy goes from +ve to –ve or –ve to +ve on either
side of y=y0, the equilibrium point y0 is semi-stable.
www.TechnicalBooksPDF.com
First Order Differential Equations 33
Figure 2.15 Plot of f(y) and df/dy associated with Gompertz’s Equation.
t
Figure 2.16 D-field plot of the Gompertz’s equation.
www.TechnicalBooksPDF.com
34 Differential Equations: A Problem Solving Approach Based on MATLAB
There is another interesting class of autonomous systems which produce real and
complex values for the roots of the equation f(y)=0. Consider the case of an autonomous
system described by the differential equation
dy
f ( y) = = ( y − 1) ( y 2 + y + 1) (2.35)
dt
The roots of f(y)=0 are
1 3
=y 1, ± j . (2.36)
2 2
In addition to a real root at y=1, there is a pair of roots that form a complex
conjugate pair. Figure 2.19 gives a plot of f(y) and df/dy.
The absence of equilibrium state associated with the complex roots seen in
Figure 2.19 is further verified by examining the directional fields associated with the
differential equation shown in Figure 2.20. The reasons for the classification of the
critical point at y=1 is unstable is also seen from Figures 2.19 and 2.20.
The example shown in eqn. (2.35) also illustrates another interesting aspect
associated with autonomous systems that there is no state of equilibrium associated
with those systems with complex solutions of f(y)=0.
Figure 2.17 Plots of f(y) and df/dy vs. y for the autonomous system described by f(y)=(1–y)2(1+y).
www.TechnicalBooksPDF.com
First Order Differential Equations 35
Figure 2.18 Directional field associated with the autonomous differential equation f(y)=(1–y)2(1+y).
www.TechnicalBooksPDF.com
36 Differential Equations: A Problem Solving Approach Based on MATLAB
Figure 2.19 Showing the critical point at y=1. The complex roots are not seen.
t
Figure 2.20 Directional field associated with the autonomous differential equation
f(y)=(1+y)(1+y+y2).
www.TechnicalBooksPDF.com
First Order Differential Equations 37
Case 1 a=–1, b=–1, c=0: One asymptotically stable (y=0) and one unstable solution
(y=–1)
,
._-
m~~ -
i
•
j <•
.,
., <.• •
·' .5
-,
., 'I
.,
www.TechnicalBooksPDF.com
38 Differential Equations: A Problem Solving Approach Based on MATLAB
Case 2 a= –1, b= –1, c=1: One asymptotically stable (y=0.62) and one unstable solution (y= –1.62)
i 0.5
~---
' • EQIoI,-
•
;;
.,
., •• • ,
·'.5
~ . "
>·,1--+--1-'/,
., • , • • •
www.TechnicalBooksPDF.com
First Order Differential Equations 39
•
, ,,
,,
,,
,,
~ ---
• E(H._
i •••
, ,,
,<,
'._.,
,,
,
•• • ,
•
S ,,
,,
j ~~ ,,
,,
,,
,,
.,
, •• •• •• ., •
.
~ .
~ ~ .. ..
,
..••
••
..,
•
.,
••
••
••.,
• • • • ., •, , , • •
www.TechnicalBooksPDF.com
40 Differential Equations: A Problem Solving Approach Based on MATLAB
Case 4 a=–1, b=0, c=1: One asymptotically stable (y=1) and one unstable solution
(y=–1)
, , ,,
,
" ,,
~
--
•
..
EOM. _
,
(Y _l~ '_----~
• , " "
] "
• " ,,
,,
j -45
" ,,
,,
., ,
-1 .5 ., ., "
,
>
www.TechnicalBooksPDF.com
First Order Differential Equations 41
Case 5 a=–1, b=1, c=0: One asymptotically stable (y=1) and one unstable solution
(y=0)
.,
,
. • ,
,,----mT
,.. 0_5
www.TechnicalBooksPDF.com
42 Differential Equations: A Problem Solving Approach Based on MATLAB
Case 6 a=–1, b=1, c=1: One asymptotically stable (y=1.62) and one unstable solution
(y=–0.62)
f{.J - - r' + . + !
,
---
~
- EQw. -
>
i
•
•
•
,-.
•• , , , , ,
•
, ,,
" ,,
,-'"
I ,
" ,,
j .. ,,
,,
,
.,
, ..
., •• • , " ,
~
www.TechnicalBooksPDF.com
First Order Differential Equations 43
www.TechnicalBooksPDF.com
44 Differential Equations: A Problem Solving Approach Based on MATLAB
−1 ± i 3
.
2
For this set of values of a, b, and c, no equilibrium conditions exist for the autonomous
system.
www.TechnicalBooksPDF.com
First Order Differential Equations 45
www.TechnicalBooksPDF.com
46 Differential Equations: A Problem Solving Approach Based on MATLAB
2.5.3 Additional examples
Several additional examples are now provided. These MATLAB based examples cover
all aspects of the study of equilibrium displaying results as the analysis proceeds.
1. Provide details on the definitions of the three forms of stability.
2. Obtain the equilibrium points by discarding complex ones if complex and real
roots exist. If duplicate real roots exist, remove them from the plots.
3. In the absence of equilibrium conditions in a specific case, state the reason (non-
autonomous equation or equation with all roots complex).
4. Verification and multiple formats of displaying the points of equilibrium (plots
of the differential equation, its derivative and the D-field plot) and indicate the
equilibrium points with the state.
5. Justify the state of the equilibrium.
6. Obtain analytical solution (implicit solution using the method of separation of
functions) if it exists and display it on the D-field plot.
www.TechnicalBooksPDF.com
First Order Differential Equations 47
www.TechnicalBooksPDF.com
48 Differential Equations: A Problem Solving Approach Based on MATLAB
,,
,,
>
,, ,
,,
,
,,., .. ,",~
~ 0.5
,
,
bo(l~
~ ,
----- --....
•
!
j ..
•
- -
.,
. . . -..
, , •
--- , , ~
~
,
• EOIo'._
" •
>
www.TechnicalBooksPDF.com
First Order Differential Equations 49
dy_dt=‘y^2+y+1’
www.TechnicalBooksPDF.com
50 Differential Equations: A Problem Solving Approach Based on MATLAB
dy_dt=‘(y-1)*(y^3+1)’;
www.TechnicalBooksPDF.com
First Order Differential Equations 51
l'(y)=4y3 - 3y2 + 1
Gel r<UI bt,) 01 ~q: RE.O.L roo" 110) ... Ihe EOM Point.
[-I«li l«li O~.o_871 O_~ .871J
,
,
.1.5 ., •
~
--..,
'-- ,
~,
www.TechnicalBooksPDF.com
52 Differential Equations: A Problem Solving Approach Based on MATLAB
dy_dt=‘y^2*(y^2-1/25)’;
www.TechnicalBooksPDF.com
First Order Differential Equations 53
"dy) ...
o
10....., ..,_
drdy) ... 10 _ :_)'mIII<II~._
o
~ 0 0 .. """'Yi"...,. gooo I""", .~ .. '" ~'''"' ........s~
o 0
www.TechnicalBooksPDF.com
54 Differential Equations: A Problem Solving Approach Based on MATLAB
""''',.'------'',
•
."'','.. .,,,.,.,.,..,,----,,-----,
".,.".,.,.,-,,.,
,,
, ,,,
.
>
~ ,
~o
,
,,
:L ,, ,
L
z ,,
,,,
,
www.TechnicalBooksPDF.com
First Order Differential Equations 55
For the remaining examples, the display of the rules has been suppressed.
dy_dt=‘2*y-sqrt(y)’;
www.TechnicalBooksPDF.com
56 Differential Equations: A Problem Solving Approach Based on MATLAB
,
>
ij 0_5
--
•
~
l,o(IYf,~2$l
"'.'<4-',,;',,--=
...,,, -- -----------------
,,
,,
., ~
--* ""'
E<lM. _
,
•• o
....
"" 0.'
0'
.,
.,
• • • , .,
www.TechnicalBooksPDF.com
First Order Differential Equations 57
dy_dt=‘(1+y)*(y-1)^2’;
www.TechnicalBooksPDF.com
58 Differential Equations: A Problem Solving Approach Based on MATLAB
,,
, ..
,,
• ,,
~ ,, ,,
~
•
~
•
,,
b'~' 1
--
,
' -' , ----- ----ly ·'1 /
l ~.-
j .(I~
.,
., ., -,• .. ~
-.-:;.-
.. ,
< _1.5
www.TechnicalBooksPDF.com
First Order Differential Equations 59
dy_dt=‘(y-1)*(y^2+y+1)’;
www.TechnicalBooksPDF.com
60 Differential Equations: A Problem Solving Approach Based on MATLAB
, ,,
, ,,
,,
••
>
0.'
, -'
_",.,r
~
< -.- - - - -- ,
•
~
j .,
0
-
.,
0 ., . .. . - , " U
---
~
...""',..... ,
.. ..
,
,.
...
,..
,.,
> ,
O.
"
••
.,
•
0
• • ~ ., 0 , , • •
www.TechnicalBooksPDF.com
First Order Differential Equations 61
dy_dt=‘-2*atan(y)/(1+y^2)’;
www.TechnicalBooksPDF.com
62 Differential Equations: A Problem Solving Approach Based on MATLAB
>
~ 0.5
rn
--..,
• EQM,_
,,
., ,
' -~
,,
., ~,e 4$ ~ 42 0 U OA M O~ ,
, -
DI 110M! F'-Id"'" 1m loll"" I IEu...... 14{l prox. Ie u......
•
•
•
~\\~\\=\\\\\\\
~\~\\\\\\\\\\\\\\\\\\\\\\\\
•, r'l\\\'0\'0\\'0\1\\~\\\\\\~\
0
I; ,. ".". I '" ,..
..•• -+
., v,f;IIII!III!!!!J1I!!!I!JIA
f-~ Ifl/M!lllll/mll!////!
••, 1,111'/// ,/@!!I//!~II/I/;.
.
www.TechnicalBooksPDF.com
First Order Differential Equations 63
dy_dt=‘2*y-3*sqrt(y)’;
www.TechnicalBooksPDF.com
64 Differential Equations: A Problem Solving Approach Based on MATLAB
--..,'
~ • EClM. _
i> 0.5
•
~ , ,
[1~1
i
1-4.5
.,
•• , , , , •
,
",
>
,..
,
,.
,
., .,
• • • <
www.TechnicalBooksPDF.com
First Order Differential Equations 65
dy_dt=‘2-3*sqrt(y)’;
www.TechnicalBooksPDF.com
66 Differential Equations: A Problem Solving Approach Based on MATLAB
•
••
www.TechnicalBooksPDF.com
First Order Differential Equations 67
dy_dt=‘y+2*y^2’;
www.TechnicalBooksPDF.com
68 Differential Equations: A Problem Solving Approach Based on MATLAB
.,
·1 -O.a -O.a -0.. -0.2 0 ,
DI...,tIoMI FlooId _ I
., • , , • ,
www.TechnicalBooksPDF.com
First Order Differential Equations 69
dy_dt=‘exp(y)-1’;
www.TechnicalBooksPDF.com
70 Differential Equations: A Problem Solving Approach Based on MATLAB
,
>
, --- ------
~ M
~
•
!
i ~5
•
-
.,
., •• •• •• , • .- . . . . ~,
--...,
• EOM _ _
"
., ~~~~
-&"'-3-2·1012J~5
,
www.TechnicalBooksPDF.com
First Order Differential Equations 71
dy_dt=‘y*(1-y)^2’;
www.TechnicalBooksPDF.com
72 Differential Equations: A Problem Solving Approach Based on MATLAB
,,
,
-
.,
~,
--..,
• EQI,O. -
• "
www.TechnicalBooksPDF.com
First Order Differential Equations 73
dy_dt=‘2*(1-y/3)*y-y’;
www.TechnicalBooksPDF.com
74 Differential Equations: A Problem Solving Approach Based on MATLAB
., • , " ,
"
www.TechnicalBooksPDF.com
First Order Differential Equations 75
dy_dt=‘y-abs(y)/y’;
www.TechnicalBooksPDF.com
76 Differential Equations: A Problem Solving Approach Based on MATLAB
,
i> 0.5
•
~
.,
_1.& ., .. ~
--""
•
,
EQM. _
_1 '.
www.TechnicalBooksPDF.com
First Order Differential Equations 77
2.6 Summary
First order differential equations have been discussed in this chapter. Differential
equations may be classified as linear, nonlinear, or autonomous. Solutions can be
found using the method based on integrating factors or the method on the separation
of functions. Solutions may be obtained using the dsolve(.) command in MATLAB
for numerical approaches based on Runge-Kutta methods (when initial conditions are
available). Even when analytical solutions are available, dsolve(.) and the Runge-
Kutta methods can provide means for the verification of the results. Particular attention
is paid to obtaining exact solutions using the method of integrating factors when the
first order differential equation is linear (depends only on the independent variable y)
and use of the separable function approach when the first order differential equation
is linear or nonlinear. The D-field patterns which can provide insight into the behavior
of the system described by the first order differential equation, are also explored. The
analysis of autonomous systems is carried out in detail. The method of separable
functions is used to obtain implicit solutions (in the absence of exact solutions, use
of Runge-Kutta methods) and multiple ways of understanding the three forms of
equilibria associated with these systems are provided.
A number of descriptive and self-contained examples are given providing a
broader view of the topics covered through multiple ways of verification of the results.
2.7 Exercises
1. Newton’s Law of cooling
a) A metal rod that has been heated to 180°F is brought to a room with an ambient
temperature of 70°F. If y represents the temperature of the rod, the rate at
which the rod is cooling can be expressed as
www.TechnicalBooksPDF.com
78 Differential Equations: A Problem Solving Approach Based on MATLAB
dy
−k ( y − R )
=
dt
The constant R is the ambient temperature in the room (70°F) and k a constant
(units of t-1) that depends on the room and its characteristics. It will determine how
fast or how slow the rod cools. Note that y(0)= 180°F. Analyze the equilibrium
conditions if k=0.25°F/min.
b) Often cooling does not flow a continuous decrease with time. If the rate of
cooling is expressed as (k1=5)
dy π
=−k y − R − k1 sin 2 t
dt 10
2. In a rural area with a population of 3000, the population fluctuates due to births,
deaths and influx of a few people who enjoy the scenic areas. The population
growth is proportional to its population size at any given time. If 30 people move
into the area every year, the overall growth in population is
dy y
= 30 +
dt k
The population at any given time is y(t) and y(0)=3000. Obtain an expression for the
population at any given time. Use k=20;
3. Obtain the integrating factors and solutions for the following first order differential
equations. Verify your results in MATLAB. Note that Dy=dy/dt.
Dy =t + y − 4
Dy= y + 4
Dy =
4t + y, y (0) =
−1
y + sin ( t ) + cos ( t ) + 5
Dy =
Dy= y + cosh ( t )
sinh ( t ) − y
Dy =
t
sinh ( t ) y
=Dy −
t t2
1
Dy
= 2y +
1+ t2
4. For the following differential equations, obtain solutions using the method of
separation of functions. Verify your results in MATLAB.
dy
= 4 x2 y 2
dx
www.TechnicalBooksPDF.com
First Order Differential Equations 79
dy
=( x − 1)( y + 3)
dx
dy x 3 − x 2
=
dx 2y
dy x 3 + x −1
=
dx ( y − 2 )2
dy 4 x − x 3
= 3
dx y −8
dy 2 ( x + 4 )
2
=
dx 1− y2
5. For the following autonomous differential equations, identify the state of
equilibrium that might exist and verify your conclusions using appropriate plots
of the D-fields.
dy y
= −y
dt y
dy
= y ( y − 1)( y + 1)
dt
dy
= 1− ey
dt
6. For the following differential equation, examine the state of equilibrium for the
set of values (combinations) of b and c
dy
= y 2 + by + c, b =[−3, −2, 0, 2,3], c =[ −3, −2, 2,3]
dt
7. Bacterial growth
The bacterial growth might often be characterized by the fact that the growth
factor depends on the square of the bacteria present at any time while the bacteria
is growing at a rate proportional to its current strength. This means that
dy
= k ( y=
2
)y (r y
1
2
+ r) y
dt
8. Effect of antibiotics and elimination of bacteria
The effect of antibiotics can be modeled as the case where the rate of elimination
is proportional to the amount of bacterial as well as time.
dy
=− ry − kt
dt
www.TechnicalBooksPDF.com
80 Differential Equations: A Problem Solving Approach Based on MATLAB
www.TechnicalBooksPDF.com
CHAPTER 3
3.1 Introduction 81
3.2 Homogeneous Differential Equations 82
3.2.1 Solution from the roots of the characteristic equation 83
3.2.2 Solution using Laplace transforms 84
3.2.3 Solution using Runge-Kutta methods 84
3.2.4 Solution using decomposition into a pair of first order differential 85
equations
3.2.5 Interpretation of the solution of the homogeneous differential 88
equation
3.2.6 Additional examples 99
3.3 Non-homogeneous Differential Equations: Particular Solutions and 119
Complete Solutions
3.3.1 Particular solution 119
3.3.2 Complete solution 121
3.3.3 Additional examples 126
3.4 Summary 177
3.5 Exercises 178
3.1 Introduction
Second order differential equations occur in the study of models such as those that
describe the behavior of mechanical, electrical, chemical, transportation systems, etc.
For example, the best way to describe the motion of a pendulum, the characteristics
of the current or voltage in electric circuits, or the flow of chemicals, etc. is through
the use of second order differential equations. If the dependent variable is y and the
independent variable is t, a general second order system can be expressed in functional
form F(.) as
www.TechnicalBooksPDF.com
82 Differential Equations: A Problem Solving Approach Based on MATLAB
dy d 2 y
F y, , 2 , t = 0 . (3.1)
dt dt
Equation (3.1) will be a linear second order differential equation (or system) if it only
contains terms in y, y’ and y’’. A linear second order differential equation is
d2 d
a (t ) y ( t ) + b ( t ) y ( t ) + c ( t ) y ( t=
) g (t ) , a (t ) ≠ 0 . (3.2)
dt 2 dt
The function g(t) on the right hand side in eqn. (3.2) is the forcing function. If a(t),
b(t) and c(t) have no time dependence and are expressed as a, b, and c, respectively, the
differential equation in eqn. (3.2) becomes a linear second order differential equation
with constant coefficients. The analysis here is limited to such differential equations.
A second order differential equation with constant coefficients in eqn. (3.2) can
be expressed using primes as the notation for the derivatives as
g ( t ) . (3.3)
ay ''+ by '+ cy =
If g(t) is zero, the differential equation in (3.3) is homogeneous and if g(t)≠0, the
differential equation is of a non-homogeneous type. It is also implied that y=y(t).
The starting point of the analysis is the assumption that a solution to a linear
differential equation with constant coefficients will be of the form ert, with r being a
constant to be determined. By substituting y = ert in eqn. (3.4), the differential equation
in eqn. (3.4) becomes
ar 2 + br + c e rt =
0. (3.5)
−b + b 2 − 4ac
r1 =
2a
. (3.7)
−b − b 2 − 4ac
r2 =
2a
Depending on whether the discriminant b 2 − 4ac is positive, zero or negative,
the roots will have the following characteristics
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 83
y '' ( t ) = 0 . (3.10)
It is clear that the roots of the characteristic equation are both 0’s and this case
can be handled either from the simple observation of the differential equation or using
the general solution in eqn. (3.9) with r=0 resulting in a solution of the form
y (t =
) c1 + c2t . (3.11)
Thus, if b=c=0, roots of the characteristic equation will be identical and equal to
zero and the solution will be a polynomial of t of order 1 (absence of any exponential
terms in t).
If on the other hand, b ≠ 0, c = 0 the characteristic equation becomes
ar 2 + br= r ( ar + b )= 0 . (3.12)
www.TechnicalBooksPDF.com
84 Differential Equations: A Problem Solving Approach Based on MATLAB
combinations of a, b and c, roots may be complex or real. For all the analysis presented
here, a ≠ 0.
If the initial conditions are given, two additional possibilities exist for obtaining
the solution to the differential equation. The first approach is based on the use of
Laplace transforms and the second one is based on Runge-Kutta methods resulting in
a numerical solution. The Laplace transform based method is discussed first.
In eqn. (3.14),
y0 = y ( 0 )
y1 = y ' ( 0 ) . (3.15)
Y ( s ) = L y ( t )
Note that L[y(t)] represents the Laplace transform of y(t). Solving for Y(s), the
expression for the Laplace transform of y(t) becomes
( as + b ) y0 + ay1
Y (s) = . (3.16)
as 2 + bs + c
Notice the similarity of the denominator in eqn. (3.16) to the characteristic equation
in eqn. (3.6). The solution y(t) is obtained by taking the inverse Laplace transform
of eqn. (3.16).
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 85
dy
=z
dt
. (3.19)
dz c b
= − y− z
dt a a
Using the matrix notation, eqn. (3.19) becomes
dy
dt 0 1
y '
=
− c b =z ⇒ X AX (3.20)
dz −
a a
dt
In eqn. (3.20) A is the coefficient matrix and X is the vector given as
0 1
A= c b
− −
a a
y (t ) y
= X = . (3.21)
y ' ( t ) z
y ( 0 ) y0
=X ( 0 ) =
y ' ( 0 ) y1
Equation (3.21) contains the initial conditions in vectorial form X ( 0 ) .
The approach seen with the decomposition of the second order differential equation
into a pair of coupled first order equations in eqn. (3.19) offers another possibility of
obtaining the solution for the homogeneous second order differential equation.
dy dy
dt dt 0 1
y ( t )
= b
=
c . (3.22)
dz
2
d y − − z (t )
dt 2 a a
dt
One can see that the two sets of equations embedded in eqn. (3.22) correspond to
y(t) and y’(t) which represent the two coupled variables (Chapter 5). The coefficient
matrix A is
www.TechnicalBooksPDF.com
86 Differential Equations: A Problem Solving Approach Based on MATLAB
0 1
A= c b . (3.23)
− −
a a
The eigenvalues of the matrix are given by (Appendix D)
0 . (3.24)
det A − λ I 2 =
Expanding the determinant in eqn. (3.24), the eigenvalues will be solutions of
aλ 2 + bλ + c =0 . (3.25)
Therefore, the eigenvalues are identical to the roots of the characteristic equation
defined in eqn. (3.6). The corresponding eigenvectors ν are obtained by solving
[ A − λ I 2 ]ν =0. (3.26)
A solution of eqn. (3.22) resulting in y(t) and y’(t) can be obtained using the
concept of eigenvalues and eigenvectors described in Appendix D. If the eigenvalues
are distinct and real, the solution y(t) and its derivative y’(t) are given by
The analysis becomes further simpler because A11 of the coefficient matrix A in eqn.
(3.23) . is zero. This leads to
1 1
= ν 1 = , ν 2 λ . (3.30)
λ1 2
Using the eigenvectors in eqn. (3.30), eqn. (3.29) becomes
( t ) c1eλ1t + c2 eλ2t . (3.31)
y=
If the eigenvalues are equal (λ), the eigenvectors will be equal resulting in
1 1
= ν 1 = , ν 2 λ . (3.32)
λ
Using the condition for equal eigenvalues from eqn. (3.8), the coefficient matrix A
can be rewritten as
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 87
0 1
A = b2
b . (3.33)
− −
4a 2 a
The eigenvalue (equal) is
b
λ= −
. (3.34)
2a
It is clear from eqn. (3.32) that the coefficient matrix A is defective because
there is only a single unique eigenvector. Therefore, we need to use the concept of
generalized eigenvectors described in Appendix D. For a [2 x 2] matrix, the generalized
eigenvectors will be
1 0
= ν g1 = , ν g 2 . (3.35)
0 1
Following the procedure described in Appendix D, the solution set can be written in
terms of a basic solutions set
b
1 1 1 + t 2a
) eλt ( vg1 + t [ A − λ I 2 ] vg1=) eλt + t [ A − λ I 2 ] = eλt
x1 ( t=
0 0
2
b
−t
4a 2
(3.36)
t
0 0
) eλt ( vg 2 + t [ A − λ I 2 ] vg 2=) eλt + t [ A − λ I 2 ] = eλt
x2 ( t= b
1 1 1− t
2a
In eqn. (3.36), I2 is the 2 x 2 identity matrix. The solution y(t) and its derivative can
now be written as the weighted sum of the two basic solutions:
b
1 + t 2a t
y (t ) . (3.37)
=c1 x1 ( t ) + c2 x2 ( t ) =c1e
λt
+ c2 eλt
( )
y ' t −t c 1 − t b
2a
a
The solution y(t) can now be written as
b
y (t ) =c1eλt 1 + t + c2 teλt =( b1 + b2t ) eλt (3.38)
2a
In eqn. (3.38), b1 and b2 are two constants and it is seen that eqn. (3.38) matches the
form of the solution for equal roots given in eqn. (3.9).
Consider the case when the eigenvalues form a conjugate pair
λ±= α ± j β . (3.39)
www.TechnicalBooksPDF.com
88 Differential Equations: A Problem Solving Approach Based on MATLAB
The solutions obtained using the decomposition match, those obtained directly
in eqn. (3.9). While acknowledging the fact that decomposition is the basis for the
Runge-Kutta method, there is no specific advantage in using this approach to obtain
the analytical solution of a second order differential equation. It must be noted that
the approach based on eigenvalues and eigenvectors also requires an extra step when
the coefficient matrix is defective.
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 89
Table 3.1 Relationship between the roots of the characteristic equation and stability.
r1 = r2 >0 Unstable
r1 = 0, r2 < 0 Stable
r1 = 0, r2 > 0 Unstable
r1 = r2 = 0 Unstable
r1, r2 = α ± j β, α = 0 Oscillatory
www.TechnicalBooksPDF.com
90 Differential Equations: A Problem Solving Approach Based on MATLAB
for k2=1:L
plot(fy(C(k1),C(k2),tt),fdy(C(k1),C(k2),tt))
end;
end;
xlim([-4,4]),ylim([-4,4])
-1.0000 + 1.4142i
-1.0000 - 1.4142i
It can be seen that the roots are complex with the real part being negative and leading
to a stable equilibrium as seen by the direction of the arrows pointing to the origin.
The phase portrait is shown in Figure 3.1.
Figure 3.1 Phase portrait associated with the differential equation in Example # 3.1. The directional
arrows are moving towards the center, demonstrating that the system is asymptotically stable as suggested
in Table 3.1 (complex roots with real part being negative).
All the cases listed in Table 3.1 have been simulated through solving the differential
equation ay”+by’+cy=0 by choosing pairs of values of b and c. The selected displays
from the output of the MATLAB run are displayed below showing all eleven cases.
Three cases deserve special mention. These correspond to cases where either one
of the roots is zero or both roots are zeros. In all these three cases, the notion of the
critical point is less obvious. In fact, it can be seen that when one of the roots is zero,
the solutions move away from a line through the origin, dy/dt=0 (unstable equilibrium)
or move towards a line through the origin, dy/dt=0 (stable). When both roots are zero,
solutions appear parallel to the line dy/dt=0, moving in opposite directions.
For all the other cases, the critical or equilibrium point is [0,0] and the solutions
either move towards it (stable) or move away from it (unstable). The only exception is
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 91
the case when the roots are purely imaginary in which case, the orbits or the trajectories
are circles or ellipses suggesting oscillatory behavior.
~-F'~~"~:~-~ .. ... .•
-~'~.'~'~-~
-_......
'"
,
,
, , , , , , , ,
.'
\ \ \
~
• , , \ , , ,
\ \ , \ \
~~~.~~,~~,~~~,~.
," _..........
, IIIIIIIIIII
! ! ! ! ! ! ! ! ! ! !
I I / I ! I I I / I I
.'
/ / / / ! / / / / / /
~
• I / / / I I I / / / /
.,
~U-L.~~,~,~~-L,~.
'"
www.TechnicalBooksPDF.com
92 Differential Equations: A Problem Solving Approach Based on MATLAB
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 93
0'
0' • , ,
~,
bo .............
, rr7;I-;T :/,;,,""1,/'7''"''''1.'-""I.r
' "'7' " ';'7'. "'--/.--'3;""":;0-/-,-,
f
, Ie / / ! I I / / / /
! !
! / I I / / / _
I I I / ! ! ! ! •
,
,,
1 f
,
I , t
,
,
)
,
I I I I J
0' ! ! ! / / ; I I
I I I
- - / / / I I I
, / / / / / I I I I I, 0/
,, / / / I I J j j 'j 'jf/
, , ,
0' ,,.•
www.TechnicalBooksPDF.com
94 Differential Equations: A Problem Solving Approach Based on MATLAB
...,.........
, • ·' . • ·".·!:toOb ... [..... U21 , .. .s.'·124 o ._
,"
,
,
.,
~-
~~~~~~~~~~~
3-2·10123
,0)
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 95
,
, - -
, ,
I , ,
\ , ,
\ , , ,
,,,--/ /
, ..... _ / //
L:~'~-=-=-.~,~~~/~.~/~~>L~,-L_ ,
~ y~)
,
,
www.TechnicalBooksPDF.com
96 Differential Equations: A Problem Solving Approach Based on MATLAB
H H ~
I / / /
, f. I / ,
-
f t
I I I
I I I
I
I
, ,
,
/ ,
,
•
I I I , , ,
'.
••
I
, I
I I
., , , , J
, , I II I
I I I j
-
/
< , I I
~H
/ I
,, / /
<
/ I
.,
I
I
•
H, ,
,"
, '..... ...."'- ,'. • • 1: _ .. [0 . 11
-~~
,
, 1- - - - - - - -
- - - - - - - - - - -
- -- --
• - - - - - - - - - - -
, - - - - - - - - - - --
. • , ,
,"
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 97
The phase plane plot associated with the differential equation in eqn. (3.44) is
shown in Figure 3.2. It is clear that both roots are negative and the system is therefore
asymptotically stable as seen by the direction of the arrows that move towards the
origin, the equilibrium, or the critical point [0,0]. Figure 3.2 also displays the state of
equilibrium along with the roots.
Figure 3.2 Phase portrait associated with the differential equation in Example # 3.2. The asymptotic
stability of the system is seen.
www.TechnicalBooksPDF.com
98 Differential Equations: A Problem Solving Approach Based on MATLAB
c1 + c2 =
1
. (3.48)
−3c1 − 2c2 =
0
A component plot of t vs. y(t) and a phase plot obtained as y(t) vs. y’(t) are shown
in Figure 3.3.
Figure 3.3 Component plots associated with the differential equation in Example # 3.2.
The solution may also be obtained using inverse Laplace transforms. Taking the
Laplace transform of the differential equation, the Laplace transform of the differential
equation Y(s) can be expressed as
s+5 3 2
Y (s)
= = − . (3.51)
( s + 2 )( s + 3) ( s + 2 ) ( s + 3)
Taking the inverse transform, the solution is obtained as
y (t ) =
−2e −3t + 3e −2t . (3.52)
Several additional examples are now given providing more details and verification
using Runge-Kutta methods.
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 99
3.2.6 Additional examples
A number of examples are now provided. In each case, the solution generated in
MATLAB provides the theory first, followed by the details of the solution. The
input is the set of values of a, b, c. If the initial conditions are given, the input set is
[a,b,c,y(0),y’(0)]. The results consist of the following displays:
1. Theory of Second Order Homogeneous Equations with constant coefficients.
2. Phase plane plot indicating the roots of the characteristic equation and the state
of stability.
3. The characteristic equation, its roots, properties of the roots, explanation on the
type of equilibrium.
4. If no initial conditions are provided (determined by the number of input values),
statement appears indicating the absence.
5. If initial conditions are given, the unknown constants are evaluated (with all the
steps shown).
6. Theory of Laplace transform based solution, inverse Laplace transform of y(t)
and Laplace transform based solution shown.
7. Comparison of all results including those obtained using dsolve(.) in MATLAB
and numerical techniques shown. The stability status is again indicated.
8. Plots of the solution (component plot and phase plot) are also provided.
Example # 3.3
abc=[1,-4,0];
www.TechnicalBooksPDF.com
100 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 3.4
abc=[1,0,9,1,-1];
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 101
_ d cr.""",'O<1S1ie E~
'"
'" Eiganval.-
h' - 4ac > O, T,t r:.{ual,ooI. )
h' - 4ac _ 0, n - r:. _ '" (nul ,001 )
c=O. r,=O,r:.tOOTr,tO,r:.~O
h' - 4ac<O, T,, - ,~ - <> ± jtJ
[' , > 0 '" '1 > 0] '" ('. 2: 01 or (" > OJ, .... ",tIIe
[', <0 ..... '2 <01 '" I'. <OJ '" I" <01 ... ymploticol)o .1IIbl&
[' I - 0"2 <01"' 1'. <O· '1 · 0~ ._
[" • OJ. 00<iI0I0r';
,, T I •
"(I ) +9~I ) _0
www.TechnicalBooksPDF.com
102 Differential Equations: A Problem Solving Approach Based on MATLAB
,..(' )+ 9 ,(' )- 0
0.. · ' E.,.- ..'+9 _ 0
(3 1 - 3i)
~ m.~ ·" u -"' jS; -' , .........
- - Go_ Sok.Ciat\ ~Iho _ r(I) - , c,CCII(IlI) · ; lft(:'JI) ) -
yet ) _ CI 008{3t) - C, sin{3t)
..
( -3." __, I ) --~ ( ". ,)
." -I
yet) = oos(3t) - ~
"'(1)+9,(1)- 0 ( rfO) - ' ."(fO) - . I ]
.,
-"
,I~"'"
Y/{t ) = oos(3 t) - ~
•
,
......
M
/ 1-. ::"'1
, ..... . •
•
~
•
,
.,
.;
,
,.,•
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 103
Example # 3.5
abc=[1,4,4,1,0];
For the remaining examples, the first display consisting of the theory is not provided.
www.TechnicalBooksPDF.com
104 Differential Equations: A Problem Solving Approach Based on MATLAB
( - 2 - 2)
E....,oI _ , RXlIS (r ,. r1 • r): - . _,..,PIOIiaOIIY ."''* oyshIm
-- G._, SoUiDn .-g Ifle ""* y~) ••n Ie, +°1'1--
yet) = e- 1 ' (Cz + C, t)
...
( c,-2e,.O ) .-~ ( "")
e,. 1
y(t ) = e- U (2t+ l )
~ ( I) + 4 11'(1) + 4v(1) _ 0
- .. ._
_on
~ T'_b",,) udt) = e- t t (2 t + l )
, .... . e
••
..!------:~
0 0.5
,OJ
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 105
Example # 3.6
abc=[1,-4,8,1,0];
www.TechnicalBooksPDF.com
106 Differential Equations: A Problem Solving Approach Based on MATLAB
_<'," .) (2 + 2i 2 - 2i)
_ P. . ol _ . ve; ",2." ± III ; ...... bleoy ......
- - - Go .... , Sok.CiOn "'""" u...- )'(I) • •~. [.,COOWI) -,,:!"i'o{IJI) J--
y(t) = _ e21 (I>.! sin(2t) - C, caI(2!))
--"""""'- --
v"(I) - 4 V(I) + 8 ~ I) _ 0
• r;omp_
x l0" , plot x 10' phoI .. pice
• , g
0
~ ;::
• ;:::
.,. ~
. •
•
.,
• , • • • ...
- •
'"
• •
x.o"
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 107
Example # 3.7
abc=[1,0,-9,-1,1];
www.TechnicalBooksPDF.com
108 Differential Equations: A Problem Solving Approach Based on MATLAB
"'(I)-II,(t)_ O
",,"_ _ E~ r' - II - 0
( -, ')
o...c.o" _ :• -..;,,_ .)'11 ......
- - a._SGIuIico'I..w..gIhlO_ r(I) .c,e',' . cle'.'-
!I(t) _ CI e-l' + C:l el'
c, +c,,-- I )
( 3c,,-3c, - 1
,
...., (~'+Z)
, • ' 0 10 . . . H .....
,
~_1
"~
.,, •
,
• • • •." •
"'" .oJ >< 10'
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 109
Example # 3.8
abc=[1,6,2,1,0];
www.TechnicalBooksPDF.com
110 Differential Equations: A Problem Solving Approach Based on MATLAB
.~ Ilibio or .....
compOMntplot
,
~. ,:' ••• r=;;;iI
L!..-"'-.J
~
.,
, , • • .,,
... M
,"
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 111
Example # 3.9
abc=[1,-3,2];
www.TechnicalBooksPDF.com
112 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 3.10
abc=[1,-2,1,1,0];
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 113
( ' ' )
E~ RMlfOOta(f,"2 . f): +".; ....... IM .........
_ _ Go ...... ,SoIWonuoinglfle_ )'(I) • •~ "',+e,~-
y(t)=e' (Ol+C,t )
DiIhoon .... )'!~".ppIy _ catdt. . . 0 0 > I y{Il) _ 1.1'(0) _ 0 I
y(t) = -e' (t - 1)
-.-"" . . P. ---
VOlt) - 2V(t) + v{t) _ 0
IIdt) = -e' (t - 1)
-.
~T,....b",,)
(d-')
1I~(t) = - e' (t - 1)
'L
• ., • :,,0lI)'l 1
'\ :>
~.,
>
~.,
, /
••
-• • • •• > ., • ,
", x 10'
www.TechnicalBooksPDF.com
114 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 3.11
abc=[1,-2,0,1,1];
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 115
.-~ ( "'" -
-I)
'
() ="2+2
yt
. ,
y"(t) - 2v'(t) _ 0
-
O-~ T'...."'rm)
_on"..' _
,
.-
" F""[''--J''''''"M~-pIo~'~.'.=;;l
."
.~-::-'!'"'~
.L 2 ~ 8
.... • ,
y(l)
. .,, '0'
www.TechnicalBooksPDF.com
116 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 3.12
abc=[1,4,0,1,1];
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 117
( 0'+0 -' )
- 4 .". _ 1 .-~
0, - 1 )
( 00--1
. ~,
y(t)=~ -,-
~(I) H i(l) .. 0
-
(UpIICO T, _ _ )
-"""'''-
Ydt) - ~ - ~
•• ,
- • • • • •••
'"
u
www.TechnicalBooksPDF.com
118 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 3.13
abc=[1,0,0];
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 119
y ( t ) yh ( t ) + y p ( t ) . (3.53)
=
In eqn. (3.53), yh(t) is the solution to the homogeneous part given in eqn. (3.9)
and yp(t) is identified as the particular solution of the nonhomogeneous differential
equation in eqn. (3.3). Before examining the two approaches to finding the particular
solution yp(t), it should be noted that the homogeneous solution can be expressed as
a linear combination of two solutions y1(t) and y2(t) as
y (t )
yh ( t ) =c1 y1 ( t ) + c2 y2 ( t ) =[ c1 c2 ] 1 . (3.54)
y2 ( t )
The two solutions y1(t) and y2(t) can be obtained from eqn. (3.9) as
e r1t
r2t ⇒ r1 ≠ r2 ( real )
e
y1 ( t ) e rt
y ( t ) = = rt ⇒ r1 =r2 =r ( real ) . (3.55)
y2 ( t ) te
cos β t
eα t ( ) ⇒ r = α + j β , r = α − j β
sin ( β t ) 1 2
The representation of the primary (or basic or basis) solutions (also known as the
fundamental solutions), y1(t) and y2(t), formed from the roots of the characteristic
equation play a crucial role in obtaining the particular solution.
Two different approaches exist for obtaining the particular solution. The first
one is the method of undetermined coefficients and the second one is the method of
variation of parameters and both methods rely on y1(t) and y2(t). There are advantages
and disadvantages and limitations to each of these methods. These methods are
described in the next section along with a comparison and approaches for obtaining
the complete solution of a non-homogeneous differential equation. We will start with
the particular solution before exploring methods to obtain the complete solution to
the differential equation expressed as the sum of the solution to the homogeneous
differential equation and the particular solution as given in eqn. (3.53).
3.3.1 Particular solution
3.3.1.1 Method of undetermined coefficients
This method relies on an initial guess of the particular solution by examining the
relationship of the roots of the characteristic function and the forcing function g(t),
www.TechnicalBooksPDF.com
120 Differential Equations: A Problem Solving Approach Based on MATLAB
thus indirectly exploring its relationship to the primary solutions y1(t) and y2(t). The
initial guess is made on the basis of hypothesizing the possible forms of the solutions
that can satisfy the differential equation and then creating a linear combination of
these. Once the initial guess is chosen, unknown constants that are used to combine
the various possible solutions are determined by substitution of the particular solution
in the differential equation and solving for them. The limitation of this method arises
from the approach itself, which is based on the association between the solution of
the homogeneous differential equation (more precisely the roots of the characteristic
equation) and the forcing function. Because the homogeneous solutions always appear
as functions of sin(.), cos(.), t and exp(rt) only, the method is applicable only when
the forcing function g(t) takes one of the two forms
g ( t ) = Ct m eqt (3.56)
t m → an t n + an −1t n −1 + a0 , n =
0,1, 2,.. . (3.58)
The method of undetermined coefficients provides the particular solution for the case
in eqn. (3.56) as
y p ( t ) = t s Am t m + Am −1t m −1 + A0 e qt . (3.59)
Equation (3.61) can be written using two unknown constants P and Q in a slightly
more compact form as
y p ( t ) = Am t m + Am −1t m −1 + A0 emµt t s P cos (ωt ) + Q sin (ωt ) . (3.62)
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 121
All the unknown constants can be determined by inserting yp(t) for y(t) in eqn. (3.3)
and solving for them.
If the initial conditions are given, a complete solution can be obtained by solving
for c1 and c2 in eqn. (3.53).
3.3.2 Complete solution
The complete solution to a non-homogeneous equation can be obtained from the
homogeneous and particular solutions. If initial conditions are given, solution can
also be obtained using Laplace transforms and Runge-Kutta methods.
y ( t ) = c1 y1 ( t ) + c2 y2 ( t ) + y p ( t ) . (3.67)
Given initial conditions y(0) and y’(0) the unknown constants, c1 and c2 can be
evaluated and the complete (exact) solution is obtained.
www.TechnicalBooksPDF.com
122 Differential Equations: A Problem Solving Approach Based on MATLAB
In eqn. (3.68), G(s) is the Laplace transform of g(t). Solving for Y(s), the Laplace
transform of y(t) becomes
( as + b ) y0 + ay1 G (s)
=Y (s) 2
+ 2
. (3.69)
as + bs + c as + bs + c
The complete solution is obtained by evaluating the inverse Laplace transform of y(t).
Details are provided in Appendix B.
0
p = g ( t ) . (3.71)
a
As an example (Example # 3.14), consider the following second order differential
equation,
y '' ( t ) − 2 y ' ( t ) =
t 2 e 2t . (3.72)
The characteristic equation is
0 . (3.73)
r 2 − 2r =
The roots are 0 and 2 and therefore, the homogeneous solution is
yh ( t =
) c1 + c2 e2t . (3.74)
We will look at the method of undetermined coefficients first. The forcing function
is the product of two terms, a quadratic term in t and exponential term containing
(2t). The scaling factor in the exponent matches one of the roots of the characteristic
equation, namely 2. This means that the initial guess of the particular solution must
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 123
involve scaling by t. In other words, one of the terms in the initial guess of the particular
solution will be
y p1 ( t ) = te 2t . (3.75)
The other term in the initial guess of the particular solution will be a quadratic equation
containing t2, t and a constant,
y p 2 ( t ) = At 2 + Bt + C . (3.76)
In eqn. (3.76), A, B, and C are constants to be determined. The initial guess of the
particular solution will be the product of eqns. (3.75) and (3.76)
p (t )
y= y p1 ( t ) y p =
2 (t ) te 2t ( At 2 + Bt + C ) . (3.77)
If yp(t) is a valid solution, it must satisfy the differential equation in eqn. (3.72). Taking
the first and second derivatives of the particular solution in eqn. (3.77) and substituting
in eqn. (3.72), an equation relating A, B and C is obtained as
2 B + 2C + 6 At + 4 Bt + 6 At 2 =
t 2 . (3.78)
Collecting matching terms,
1
6 A =1 ⇒ A = (3.79)
6
1
6 A + 4 B =⇒
0 B=− (3.80)
4
1
2 B + 2C =0 ⇒ C = (3.81)
4
Substituting for A, B, and C, the particular solution in eqn. (3.77) becomes
t2 t 1
( t ) te2t − +
y p= (3.82)
6 4 4
Now, we can explore the solution using the method of variation of parameters.
Because the roots of the characteristic function are 0 and 2, the two primary solutions
of the homogeneous part are
y1 ( t ) = 1
. (3.83)
y2 ( t ) = e 2 t
It is easy to observe that the solution to the homogeneous part is a linear combination
of y1(t) and y2(t) in eqn. (3.83). This means that the Wronskian W is
y1 ( t ) y2 ( t ) 1 e 2t
=W = 2t
. (3.84)
y1 ( t ) y1 ( t ) 0 2e
' '
www.TechnicalBooksPDF.com
124 Differential Equations: A Problem Solving Approach Based on MATLAB
1
1 −
2 . (3.85)
W −1 =
1 2t
0 e
2
The intermediate vector v ( t ) in eqn. (3.66) is
1 2
− 2 t exp ( 2t )
v (t ) = . (3.86)
1 2
t
2
The particular solution is obtained using eqn. (3.65) as
1 1 1 1
y p ( t )= t 2 − t + te 2t − e 2t . (3.87)
6 4 4 8
It might appear that the particular solution obtained using the method of variation of
parameters contains an extra term − 1 e 2t . But this is not an error because it is a scaled
8
version of one of the solutions, namely
y2 ( t ) = e 2t . (3.88)
This term can always be absorbed into the homogeneous solution. To see this, let
us write the complete solution using the method of undetermined coefficients first,
t2 t 1
y ( t ) = yh ( t ) + y p ( t ) = c1 + c2 e 2t + te 2t − + . (3.89)
6 4 4
The complete solution using the method of variation of parameters is
t2 t 1 1 t2 t 1
y ( t ) = c1 + c2 e 2t + te 2t − + − e 2t = c1 + c3 e 2t + te 2t − + (3.90)
6 4 4 8 6 4 4
It is now easy to see that equations (3.89) and (3.90) are a match except for the
unknown constants and without any loss of significance, c3 can be replaced by c2. If
the initial conditions are given, the constants c1 and c2 can be evaluated.
Consider another example (Example # 3.15). The second order differential
equation is
y '' ( t ) + 16 y ( t ) =
t cos ( 4t ) , y ( 0 ) =
−1, y ' ( 0 ) =
1 (3.91)
The characteristic equation is
r 2 + 16 =
0. (3.92)
The roots are ±4 j resulting in the homogeneous solution of
yh ( t ) c1 cos ( 4t ) + c2 sin ( 4t )
= (3.93)
The forcing function is
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 125
g ( t ) = t cos ( 4t ) . (3.94)
Because the forcing function contains the term cos(4t), the initial guess of the solution
based on the method of undetermined coefficients is
[A
y p (t ) = 1t + A0 ] t
P cos ( 4
t ) + Q sin ( 4t )
. (3.95)
corresponds to t corresponds to cos ( 4 t )
Note that the scaling by t arises from the match of one of the solutions with the
cos(.) term in the forcing function. The quantity in the first bracket is the term from
the presence of the term t in the forcing function and the term arises from cos(4t).
Rewriting eqn. (3.95) in terms of unknowns B1, B2, B3, B4, we have
y p ( t ) = B1t 2 cos ( 4t ) + B2 t 2 sin ( 4t ) + B3t cos ( 4t ) + B4 t sin ( 4t ) . (3.96)
Substituting eqn. (3.96) in the left hand side of eqn. (3.91), we get
2 B1 cos ( 4t ) + 8 B4 cos ( 4t ) + 2 B2 sin ( 4t ) − 8 B3 sin ( 4t ) + 16 B2 t cos ( 4t ) − 16 B1t sin ( 4t ) =
t cos ( 4t )
(3.97)
Collecting the appropriate terms and equating their coefficients, we have
16 B2 = 1 . (3.98)
16 B1 = 0 (3.99)
0
2 B1 + 8 B4 = (3.100)
0
2 B2 − 8 B3 = (3.101)
From equations (3.98)–(3.101), we have
1
B2 = (3.102)
16
1
B3 = (3.103)
64
B=
1 B=
4 0 (3.104)
Substituting the values of B1, B2, B3, B4 in eqn. (3.96), the particular solution in eqn.
(3.96) becomes
1 2 1
=y p (t ) t sin ( 4t ) + t cos ( 4t ) . (3.105)
16 64
www.TechnicalBooksPDF.com
126 Differential Equations: A Problem Solving Approach Based on MATLAB
3.3.3 Additional examples
A MATLAB script was written to obtain the complete solution to a second order
linear non-homogeneous differential equation with constant coefficients. The goal
was to create a document consisting of theory, steps involved, solutions using multiple
methods, comparison of the solution, etc. All these were accomplished through a
simple input consisting of a vector of values of a, b, c, initial conditions, and another
input consisting of the forcing function. The results obtained consist of the following
displays:
1. Description of the Method of Variation of parameters (MVP).
2. Description of the method of undetermined coefficients (MUC).
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 127
www.TechnicalBooksPDF.com
128 Differential Equations: A Problem Solving Approach Based on MATLAB
Cf" e<'001{""t)
a1/'" (t ) + W(t ) + cp{t) - { Ct .. eI" ' ifl{(o.I/ )
Root' of fie charecleristiceq.uation. a('.br~, . .. . cd : IJ:I (Compl8JC)
•• 0, if p-ojo,l . o~1l'
.· l . lf p-ojo,l . <t~
Jp(1) _ 1'(A..t'" ... A.._,r-' ... ...... A"t' ... A, I ", Ao)o:"'""",(Id )
8,,' ...
... 1"{8",t'" ... 8",_, . - ' ... ...... B,I ... a.)o:'" .u.{....)
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 129
Coefficients)
www.TechnicalBooksPDF.com
130 Differential Equations: A Problem Solving Approach Based on MATLAB
Coefficients)
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 131
Example # 3.18
abc=[1,-2,0];gt=‘t^2*exp(2*t)’;
www.TechnicalBooksPDF.com
132 Differential Equations: A Problem Solving Approach Based on MATLAB
( o" 2e"" )
P8IIio:Ua r soIuIion obtairoed may oonlllin Y, (I) or Y2(t) -Mlicll can
be Included In tie 1"('''00\18- lOIuIion wltll approp!\al8 scaling lactors
_ e' (4i' -4Ji'·HII-3)
Yp(t ) _ :u
Co""ieIe SoIuIion twill ...... nown oonttanls b, & b2 )
y{t) = b, +Yp(t) + ~ e2 1
hltlcular Iol utlon: Method of Undetennlned Coefficients
lI"(t) - 2 1/(1) = t' e"
_ ot 1M a-....,Iorllllc: Of IwxMIrf EqUlllIon
(0 2)
1_ guHI lor 1M ~ dtIon (On_1'CIOI "'n:IIM; .... ir'4:! by I)
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 133
Coefficients)
Example # 3.19
abc=[1,2,1];gt=‘4*exp(t)’;
www.TechnicalBooksPDF.com
134 Differential Equations: A Problem Solving Approach Based on MATLAB
,-'
( -e-' ,,-. )
a- ' - t e-l
y,.(t) = f!
Cafl1llell Solution (wlh .........,..noon.urQ b 1 & btl
y{t ) "" y,,(t ) + b, e- 1 + b:1 t e- 1
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 135
Coefficients)
www.TechnicalBooksPDF.com
136 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 3.20
abc=[1,-3,-4,1,-1];gt=‘2*exp(-t)’;
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 137
WRONSK"'N (WJ ~-
( -,-'e-' '''c" )
4.
....1·) - -"(
SI:*ooIion oIlhIi ~ Oin.~ EqUlllan (Co & ~ ori_)
www.TechnicalBooksPDF.com
138 Differential Equations: A Problem Solving Approach Based on MATLAB
Coefficients)
www.TechnicalBooksPDF.com
Linear Second Order Differential Equations with Constant Coefficients 139
_ e-'(2,,!i'_IOf+23)
( ) -
YLt 25
P . . _,.,....",
Yp(t) =-¥
eo",,_ SoIWon
y(t) = .-. (2'"".;IQ'+23)
~
, r"""=':-:O"="=-= "'·C
2~
F;:;;]
"'''----,
--.
.-
phIt. . plot
,
'. .~--,~- ~"~. .. ,
'"
www.TechnicalBooksPDF.com
140 Differential Equations: A Problem Solving Approach Based on MATLAB
For the remaining examples the displays on their theory are not shown.
Example # 3.21
abc=[1,0,4,-1,1];gt=‘cos(2*t)’;
Linear Second Order Differential Equations with Constant Coefficients 141
Coefficients)
142 Differential Equations: A Problem Solving Approach Based on MATLAB
1O _ _ t ", _ I )
p-,-
n. ~bI Equotion
11"(1) + 4 P(I) - ocr.(21)
y,(t) = "11 2
0)
( . _ _ 1 ., _ 1 )
~--
y(t) = 0"(220 ) - <Xl6(2/) + !...!!j!!l
, eornp_plol
, ""M'"
~ " ~
;=' 0
>
~
• , • •• ., ,
" .... • ,.. "
Linear Second Order Differential Equations with Constant Coefficients 143
Example # 3.22
abc=[1,2,1,0,1];gt=‘4*t*exp(t)’;
144 Differential Equations: A Problem Solving Approach Based on MATLAB
Coefficients)
Linear Second Order Differential Equations with Constant Coefficients 145
~--
lI(t)=e- ' (2t -e2'+ t el'+ I)
~ -~
,~
'II ; : :
~
• - .- -.."
•• ,
... ~ . 1000
,"
2!DJ J(D)
146 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 3.23
abc=[1,-2,1];gt=‘4*t*exp(t)’;
Linear Second Order Differential Equations with Constant Coefficients 147
Coefficients)
Example # 3.24
abc=[1,0,0,0,-1];gt=‘t^2+t+1’;
148 Differential Equations: A Problem Solving Approach Based on MATLAB
Coefficients)
Linear Second Order Differential Equations with Constant Coefficients 149
~- O )
( C, __ I
._. ( ,,=- -1)
~ 0
Example # 3.25
abc=[1,1,2,0,-1];gt=‘exp(t)*sin(t)’;
Linear Second Order Differential Equations with Constant Coefficients 151
(-1+4' -j -4' )
I.... gue. for the I*ICWt .,kllion (AoaI .... r-.: no a::aIing byl)
~ (,) = ~ - l
L ~
SoI ... ion uoiOil morse l.Itjja oo
Linear Second Order Differential Equations with Constant Coefficients 153
Example # 3.26
abc=[1,-3,-4,1,-1];gt=‘2*t*exp(-t)’;
154 Differential Equations: A Problem Solving Approach Based on MATLAB
Coefficients)
Linear Second Order Differential Equations with Constant Coefficients 155
0,+ •• ' )
( 4 c, - c, - /;, - - 1
Example # 3.27
abc=[1,8,16];gt=‘2*t*exp(-4*t)’;
Linear Second Order Differential Equations with Constant Coefficients 157
Coefficients)
Example # 3.28
abc=[1,8,16];gt=‘2*t^2*exp(-4*t)’;
158 Differential Equations: A Problem Solving Approach Based on MATLAB
Linear Second Order Differential Equations with Constant Coefficients 159
Coefficients)
Example # 3.29
gt=‘6’;abc=[1,1,0];
160 Differential Equations: A Problem Solving Approach Based on MATLAB
Coefficients)
Linear Second Order Differential Equations with Constant Coefficients 161
Example # 3.30
gt=‘t*exp(2*t)*cos(2*t)’;abc=[1,0,4];
162 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 3.31
gt=‘t^2*cos(2*t)’;abc=[1,0,4];
Linear Second Order Differential Equations with Constant Coefficients 163
Coefficients)
164 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 3.32
gt=‘t’;abc=[1,1,0];
Linear Second Order Differential Equations with Constant Coefficients 165
Coefficients)
Example # 3.33
gt=‘t^2*exp(-2*t)’;abc=[1,2,0];
166 Differential Equations: A Problem Solving Approach Based on MATLAB
Coefficients)
Linear Second Order Differential Equations with Constant Coefficients 167
Example # 3.34
gt=‘t’;abc=[1,-1,-1];
168 Differential Equations: A Problem Solving Approach Based on MATLAB
Coefficients)
Example # 3.35
gt=‘t*exp(t)’;abc=[1,-3,2];
Linear Second Order Differential Equations with Constant Coefficients 169
Coefficients)
170 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 3.36
gt=‘t^2+t+2’;abc=[1,0,0];
Linear Second Order Differential Equations with Constant Coefficients 171
Coefficients)
Example # 3.37
abc=[1,3,2];; gt=‘t^2*exp(-2*t)’;
172 Differential Equations: A Problem Solving Approach Based on MATLAB
Coefficients)
Linear Second Order Differential Equations with Constant Coefficients 173
Example # 3.38
gt=‘t*exp(-2*t)’;abc=[1,4,4];
174 Differential Equations: A Problem Solving Approach Based on MATLAB
Coefficients)
Example # 3.39
gt=‘6*sin(t)’;abc=[1,0,1];
Linear Second Order Differential Equations with Constant Coefficients 175
Coefficients)
176 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 3.40
gt=‘t^2*exp(-2*t)*sin(3*t)’;abc=[1,4,13];
Linear Second Order Differential Equations with Constant Coefficients 177
Coefficients)
3.4 Summary
This chapter is devoted to the detailed study of second order differential equations
with constant coefficients. The methodology based on the roots of the characteristic
equation has been the primary focus for the determination of the solution. Unlike the
conventional pedagogic formats where other approaches for obtaining the solutions
are presented separately either in the Appendix or in other chapters, all the methods
to obtain the solutions are presented together here. These methods include breaking
the second order differential equation into a pair of coupled first order differential
equations, Laplace transforms, as well as numerical methods based on Runge-
Kutta using MATLAB. This allows the reader to compare the results from different
approaches. The results also include detailed analysis of the phase portraits which help
explain the stability of the systems modeled through these differential equations. While
homogeneous differential equations are solved through the multiple ways described
above, non-homogeneous differential equations are solved through the use of method
of variation of parameters as well as the method of undetermined coefficients in order
to obtain the particular solution. The results from these two approaches for obtaining
the particular solutions are compared and explanations are provided appropriately
in cases where the particular solutions appear different. Even in the case of the non-
homogeneous differential equations, Laplace transforms as well as ODE based methods
are employed as additional verification steps. The examples cover a substantial number
of different cases and the solution in each case is prepared to be self-contained with
appropriate theory.
178 Differential Equations: A Problem Solving Approach Based on MATLAB
3.5 Exercises
1. Examine the phase portraits for the set of second order homogeneous differential
equations with constant coefficients with [a,b,c] as a=1, b=[-2,-1,-.5,0,0.5,1,2,3],
c=[-2,-1,-.5,0,0.5,1,2,3].
2. For all the cases above, obtain the general solutions starting with the roots of the
characteristic equation and formulating the solution from the roots. Verify your
results directly using MATLAB.
[a,b,c]
[1,-4,-4]
[1,-4,-3]
[1,-4,2]
[1,-4,1]
[1,-3,-4]
[1,-3,-3]
[1,-3,0]
[1,-3,2]
[1,-3,1]
[1,-2,-4]
[1,-2,-3]
[1,-2,2]
[1,-2,1]
[1,4,-4]
[1,4,-3]
[1,4,2]
[1,4,1]
[1,5,-4]
[1,5,-3]
[1,5,0]
[1,5,2]
[1,5,1]
[1,6,-4]
[1,6,-3]
[1,6,0]
[1,6,2]
[1,6,1]
Linear Second Order Differential Equations with Constant Coefficients 179
3. For the set of differential equations with [a, b, c, y(0), y’(0)], obtain the complete
solution using (a) roots (b) Laplace transforms and (c) using Runge-Kutta methods
and verify that the results match.
[1,-4,-4,-1,1]
[1,-4,-3,-1,1]
[1,-4,0,1,-1]
[1,-4,2,1,-1]
[1,-4,1,1,-1]
[1,-3,-4,1,-1]
[1,-3,-3,1,-1]
[1,-3,0,1,-1]
[1,-3,2,1,-1]
[1,-3,1,1,-1]
[1,-2,-4,1,-1]
[1,-2,-3,1,-1]
[1,-2,2,1,-1]
[1,-2,1,-1,1]
[1,4,-4,-1,1]
[1,4,-3,-1,1]
[1,4,2,-1,1]
[1,4,1,-1,1]
[1,5,-4,-1,1]
[1,5,-3,-1,1]
[1,5,0,-1,1]
[1,5,2,-1,1]
[1,5,1,-1,1]
[1,6,-4,-1,0]
[1,6,-3,1,0]
[1,6,0,-1,0]
[1,6,2,0,-1]
[1,6,1,0,1]
4. For the following sets of differential equations identified by the coefficients a,
b, c as a row vector and the corresponding forcing functions, obtain expressions
for the particular solution obtained using the method of variation of parameters
and the method of undetermined coefficients.
A=[1,2,1]; g(t)=t exp(-t)
A=[1,2,1]; g(t)=tcos(t);
180 Differential Equations: A Problem Solving Approach Based on MATLAB
A=[1,-2,-3]; g(t)=t2exp(3t)
A=[1,4,0]; g(t)=t2+t+2
A=[1,4,4];g(t)=texp(-2t)
A=[1,0,0];g(t)=t+5;
A=[1,0,-9]; g(t)=t exp(2t)
A=[1,0,25]; g(t)=t sin(5t)
A=[1,-2,2]; g(t)=exp(t) cos(t)
A=[1,2,2]; g(t)=exp(-t)*sin(t);
5. Obtain the complete solutions for the problem in 5.5 with the initial conditions
given. Verify your results using Laplace transforms and plot the results obtained
using ode45 and the roots.
Initial conditions constitute the vector [y(0);y’(0)].
A=[1,2,1];g(t)=t exp(-t);IC=[1;-1]
A=[1,2,1];g(t)=tcos(t));IC=[1;-1]
A=[1,-2,-3]; g(t)=t2exp(3t);IC=[1;-1]
A=[1,4,0];g(t)=t2+t+2;IC=[1;-1];
A=[1,4,4];g(t)=texp(-2t);IC=[-1;1];
A=[1,0,0];g(t)=t+5;IC=[2;1];
A=[1,0,-9];g(t)=texp(2t);IC=[1,-2];
A=[1,0,25];g(t)=tsin(5t);IC=[-1,1];
A=[1,-2,2];g(t)=exp(t)cos(t);IC=[1,0]
A=[1, 2,2];g(t)=exp(-t)sin(t);IC=[1,0]
CHAPTER 4
4.1 Introduction
The concept of a second order linear differential equation with constant coefficients
can be extended to higher order differential equations. A general higher order linear
differential equation with constant coefficients can be written as
An y ( n ) ( t ) + An −1 y ( n −1) ( t ) + A0 y ( t ) =
g ( t ) . (4.1)
In eqn. (4.1), A0, A1,.., An are constants and
d n y (t )
y ( n) ( t ) = . (4.2)
dt n
When the excitation function or the external forcing function g(t)=0, eqn. (4.1)
becomes a homogeneous type and g(t) ≠ 0, eqn. (4.1) becomes a non-homogeneous
type. The solution to the differential equation (4.1) may be obtained using procedures
similar to the ones presented in connection with the second order ones as described
in Chapter 3. These include the use of the characteristic equation or the characteristic
182 Differential Equations: A Problem Solving Approach Based on MATLAB
Following the approach and arguments put forth in obtaining the solution for a second
order homogeneous differential equation with constant coefficients, the basis solution
vector becomes
y1 ( t )
y2 ( t )
Y ( t ) = . . (4.4)
yn −1 ( t )
y (t )
n
Note that the solution vector in eqn. (4.4) may also be written as row vector of size
[1 x n]
Y ( t ) = y1 ( t ) y2 ( t ) . yn −1 ( t ) yn ( t ) . (4.5)
yh ( t ) = ∑ ck yk ( t ). (4.6)
k =1
In eqn. (4.6), the coefficients ck may be obtained if initial conditions are provided
and the fundamental solution set consisting of the basic solutions, y1(t), y2(t),..,yn(t),
are formed from the roots of the characteristic equation in eqn. (4.3).
The nature of the solution set is more complicated than the three forms associated
with the case of a second order differential equation because the interrelationships
(if any) among the roots of eqn. (4.3) determine the complexity of the solution set.
Therefore, one needs to consider different values of n (2, 3, 4,..) separately to formulate
the solution set. While the solution set for n=2 is described in Chapter 3, the case of
n=3, 4 will be presented in detail now and higher order cases will be discussed in
general terms.
Linear Higher Order Differential Equations with Constant Coefficients 183
y1 ( t ) e r1t
r2t
Y= ( t ) y2 (= t )
e , r1 ≠ r2 ≠ r3 (4.8)
y3 ( t ) e r3t
If all the roots are identical, the solution vector is
y1 ( t ) e rt
rt
Y ( t )= y2 ( t ) = te , r= r1= r2= r3 . (4.9)
y3 ( t ) t 2 e rt
If the two roots are equal and real, the solution vector is
y1 ( t ) e rt
r1t
Y= ( t ) y2 =( t ) e , r=≠ r1 r2 (4.10)
y3 ( t ) te r1t
The remaining possibility is that one root is real while the other two form a complex
conjugate pair with real valued constants α and β. The solution vector is
y1 ( t ) e rt
αt
Y ( t ) = y2 ( t ) =e cos ( β t ) , r ≠ r1,2 =α ± j β . (4.11)
y3 ( t ) eα t sin ( β t )
The nature of the roots can now be expanded to provide the solution set for
differential equations of order 4. We identify the four roots as rk, k=1, 2, 3, 4. If all
roots are real and distinct, the solution vector is
y1 ( t ) e r1t
= y2 ( t ) e r2t
= Y ( t ) y3 ( t ) e r3t . (4.12)
rt
y4 ( t ) e 4
When all four roots are real and equal, the solution vector becomes
y1 ( t ) e rt
rt
y2 ( t ) te= , r r
Y (t ) =
= (4.13)
y3 ( t ) t 2 e rt 1,2,3,4
3 rt
y4 ( t ) t e
It is possible to proceed similarly when two of the roots are equal in pairs or one
is distinct and three are equal. The other cases will be when two are distinct and the
184 Differential Equations: A Problem Solving Approach Based on MATLAB
other two form a complex pair, and when two real roots are equal and the other pair
is complex. The final case will correspond to the case of two pairs of equal complex
conjugate sets.
y1 ( t ) e r1t
rt
y2 ( t ) e =
Y ( t ) =
= , r ; r r (4.14)
y3 ( t ) te rt 1 2,3,4
2 rt
y4 ( t ) t e
y1 ( t ) e r1t
r2t
y2 ( t ) e , r =
Y (t ) =
= , r ; r r (4.15)
y3 ( t ) e rt 1 2 3,4
rt
y4 ( t ) te
y1 ( t ) e r1t
r1t
y ( t ) te =
Y ( t ) 2=
= , r r=
, r r ,r (4.16)
y3 ( t ) e r3t 1 1,2 3 3 4
r3t
y4 ( t ) te
y1 ( t ) e r1t
y ()t e r2 t
Y ( t )= 2 = α t
(4.17) , real r , r and r = α ± j β
y3 ( t ) e cos ( β t ) 1 2 3,4
αt
y4 ( t ) e sin ( β t )
y1 ( t ) e rt
y (t ) te rt
, real r= r and
Y ( t )= 2 = r3,4= α ± j β (4.18)
y3 ( t ) eα t cos ( β t ) 1,2
αt
y4 ( t ) e sin ( β t )
y1 ( t ) eα t cos ( β t )
αt
y (t ) e sin ( β t ) , r = r = α ± j β
Y ( t )= 2 = (4.19a)
y3 ( t ) teα t cos ( β t ) 1,2 3,4
αt
y4 ( t ) te sin ( β t )
y1 ( t ) eα1t cos ( β1t )
y2 ( t ) eα1t sin ( β1t )
Y (t ) = = α1 ± j β1 , r3,4 =
,r = α 2 ± j β 2 (4.19b)
y3 ( t ) eα 2t cos ( β 2 t ) 1,2
α2t
y4 ( t ) e sin ( β 2 t )
It can easily be seen that as the order of the differential equation increases, the
possible grouping of the basic solutions becomes more diverse making it difficult to
form a solution. A general approach can be stated as follows:
Linear Higher Order Differential Equations with Constant Coefficients 185
If the multiplicity of the roots is m (m<n, m roots are equal to r) and if the roots
are real, the solutions can be expressed as
e rt , te rt , t 2 e rt , , t m −1e rt . (4.20)
The remaining roots, (n-m) will be distinct, each with a unique solution. When n>3,
possibilities exist that conjugate complex pair of roots might also display multiplicity.
The multiplicity of m results in 2m solutions as
The particular solution resulting from the excitation force represented by g(t) in
eqn. (4.1) is represented by yp(t).
While the particular solution may be obtained using the method of undetermined
coefficients as it was done for the case of second order systems, the process of obtaining
the solution is simplified and more formal through the use of the method of variation
of parameters. This approach requires the use of the Wronskian associated with the
nth order differential equation. Proceeding similarly as in the case of a second order
differential equation, the Wronskian W becomes
y1 y2 . . yn
(1) (1) 1
y1 y 2 . . yn( )
W = . . . . . . (4.23)
. . . . .
( n −1) n −1
y2(
n −1)
y1 . . yn( )
The particular solution yp(t) is given by
y p ( t ) = y1 ( t ) y1 ( t ) yn ( t ) ∫ v ( t )dt . (4.24)
In eqn. (4.24),
186 Differential Equations: A Problem Solving Approach Based on MATLAB
0
0
.
v ( t ) = W −1 . (4.25)
.
g (t )
An
In eqn. (4.25), W–1 is the inverse of the Wronskian and the matrix on the right
hand side is of size [n x 1] with the first (n-1) elements being zeros. If initial conditions
IC are given, the unknown coefficients c1, c2, .., cn in eqn. (4.22) can be determined,
=
y ( 0 ) y (1) ( 0 ) y ( n −1) ( 0 )
IC = [ y0 y1 yn −1 ] . (4.26)
Once the unknown coefficients are evaluated, the complete solution of the
differential equation in eqn. (4.1) can be obtained.
4.4.1 Laplace transform
As shown in Appendix B, the Laplace transform based approach is a simple and
direct way of obtaining the solution to a set of differential equations or a higher order
differential equation. The solution is obtained only when initial conditions are available.
Taking the Laplace transform of the differential equation in eqn. (4.1), it is
possible to write
y0 An s n −1 + An −1 s n − 2 + + A1 + y1 An s n − 2 + An −1 s n − 3 + + A2 + + yn −1 An
A( s) =
An s n + An −1 s n −1 + + A1 s + A0
(4.27)
G (s)
B (s) = . (4.28)
An s + An −1 s n −1 + + A1 s + A0
n
In eqn. (4.28) G(s) is the Laplace transform of g(t). If Y(s) is the Laplace transform
of the solution y(t),
( s ) A ( s ) + B ( s ). (4.29)
Y=
Linear Higher Order Differential Equations with Constant Coefficients 187
The solution y(t) is obtained by taking the inverse Laplace transform of eqn. (4.29).
4.4.2 Numerical techniques
If the initial conditions are available, it is also possible to obtain the solution
numerically using the Runge-Kutta method described in Appendix A. The first step
in the solution is the creation of n-first order differential equations. We define
Z1 = y ( t )
Z2 = y( ) (t )
1
Z3 = y(
2)
(t ) (4.30)
Zn = y(
n −1)
(t )
Using eqn. (4.30), it is possible to write n-first order equations as
Z1(1) = Z 2
Z 2(1) = Z 3
Z 3(1) = Z 4
(4.31)
(1)
Z n −1 = Z n
An −1 A A A g (t )
Z n(1) =− Z n − n − 2 Z n −1 − − 1 Z 2 − 0 Z1 +
An An An An An
Equation (4.31) can be expressed in matrix form as
Z1(1) 0 1 0 0 0 0
Z1
(1) 0 0 1 0 0
0
Z2 Z2
(1) 0 0 0 0 0 0
Z3 Z3
= . . . ... . . + (4.32)
0 0 0 0 1 0
Z n(1−)1 Z n −1
− A0 A1 A2 A A g (t )
(1)
A − − − n−2 − n −1 Z n
Z n n An An An An An
Equation (4.32) can be simplified by defining the following:
A A A
an −1 =
− n −1 , an − 2 =
− 2 −1 , , a0 =
− 0 (4.33)
An An An
g (t )
h (t ) = (4.34)
An
188 Differential Equations: A Problem Solving Approach Based on MATLAB
Z1(1)
(1)
Z2
(1)
Z
Z' = 3 (4.35)
Z n(1−)1
(1)
Z n
0 1 0 0 0
0 0 1 0 0 0
0 1 0 0
0 0 1 0 0
0 0 0 0 0
0 0 0 0 0
A = . . . ... . .
0 0 0 0 1
0 0 0 0 1
A0 A1 A2 An − 2 A
− A − A − A − A − n −1 a0 a1 a2 an − 2 an −1
n n n n An
(4.36)
0
0
0
b (t ) =
(4.37)
0
h ( t )
The higher order differential equations can now be written in the form of a matrix
equation as
Z ' ( t ) AZ ( t ) + b ( t ).
= (4.38)
It should be noted that numerical evaluation of the solution requires the availability
of the initial conditions given in eqn. (4.26).
4.6 Examples
Example # 4.1 Consider a 3rd order differential equation,
y ''' ( t ) + y ' ( t ) =
4 + sin ( t ). (4.39)
Linear Higher Order Differential Equations with Constant Coefficients 189
The roots of the characteristic equation are (one real and a pair of complex ones)
0
− j . (4.42)
j
The solution set associated with the homogeneous differential equation is
y1 ( t ) = t
y2 ( t ) = cos ( t ) . (4.43)
y3 ( t ) = sin ( t )
The solution to the homogeneous differential equation is
yh ( t ) =
b1 y1 ( t ) + b2 y2 ( t ) + b3 y3 ( t ) =
b1t + b2 cos ( t ) + b3 sin ( t ) . (4.44)
Using the solution set in eqn. (4.43), the Wronskian W in eqn. (4.23) becomes
1 cos ( t ) sin ( t )
=W 0 − sin ( t ) cos ( t ) . (4.45)
0 − cos ( t ) − sin ( t )
The vector v ( t ) in eqn. (4.25) is
sin ( t ) + 4
v (t ) = − cos ( t ) sin ( t ) + 4 . (4.46)
− sin ( t ) sin ( t ) + 4
The particular solution can be obtained using eqn. (4.24) and is
t
y p (t ) =
4t − cos ( t ) − sin ( t ). (4.47)
2
The complete solution is
t
y ( t ) = yh ( t ) + y p ( t ) = b1t + b2 cos ( t ) + b3 sin ( t ) + 4t − cos ( t ) − sin ( t ). (4.48)
2
Applying the initial conditions in eqn. (4.40) to the solution in eqn. (4.48), the
constants b1, b2, b3 are obtained as
190 Differential Equations: A Problem Solving Approach Based on MATLAB
b1 = 0 b2 = 1 b3 = −3 . (4.49)
Substituting the values of the constants in eqn. (4.48), the solution to the 3rd order
differential equation in eqn. (4.39) becomes
t
y (t ) =
4t − 3sin ( t ) − sin ( t ) . (4.50)
2
The Laplace transform of the solution can be obtained using eqn. (4.29) as
s 4 − s 3 + 5s 2 + 4
Y (s) = . (4.51)
(s + s)
3 2
Taking inverse Laplace transforms, eqn. (4.51) leads to a solution matching the one
in eqn. (4.50).
Example # 4.2 Consider another 3rd order differential equation,
y ''' ( t ) − y '' ( t ) − y ' ( t ) + y ( t ) =
t 2 + t . (4.52)
Using the solution set in eqn. (4.56), the Wronskian W in eqn. (4.23) becomes
e − t et tet
−t
W=
−e e e ( t + 1) .
t t (4.58)
e − t et et ( t + 2 )
Linear Higher Order Differential Equations with Constant Coefficients 191
The vector v ( t ) in eqn. (4.25) is
t t
e ( t + 1)
4
− t e − t ( t + 1)( 2t + 1) .
v (t ) = (4.59)
4
t
e − t ( t + 1)
2
The particular solution can be obtained using eqn. (4.24) and is
y p ( t ) = t 2 + 3t + 5 . (4.60)
Applying the initial conditions in eqn. (4.53) to the solution in eqn. (4.61), the
constants b1, b2, b3 are obtained as
1 11
b1 = − b2 = − b3 = 2. (4.62)
2 2
Substituting the values of the constants in eqn. (4.62), the solution to the 3rd order
differential equation in eqn. (4.61) becomes
1 11
y ( t ) = 3t − e − t − et + 2tet + t 2 + 5 . (4.63)
2 2
The Laplace transform of the solution can be obtained using eqn. (4.29) as
−s5 + s 4 + s3 + s + 2
Y (s) = . (4.64)
s 3 ( s − 1) ( s + 1)
2
Taking inverse Laplace transform, eqn. (4.64) leads to a solution matching the one
in eqn. (4.63).
Example # 4.3 Consider a 4th order differential equation,
y '''' ( t ) − y ( t ) =et + e − t . (4.65)
The initial conditions are
y (0) = 1
y ' (0) = 1
. (4.66)
y '' ( 0 ) = −1
y ''' ( 0 ) = −1
The characteristic equation associated with the differential eqn. (4.65) is
r 4 −1 =0 . (4.67)
−1
1
− j . (4.68)
j
The solution set associated with the homogeneous differential equation is
y1 ( t ) = e − t
y2 ( t ) = e t
. (4.69)
y3 ( t ) = cos ( t )
y4 ( t ) = − sin ( t )
Note that use of –sin(t) or sin(t) in eqn. (4.69) will not change the result. The solution
to the homogeneous differential equation is
1 1 + e 2t
v (t ) =
4
( ) . (4.72)
sin ( t ) cosh ( t )
cos ( t ) cosh ( t )
1 1 3
b1 = b2 = b3 = b4 = −1 . (4.75)
8 8 2
Substituting the values of the constants in eqn. (4.74), the solution to the 4th order
differential equation in eqn. (4.65) becomes
3 1 1
y ( t )=cos ( t ) + sin ( t ) − cosh ( t ) + t sinh ( t ). (4.76)
2 2 2
The Laplace transform of the solution can be obtained using eqn. (4.29) as
s 5 + s 4 − 2 s 3 − 2 s 2 + 3s + 1
Y (s) = . (4.77)
(s 2
− 1)( s 4 − 1)
Taking the inverse Laplace transform, eqn. (4.77) leads to a solution matching the
one in eqn. (4.76).
Example # 4.4 Consider another 4th order differential equation,
y '''' ( t ) + y ' ( t ) =te − t + 4 . (4.78)
2 2
The vector v ( t ) in eqn. (4.25) is
4 + te − t
1
− ( t + 4et )
3
v ( t ) = − 2 e − 2 t cos 3 t t + 4et .
1
3 ( ) (4.85)
2
2 −1t 3
e 2 sin
t ( t + 4et )
3 2
The particular solution can be obtained using eqn. (4.24) and is
e−t
− (12t − 72te 2t + 3t 2 + 16 ) .
y p (t ) = (4.86)
18
The complete solution is
t
3 t
3 e−t
y ( t ) =b1 + b2 e − t + b3 e 2 cos
2
t − b4 e 2 sin
2
t −
18
(12t − 72te2t + 3t 2 + 16 ) .
(4.87)
Applying the initial conditions in eqn. (4.79) to the solution in eqn. (4.87), the constants
b1, b2, b3, b4 are obtained as
19 13 3
b1 =1 b2 = 1 b3 = − b4 =. (4.88)
9 9
Substituting the values of the constants in eqn. (4.88), the solution to the 4th order
differential equation in eqn. (4.87) becomes
Linear Higher Order Differential Equations with Constant Coefficients 195
1 2 1 19 t 3 13 3 2t 3
y ( t ) =1 + 4t + e − t − te − t − t 2 e − t − e 2 cos t − e sin t . (4.89)
9 3 6 9 2 9 2
The Laplace transform of the solution can be obtained using eqn. (4.29) as
2
4 3 1
−s +
s 1+ s
Y (s) = . (4.90)
s ( s 3 + 1)
Taking the inverse Laplace transform, eqn. (4.90) leads to a solution matching
the one in eqn. (4.89).
When analytical approaches based on the roots of the characteristic equation
become cumbersome (as the order of the differential equation increases), the convenient
option is to rely on the Laplace transform based approach. In all cases, additional
verification is possible using numerical techniques based on Runge-Kutta methods
as described in Appendix A and in Section 4.4.2. The MATLAB script for the case of
a 3rd order differential equation and results are given first.
Example # 4.5 Consider the case of the following 3rd order differential equation,
The MATLAB script created for solving the differential equation and the results are
shown.
function higherorder_numerical_example
% june 2017 solution of a higher order differential equation using Laplace transform
% and verification using Runge-Kutta method P M Shankar
% y’’’(t)+y’’(t)-2y’(t)=t+exp(t), y(0)=1, y’(0)=1,y’’(0)=-1
syms t s
A3=1;A2=1;A1=-2;A0=0;
y0=1;y1=1;y2=-1; % initial conditions
gt=t+exp(t); % forcing functions
Dr=(A3*s^3+A2*s^2+A1*s+A0); % Denominator of the Laplace transform
As=(y0*(A3*s*s+A2*s+A1)+A3*y2+y1*(A2+A3*s))/Dr;
Bs=laplace(gt,t,s)/Dr; % Laplace transform of the forcing function
yL=ilaplace(As+Bs,s,t); % inverse Laplace transform to get the solution
simplify(yL,’steps’,100); % analytical solution using Laplace
fy=MATLABFunction(yL);
syms z(t) % use z as a placement or dummay variable
D3=diff(z,3);
D2=diff(z,2);
D1=diff(z,1);
f=[A3*D3+A2*D2+A1*D1+A0*z==t+exp(t)];
V = odeToVectorField(f);% break higher order DE into 3 first order ones
F = MATLABFunction(V,‘vars’, {‘t’,‘Y’});% create inline Function for ODE
tspan=[0 5];
[T,yode]=ode45(F,tspan,[1;1;-1]);
% numerical solution; only use the first column of the solution yode
196 Differential Equations: A Problem Solving Approach Based on MATLAB
figure,plot(T,fy(T),‘r-’,T,yode(:,1),’k*’)
xlabel(‘time t’),ylabel(‘solution’)
legend(‘analyt’,‘numerical’)
syms y(t)
yy=[y(t)==yL]; % create the expression for the title
title([‘$’ latex(yy) ‘$’],‘interpreter’,‘latex’,‘fontsize’,14,‘color’,‘b’)
end
Figure 4.1 Plot of the solution y(t) for the Example # 4.5.
0
0
0
. (4.99)
0
0
−1
Taking the Laplace transform of the differential equation in eqn. (4.97), the Laplace
transform of the solution is
1
s+ + s 4 + s5 + 1
( s + 1)
2
Y (s) = . (4.100)
s 5 ( s + 1)
Taking the inverse Laplace transform of eqn. (4.100) leads to the solution
198 Differential Equations: A Problem Solving Approach Based on MATLAB
Figure 4.2 Plot of the solution y(t) for the Example # 4.6.
t3 t4 1
y ( t ) = 16 − 10t + 3t 2 − + − 15e − t − 5te − t − t 2 e − t . (4.101)
2 12 2
The verification is provided in Figure 4.3.
Example 4.8 Consider the case of a 7th order differential equation
0
0
−1
−1
1 . (4.104)
1
2
(
1− j 3 )
1
2
(
1+ j 3 )
Linear Higher Order Differential Equations with Constant Coefficients 199
Figure 4.3 Plot of the solution y(t) for the Example # 4.7.
Taking the Laplace transform of the differential equation in eqn. (4.102), the Laplace
transform of the solution is
s8 − s 6 + s 5 − s 3 + s 2 + 1
Y (s) = . (4.105)
s 4 ( s − 1)( s + 1) ( s 2 − s + 1)
2
Taking the inverse transform of eqn. (4.105), the solution to the differential equation
becomes
1 3 1 1 2 3 2t 3
y ( t ) =2 − 2t + et − e − t − te − t − t 3 + e sin t . (4.106)
2 2 3 6 6 2
The verification is given in Figure 4.4.
In keeping up with the theme of this manuscript, theoretical aspects are provided
with every example given. Of specific mention is the fact that explicit values of the
fundamental solution set based on the roots are provided for every example, for all
types of relationships among the roots as mentioned in Section 4.4.2.
The MATLAB script generates the following displays.
1. Based on the vector A representing the coefficients, a determination is made
regarding the order of the differential equation and the general form of the
equation, the characteristic equation, roots and the form of the general solution
is provided. While the form of the general solution is simple for order 2, with
order 3 and order 4, more possibilities exist for the general solution based on the
relationships among the roots of the characteristic function. All these possibilities
are automatically shown.
200 Differential Equations: A Problem Solving Approach Based on MATLAB
2. The roots of the characteristic equation and the set of solutions forming the
solution to the homogeneous differential equation are shown next.
3. The method of variation of parameters used to obtain the particular solution is
shown.
4. The particular solution is then obtained, tested by substitution in the differential
equation and the validation is shown.
5. The general solution incorporating the particular one is shown and the analysis
ends if initial conditions are not provided.
6. If the initial conditions are provided, the applicable theory for the specific highest
order is shown.
7. The Laplace transform of the solution y(t) is shown along with the solution to
the differential equation.
8. The solution is then verified by applying the initial conditions to the general
solution obtained using the roots displaying the values of the unknown constants
as well as the complete solution obtained from the roots.
9. The solution obtained using dsolve(.) is also shown for the sake of completeness.
10. The numerical computational approach is shown next with the decomposition
of the higher order into several first order differential equations.
11. The plots of the solutions obtained using various methods are shown as in the
final display.
Figure 4.4 Plot of the solution y(t) for the Example # 4.8.
Linear Higher Order Differential Equations with Constant Coefficients 201
Example # 4.9
A=[1 0 1 0];IC=[0,1,-1];gt=‘cos(t)+sin(t)’;
Characteristic
202 Differential Equations: A Problem Solving Approach Based on MATLAB
IV ..
,,(1) lI:(t ) 1/1(1)
,,(t ) ';(1) ";(1)
1
[ ,:'{t ) 1Il'(1) 1&'(1)
lI,o(') =~-~-~-~
,.. tt.-,."' ...._ .. O••• ral EON
DeAl.. ofWron~n
( I ooo(t) ""'t) )
-""
w_ ( 0 - sin(t) ,,,,t) )
( 0 - cm(t ) - sin(t ) )
v'2 sin (t + i)
J2";U+!) _!
I{I ) ..
•
Linear Higher Order Differential Equations with Constant Coefficients 203
Y (t) --~-~-~
2 2 2
y( t)=~-~-~
Cl",,1eIt sWI.Ion using ...... ~.ce ,.... rorm.
y(t)_~_~_~
Example # 4.10
A=[1 -1 -1 1];IC=[-1,0,1 ];gt=‘exp(t)-t*exp(-t)’;
Characteristic
Linear Higher Order Differential Equations with Constant Coefficients 205
Yl (t )= 1t
Y3(t ) = t el
WRONSKIAN IV _
~,(I)
,,(t )
r,o,(l) VI( I)
,,(1) i.(I)
1
[ !I.'(I) ~( t) ~(t)
VALnPASS
206 Differential Equations: A Problem Solving Approach Based on MATLAB
--
w_
(e~'
(-e-'
f!
( e-' f! el (t + 2»
eI
tel)
f! (t+ 1»
ill') ..
(2 '+1) (.e-"_I)
,
,- ..,...
I .. - ••
Yilt )) -_ 11
Yj(t Yo )
( Y;(I) _" - 11-' - y, + Yo + Yo
208 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 4.11
A=[1 0 0 0 -1];IC=[1,-1,0,-1 ];gt=‘t+cos(t)’;
Characteristic
Linear Higher Order Differential Equations with Constant Coefficients 209
WRONSKloO.N IV _
VI(I) volt)
,,(1) ~(I)
V3(t)
v.,(I)
V.(I)
!I.(I)
1
[ v'I'(l) ~(t) ~(t) ~
v:"(I) V{(I) IIT(I) ,r.
y, (t)=-t -~-~
of P... "",Il ..
J(t)dI
fl t) ...
.,. ...
( ..".))
•
,
';0(1) ('+<0(2)
,
<0>0(,) ("' <0>0('))
210 Differential Equations: A Problem Solving Approach Based on MATLAB
Yd.) 2 iii+t~+"-1
Sck.CIan )1(1:) ..1r4;J ....... 1II~
y(t) = Q~'" - t + ~ + f + "11)- I"t)
( I II-I)
eo.....--.tIonuolng_(~ .. ~"....WI.)
.,(1) - ~ - I +~+ i+ ~ - ~
Con,ll ... -.tIon uoIng ...... UpItot_iotmI
IIll) - ~ - I +~+ i+ ~ - ~
eo...,.11111 -.tiM uoIng d.....) kI Mo •
.,(1) - ~ - 1+ ~ +i+ ~ - ~
Linear Higher Order Differential Equations with Constant Coefficients 211
Example # 4.12
A=[1 0 0 -1 0];IC=[-1,1,0,1];gt=‘exp(-t)’;
Characteristic
212 Differential Equations: A Problem Solving Approach Based on MATLAB
Linear Higher Order Differential Equations with Constant Coefficients 213
11(.).. !=f!
,.-1 ;<4')
••- 1 ;<4')
B(')_;
_ ~~~~=- _ __
~1111 eq_ II'Id 1_ CondiI_ (g"")
~(t) - vet)_e-'
( , (0) _ - \ "(0) .. 1 ('(0) .. 0 ,..(0) _ I )
LIpIoco T.. -..oV(o)oIl'10
"t (.) __a+,,-,·+ f
--)1(1)""'-......
r; + if +
,,(t) _
. _.'
2.-1 (...(4tJ!Ao(4<» _3
214 Differential Equations: A Problem Solving Approach Based on MATLAB
~_)(tn.(I)o1,(I)
u_
0bI8in _.-~ _ _ Ib,
•eo""-..,...1oII
,"'.>- uIifI9 ( -3 I I -"Pcono)..... )
toOII (.........
•• ) t..!
",I .. ! + + '· '7 q..j + tJI, i"(
I<'
T r 41) 3
~-.......,-~--
r;
'(1) .. + if + t . 1(...( 4')/.11.:(4'» - 3
Co/rpIIoIl_ """"V """""C.) ..........
")
",I - t..! .o'
" +T+ 10 '7q<)+ .~. ' -'( 41 ) - 3
i
Y,'(IJ - Y. )
Y;(t ) .. Y,
( Y;C' )" Y,
Y; (t ) .. e-' + Y,
... ,
Linear Higher Order Differential Equations with Constant Coefficients 215
Example # 4.13
A=[1,1,-2,0];IC=[1,1,-1];gt=‘t+exp(t)’;
Characteristic
216 Differential Equations: A Problem Solving Approach Based on MATLAB
IV ..
,,(1) 1'1(1) ,,(1)
~(t) ,,(1)
,,(I )
1
[ Ji(I) "W) -'(I )
~(t)-1f-¥-i-~-1
T. . . . -,.Ir¥ _ _ "'-...iII(QN
YALID'A.SS
o.WJt ofWronelda n
( I e- 21 e')
( 0 _2e- z, e')
( 0
'1"+1
Linear Higher Order Differential Equations with Constant Coefficients 217
A(.) _
BI·) =
IInCIlnIIIII Cordi.... (given)
+ v'lt) - 2lilt) = t + ..
( , (0) _ I rI(O) _ 1 "-(0) _ - 1 )
l8pIIa T .......m Y(s) of)l(1)
~ ,) - If - "fr'! -\ + 'f - ~ + I
Co"..,1eII toIutlon Uling dllllMC.) WI t.1&1ab
Example # 4.14
A=[1,1,0,0,0,0];IC=[1;0;1;0;1];gt=‘t’;
Linear Higher Order Differential Equations with Constant Coefficients 219
tnvot,..
upIK. bliNd toIution
orr->l11 EqUllion _1riW ~
JI""(') + >"'(' ) ~,
( ,(0) .. I ,,(0) .. 0 r'(0) .. I '-(0) .. 0 ,"(0) " 1 )
" L (, ) = (-'+~f"0+1)
+"+I )
Salutlon)'(l) ..1"41 irwI ... Lapl«e I........orm '" Yl (I)
- 1 12,~ r' ~
() = 2 t+ 2 e -"2+'3-24+i1ij- 1
yt
SdoAlon y(t) uaIng dIoM(J In MatIioIl
_.
~ ......
~
Y'(t) _ t _ Yo
•
/'
•o 0.5 1 1.5 2
....
2.5 3 15 4 U 5
220 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 4.15
A=[1,0,1,1,0,1];IC=[1;0;0;0;1];gt=‘exp(t)’;
Linear Higher Order Differential Equations with Constant Coefficients 221
Example # 4.16
A=[1,0,0,-1,0,0];IC=[1;0;1;0;0];gt=‘exp(-t)’;
222 Differential Equations: A Problem Solving Approach Based on MATLAB
y,(.) __ ;fr-'."u·
~ .. -..
SoIuIIon !'CIluoIroII-'" L...-......... <II Y. (II
4v'3d "'.(;+*)
lI( t) "" slnh(t) - t - , +2
_!IIII..w,g-..cJ"_~
••!o-~.".,~~-~,,~~,~':U~ ,
... , u • 0.5 5
Linear Higher Order Differential Equations with Constant Coefficients 223
Example # 4.17
A=[1,1,0,0,0,0,0];IC=[1;0;0;0;1;0];gt=‘exp(-t)*t’;
224 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 4.18
A=[1,0,0,1,0,0,0];IC=[0;0;0;0;0;1];gt=‘t+5’;
Linear Higher Order Differential Equations with Constant Coefficients 225
226 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 4.19
A=[1,0,0,1,0,0,0,0];IC=[1;0;0;0;0;0;1];gt=‘t’;
Linear Higher Order Differential Equations with Constant Coefficients 227
Example # 4.20
A=[1,0,0,1,0,0,0,0];IC=[1;0;0;-1;0;0;1];gt=‘t*exp(-t)’;
228 Differential Equations: A Problem Solving Approach Based on MATLAB
Linear Higher Order Differential Equations with Constant Coefficients 229
Example # 4.21
A=[1,0,-1,1,0,-1,0,0];IC=[1;0;0;0;0;0;1];gt=‘t’;
230 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 4.22
A=[1,0,-1,1,0,-1,0,0];IC=[1;0;0;0;0;0;1];gt=‘t+exp(-t)’;
Linear Higher Order Differential Equations with Constant Coefficients 231
232 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 4.23
A=[1,0,-1,1,0,-1,0,0];IC=[1;0;0;0;0;0;1];gt=‘exp(-t)’;
Linear Higher Order Differential Equations with Constant Coefficients 233
4.7 Summary
In this chapter, we explored ways of solving higher order differential equations with
constant coefficients. The characteristic equation is used to formulate the solution to
the homogeneous differential equation while the concept of the Wronskian introduced
in Chapter 3 is invoked to get the particular solution. The difficulties encountered
in using the roots of the characteristic equation of the higher order differential
equations is clearly articulated in terms of the relationships that might exist among
the various roots making it difficult to proceed as the order increases beyond 4. As
has been done throughout, the solution obtained through the use of roots and the
Wronskian is compared to the one obtained using the theory of Laplace transforms.
Additional confirmation is provided through the use of numerical techniques based
on the Runge-Kutta method in MATLAB. Differential equations with orders larger
than the 4th are solved using Laplace transforms and results are compared using the
Runge-Kutta method.
234 Differential Equations: A Problem Solving Approach Based on MATLAB
4.8 Exercises
1. Consider a higher order differential equations with a coefficient vector A=[An,An-
1,..,A0]. Obtain the characteristic equation, roots and the homogeneous solution.
Does the solution match the one obtained using solve(.) in MATLAB.
A=[1,-3,-1,0]
A=[1,0,-2,-1]
A=[1,-1,0,-4];
A=[1,-1,0,0];
A=[1,0,0,-3];
A=[1,0,-3,0];
A=[1,-1,1,0];
A=[1,0,0,0];
A=[1,0,0,1];
A=[1,-4,0,0];
A=[1,0,0,-8,0];
A=[1,4,0,0,0];
A=[1,0,0,1,0];
A=[1,0,0,-1,0];
A=[1,-1,0,0,0];
2. A number of third order differential equations are identified by the coefficient
vector A=[A3,A2,A1,A0]. For each of the cases, a forcing function g(t) is
provided. Obtain the particular solution in each case. Provide the homogeneous
solution set and Wronskian in each case.
A=[1,1,0,0]; g(t)=texp(-t)+t
A=[1,-1,0,0];g(t)=t;
A=[1,0,4,0];g(t)=cos(2t)
A=[2,-5,2,0]=g(t)=exp(2t)
A=[1,0,-9,0];g(t)=cosh(3t);
A=[1,-4,-5,0]; g(t)=t+t^2exp(5*t)
A=[2,0,-2,0];g(t)=sinh(t)
A=[1,2,0,-1];g(t)=cos(t);
A=[2,1,0,0];g(t)=t^2;
A=[1,0,0,-8,0];g(t)=t+exp(2t)
A=[1,4,0,0,0];g(t)=t*exp(-4t)
A=[1,0,0,1,0];g(t)=exp(-t)
A=[1,0,0,-1,0];g(t)=5t+exp(t)
A=[1,-1,0,0,0];g(t)=t+t^2
A=[1,-1,-1,0,0];g(t)=t;
Linear Higher Order Differential Equations with Constant Coefficients 235
3. For the given initial conditions, obtain the complete solutions. Verify the results
using Laplace transforms and ode45.
A=[1,1,0,0];g(t)=t*exp(-t)+t;IC=[1,-1,0];
A=[1,-1,0,0];g(t)=t;IC=[1,1,0];
A=[1,0,4,0];g(t)=cos(2*t);IC=[0,-1,0];
A=[2,-5,2,0];g(t)=exp(2*t);IC=[-1,-1,0];
A=[1,0,-9,0];g(t)=cosh(3*t);IC=[0,-1,1];
A=[1,-4,-5,0];g(t)=t+t^2*exp(5*t);IC=[-1,-1,1];
A=[2,0,-2,0];g(t)=sinh(t);IC=[0,-1,-1];
A=[1,2,0,-1];g(t)=cos(t);IC=[-1,1,0];
A=[2,1,0,0];g(t)=t^2;IC=[0,-1,1];
A=[1,0,0,-8,0];g(t)=t+exp(2*t);IC=[1,0,-1,1];
A=[1,4,0,0,0];g(t)=t*exp(-4*t);IC=[1,0,1,1];
A=[1,0,0,1,0];g(t)=‘exp(-t)’;IC=[1,1,0,1];
A=[1,0,0,-1,0];g(t)=‘5*t+exp(t)’;IC=[1,0,-1,0];
A=[1,-1,0,0,0];g(t)=t+t^2;IC=[1,1,0,0];
A=[1,-1,-1,0,0];g(t)=t;IC=[1,0,0,0];
CHAPTER 5
5.1 Introduction
Systems often comprise more than one component or rely on two or more components
linked together for efficient operations. Examples include electrical, mechanical
and chemical flow systems, and traffic networks. Such systems require two or more
dependent variables for modeling and the behavior or operation of the systems can be
described in terms of a set of coupled first order differential equations. The analysis
presented here examines only linear systems with constant coefficients. We start with
the case of a pair of coupled equations before we explore coupled systems with three
or more variables.
First Order Coupled Differential Equations with Constant Coefficients 237
x
x = 1 . (5.3)
x2
While eqn. (5.1) is homogeneous, the non-homogeneous set of differential equations
can be expressed as
dx1
dx dt
= = Ax + g ( t ) . (5.4)
dt dx2
dt
In eqn. (5.4),
g ( t ) . (5.5)
g (t ) = 1
g 2 ( t )
In eqn. (5.5), g1(t) and g2(t) are the forcing functions. If the initial conditions are
available, they can be expressed in vectorial form as
x (0)
x (0) = 1 . (5.6)
x2 ( 0 )
We will now consider the homogeneous and non-homogeneous differential
equations separately.
5.2.1 Homogeneous systems
5.2.1.1 Solution using eigenvalues and eigenvectors
Consider the case of a pair of first order homogeneous equations expressed as
dx
1
dx dt x (0)
= = x (0) 1
Ax , = . (5.7)
dt dx2 x2 ( 0 )
dt
238 Differential Equations: A Problem Solving Approach Based on MATLAB
In eqn. (5.7),
A A12
A = 11 (5.8)
A21 A22
The solution to the first order homogeneous (coupled) system can be obtained by
examining the coefficient matrix A in eqn. (5.8) and its properties in terms of the
eigenvalues and eigenvectors. The concepts of eigenvalues and eigenvectors are
discussed in Appendix D. From the analysis presented in Appendix D, three distinct
possibilities exist for the two sets of eigenvectors: real and distinct, real and equal or
form a complex conjugate pair.
Distinct eigenvectors
When the coefficient matrix is not defective (it has two distinct eigenvectors), two
possibilities exist, either the eigenvalues are distinct or equal. Consider the case where
the two eigenvalues are real and distinct. If the two eigenvalues associated with A
are λ1 and λ2 with corresponding eigenvectors v1 and v2 , the two linearly independent
solution vectors are
X 1 ( t ) = v1eλ1t
. (5.9)
X 2 ( t ) = v2 eλ2t
The fundamental matrix X(t) associated with the system is the [2 x 2] matrix
X ( t ) = X 1 X 2 (5.10)
The general solution of the homogeneous system is the superposition of the two
solutions in eqn. (5.9) as
2
x (t ) =
Xc= ∑ ck X k ( t ) . (5.11)
c1 X 1 ( t ) + c2 X 2 ( t ) =
k =1
In eqn. (5.11), c is the vector with two elements c1 and c2 representing the two
unknown constants or scaling factors.
The two unknown coefficients can be evaluated from the initial conditions x ( 0 )
in eqn. (5.7). The analysis and the solution given in eqn. (5.9) and eqn. (5.11) do not
change even when λ1 = λ2 = λ, if the two eigenvectors are distinct because the set of
equations in eqn. (5.9) represents two linearly independent solutions.
Complex eigenvectors
When eigenvectors are complex, eigenvalues are also complex and vice versa. If the
two eigenvalues are
λ1,2= λ±= α ± j β . (5.12)
In eqn. (5.12), α and β are real. The two eigenvectors are
v1,2= v±= u ± jw . (5.13)
First Order Coupled Differential Equations with Constant Coefficients 239
Equal eigenvectors
When the eigenvectors are equal (this certainly implies that eigenvalues are equal),
the coefficient matrix is defective and two independent solution vectors do not exist.
This case requires the generation of a pair of generalized eigenvectors as described in
Appendix D. While it is possible to keep the single eigenvector obtained and get an
extra single generalized eigenvector and use these two, the approach described here
does not use the original eigenvector. Instead, a pair of generalized eigenvectors is
obtained from the solution of
2
( A − λ I2 ) v =0. (5.15)
In eqn. (5.15), I2 is the 2 x 2 identity matrix and if the pair of generalized eigenvectors
are vg and vg2, the solution vectors become (Appendix D)
1
X 1 ( t=
) eλt vg1 + t ( A − λ I 2 ) vg1
. (5.16)
X 2 ( t=
) eλt vg2 + t ( A − λ I 2 ) vg2
The general solution is once again given by eqn. (5.11) with the solution vectors
given in eqn. (5.16). It should be noted that for the case of a 2 x 2 defective matrix,
the generalized eigenvectors will be (see appendix D)
1
vg1 =
0
(5.17)
0
vg 2 =
1
5.2.1.2 Solution without using eigenvectors
While the solutions to a set of first order coupled homogeneous differential equations
with constant coefficients is simple and straightforward, it creates some difficulties
when the coefficient matrix is defective. It is possible to obtain the solutions using the
characteristic equation approach outlined in Chapter 3 in connection with the solutions
of second order homogeneous differential equations with constant coefficients. The
same approach can be implemented here by converting a pair of homogeneous first
order equations into a second order differential equation of constant coefficients.
Consider the first differential equation in x1 in eqn. (5.1). Its differentiation leads to
x1'' A11 x1' + A12 x2' .
= (5.18)
240 Differential Equations: A Problem Solving Approach Based on MATLAB
Equation (5.18) can be rewritten using the differential equation for x2 from eqn. (5.1)
and creating a second order differential equation in x1 as
x1'' =A11 x1' + A12 [ A21 x1 + A22 x2 ] =A11 x1' + A12 A21 x1 + A22 ( x1' − A11 x1 ) (5.19)
Using the method based on the roots of the characteristic equation developed in
Chapter 3, it is possible to get a general solution for x1(t). Substituting x1(t) in the first
differential equation eqn. (5.1), a general solution for x2(t) can be obtained. Using the
initial conditions, the unknown coefficients can be obtained completing the solution.
In some of the instances, A12=0 and A21≠0. In this case, the first differential
equation eqn. (5.1) is used to obtain a second order differential equation in x2(t) and the
procedure is repeated to obtain the solution for x1(t). In the special case of A12= A21=0,
the two differential equations are uncoupled and they can easily be solved.
x1 ( t )
−1 −1 x1 ( 0 )
=
L [ sI 2 − A] . (5.21)
2 ( )
x t 2 ( )
x 0
In eqn. (5.21), I2 is a [2 x 2] identity matrix and [sI2 – A]–1 is the inverse of the
matrix [sI2 – A]. Inversion of a matrix is described in Appendix D. Solutions may also
be obtained using numerical techniques outlined in Appendix A.
order system. While the detailed procedure is described in Appendix C, the analytical
solutions are not plotted alongside the quiver(.) plot.
clear;close all;
% generate phase plots for several coefficient matrices
% P M Shankar, July 2017
for k=1:12
if k==1
A=[-1,2;2,1];
elseif k==2
A=[-1,2;-4,1];
elseif k==3
A=[-1,-1;1,-1];
elseif k==4
A=[2,1;-1,2];
elseif k==5
A=[2,-2;1,-1];
elseif k==6
A=[-2,2;1,-1];
elseif k==7
A=[2,0;1,1];
elseif k==8
A=[2,0;0,2];
elseif k==9
A=[-1,0;-1,-1];
elseif k==10
A=[-2,0;0,-2];
elseif k==11
A=[-2,1;0,-2];
elseif k==12
A=[2,2;-2,-2];
end;
[x1,x2]=meshgrid(-3:.5:3,-3:.5:3);
DX1=A(1,1)*x1+A(1,2)*x2;
DX2=A(2,1)*x1+A(2,2)*x2;
figure
quiver(x1,x2,DX1,DX2,1.5,‘color’,‘r’),xlabel(‘x_1(t)’),ylabel(‘x_2(t)’)
xlim([-3,3]),ylim([-3,3])
lambda=eig(sym(A));
title([‘EigenValues\Rightarrow’,’ [‘,num2str(double(lambda’)),‘]’])
end;
The results are presented below. Consider the case of the coefficient matrix
−1 2
A= . (5.23)
2 1
The eigenvalues are real with one of them being positive and the other being negative
resulting in the phase portrait in Figure 5.1. The solution moves away from the critical
point indicating that the system is unstable.
242 Differential Equations: A Problem Solving Approach Based on MATLAB
Figure 5.1 The eigenvalues are real and have opposite signs. The solutions move away from the critical
point [0,0] indicating that the system is unstable.
Figure 5.2 The eigenvalues are purely imaginary. The solutions continously encircle the critical point
[0,0], indicating that the system is oscillatory.
Figure 5.3 The eigenvalues are complex with a negative real part. The solutions move towards the critical
point [0,0] indicating that the system is asymptotically stable.
244 Differential Equations: A Problem Solving Approach Based on MATLAB
Figure 5.4 The eigenvalues are complex with a positive real part. The solutions move away from the
critical point [0,0] indicating that the system is unstable.
Figure 5.5 One of the eigenvalues is zero while the other one is positive. The solutions move away (opposite
direction) from a diagonal line going through the critical point [0,0] indicating that the system is unstable.
First Order Coupled Differential Equations with Constant Coefficients 245
The eigenvalues form a complex conjugate pair with the real part being positive
resulting in the phase portrait in Figure 5.4. The solutions continously move away
from the critical point [0,0] indicating that the system is unstable.
Consider the case of the coefficient matrix
2 −2
A= . (5.27)
1 −1
The eigenvalues are real with one of them being a zero and the other one being positive
resulting in the phase portrait in Figure 5.5. The solutions move away (opposite
direction) from a diagonal line through critical point [0,0] indicating that the system
is unstable. The unstable nature in this case being defined w.r.t. a line is due to the
existence of an eigenvalue of 0.
Consider the case of the coefficient matrix
−2 2
A= . (5.28)
1 −1
The eigenvalues are real with one of them being a zero and the other one being
negative resulting in the phase portrait in Figure 5.6. The solutions move towards the
diagonal line through the critical point [0,0], indicating that the system is stable. The
stability in this case being defined w.r.t. a line is due to the existence of an eigenvalue
of 0.
Consider the case of the coefficient matrix
Figure 5.6 One of the eigenvalues is zero while the other one is negative. The solutions point to the a
diagonal line through the critical point [0,0] indicating that the system is stable.
246 Differential Equations: A Problem Solving Approach Based on MATLAB
Figure 5.7 Both eigenvalues are positive. The solutions move away from the critical point [0,0],
indicating that the system is unstable.
2 0
A= . (5.29)
1 1
The eigenvalues are real and positive resulting in the phase portrait in Figure 5.7. The
solutions move away from the critical point [0,0] indicating that the system is unstable.
Consider the case of the coefficient matrix
2 0
A= . (5.30)
0 2
The eigenvalues are real and positive resulting in the phase portrait in Figure 5.8. The
solutions move away from the critical point [0,0], indicating that the system is unstable.
Consider the case of the coefficient matrix
−1 0
A= . (5.31)
−1 −1
The eigenvalues are real and negative resulting in the phase portrait in Figure 5.9.
The solutions move towards the critical point [0,0], indicating that the system is
asymptotically stable.
Consider the case of the coefficient matrix
First Order Coupled Differential Equations with Constant Coefficients 247
Figure 5.8 Both eigenvalues are equal and positive. The solutions move away from the critical point
[0,0], indicating that the system is unstable.
Figure 5.9 Both eigenvalues are negative. The solutions move towards the critical point [0,0], indicating
that the system is asymptotically stable.
248 Differential Equations: A Problem Solving Approach Based on MATLAB
Figure 5.10 Both eigenvalues are negative. The solutions move towards the critical point [0,0] indicating
that the system is asymptotically stable.
−2 0
A= . (5.32)
0 −2
The eigenvalues are real and negative resulting in the phase portrait in Figure
5.10. The solutions move towards the critical point [0,0] indicating that the system
is asymptotically stable.
Consider the case of the coefficient matrix
−2 1
A= . (5.33)
0 −2
The eigenvalues are real and negative resulting in the phase portrait in Figure
5.11. The solutions move towards the critical point [0,0] indicating that the system
is asymptotically stable. Note the difference in how the solutions move towards the
critical point in this case vs. what is seen in Figure 5.10. Even though the eigenvalues
for the matrices in eqns. (5.32) and (5.33) are identical, the matrix in eqn. (5.32) is
symmetric and therefore it is not defective (it has two distinct eigenvectors). The
matrix in eqn. (5.33) is not symmetric and it is defective because it only has a single
eigenvector. Details can be seen in Appendix D.
Consider the case of the coefficient matrix
First Order Coupled Differential Equations with Constant Coefficients 249
2 2
A= . (5.34)
−2 −2
Figure 5.11 Both eigenvalues are negative. The solutions move towards the critical point [0,0], indicating
that the system is asymptotically stable. Note the difference in how the solutions move towards the critical
point in this case vs. what is seen in Figure 5.10. This is due to the fact that the matrix is defective in this
case while the matrix is not defective for the case depicted in Figure 5.10.
Figure 5.12 Both eigenvalues are zeros. The solutions move in opposite directions with respect to the line
through the critical point [0,0] indicating that the system is unstable.
250 Differential Equations: A Problem Solving Approach Based on MATLAB
The eigenvalues are real and both of these are 0’s resulting in the phase portrait in
Figure 5.12. The solutions move in opposite directions with respect to the line through
the critical point [0,0], indicating that the system is unstable.
The phase plane plots and the stability criteria associated with a pair of first
order homogeneous differential equations with constant coefficients is summarized
in Table 5.1
5.2.1.5 Examples
A set of examples demonstrating the different pairing of the eigenvalues described
above will now be given before MATLAB® based examples are provided.
Example # 5.1 Consider a pair of coupled differential equations represented by the
coefficient matrix
1 2 . (5.35)
A=
3 2
This coefficient matrix represents the two coupled differential equations,
1 (t ) x1 ( t ) + 2 x2 ( t )
'
x=
. (5.36)
x2' ( t ) 3x1 ( t ) + 2 x2 ( t )
=
The initial conditions are
x1 ( 0 ) 1
= . (5.37)
x2 ( 0 ) 0
The two eigenvalues associated with the coefficient matrix and the corresponding
eigenvectors are
−1
λ1 =
−1 v1 = 1
2 . (5.38)
λ2 4=
= v2 3
1
The solution set can now be written as
2
x1 ( t ) =
−c1e − t + c2 e 4t
3 . (5.39)
x2=( t ) c1e + c2 e4t
−t
The two unknowns constants c1 and c2 may be obtained by applying the initial
conditions in eqn. (5.37). This leads to
2
1 =−c1 + c2
3 . (5.40)
0= c1 + c2
Table 5.1. Eigenvalues, eigenvectors and stability.
2e5t + 3
x1 ( t ) = e − t
5
. (5.42)
−t e − 1
5t
x2 ( t ) = 3e
5
The two coupled equations can be converted to a single second order differential
equation in x1(t) as
x1'' ( t ) − 3 x1' ( t ) − 4 x1 ( t ) =
0 (5.43)
Equation (5.43) can be solved using the methods described in Chapter 3. Note that
the roots of the characteristic equation associated with the second order differential
equation in eqn. (5.43) will be -1 and 4, matching the eigenvalues obtained directly
from the coefficient matrix in eqn. (5.35). The solution for x1(t) can be expressed in
terms of two unknown constants b1 and b2 as
( t ) b1e−t + b2 e4t .
x1= (5.44)
Using one of the differential equations in eqn. (5.36), the solution for x2(t) becomes
3
x2 ( t ) =
−b1e − t + b2 e 4t . (5.45)
2
Applying initial conditions given in eqn. (5.37), eqn. (5.44) and (5.45) can be solved
for b1 and b2 as
3
b1 =
5
. (5.46)
2
b2 =
5
Substituting the values of b1 and b2 in eqns. (5.44) and (5.45), the solutions obtained
match those given in eqn. (5.42).
In terms of the Laplace transforms, the Laplace transforms of the solutions to set of
differential equations in eqn. (5.36) becomes
s−2
X1 ( s ) = −
− s 2 + 3s + 4
(5.47)
3
X2 (s) = − 2
− s + 3s + 4
First Order Coupled Differential Equations with Constant Coefficients 253
Taking inverse Laplace transforms of eqn. (5.47), the solution set becomes
2 4t 3 − t
(t )
x1= e + e
5 5
. (5.48)
3 3
x2=( t ) e 4t − e − t
5 5
Note that the solution set in eqn. (5.48) matches the set in eqn. (5.42). The phase
portrait shown in Figure 5.13 illustrates that the system represented by the coefficient
matrix in eqn. (5.35) is unstable.
Figure 5.13 The phase plane plots or gallery of solutions. The directional arrows clearly show that the
solutions are moving away from the critical point, indicating that the system is unstable.
The eigenvalues and eigenvectors associated with the coefficient matrix are
1 + i
λ1 =
−i v1 =
1
. (5.52)
1 − i
λ2 i =
= v2
1
Notice that the eigenvectors are purely imaginary and therefore, the solution will
consist of sines and cosines. The solution set is
x1 ( t )= c1 cos ( t ) + sin ( t ) + c2 cos ( t ) − sin ( t )
. (5.53)
x2 ( t ) c1 cos ( t ) − c2 sin ( t )
=
Applying the initial conditions in eqn. (5.51), the two constants are obtained as
=c1 1=
c2 1 . (5.54)
Using the values of c1 and c2, the solution set becomes
x1 ( t ) = 2 cos ( t )
π . (5.55)
x2 ( t )
= 2 cos t +
4
The set of differential equations can be converted to a second order differential
equations as
x1'' ( t ) + x1 ( t ) =
0 . (5.56)
The roots of the characteristic equation associated with the second order differential
equation are [I, -i]. The solution set becomes
x1 ( t ) b1 cos ( t ) − b2 sin ( t )
=
b1 b b b . (5.57)
cos ( t ) − 2 cos ( t ) − 1 sin ( t ) − 2 sin ( t )
x2 ( t ) =
2 2 2 2
Applying initial conditions, the two unknown constants become
=b1 2=b2 0 . (5.58)
Using the values of b1 and b2 in eqn. (5.57), one obtains the solution set matching the
one given in eqn. (5.55).
The solution to the set of differential equations can also be obtained using Laplace
transforms. The Laplace transforms of the two differential equations become (with
the initial conditions included)
2 s −1
1 (s)
X= +2 2
s2 + 1 s +1
. (5.59)
2 s +1
X2 (s) =
− 2 + 2
s +1 s +1
First Order Coupled Differential Equations with Constant Coefficients 255
Figure 5.14 The phase plane plots or gallery of solutions. The directional arrows clearly show that the
solutions form elliptical orbits indicating stability.
The roots of the characteristic equation are [1, 1]. This leads to a solution for x2(t) as
2 (t )
x= et ( b1 + b2 t ) . (5.70)
Substituting eqn. (5.70) in the second differential equation in eqn. (5.62), the solution
for x1(t) becomes
b2 t
x1 ( t ) = −
e . (5.71)
2
Applying initial conditions, the two constants are evaluated as
b1 = 0 b2 = −2 . (5.72)
Substituting for b1 and b2 in eqn. (5.70) and eqn. (5.71) leads to the solution set obtained
from the eigenvector set given in eqn. (5.68).
The Laplace transforms of the set of differential equations (with initial conditions) are
1
X1 ( s ) =
s −1
1 . (5.73)
X 2 ( s ) = −2
( s − 1)
2
First Order Coupled Differential Equations with Constant Coefficients 257
Figure 5.15 The phase plane plots or gallery of solutions. The directional arrows clearly show that the
solutions are moving away from the critical point, pointing out that the system is unstable.
The eigenvalues of the coefficient matrix are equal even though the coefficient matrix
is not defective because two distinct eigenvectors are associated with A in eqn. (5.75).
The eigenvalues and eigenvectors are
1
λ1 2=
= v1
0
. (5.78)
0
λ2 2=
= v2
1
The solution set in terms of two unknown constants c1 and c2 becomes
x1 ( t ) = c1e 2t
. (5.79)
x2 ( t ) = c2 e 2t
Applying initial conditions, the solution set becomes
x1 ( t ) = e 2t
. (5.80)
x2 ( t ) = e 2t
It is clear from the set of differential equations in eqn. (5.76) that the set does
not constitute a pair of coupled equations and therefore, no second order differential
equation is necessary to obtain the solution set. Using the concept of Laplace
transforms, the Laplace transforms become
1
X1 ( s ) =
s−2
. (5.81)
1
X2 (s) =
s−2
Taking inverse Laplace transforms, the set of Laplace transforms in eqn. (5.81) leads
to the solution set in eqn. (5.80).
The phase portrait for the coefficient matrix in eqn. (5.75) is shown in Figure
5.16. The unstable equilibrium conditions are seen.
Example # 5.5 It is interesting to observe how the solutions behave for a system having
equal eigenvalues with a degenerate coefficient matrix. Consider a set of differential
equations represented by the coefficient matrix
2 1
A= . (5.82)
0 2
While the two eigenvalues of the matrix are equal (each being 2), the matrix is defective
requiring the use of generalized eigenvectors. The use of the generalized eigenvectors
alters the gallery of solutions as seen in Figure 5.17.
The set of differential equations associated with the coefficient matrix in eqn. (5.82) is
x1' ( t ) 2 x1 ( t ) + x2 ( t )
=
. (5.83)
x2' ( t ) = 2 x2 ( t )
First Order Coupled Differential Equations with Constant Coefficients 259
Figure 5.16 The phase plane plots or gallery of solutions. The directional arrows clearly show that the
solutions (straight lines) are moving away from the critical point, pointing out that the system is unstable.
Figure 5.17 The phase plane plots or gallery of solutions. The directional arrows clearly show that the
solutions (no longer straight lines) are moving away from the critical point, indicating that the system is
unstable. The use of the generalized eigenvector (due to the defective nature of the coefficient matrix)
alters the nature of the solutions.
260 Differential Equations: A Problem Solving Approach Based on MATLAB
( t ) e2t c1 + c2te2t
x1=
. (5.86)
x2 ( t ) = c2 e 2t
Applying the initial conditions, the constants can be evaluated as
=c1 0=c2 1 . (5.87)
The solution set now becomes
x1 ( t ) = te 2t
. (5.88)
x2 ( t ) = e 2t
If we compare the solution set in eqn. (5.80) and the solution set in eqn. (5.88), it is
seen that the defective nature of the matrix leads to scaling by t in eqn. (5.88). This
leads to the difference in the trajectory of the solutions as seen in Figures 5.16 and 5.17.
Example # 5.6 Consider a pair of coupled differential equations represented by the
coefficient matrix
1 1
A= . (5.89)
−2 1
The set of corresponding differential equations is
1 (t ) x1 ( t ) + x2 ( t )
'
x=
. (5.90)
x2' ( t ) =
−2 x1 ( t ) + x2 ( t )
The initial conditions are given as
x1 ( 0 ) 1
= . (5.91)
x2 ( 0 ) 0
First Order Coupled Differential Equations with Constant Coefficients 261
2 t
=x1 ( t )
2
( 2t ) + 22 e c cos ( 2t ) .
e c1 sin t
2
(5.93)
=x2 ( t ) e c cos ( 2t ) − e c sin ( 2t )
t
1
t
2
x1 ( t ) = et cos( 2t )
. (5.95)
x2 ( t ) = − 2e sin ( 2t )
t
1 + i 2 1 − i 2 . (5.97)
The pair of complex roots leads to the solution set as
=
( ) ( )
x1 ( t ) et b1 cos 2t − b2 sin 2t
. (5.98)
x2 ( t ) = ( ) ( )
− 2e b1 sin 2t + b2 cos 2t
t
Applying initial conditions, the two constants b1 and b2 are evaluated as
=b1 1=
b2 0 . (5.99)
Substituting the values of b1 and b2 is eqn. (5.98), the solution set matching the set
given in eqn. (5.95) is obtained.
262 Differential Equations: A Problem Solving Approach Based on MATLAB
1 (t ) x1 ( t ) − x2 ( t )
'
x=
. (5.102)
x2' ( t ) =
− x1 ( t ) + x2 ( t )
The initial conditions are given as
x1 ( 0 ) 1
= . (5.103)
x2 ( 0 ) −1
Figure 5.18 The phase plane plots or gallery of solutions. The directional arrows clearly show that the
solutions are moving away from the critical point, pointing out that the system is unstable.
First Order Coupled Differential Equations with Constant Coefficients 263
1
λ1 0=
= v1
1
. (5.104)
−1
λ2 2=
= v2
1
Using the eigenvalues and eigenvectors, the solution set becomes
x1 ( t =
) c1 − c2 e2t
. (5.105)
x2 ( t =
) c1 + c2 e2t
Applying the initial conditions in eqn. (5.103), the two constants c1 and c2 can be
evaluated as
c1 = 0 c2 = −1 . (5.106)
The roots of the characteristic equation are 0 and 2 which lead to the solution set in
eqn. (5.107). The Laplace transforms of the differential equations are
1
X1 ( s ) =
s−2
. (5.109)
1
X2 (s) =
2−s
Taking the inverse Laplace transform of the set in eqn. (5.109), the solution set obtained
matches the solution set in eqn. (5.107).
Example # 5.8 It is possible to compare this example to the case of a set of differential
equations represented through the coefficient matrix
0 1
A= . (5.110)
0 −3
The eigenvalues are 0 and -3. The gallery of solutions is displayed in Figure 5.20
which shows that the directional arrows point to the critical point demonstrating the
system is asymptotically stable.
264 Differential Equations: A Problem Solving Approach Based on MATLAB
Figure 5.19 The phase plane plots or gallery of solutions. The directional arrows show that the solutions
are straight lines and that they are moving away from a line through critical point, indicating that the
system is unstable.
Figure 5.20 The phase plane plots or gallery of solutions. The directional arrows show that the solutions
are straight lines and are moving towards a line through the critical point indicating that the system is
asymptotically stable.
First Order Coupled Differential Equations with Constant Coefficients 265
1
= λ1 0= v1
0
. (5.114)
0
= λ2 0= v2
1
Using the generalized eigenvectors and the eigenvalue, the solution set in terms of
two unknown constants c1 and c2 becomes
x1 ( t=
) c1 ( 2t + 1) + 2c2t
. (5.115)
x2 ( t ) =
−2c1t − c2 ( 2t − 1)
Applying the initial conditions and evaluating the unknown constants, the solution
set becomes
x1 ( t ) =−4t − 1
(5.116)
x2 ( t=
) 4t − 1
The second order differential equation is unique and it is given by
x1'' ( t ) = 0 . (5.117)
The roots of the characteristic equation are equal and each is equal to zero leading to
the solution set as
x1 ( t =
) b1 + b2t
b2 . (5.118)
x2 ( t ) =−b1 − b2 t +
2
Applying initial conditions, the values of b1 and b2 are obtained as
b1 =
−1 b2 =
−4 . (5.119)
266 Differential Equations: A Problem Solving Approach Based on MATLAB
Substituting for b1 and b2, the solution set obtained matches the result in eqn. (5.116).
Taking Laplace transforms of the differential equations, the Laplace transforms
are obtained as
−s − 4
X1 ( s ) =
s2
. (5.120)
−s + 4
X2 (s) =
s2
Taking the inverse Laplace transforms, the solution set obtained matches the solution
set in eqn. (5.116).
Example #5.10 Consider a pair of coupled differential equations represented by the
coefficient matrix
−1 0
A= . (5.121)
−2 −3
Figure 5.21 The phase plane plots or gallery of solutions. The directional arrows clearly show that the
solutions are moving away from a line through the critical point, pointing out that the system is unstable. The
case of a single eigenvalue of zero and double zero eigenvalues can be compared and seen that in the latter
case arrows only point in two directions while in the former case they are moving away in four directions.
First Order Coupled Differential Equations with Constant Coefficients 267
0
λ1 =
−3 v1 =
1
. (5.124)
−1
λ2 =
−1 v2 =
1
The solutions set using eigenvalues and eigenvectors becomes
x1 ( t ) = −c2 e − t
. (5.125)
2 (t )
x= c1e −3t + c2 e − t
Applying initial conditions, the constants c1 and c2 are evaluated as
=c1 0=c2 1 . (5.126)
Using the values of c1 and c2, the solution set in eqn. (5.125) becomes
x1 ( t ) = −e − t
. (5.127)
x2 ( t ) = e − t
Because the first differential equation in eqn. (5.122) does not contain x2, the second
order differential equation in x2 is created starting from the second differential equation
in eqn. (5.122) as
x2'' ( t ) + 4 x2' ( t ) + 3 x2 ( t ) =
0 . (5.128)
The roots of the characteristic equation are -3 and -1 and a solution set matching the
set in eqn. (5.127) is obtained in this case.
Taking the Laplace transforms of the differential equations, the Laplace transforms
become
−1
X1 ( s ) =
s +1
. (5.129)
1 2 1
X2 (s) = + =
s + 3 ( s + 3)( s + 1) s + 1
Taking inverse Laplace transforms, a solution set matching the set in eqn. (5.127) is
obtained.
268 Differential Equations: A Problem Solving Approach Based on MATLAB
Figure 5.22 The phase plane plots or gallery of solutions. The directional arrows clearly show that
the solutions are moving towards to the critical point and converging pointing out that the system is
asymptotically stable.
x1 p ( t )
xp (t ) = . (5.131)
x2 p ( t )
x ( t ) xh ( t ) + x p ( t ) . (5.132)
=
The particular solutions set can be obtained from the fundamental matrix using the
method of variation of parameters described in in Appendix D as (see eqn. (D. 140)) as
x1 p ( t ) −1
x p ( t ) =
= X ( t ) ∫ X ( t ) g ( t ) dt (5.133)
x
2p ( t )
First Order Coupled Differential Equations with Constant Coefficients 269
Note that X(t) is the fundamental matrix defined in eqn. (5.10). If the initial conditions
are given, the unknown coefficients c1 and c2 can be obtained. Given the initial
conditions, the solution can also be obtained using the concept of Laplace and inverse
Laplace transform as
x1 ( t ) −1 x ( 0 )
=L−1 [ sI 2 − A] 1 + L ( g ( t ) ) . (5.134)
x2 ( t ) x2 ( 0 )
1 + i
λ1 =
−i v1 =
1
. (5.139)
1 − i
λ2 i =
= v2
1
The fundamental matrix associated with the coefficient matrix (and the homogeneous
differential equations set) is
cos ( t ) + sin ( t ) cos ( t ) − sin ( t )
X ( t ) =
= X 1 X 2 . (5.140)
cos ( t ) − sin ( t )
The solution to the set of homogeneous differential equations is
The particular solution set is obtained using the expression in eqn. (5.133) as
sin ( t ) t 2 cos ( t ) t cos ( t )
− +
xp (t ) = 2 2 2 . (5.142)
sin ( t ) t 2 cos ( t ) t 2 sin ( t ) t cos ( t ) t sin ( t )
− + − −
4 4 4 4 4
The general solution to the non-homogeneous set of differential equation is the sum
of the homogeneous and particular solution sets. Using eqns. (5.141) and (5.142), the
general solution becomes
sin ( t ) t cos ( t )
x1 ( t ) cos ( t ) + sin ( t ) cos ( t ) − sin ( t )
+ (1 − t )
2 2
= c1 + c2 + .
x2 ( t ) cos ( t ) − sin ( t ) sin ( t ) 1 − t + t 2 − t cos ( t ) 1 + t
4
( ) 4 ( )
(5.143)
Applying initial conditions to eqn. (5.143), the two constants c1 and c2 are evaluated as
c1 1
c = 1 . (5.144)
2
Substituting the values of c1 and c2 in eqn. (5.143) and simplifying, the solution set
becomes
sin ( t ) t cos ( t )
x1 ( t ) = 2 cos ( t ) + + (1 − t )
2 2
. (5.145)
sin ( t ) t cos ( t )
( t ) cos ( t ) +
x2=
4
( t 2 − t − 3) −
4
(1 + t )
Incorporating the initial conditions, the Laplace transform of the differential equation
can be performed and the Laplace transform set becomes
2 2 s + 1 + s + 2 ( s − 1)
2
( ) s + 1
s2 + 1 2
X1 ( s ) s2 + 1
= . (5.146)
X 2 ( s ) 2s
s
+ 1 ( s + 1) − 2 −2
( s + 1)
2
2 s +1
2
s +1
Taking inverse Laplace transforms, the solution set matching the solution set in eqn.
(5.145) is obtained.
Example # 5.12 The coefficient matrix, forcing functions, and initial conditions are
given as
1 2
A= . (5.147)
2 1
First Order Coupled Differential Equations with Constant Coefficients 271
t
g ( t ) = − t . (5.148)
e
x1 ( 0 ) 1
= . (5.149)
x2 ( 0 ) 0
The set of coupled homogeneous set of differential equation becomes
x1' ( t ) =x1 ( t ) + 2 x2 ( t ) + t , x1 ( 0 ) =1
. (5.150)
x2' ( t ) = 2 x1 ( t ) + x2 ( t ) + e − t , x2 ( 0 ) = 0
The eigenvalues and eigenvectors of the coefficient matrix are
−1
λ1 =
−1 v1 =1
. (5.151)
1
λ2 3=
= v2
1
The fundamental matrix associated with the coefficient matrix (and the homogeneous
differential equations set) is
−e − t e 3t
X ( t ) =
= X 1 X 2 − t . (5.152)
e e 3t
The solution to the set of homogeneous differential equations is
−e − t e 3t
xh ( t ) =c1 X 1 + c2 X 2 =c1 − t + c2 3t . (5.153)
e e
The particular solution set is obtained using the expression in eqn. (5.133) as
t e − t te − t 5
− − −
3 8 2 9
x p ( t ) = −t . (5.154)
te e − t 2t 4
− − +
2 8 3 9
The general solution to the non-homogeneous set of differential equations is the sum
of the homogeneous and particular solution sets. Using eqns. (5.153) and (5.154), the
general solution becomes
t e − t te − t 5
− − −
x1 ( t ) −e
−t
e 3 8
3t
2 9
= c1 − t + c2 3t + − t . (5.155)
x2 ( t ) e e te − e − 2t + 4
−t
2 8 3 9
272 Differential Equations: A Problem Solving Approach Based on MATLAB
Applying initial conditions to eqn. (5.149), the two constants c1 and c2 are evaluated as
−1
c1
=
c 49 . (5.156)
2
72
Using the constants c1 and c2 in eqn. (5.156), the solution set in eqn. (5.155) becomes
t 7 49 t 5
x1 ( t ) =+ e − t + e3t − e − t −
3 8 72 2 9
. (5.157)
49 3t 9 − t 2t t − t 4
x2 ( t=) e − e − + e +
72 8 3 2 9
The Laplace transform relationship is obtained as
1
2
( s − 1) 2 + 1
s
− −
X 1 ( s ) ( s + 1) ( − s + 2s + 3) ( − s + 2s + 3)
2 2
= . (5.158)
X 2 ( s ) 1
2 2 + 1
s − s −1
−
( − s + 2 s + 3) ( s + 1) ( − s + 2 s + 3)
2 2
Taking the inverse Laplace transforms, the solution set matching the set in eqn. (5.157)
is obtained.
Example # 5.13 The coefficient matrix, forcing functions and initial conditions are
given as
1 0
A= . (5.159)
−2 3
t2
g ( t ) = − t . (5.160)
te
x1 ( 0 ) 1
= . (5.161)
x2 ( 0 ) 1
The set of coupled homogeneous set of differential equation becomes
x1' ( t ) =
x1 ( t ) + t 2 , x1 ( 0 ) =
1
. (5.162)
x2' ( t ) =
−2 x1 ( t ) + 3 x2 ( t ) + te − t , x2 ( 0 ) =
1
The eigenvalues and eigenvectors of the coefficient matrix are
1
λ1 1=
= v1
1
. (5.163)
0
λ2 3=
= v2
1
First Order Coupled Differential Equations with Constant Coefficients 273
The fundamental matrix associated with the coefficient matrix (and the homogeneous
differential equations set) is
et 0
X ( t ) =
= X 1 X 2 t . (5.164)
e e 3t
The solution to the set of homogeneous differential equations is
et 0
xh ( t ) =c1 X 1 + c2 X 2 =c1 t + c2 3t . (5.165)
e e
The particular solution set is obtained using the expression in eqn. (5.133) as
−t 2 − 2t − 2
.
x p ( t ) = 16 (5.166)
− t − 1 e − t − t e − t − 2 t 2 − 52
9 16 4 3 27
The solution set can now be expressed as the sum of the homogeneous and particular
solutions as
−t 2 − 2t − 2
x1 ( t ) et 0
=c + c +
1 t 2 3t 16 1 − t t − t 2 2 52 . (5.167)
x
2 ( t ) e
e
− t − e − e − t −
9 16 4 3 27
Applying initial conditions in eqn. (5.161) to the solution set in eqn. (5.167), the two
constants are obtained as
3
c1
c = 5 . (5.168)
2 −
432
Substituting eqn. (5.168) in eqn. (5.167), the solution set becomes
x1 ( t ) = 3et − 2t − t 2 − 2
1 −t 5 3t 16 t 2 52 . (5.169)
x2 ( t ) = 3et −
e − e − t − e−t − t 2 −
16 432 9 4 3 27
The Laplace transform relationship is obtained as
2
+1
s3
X1 ( s ) s −1
=
1 . (5.170)
X 2 ( s ) +1 2
+ 1
( s + 1)
2
3
s
−2
s −3
( s − 1 )( s − 3)
Taking the inverse Laplace transform, the solution set matching the set in eqn. (5.169)
is obtained.
274 Differential Equations: A Problem Solving Approach Based on MATLAB
x (0)
x (0) = 1 (5.173)
x2 ( 0 )
While the critical point associated with a pair of coupled first order homogeneous
differential equations with constant coefficient is [0, 0], the critical point associated
with set of the non-homogeneous differential equations in eqn. (5.171) is the solution of
dx 0
= Ax + q = . (5.174)
dt 0
In other words, the critical point is the solution of
0
Ax + q = ⇒ Ax =−q (5.175)
0
Using simple principles of linear algebra, the critical point becomes
x10 −1
−q1
= A [ −q ]= A −q . (5.176)
−1
x20 2
In eqn. (5.176), A–1 is the inverse of the matrix A. Note that if q is a null vector,
the critical point will the origin, [0, 0]. But, when q is not a null vector, it is obtained
as [x10, x20]. If α(t) and β(t) denote the departure of x1(t) and x2(t) from their respective
equilibrium values,
( t ) x1 ( t ) − x10
α=
. (5.177)
( t ) x2 ( t ) − x20
β=
First Order Coupled Differential Equations with Constant Coefficients 275
Using eqn. (5.177), the non-homogeneous differential equation set in eqn. (5.171)
can be expressed as
d
α ( t ) + x= A11 α ( t ) + x10 + A12 β ( t ) + x20 + q1
10
dt
. (5.178)
d
β ( t ) + x=
A21 α ( t ) + x10 + A22 β ( t ) + x20 + q2
20
dt
Carrying out the differentiation leads to
d
α ( t ) = A11α ( t ) + A12 β ( t ) + A11 x10 + A12 x20 + q1
dt
. (5.179)
d
β ( t ) = A21α ( t ) + A22 β ( t ) + A21 x10 + A22 x20 + q2
dt
Because [x10, x20] is the solution to eqn. (5.175),
A11 x10 + A12 x20 =
−q1
. (5.180)
A21 x10 + A22 x20 =
− q2
Using eqn. (5.180), eqn. (5.179) becomes
d
=α ( t ) A11α ( t ) + A12 β ( t )
dt
. (5.181)
d
β ( t ) A21α ( t ) + A22 β ( t )
=
dt
It can be seen that eqn. (5.181) is a homogeneous coupled first order system defined
by the same coefficient matrix A. In other words, eqn. (5.181) is the homogeneous
equivalent of the non-homogeneous set given in eqn. (5.171) with a new set of initial
conditions
( 0 ) x1 ( 0 ) − x10
α=
. (5.182)
( 0 ) x2 ( 0 ) − x20
β=
Once eqn. (5.181) is solved for α(t) and β(t) with the initial conditions in eqn. (5.182),
the solution set of the non-homogeneous differential equation set can be written using
eqn. (5.177) as
( t ) α ( t ) + x10
x1=
. (5.183)
( t ) β ( t ) + x20
x2=
It is clear from the discussion above that the approach described here works only
when the coefficient matrix is invertible (determinant of the matrix cannot be zero).
An example is shown now comparing the two approaches to illustrate that the method
described above is rather simple.
Example # 5.14 Consider a non-homogeneous coupled system with the coefficient
matrix, forcing functions and initial conditions are given as
1 1
A= . (5.184)
4 1
276 Differential Equations: A Problem Solving Approach Based on MATLAB
3
g ( t ) = . (5.185)
4
x1 ( 0 ) 1
= . (5.186)
x2 ( 0 ) −1
The set of differential equations are
x1' ( t ) = x1 ( t ) + x2 ( t ) + 3, x1 ( 0 ) = 1
(5.187)
x2' ( t ) =
4 x1 ( t ) + x2 ( t ) + 4, x2 ( 0 ) =
−1
The equilibrium or the critical point of the non-homogeneous system is obtained
using eqn. (5.176)
1
−
x10 1 1 −3 3
−1
= = . (5.188)
x20 4 1 −4 − 8
3
The phase plane plot for the non-homogeneous system and the homogeneous system
are given. They show that the critical point matches the values in eqn. (5.188) for
the non-homogeneous system described by the differential equations in eqn. (5.187).
Using the new critical point, the new initial conditions are
4
α ( 0 )= x1 ( 0 ) − x10=
3
. (5.189)
5
β ( 0 )= x2 ( 0 ) − x20=
3
The equivalent set of homogeneous differential equations is
4
α ' (t ) =α (t ) + β (t ) , α ( 0) =
3
(5.190)
5
β ' ( t ) =+
4α ( t ) β ( t ) , β ( 0 ) =
3
The eigenvalues and eigenvectors of the coefficient matrix are
1
− 2
λ1 =
−1 v1 =
1 . (5.191)
1
λ2 3=
= v2 2
1
First Order Coupled Differential Equations with Constant Coefficients 277
Figure 5.23 Phase portrait associated with the non-homogeneous system in Example # 5.14. The critical
point is not located at the origin.
Figure 5.24 Phase portrait associated with the modified homogeneous system in Example # 5.14. The
critical point is now at the origin.
278 Differential Equations: A Problem Solving Approach Based on MATLAB
e−t e 3t
= X 1 X 2 2
X ( t ) =
2 . (5.196)
−t
e e3t
The solution to the set of homogeneous differential equations is
e−t
e 3t
−
xh ( t ) =b1 X 1 + b2 X 2 =b1 2 + b . (5.197)
−t 2 23t
e e
The particular solution set is obtained using the expression in eqn. (5.133) as
1
− 3
x p ( t ) = . (5.198)
− 8
3
First Order Coupled Differential Equations with Constant Coefficients 279
The solution set can now be expressed as the sum of the homogeneous and particular
solutions as
1
e−t e 3t −
x1 ( t ) − 3
= b1 2 + b2 2 + . (5.199)
x
2 ( t ) −t 3t 8
e e −
3
Applying the original initial conditions given in eqn. (5.186), the two constants b1
and b2 become
1
−
1 2
b
b = . (5.200)
2 13
6
Substituting b1 and b2 in eqn. (5.199), the solution set of the non-homogeneous set
becomes
1 − t 13 3t 1
e + e −
x1 ( t ) 4 12 3 .
= (5.201)
x ( t )
2 − e + e − 8
1 − t 13 3 t
2 6 3
Notice that the solution sets in eqn. (5.195) and eqn. (5.201). Furthermore, it can be
seen that the particular solution in eqn. (5.198) matches the equilibrium or the critical
point in eqn. (5.188). It should be noted that the approach based on converting the non-
homogeneous system to an equivalent homogeneous system with a new set of initial
conditions works only when the forcing functions are numbers, with the coefficient
matrix being invertible.
In eqn. (5.205),
λk t
k (t )
x= v=
ke X k=
, k 1, 2,..., n . (5.206)
The distinct eigenvectors are represented by vk and the corresponding eigenvalues
are λk . The fundamental matrix associated with the set of differential equations is
X ( t ) = X 1 X 2 X n . (5.207)
First Order Coupled Differential Equations with Constant Coefficients 281
In eqn. (5.210),
X ( 0 ) = X ( t ) t =0
(5.211)
xp (0) = xp (t )
t =0
The power of (-1) on the right hand side of eqn. (5.213) implies the inverse of the
matrix. Once c is substituted in eqn. (5.208), the complete solution is obtained.
{ −1
}
x ( t ) =L−1 [ sI n − A] x ( 0 ) + L ( g ( t ) ) . (5.214)
282 Differential Equations: A Problem Solving Approach Based on MATLAB
5.3.3 Examples
Example # 5.15 Consider the coefficient matrix A, initial conditions x ( 0 ) and the
forcing function g ( t ) given by
0 −1 1
A = 0 2 0 . (5.215)
−2 −1 3
0
x ( 0 ) = 0 .
(5.216)
1
1
g ( t ) = t .
(5.217)
e − t
The coupled differential equations can be expressed as
x1' ( t ) =
− x2 ( t ) + x3 ( t ) + 1
x2' ( t ) 2 x2 ( t ) + t
= . (5.218)
x (t ) =
'
3 −2 x1 ( t ) − x2 ( t ) + 3 x3 ( t ) + e −t
2
xh ( t ) X=
= (t ) c c2 e 2t (5.221)
e ( c1 + c3 e )
t t
Using the method of variation parameters expressed in eqn. (5.133), the particular
solution set is given by
e−t t 9
− −
6 2 4
t 1
x p ( t )= − − . (5.222)
2 4
−t
e t 7
− 6 − 2 − 4
The complete solution is the sum of the homogeneous and particular solutions and
the solutions set is given as
et e−t t 9
( 2c1 − c2 e + c3 e ) +
t t
− −
2 6 2 4
t 1
= x (t ) c2 e 2t − − . (5.223)
2 4
e−t t 7
e ( c1 + c3 e ) −
t t
− −
6 2 4
Applying the initial conditions in eqn. (5.216), the unknown constants are
3
c1 2
1
c = c2 .
= (5.224)
4
c3 17
12
Substituting the constants from eqn. (5.224), the solutions set for the differential
equations in eqn. (5.218) becomes
7 2t 3 t e − t t 9
e + e + − −
12 2 6 2 4
e 2t t 1
x (t )
= − − . (5.225)
4 2 4
17 2t 3 t e − t t 7
12 e + 2 e − 6 − 2 − 4
284 Differential Equations: A Problem Solving Approach Based on MATLAB
Based on the relationship of the Laplace transforms and differential equations given
in eqn. (5.214), the Laplace transform of the solution set becomes
−2 s 3 + 4 s + 1
− 2
s ( s − 1)( s + 1)( s − 2 )
1
xL ( s ) = . (5.226)
s2 ( s − 2)
4 3 2
− − s − 2s + 2s + 3s + 1
s 2 ( s − 1)( s + 1)( s − 2 )
Taking the inverse Laplace transform, the solution set obtained matches the set in
eqn. (5.225).
Example # 5.16 Consider the coefficient matrix A, initial conditions x ( 0 ) and the
forcing function g ( t ) given by
−1 −1 1
−1 2 −1 .
A= (5.227)
−1 1 0
0
x ( 0 ) = 1 .
(5.228)
1
te − t
g ( t ) = e − t . (5.229)
et
The coupled differential equations can be expressed as
x1' ( t ) =
− x1 ( t ) − x2 ( t ) + x3 ( t ) + te − t
x2' ( t ) =
− x1 ( t ) + 2 x2 ( t ) − x3 ( t ) + e − t . (5.230)
x (t ) =
'
3 − x1 ( t ) + x2 ( t ) + e t
Equation (5.231) shows that the coefficient matrix is defective because distinct
eigenvectors do not exist for the pair of equal eigenvalues. This requires the generation
of generalized eigenvectors (vg 2 and vg 3) for the eigenvalue pair. These can be obtained
using the method described in Appendix D and they are
1 1
−
2 2
= v2 =
λ2,3 1= v3 . (5.232)
1 0
0 1
The fundamental matrix becomes
−t et et
2e −
2 2
3t 3et t
X
= ( t ) e−t et + 1 −
. (5.233)
2 2
3et t 3t
e−t −e t − 1
2 2
Using a set of unknown constants to be determined, the solutions to the associated
homogeneous set of differential equations become
c c
2c1e − t − 2 et + 3 et
2 2
− t c2 t 3c3tet
xh ( t=
) X () 1
t c
= c e + e ( 3 t + 2 ) − (5.234)
2 2
t
− t 3c2 te c3 t
c1e + 2 − 2 e ( 3t − 2 )
Using the method of variation parameters expressed in eqn. (5.133), the particular
solution set is given by
e −t
( 2t − e 2t + 2te 2t + 2t 2 + 1)
4
xp (t ) = e −t
( 4t − e 2t
+ 2 te 2t
− 6t 2 2t
e + 2t 2
+ 1)
. (5.235)
8
− t ( 4t − e + 10te − 6t e + 2t + 5 )
2t 2t 2 2t 2
e
8
286 Differential Equations: A Problem Solving Approach Based on MATLAB
The complete solution is the sum of the homogeneous and particular solutions and
the solutions set is given as
−t c2 t c3 t
2c1e − e + e + e −t
( 2t − e 2t + 2te 2t + 2t 2 + 1)
2 2 4
c2 t 3c3te t
( 4t − e 2t
+ 2te 2t
− 6t 2 2t
e + 2t 2
+ 1)
x () 1
t
=
(5.236)c e −t
+ e ( 3t + 2 ) − + e −t
.
2 2 8
− t 3c2 tet c3 t ( 4t − e + 10te − 6t e + 2t + 5 )
2 t 2 t 2 2 t 2
c1e + 2 − 2 e ( 3t − 2 ) + e
−t
8
Applying the initial conditions in eqn. (5.216), the unknown constants are
1
c1 8
7
c = c2 .
= (5.237)
8
c3
3
8
Substituting the constants from eqn. (5.224), the solutions set for the differential
equations in eqn. (5.218) becomes
e −t
( t − e 2t + 2te 2t + 2t 2 + 1)
2
( 2t + 3 e 2t
+ 4te 2t
− 3t 2 2t
e + t 2
+ 1)
x ()
t = e −t
. (5.238)
4
− t ( 2t + e + 8te − 3t e + t + 3)
2t 2t 2 2t 2
e
4
Based on the relationship of the Laplace transforms and differential equations given
in eqn. (5.214), the Laplace transform of the solution set becomes
s3 + 3
( s − 1) ( s + 1)
3 3
− s 5 − 2 s 4 + 2 s 3 + 7 s 2 + 3s + 3
xL ( s ) = − . (5.239)
( s 2 − 1)
3
− s 5 − 2 s 4 + 5s 2 + 5s + 5
−
( s 2 − 1)
3
Taking the inverse Laplace transforms, the solution set obtained matches the set in
eqn. (5.238).
First Order Coupled Differential Equations with Constant Coefficients 287
Example # 5.17 Consider the coefficient matrix A of size [4 x 4], initial conditions
( ) and the forcing function g ( t ) given by
−1 0 0 0
0 −1 0 1
A= . (5.240)
0 0 1 −1
0 0 0 1
0
1
x ( 0 ) = . (5.241)
1
−1
et
−t
te
g ( t ) = − t . (5.242)
e
t
The set of differential equations associated with the coefficient matrix is
x1' ( t ) = − x1 ( t ) + et
' −t
2( )
x t = − x2( )
t + x 4( )
t + te . (5.243)
x3' ( t ) = x3 ( t ) − x4 ( t ) + e − t
4 (t ) x4 ( t ) + t
'
x=
The eigenvalues of the matrix are
λ1,2 = 1
. (5.244)
λ3,4 = −1
The difficulties arise because the coefficient matrix only has three eigenvectors,
0 1 0
0 0 1
, ,
1 0 0 . (5.245)
0 0 0
There is a need to determine which of the eigenvalues are degenerate so that appropriate
generalized eigenvectors can be created. To find this out, the first step is to determine the
eigenvectors associated with the eigenvalue of 1. These are obtained as the solution of
( A − λ I4 ) =
0 . (5.246)
288 Differential Equations: A Problem Solving Approach Based on MATLAB
c4 et − t − 1
Applying initial conditions, the constants become
1
c1 − 2
c2 1
=c = 7 . (5.254)
c3
c4 2
0
The solutions set now becomes
sinh ( t )
2 −t
e−t + t e − t
2
x (t ) = −t . (5.255)
7
e −t − e
t
− 2
2 2
− t − 1
290 Differential Equations: A Problem Solving Approach Based on MATLAB
1 0 0 0
0 1 0 0
A= . (5.257)
1 4 −3 0
−1 −2 0 −3
1
1
x (0) = . (5.258)
1
−1
e −3t
3t
te
g ( t ) = t . (5.259)
e
t
t + e
The set of differential equations associated with the coefficient matrix is
1 (t ) x1 ( t ) + e −3t
x= '
2 (t ) x2 ( t ) + te
' 3t
x=
x3' ( t ) =x1 ( t ) + 4 x2 ( t ) − 3 x3 ( t ) + et . (5.260)
'
x4 ( t ) =− x1 ( t ) − 2 x2 ( t ) − 3 x4 ( t ) + t + e
t
The matrix is not defective because four distinct eigenvectors exist. These are
0 0 −4 −8
0 0 2 2
, , , . (5.262)
1 0 1 0
0 1 0 1
The first two eigenvectors are associated with the eigenvalue of -3 and the other two
are associated with the eigenvalue of 1. Using the eigenvalues and paired eigenvectors,
the fundamental matrix becomes
0 0 −4et −8et
0 0 2et 2e t
X ( t ) = −3t (5.263)
e 0 et 0
−3t
0 e 0 et
The solution for the homogeneous set is
−4et ( c3 + 2c4 )
2et ( c3 + c4 )
xh ( t ) = . (5.264)
c3 et + c1e −3t
t −3t
c4 e + c2 e
The particular solutions set is
e −3t
−
4
e 3t
( 2t − 1)
4
x p ( t ) = −3t . (5.265)
e
− 144 ( 36t − 36e + 32e − 48te + 9 )
4t 6t 6t
−3t
t e e3t et te −3t te3t 1
3 + 16 + 9 + 4 + 4 − 6 − 9
Combining the homogeneous and particular solutions, the general solution becomes
e −3t
− 4 e t
( c3 + 2c4 ) −
4
3t
e
2e ( c3 + c4 ) +
t
( 2t − 1)
4
x (t ) = −3t
. (5.266)
t e
c3 e + c1e − 144 ( 36t − 36e + 32e − 48te + 9 )
−3t 4t 6t 6t
t −3t t e −3t e3t et te −3t te3t 1
c4 e + c2 e + 3 + 16 + 9 + 4 + 4 − 6 − 9
292 Differential Equations: A Problem Solving Approach Based on MATLAB
−3t 3t t −3t 3t
t − 5e + e − 11e + te − te − 1
3 16 9 16 4 6 9
The Laplace transforms become
5 1
−
4 ( s − 1) 4 ( s + 3)
( s − 3) + 1
2
( s − 1)( s − 3)
2
X (s) = . (5.269)
s 4 + 2 s 3 − 23s 2 − 20 s + 156
( s − 1) ( s − 9 )
2 2
6 5 4 3 2
− s − 2 s − 12 s + 18s + 48s − 36 s + 27
s 2 ( s − 1) ( s 2 − 9 )
2
Taking the inverse Laplace transforms, the solution set matching the one in eqn.
(5.268) is obtained.
Example # 5.19 Consider the coefficient matrix A of size [4 x 4], initial conditions
x ( 0 ) and the forcing function g ( t ) given by
−1 −4 0 0
1 3 0 0
A= . (5.270)
1 2 1 0
0 1 0 1
First Order Coupled Differential Equations with Constant Coefficients 293
1
−1
x ( 0 ) = . (5.271)
1
−1
et
t
te
g ( ) 2 −t .
t = (5.272)
t e
4
The set of differential equations associated with the coefficient matrix is
x1' ( t ) = − x1 ( t ) − 4 x2 ( t ) + et
x2 ( t ) =x1 ( t ) + 3 x2 ( t ) + te
' t
x3' ( t ) = x1 ( t ) + 2 x2 ( t ) + x3 ( t ) + t 2 e − t . (5.273)
x4' ( t ) = x2 ( t ) + x4 ( t ) + 4
The eigenvalues of the matrix are
λ1,2,3,4 = 1 . (5.274)
The matrix is defective because only two distinct eigenvectors exist,
0 0
0 0
, (5.275)
1 0
0 1
Because all the eigenvalues are equal and the matrix is defective, this case can be
treated as an example of a defective matrix with algebraic multiplicity of 4. The four
generalized eigenvectors in this case constitute an identity matrix of size 4 and these
eigenvectors are
1 0 0 0
0 1 0 0
, , , . (5.276)
0 0 1 0
0 0 0 1
Using the eigenvalues and generalized eigenvectors, the fundamental matrix becomes
−et ( 2t − 1) −4tet 0 0
te t
e ( 2t + 1) 0
t
0
X (t ) = te t
2tet et 0 (5.277)
2 t
t e
et ( t 2 + t ) 0 et
2
294 Differential Equations: A Problem Solving Approach Based on MATLAB
12
t 3 et t 4 et
+ −4
3 12
Combining the homogeneous and particular solutions, the general solution becomes
tet ( 2t 2 + 3t − 3)
−et ( 2c1t − c1 + 4c2 t ) −
3
2 t
t e
et ( c2 + c1t + 2c2 t ) + ( t + 1)
3
x ()
t = −t . (5.280)
e
et ( c3 + c1t + 2c2 t ) −
12
( 6t − 6 t 2 2t
e − 4t 3 2t
e + 6t 2
+ 3 )
et ( 2c4 + 2c2 t + c1t 2 + 2c2 t 2 ) t 3 et t 4 et
+ + −4
2 3 12
Applying initial conditions, the constants become
1
c1 −1
c2
=c = 5 . (5.281)
c3
4
c4
3
First Order Coupled Differential Equations with Constant Coefficients 295
5.4 Numerical Solutions
It is clear that as the size of the coefficient matrix increases, the complexity involved in
obtaining the solutions using eigenvalues and eigenvectors increases because defective
matrices require detailed exploration to identify the degenerate eigenvalues and obtain
the appropriate set of generalized eigenvectors. On the other hand, the approach based
on Laplace transforms is clear, straightforward and formulaic and therefore, it can
be implemented easily. In addition to these analytical approaches, it is also possible
to use the Runge-Kutta methods for the numerical evaluation of the solutions. The
use of numerical approaches also permits another level of verification of the results.
296 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 5.20 An example of a 3 x 3 coefficient matrix and the set of coupled first
order differential equations is now presented. Consider the coefficient matrix A, initial
conditions x ( 0 ) and the forcing function g ( t ) given by
2 −1 −1
−1 2 −1 .
A= (5.284)
−1 −1 2
0
x ( 0 ) = −1 .
(5.285)
1
t
g ( t ) = t 2 .
(5.286)
et
The coupled differential equations can be expressed as
x1' ( t ) = 2 x1 ( t ) − x2 ( t ) − x3 ( t ) + t
x2' ( t ) =
− x1 ( t ) + 2 x2 ( t ) − x3 ( t ) + t 2 . (5.287)
x (t ) =
'
3 − x1 ( t ) − x2 ( t ) + 2 x3 ( t ) + e t
The approach based on Laplace transform is used to get the analytical solutions and
the numerical solutions are obtained using ode45 in MATLAB. The MATLAB script
and results are given.
function example_numerical_firstorder_multiple
% June 2017 p m shankar solve a coupled system using Laplace transforms and
% compare the results to those obtained numerically
close all
A=[2,-1,-1;-1,2,-1;-1,-1,2]; % coefficient matrix
xx0=[0; -1; 1];% initial conditions
syms t s;
ft={t;t^2;exp(t)}; % forcing functions
B=(s*eye(3)-sym(A)); % this sI-A
F=laplace(ft,t,s); % Laplace transforms of forcing functions
W=inv(B)*(F+xx0); % Laplace transforms
w=simplify(ilaplace(W,s,t),‘steps’,100); % inverse Laplac: solution set
% create inline MATLAB functions for the analytical solutions
fy1=MATLABFunction(w(1,1));
fy2=MATLABFunction(w(2,1));
fy3=MATLABFunction(w(3,1));
tspan=[0 5]; % time span for numerical integration
[tt,yy]=ode45(@examplef,tspan,xx0);
plot(tt,fy1(tt),‘r’,tt,yy(:,1),‘r*’,tt,fy2(tt),‘k’,tt,yy(:,2),‘ko’,...
tt,fy3(tt),‘b’,tt,yy(:,3),‘bs’,‘linewidth’,1.5)
First Order Coupled Differential Equations with Constant Coefficients 297
xlabel(‘time t’),ylabel(‘solutions’)
legend(‘x_1(t)-analyt’,‘x_1(t)-ode’,‘x_2(t)-analyt’,‘x_2(t)-ode’,...
‘x_3(t)-analyt’,‘x_3(t)-ode’,‘location’,‘southwest’)
syms x_1(t) x_2(t) x_3(t)
% for solution display on the plot
yt1=[x_1(t)==w(1,1)];
yt2=[x_2(t)==w(2,1)];
yt3=[x_3(t)==w(3,1)];
text(0.5,4e6,[‘$’ latex(yt1) ‘$’],’interpreter’,‘latex’,...
‘fontsize’,16,‘color’,‘b’,’‘fontweight’,‘bold’)
text(0.5,3e6,[‘$’ latex(yt2) ‘$’],‘interpreter’,‘latex’,...
‘fontsize’,16,‘color’,‘b’,‘fontweight’,‘bold’)
text(0.5,2e6,[‘$’ latex(yt3) ‘$’],‘interpreter’,‘latex’,...
‘fontsize’,16,‘color’,‘b’,‘fontweight’,‘bold’)
end
function dydt = examplef(t,y)
dydt=zeros(3,1);
dydt(1,1)=t + 2*y(1,1) - y(2,1) - y(3,1);
dydt(2,1)= -y(1,1)+2*y(2,1) - y(3,1)+t^2;
dydt(3,1)=exp(t) -y(1,1) - y(2,1)+2*y(3,1);
end
298 Differential Equations: A Problem Solving Approach Based on MATLAB
5.5 Examples
Part 1 A pair of first order equations
Starting with the theoretical descriptions of the methods for solving the pair of
equations. The MATLAB script displays the following:
1. The summary of all the theoretical methods used are shown first. The methods
are based on the use of eigenvectors and eigenvalues (including the case when
the coefficient matrix is defective), conversion into a second order homogeneous
equation of constant coefficients and the Laplace transforms.
2. The phase plane plot is shown with the eigenvalues and the state of equilibrium.
3. The mechanics of forming the solution using the eigenvalues and eigenvectors
are illustrated next. The results contain the eigenvalues (indications when they
form a complex conjugate pair) and, eigenvectors (the need for generalized
eigenvectors if the matrix is defective).
4. The general solution is shown and the unknown constants are evaluated based
on the initial conditions.
5. The approach based on Laplace transforms is presented next along with the
transforms of the two solutions and the solution.
6. The solution obtained directly using MATLAB command dsolve(.) is also shown.
7. The numerically obtained solution is obtained and compared to the analytical
solution in plots.
8. The set of first order equations is converted to the second order equation and is
shown with the roots of the characteristic equation (same as the eigenvalues) and
the solution is derived, constants evaluated, one of the solutions is determined
first and using the input set, the second solution is extracted. The display also
indicates whether x(t) or y(t) was obtained first. If the two differential equations
are independent, dx/dt=ax and dy/dt=by, a statement indicates that the equations
are not coupled.
Example # 5.21
A=[1,2,3,2,1,0];
First Order Coupled Differential Equations with Constant Coefficients 299
Characteristic
300 Differential Equations: A Problem Solving Approach Based on MATLAB
( '?-" -' )
c,+oa_ O
x, ( l..
)
.
• ' ( l"'+~)
I
...(), .. h' j'" 'I
Solutions (Inv..... Lllplaoo,dsolv.(.) & Ru nge-KutlJl)
,~ i---,=::;:C'il
.-
"
...
~
,~
-+-~ -+-~
- ,~
-+-<
~1000
-+-,
" ~
.. , ~ , ~,
~
•• •• •• ,
lime , limet
First Order Coupled Differential Equations with Constant Coefficients 301
Example # 5.22
A=[-1,0,-2,-3,-1,1];
Characteristic
302 Differential Equations: A Problem Solving Approach Based on MATLAB
( r(I) .. - .ail) )
"(I)_ - b(I) -3,(1)
• , , ,
, ,I ii ~I
, ,
,
,- , ,
, I I
-,
~, I
• ,
I , I
,
I
, I I
I
,, I
-
I
, , ,
fi1t I
1 1 , ,
• , ,
• ·OJ
• •
e-pIOliO ... _ , , .. , of f lrol 0nS0r Uroe .. O_nII.. E q _
......" ( - ' 0 ) ~w (
-!AI -2 - 3 E.,...,.. VI') r(I)
_ -2":r(I)
- z(l)
_ 3V(I)
)
IC
(-')
I
Iigt_...,..
......,
ReIl.<'II:I \IIOllnd ......... ,
E;,oo" ' • (' ) (: -,')
-.-,-, )
--
--
...... -
,,(1) _ q ,,-,
( '"-.--,
+ '" ,,~..
)
--
+.,, _ 1
:r.(I) _ -e~ '
,-"."--~..
~ ...,. ,,(I) _,,-<
First Order Coupled Differential Equations with Constant Coefficients 303
',----;::=.~
.-
-~M
-.-~
-.-<
., , , ,, ,
05
....,
1 15 05
.,.,
1 1.5
( ~'
-2 - 3
0) E"*",,,"
M_~ ( ,,(» - ~.{ .)
11'(1) _ _ 2:«t) _ 3y{IJ
)
Ie
(-.)
I
:r,(t) = - e-'
y,(I) :e- '
304 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 5.23
A=[0,1,0,-2,0,1];
Characteristic
First Order Coupled Differential Equations with Constant Coefficients 305
GoMoll '".(' ) - CJ - T•
zdl) -~-~
~dl ) "'e- 2 !
-..
"4 (' ) -
",(,)
t - .y.
-"
.0 r------;~;~J
- "
~"" -+-d
.- ".,
~.
, ,
011
....,
1 1..5 0..5
.... ,
1 U
306 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 5.24
A=[1,-1,-1,1,1,-1];
Characteristic
First Order Coupled Differential Equations with Constant Coefficients 307
• Ei(jono_I A) .. (~ )
Or-. eIg ........
UNSTAelE
z... _11>0 _ ....
•
,
"
,,' ' , ",
,, , ", ", ,
,
,
,
,
, , ,
~o
", , , ,
", , , , ""-
., ,
,
, , ,
""-
"-
"-
• , ,
,
"
"-
"- , ,"
,,"-
.•., , • •
~" (' - ') ~W (:r(t)"Z(t) _ ~(t»)
_I... -1 I E~ I/"(t) - !/I:t)-r(t) <( ")
E..........
~)
(6)
(: ~' )
",.(t) .. c,-qe"
!Io(t) - c, + qe"
· [~l - ( -o) )
r .(t) _ .I'
,..(t) _ -e"
308 Differential Equations: A Problem Solving Approach Based on MATLAB
--
__ La,....,. %, (1) _ etl
--
~~ ,)
¥t(t ) - -el'
2:01(1) - c"
...ell -_"
,
~
- M .
-" -
~
-+-4 ~
-+-~
~.
~ • ~"
•
~ ~
,, , , ~
, , ,
" ."., " " ."" "
2" order Oltr.l .. ,U" Equ.uon - . . ...Iutlon ut
%1(t ) - ~ + b,c"
,,(1) _ .. - 6,."
- .. ~-
Ib,.,:!' "
%,(1) _ ';"
(. I)
¥I (t ) _ -fIl'
For the remaining examples, the first display containing the theoretical aspects is not
shown.
First Order Coupled Differential Equations with Constant Coefficients 309
Example # 5.25
A=[1,-1,-1,-1,0,1];
310 Differential Equations: A Problem Solving Approach Based on MATLAB
--
----
-0
~. , ~-
•
•
~
•
~.
~
•
;;.-~.
I
, ,
• 0
" ....
• "
2" O<'dIo.DI"", .. ,UIII EqullllDn _
0
0
" ....
• "
d ...1uIIoro MIl
~.( '
_I.of -1 - 1
- ')~_( ""(1) _ ,,(1)_,(1» )
E...... V(I) - -,,(I)-,(t) IC
(OJ
1
~_In_
• •."" ( -f f)
"'L (t) - -~
1tL (t ) ,., .-.10 ( ';"'-:,."'" ~.., ••)
First Order Coupled Differential Equations with Constant Coefficients 311
Example # 5.26
A=[-1,2,-1,1,2,1];
312 Differential Equations: A Problem Solving Approach Based on MATLAB
.,Lil) .. 2 COA(I)
'L(t ),., COA(I) - sin( l)
",,(I) .. 2 000(1)
. ...,
o
'---------'
0.5 1 1.5 2
p>,.to,l .. (2 0)
Example # 5.27
A=[-3,1,-4,2,-1,1];
314 Differential Equations: A Problem Solving Approach Based on MATLAB
---
110m Dir...."... e"",
Xt(_) .. . I .~t - ..~::t
Yt (.j .. ..f.:t + ,,'2,
--
,....... La..,.
!Set,.: ,'"
" - if'
zdl) " T - ---r
lIdl) ..
~(I )-If-¥
If "'"
~-..c .)
.,.,(Il-¥-¥
• »I-r~,.;:;
-.-,.
•
Ii'
,
-j; "
•
10
.-
~.
,~ ,
, M
...,, u , , 0.5
~.(-3
-IAI - 4
')
2
~_~( z'(t) _ ~(t) _ b( t»)
E~_ V(t) .. 2,(1) _ b (l ) IC
(_')
I
Example # 5.28
A=[1,0,-2,1,1,0];
316 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 5.29
A=[0,1,-1,-2,1,-1];
( .'(.,- ,
~(I) '"
•.
First Order Coupled Differential Equations with Constant Coefficients 317
-:1(1) - 2,(1)
EopI .... _ _
)
, ,
• (.....-Clj.. ( : : )
,
QJ.Pl:ITABU_
• , ,
, , ,
- , ,\ ~ ~\
\
, \ \
\
\
\ \
, , \ \
j;o
\
\
,
~ ~ \ ,
-
\
\
,, ,, ,
,
\
, ,
, ,
\ \
\
•
\
,
,
,
•
• . •., , • •
Complollt'''_ P... ol'l. . o.do<u.. .. Orw. ..... fq ...........
__ ("-'(t+ l) Ie.... )
[go .t', I (_-I -I e-' -<I- I (t - I )
-...
w,(t) ... -co , ,,-' - ,,>11- ' (I - I )
-~.
.... ( ",<,__
a 'I ) -[~J- (~,)
318 Differential Equations: A Problem Solving Approach Based on MATLAB
•• 0.5
....
1 1.!i , .• ....
- 0.5 1.!i ,
~"('
MMIb;[AI - I • )~_w(
-2 E__ V{I) 0'
.. ,-z{l
., -""
) _ 2 ~I) ) IC_
('L)
A""O . Croue EquaLionin~ . J (I) +I>i{I)+cz(I) _ O
E~ 2'" _ . DE In . _dlNo. ... _ E q . -
z'"(I) + 2z'(1) + z {t) .. 0 ( _L _ I )
Example # 5.30
A=[2,0,0,2,1,1];
320 Differential Equations: A Problem Solving Approach Based on MATLAB
--
lramDil._otIoIf:.,.
z d l ) • tI,
--
-~-
--,
, d' )-e"
%J(I) '" <I'
l1li1 ) ... <I'
.-
~
-M -~
-
~
-+-d ~
-+--
~.
•
~
»
• ~
»
•
,, ,,
,
" .... , "
, ,
" ,"
,
...
2:" ordotr DlfhAntlll EqUlll10n INIMd .olutlon Nt
~.
Mlir\o tAl un ~ ... ( r(l ) _ b (l ) )
EquIIlont 11'(1) '" 2~ 1) ·(:l
" 12"":2,"0 .. No E........ nt 2"" _ , ..... ntiol E()'t; E"' ...... _ .... , .........
""Iof..,,1or1t Fill' 0rII0, DiIIorontlll E"'......
"1 (1) "' '' " .
10>(1)- " '"
( I I)
First Order Coupled Differential Equations with Constant Coefficients 321
Example # 5.31
A=[2,2,-2,-2,-1,-1];
322 Differential Equations: A Problem Solving Approach Based on MATLAB
zt!I) - -<4I 1 - 1
~dl )- 41 - 1
z.(I) _ - 41 - I
111<1)_ 41 _ 1
,·r---------r==e.;cill
•
•J
-.
~~
1c.'-.,.,"
1. . . . . . . . .
0.5
...,
1 1.5 ,
(-1- 4 )
ZI(I) __ 41 _ 1
1/1(1)_ <411 _ 1
First Order Coupled Differential Equations with Constant Coefficients 323
Example # 5.32
A=[1,1,-2,1,1,0];
324 Differential Equations: A Problem Solving Approach Based on MATLAB
---
""'" cw:.. ..... ~ YL(_l -
x.(., .
L
,-1
"'_ hU
.d .+l
e' ooe{ .,./21)
:l"i.(I) _
--
'*"II """"'"I .)
IIdt) - - ./'ie' .m(v'2I)
,...(t) _ " ""(~ I)
1/.(1) - - ..12..' ,.; n( "" , )
( I+ Ji' 1_,,1; , )
-- V..tftc.tlo ..
•
~
~
,,
~.
.
•
-
-+- .
,~
" " " " ..., "
,
V_CIIIJon
u u ,
-+-.
-
~
~ ~"
•
~Iow
~_.. ( r (t )- :l:(t)+V(t) + 3 )
Equllm V(t )_ b {t) + y(t )+ 4
;r.. (t)-'i+~- l
".(1) - Uf - or - I
SaIulloI'I'" "'*G -..;.)
:l:4(t) - c; + ~ - 1
",'l - "I' - 'T - !
First Order Coupled Differential Equations with Constant Coefficients 327
Example # 5.34
abc=[1,1,0,2,1,0];gt1=‘t*exp(2*t)’;gt2=‘exp(t)’;
328 Differential Equations: A Problem Solving Approach Based on MATLAB
Verlflc:atlon
l~
M
~
loo
•• .. .. .. ... ,
-+-d
~.
• - ,
" l
" U l .'
"
Verlflc.tlon
00
~
00 -+-~
~ -:-~
~
••
" .. .. .. ... , l
" U l.'
"
,
~w
,-
".....".,Sciulon
~
( %'(1) _ 0:(1) + ~(I) + I';' )
VI') - t! + 2~(1)
_Ow
,- (:)
[ <,"l I ( -.I (I +~;t.t + I»)
M'l -
Conci\i(>",
0:.(1) _ .I (1.1 - I + I)
~(I ) ~ e' (.I - I )
Sck.tlon ... """"0 _11(. )
~(I) _ .I (1.1 - j + I)
1141) _.I (.I - I)
First Order Coupled Differential Equations with Constant Coefficients 329
Example # 5.35
abc=[-1,-2,1, -1,-1,1];gt1=‘t’;gt2=‘exp(t)’;
330 Differential Equations: A Problem Solving Approach Based on MATLAB
, ,
,
·, ,
~ .
...-.
•-
~
, ~
...-.'"
, --:-;:;"'1
,, ,. , " ,.. U ,
" " " "
,-
timet
_Ow
~~
Eq.at_
(0:'(1)_1 - :«1) _ 2,(1) )
V(I) _ .t + ,,(I) - Jl(1) Condliono ( ~' )
PA'tiaA,SoIulOn
~ [""'
'''<')1 -
( 1-)+1)
\+.-
V_ion ~ ._ftulion in "'" _ _ Eq .... ionft
M.. t be • NUU v.c:IOt
First Order Coupled Differential Equations with Constant Coefficients 331
Example # 5.36
A=[-1,-2;1,-1];x0=[-1 1];gt={‘t’;‘exp(t)’};
332 Differential Equations: A Problem Solving Approach Based on MATLAB
-.
Particular.rId Complete Solution.
oIII - ~I) + 1(1}
,-
FWId-ul .... Mr. of fit ...
Conditioi'll ...
X (t ) _ IX,(I ), X,(t), ... ,X. (t)]
1 (0) .
"CO,
..:(~)
( ...(0)
)
1(1) _ X(I)HJ',( t)
a %, (I) _ I _ Z,(I )_ h , (I » )
( r,(t) _.t + :r,(f) - :r,{tl
"
First Order Coupled Differential Equations with Constant Coefficients 333
--,
_1_1.41 1 1).1.411G> I ,.. ,1
EIgorJtr- _1"."1 1 ~ .. ' . ,.0; 1 to;
! - ~ - .j2e -1 (~oos(v'2t)+CISin(.j2t»+i)
( ! + ~ +e-' (CI oos(v'2t) - Co.! sin(v'2 t)) - ~
334 Differential Equations: A Problem Solving Approach Based on MATLAB
Particular
(t)
First Order Coupled Differential Equations with Constant Coefficients 335
.... n1 •
,- i _. ' (''''':''''):''' '''i'''')) +1
i +i + .. ,-;<".) - '''''';-<'''') - J
.....
...-,..
V~P'
-
VL, t<V.,,)ooo (:)
, + j+
t.' ....:",,). ,"=;<...,
i-f - .. , =< ,.,,_,~ +1
-I
336 Differential Equations: A Problem Solving Approach Based on MATLAB
., .-,
-- ~ "· '10' I ':
.~~~~--~--~--~~
o • 2 25 3
O~ 1~
T_
1 ~ 8o-'m(v'f')_'./!'-'oH(A')_1
3+3 + !I [8 !I
:~~~ o 15 2 25 3
"'"
First Order Coupled Differential Equations with Constant Coefficients 337
Example # 5.37
abc=[2,-5,1,-2,0,1];gt1=‘-cos(t)’;gt2=‘sin(t)’;
338 Differential Equations: A Problem Solving Approach Based on MATLAB
- <
'i
." ;~
·n
" 02
"' .. ,
"' 'm." " "
,. u ,
, V.nticatlon
j[ "
• ~
•
~.
•
" 02
......, "
"' "' "'_
,
"
,. U ,
~w (z'(t)_2%(t)_C<III( I)_6~1)) , _ (:)
E,._ vet) _.in(t) + z(l) _ 211(1) Coro\W'J,..
PIII_'ScIu"'"
HI
[Z'('lj
M' l
_ (2tcoo(t) -~-~- t li"(t) )
j wo(t)-~-~
vto¥ ,...,..,..-.-IftIlll __ E q _
IoIoaIbeIN.Al. _
_ ... uotroelg· .. _ .. \ $.
z..{t ) _ 21 ~oo(t) - 8 ';11(1)- 1 ...,(1)
Example # 5.38
A=[0 -1 1;0 2 0;-2 -1 3];x0=[0 0 1];gt={‘1’;‘t’;‘exp(-t)’};
340 Differential Equations: A Problem Solving Approach Based on MATLAB
(!Z !:i)
u')
r,(I) _ :r,(I)_z,(t)+ l )
u z2(t) _ t + Z:r,(t )
• ( zl,(I) - .,- ' - 2 %, (I) - %, (I) + 3:r,(t)
0· ' 1
" ,
·2 · ' 3
--, ,
, Bg'h • •
,
,
0 ,,
. 5 ,.,,
,
Eigenvalues (3) & Eigenvec~ .. (3~ r.IaIrbc NOT dele<:tNe
First Order Coupled Differential Equations with Constant Coefficients 341
Particular
(t)
342 Differential Equations: A Problem Solving Approach Based on MATLAB
'... "r:.~'"1)
[ "'.(1)
1_ ( 0
A. 1")
~~' ) + (""
.9I~.') )
r .(I ) ,.(1)
0Z'f (0)
(O) )
(
... (0)
-
f ', AI.
I [I..... v V.~)
"i-i+~+¥-'
~ -1-1
"\f-tT-i+¥-l
- (n
-..c . ~Y.ru
., .,II~".~)oo
T-j+.r.rr+'f-t
~-I-I
"\f-'T-i+¥-i
- ,-0)
y.~)
'LfI~y.ft)oo
'i-I+.r.rr+/f-!
~ -1-\
"\f-'i-i+"f-f
.'. ,I
•
, ,
•• ., ,
- "
344 Differential Equations: A Problem Solving Approach Based on MATLAB
.I' , I
T - 2- i
' 00
~
~
I-.- ~"·"';" . . . I
ro
m
S ~
i!
• ~
ro
"
, ,
••
-.
"
,
-
"
17"' _ C _ ~ + l.!: _I
12. 2 4
"
~
I~~'
-, '~' -I
~
i~
j
•
-
'00
•• "
, ,
" ~. "
First Order Coupled Differential Equations with Constant Coefficients 345
Example # 5.39
A=[2,-1,-1;-1,2,-1;-1,-1,2];x0=[0 -1 1];gt={‘t’;‘t^2’;‘exp(t)’};
346 Differential Equations: A Problem Solving Approach Based on MATLAB
~~i{O) ( ~l )
2·' .,
__ A .,2.'
., _1 2
, .,, .,,
,
".01•••.' -' , ,
First Order Coupled Differential Equations with Constant Coefficients 347
Particular
(t)
348 Differential Equations: A Problem Solving Approach Based on MATLAB
0.,.. [,,'O
J1 ( _'O
J) (.'O
' 'r(I)J) _ A :.,(1) "'" ,.(1)
....(1) ... (1) ,.(1)
0. . . . .
_,OJ )
.... (0)
ConcMio ... ( ...{O)
.......
,.....
_'O X~.~.) 1
J) _L-' [ X"'J
~?)
( ... (1) X.(. )
i-~-*+~+'-8
i-~-;'-h + ~-H
t;+~+\t +~- H
First Order Coupled Differential Equations with Constant Coefficients 349
f-'Ifi'-~+\t+'-H
"""'"
Eigetwal..-
& EiganYKk>rs: y .tt)
f-'III"-.-'+'-H
N+"lI"+\t+t-fi
f-'Ifi'-~+\t+,-H
"""'"
ds<lMI(.~ Y4(1) f-'III"-'-'+'-fi
y,,{tt-y.lt .... 0) N+"lI"+\t+'-fi
f-'Ifi'-~+\t+'-H
f-'III"-.-'+'-H
N+"lI"+\t+t-fi
~
.- ~
I. T- .,n
'112 - .,"+~+I'
=
•
~.
••..
•
••
••
.,~
• "
, "
,
T~
350 Differential Equations: A Problem Solving Approach Based on MATLAB
~-1nf-iT-~+~-H
•
._.
I=-=-(Ie",g, lui
- ., ~
•-
.~
§
•
-..
-- ~
. ,- ..
• ,
-"
,
.~~-:--~
o 05 1.!1 2 ,
T~
First Order Coupled Differential Equations with Constant Coefficients 351
For the remaining examples, the first two displays containing the theoretical aspects
are not shown.
Example # 5.40
A=[-1,-1,1;-1,2,-1;-1,1,0];x0=[0 1 1];gt={‘t*exp(-t)’;‘exp(-t)’;‘exp(t)’};
352 Differential Equations: A Problem Solving Approach Based on MATLAB
Particular
(t)
First Order Coupled Differential Equations with Constant Coefficients 353
-- [
.".) 1 ( n'.» )+ (.10 )
~ .. (. )
... (. )
• A zo,(. )
1 .(')
n'O)
zo, (O) )
",I)
10(' )
(
1 .(0)
X,I ' )
x~.)
1_ [d . _ A)"' ( n~_O)lO) ) + 1< 1. - 'W' ( G,I ') )
~.. )
[ X.(. ) ... (0) G.(o)
nl' ) )
~~.') _ f. - '
[ X,I' )
x~.~.)
1
(
1 .(1) X.(. )
~_oA""",*"I """""'"
.,. ..,,...............
.' j, -<" ........ .. )
.' (.,~ ,)
- 0)
-.... ~ y,.ll)
",1-",'''''
. ' ("
,
• '(.. ...... '.....!
,
• '(,,·· ..... •............. ·'1
......................
•
,
-,-
',ro
')oY.~)oo
" .. ( : )
, '.... ,)
. ' (...........
.·f·..•..... ·.............. "l
•
.. (........,...............
•
)
"
•
First Order Coupled Differential Equations with Constant Coefficients 355
j
i!~
• ~.
."• ,
"
, ,
T~ "
.- ' (tt ....•... ''''-3'''''+1''')
"
• •
---
• -- " .~'.' "
"
•
•
,
S
i!
•
•
<
~
•
•
."• .. "
T_
, ,
356 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 5.41
A=[-1,0,0,0;0,-1,0,1;0,0,1,-1;0,0,0,1];x0=[0 1 1 -1];gt={‘exp(t)’;‘t*exp(-t)’;‘exp(-t)’;‘t’};
First Order Coupled Differential Equations with Constant Coefficients 357
Particular
(t)
358 Differential Equations: A Problem Solving Approach Based on MATLAB
I ...... . - cO) )
:.,(0)
Conditio.. ( r .(O)
-...,-
~
aiuh(t)
e-'-t+¥
If - 7
.-' - t - 2
- t- I
First Order Coupled Differential Equations with Constant Coefficients 359
.....
Comparison of An.lytlelll Solution.
sinh(t)
l': igBrH ...... e-'- I +¥
&EIgen\eCbra: y.(t)
,-,-t-
7.1.' ,
-I - 1
.....
dsd'.e(. ~ Y,,(I)
si nh (l)
e-' -t+ ¥
Yd(lrY.(I~ U) , -,-1-
7ft
-I - 1
.-, ,
.....
Laplaca Toallllkrm
sinh(l)
e-'- I +¥
y:~:~.(t,.. (n ,7 0-,--1-
'.'
- I -1
,
sinh(t)
360 Differential Equations: A Problem Solving Approach Based on MATLAB
,
--
e-'- t +"'-'
,
.., • -,
- - eilo· ".','g " ....
.
S .,
•
,
•
• ·u
>
.,
•• ,
"
, ,
" Tm.
Ii. ~- ,
~ -T- t - 2
ro
ro
ro
.
1:-:-;;::'·
-, -.1","'
Ji~
•
.~
':~~~o 1~
T~
2 3
First Order Coupled Differential Equations with Constant Coefficients 361
Example # 5.42
A=[-1 -4 0 0; 1 3 0 0; 1 2 1 0;0 1 0 1];x0=[1 -1 1 -1];gt={‘exp(t)’;‘t*exp(t)’;‘t^2*exp(-t)’;‘4’};
362 Differential Equations: A Problem Solving Approach Based on MATLAB
·, ... 0 0
13 0 0
12 1 0
o1 0 1
,, ,, ,,
B; " . - ,, B. " • •
,, ,,
EIganv_ (.) & E Iganv8C~f'I (2) .. MaUl. DEFECTIVE:
Generali:e<leo_eaors ftlqJltedI
,,, ,, ,, ,,
8.' .. _.
1\<:1. Goooo_-, , ,, ,, ,,
AIgebr* muIbpIicily {pi of It-. . . . . .IJ. A ~ """''''"tic rnllipUcily (m)
... G.n_lzecl9ge .... donI ... lOlJbl.of [ (A - A/.r I__ 0
-e (2c\t-cl + 4c,t)
€ (C:!+c1t+2 C:!t)
e (ea+CI t+2C:!t)
,
J (2 ", +2", Ii·~, 1'+2 ",")
Particular
(t)
364 Differential Equations: A Problem Solving Approach Based on MATLAB
""i
(. -1)
' (-"+1 •• 1)
(. - 1)'
--
l .. _ ...
o! (_lo'_,"•••o-lI)
•
.. ( ...., .....o-lI)
•
." (••-..... +I., ...-.................... o-lI)
'" 12
3e' - e;. + If- + 'if - I ~ - 4
- .. ...•
(. ~ ..• ".)
~
SGluliOn:
-<.~ y.~)
y~~y.~~ U)
- •
-
( . ,~
.
~
-
~T,._
. .............\
-
(
•
.
"( ' ''-410' ..... )
,:~:!.~~ (D · .........,....'.....................
.(
Ii
)
,
.. (- '''- 31'+g'+3)
~:~--
o
.
-,
-- ~
,~L-------------------------c---~
00.511.52 3
r_
,
"(_"_3"+3.+3)
'"I
.j---_..--
~~~~~--~--~--~~
o M 1 15 25 3
r_
366 Differential Equations: A Problem Solving Approach Based on MATLAB
.l -----
~ ~--~--~------~------~
00.511.52 3
T_
First Order Coupled Differential Equations with Constant Coefficients 367
Example # 5.43
A=[1,0,0,0;0,1,0,0;1,4,-3,0;-1,-2,0,-3];x0=[1 1 1 -1];gt={‘exp(-3*t)’;‘t*exp(3*t)’;‘exp(t)‘;’
t+exp(t)’};
368 Differential Equations: A Problem Solving Approach Based on MATLAB
Particular
(t)
First Order Coupled Differential Equations with Constant Coefficients 369
,-,
l!': .... ,
(,,0"-"'14)
oJ
•
•- (a'-.' '''t32'''-tll ''''. IIi)
Iii
i - tit +~-!ff+"j - tf -,
....-
-~
I EIfOtI_I>,", Y.~)
-... (.,-. ,,.,,..... . -. ,......
if + "'!~'- "
)
-
~ , ~Y.~)
Y~~'.'~ 0)
'1'-.;
.. (II ...........)
_.
j-
•
,.
~( . , _ .. ' ... +JII ... _ .
'1' - .;
""" < .. (" ...........1
•
,.
• " (.,-" ,''',.,-.,,, -I
370 Differential Equations: A Problem Solving Approach Based on MATLAB
~ - . -,1,
~ • •
~
j-.- ~.' .¢d, j 0
§
•" "
"
•
,, , , ,
"' "
Th"
,- I:-:-c.:-,·, k'.
•
+ o"{2'_ ')
•
,- . -, 'g
-I
-
•-
§
"
-
,~~~-!",~---.J
au
-U 22~3
First Order Coupled Differential Equations with Constant Coefficients 371
'"
,·1
,~
•• .. ,.
T~
,
•~L------------------c----c----"
OO-'11-'22~3
~.
372 Differential Equations: A Problem Solving Approach Based on MATLAB
Example # 5.44
A=[0,0,1,0;0,0,0,1;2,1,1,1;-5,2,5,-1];x0=[0 0 0 -1];gt={‘t’;‘exp(-t)’;‘5’;‘cos(t)’};
First Order Coupled Differential Equations with Constant Coefficients 373
Particular
(t)
374 Differential Equations: A Problem Solving Approach Based on MATLAB
,
l\f - i + ~ + ~ + W+ 'f + .,111'+f) - 2
Y+ ¥ _Ill:''' +1Uj' -~ - ~ +~ +i..!f- - ~
'\If -'II' -'IIi" -'+\f- 'f - "1'<'L I
n:r - ~+.Jt' +~ -'I + ~ - i!f- +1
~_"'_~I_,*-
-
~~y~)
V~Y.'~ 0)
~ - 1of ~ + ~ of U- - ~ +e" (1+ 1)- 2
y - D,~" +~ _ ~ _ Y +~ +." (y + If)-
V-~-/-~ of V - ~-·" (1+H)-l
lIfr +~ of ~ - U- +t.;tl -."' (y + If) +1
aw -1+ TI;'~ + U of U- +~ + "''1i+!l_ 2
'I of Hjf! - nr,;. + ~ -~- If +~ of Ilf! -
~ - ~ - ~ -1+ Y - tt! - "'''''''ll_ J
tIfr-~ + V+~- u.+~-IIf! +t
First Order Coupled Differential Equations with Constant Coefficients 375
,
376 Differential Equations: A Problem Solving Approach Based on MATLAB
First Order Coupled Differential Equations with Constant Coefficients 377
Example # 5.46
A=[0,0,0,0,1;0,0,0,1,1;0,0,0,1,1;0,2,0,-1,0;0,0,0,0,1];x0=[0 0 0 1 -
1];gt={‘t’;‘t’;‘t^2’;‘cos(t)’;‘5’};
378 Differential Equations: A Problem Solving Approach Based on MATLAB
." L_ _ __ , -_--:_ _ _ _ _ __
00511.52
- 1
First Order Coupled Differential Equations with Constant Coefficients 379
.~~~~~
o 15
T~
2 3
..... ..
.~ ~.~,~ -:,~~~,~,::~-:,-----:,---~,
T~
380 Differential Equations: A Problem Solving Approach Based on MATLAB
"" .. "
T_
, ,
~
4'" _ ~
ro 1-=-: 1
ro
-., •
> ro
••
~
•
,.
"
-,. ", , , ,
" "
T_
First Order Coupled Differential Equations with Constant Coefficients 381
5.6 Summary
First order coupled differential equations have been presented in this chapter. The
case of a pair of homogeneous first order equations is presented first. The analysis of
the properties of systems described by these equations is carried through the use of
phase portraits and state of equilibrium. The solution is obtained using the concept
of eigenvalues and eigenvectors with detailed attention given to the case of defective
coefficient matrices and generalized eigenvectors. The solution is also obtained by
converting the set of equations to a second order homogeneous differential equation
with the solution set obtained using the roots of the characteristic equation, thus
avoiding the need for generalized eigenvectors. The solution set is also obtained using
Laplace transforms, thus providing a very general means of obtaining and comparing
the solutions. Detailed examples are given, with each example annotated with the
appropriate theory, along with comparison of results and verification using Runge-
Kutta methods. The analysis is then extended to the case of a pair of non-homogeneous
first order differential equations with the particular solutions set obtained using the
method of variation of parameters. Once again, the solution set is validated through
the use of Laplace transforms and verified through the use of Runge-Kutta methods.
The study is extended to sets of multiple coupled first order non-homogeneous
systems. The solution is once again obtained using eigenvalues and eigenvectors with
an increase in complexity as one goes from a pair of equations to three, four and more.
The use of the eigenvalue based approach is limited to n<5 because of the computational
complexity associated with defective matrices. Laplace transform based solution has
been used as a means for verification and for sets with 5 or more equations, only the
Laplace transform method is used to obtain the solution. In every case, the solution
is further verified using the Runge-Kutta method.
The examples shown cover a wide array of possibilities with each example fully
annotated with the appropriate theory, explanations, justifications and even verification
carried out symbolically and displayed.
5.7 Exercises
1. For the set of values a and b given below, examine the phase plots and verify
that they reflect the state of equilibrium suggested by the eigenvalues.
a=[-3,-2,-1,0,1,2,3];
b=[4,-4,0,-2,1,-1];
A=[1,a;-1,b];
2. For all the cases above, obtain solutions to associated homogeneous system.
Verify your results using the Laplace transforms, conversion to a second order
differential equation and finally ode 45.
A=[A11,A12,A21,A22,x1(0),x2(0)]
A= [1, -3, -1, 1, -1, 1];
A= [-1, -3, 1, -1, -1, 1];
A=[1, 0, -1, -2,1,0];
A=[1, 2, 3, 2, -1, 0];
A=[2,-2, -1,-2,0, 1];
A=[ 1 3 -1 -1, -1, 1];
382 Differential Equations: A Problem Solving Approach Based on MATLAB
A=[0,3,1,2,-1,1];
3. Particular and complete solutions. A is A=[A11,A12,A21,A22,x1(0),x2(0)]
A= [1, -3, -1, 1, -1, 1];g1(t)=‘t*exp(2*t)’;g2(t)=‘t’;
A= [-1, -3, 1, -1, -1, 1];g1(t)=‘cos(t)’;g2(t)=‘sin(t)’;
A=[1, 0, -1, -2,1,0];g1(t)=‘t*exp(t)’;g2(t)=‘exp(-2*t)’;
A=[1, 2, 3, 2, -1, 3];g1(t)=‘exp(-t)’;g2(t)=‘4+t’;
A=[2,-2, -1,-2,1, 1];g1(t)=‘cosh(sqrt(6)*t)’;g2(t)=‘t’;
A=[ 3, 0, -4,-2, 0, 1];g1(t)=‘t’;g2(t)=‘t+5’;
A=[0,3,1,2,-1,1];g1(t)=‘t*exp(-t)’;g2(t)=‘exp(-t)’;
A=[3,0,1,-3,-1,1];g1(t)=‘cosh(3*t)’;g2(t)=‘sinh(3*t)’;
4. For the following coefficient matrices, obtain the general homogeneous solution
using the eigenvalues and eigenvectors. Provide the eigenvectors, eigenvalues and
state whether the matrix is defective and if generalized eigenvalues were used.
Provide the fundamental matrix as well. Compare the solution to one obtained
from MATLAB.
A=[1,1,-1;0,-1,0;1,0,1];
A=[1,-1,1;0,-1,0;1,0,1];
A=[1,1,1;-1,1,1;1,0,0];
A=[-3,0,-1;-1,1,0;1,0,0];
A=[-3,1,-1;-1,-1,-1;0,2,0];
A=[1,1,0,0;1,0,1,1;1,0,0,1;0,0,1,0];
A=[1,1,0,0;1,1,1,1;1,0,0,-1;0,1,0,1];
A=[1,0,0,4;1,0,-1,-1;-1,0,0,1;2,0,0,3];
A=[0,-2,0,0;2,0,0,0;4,0,0,0;0,0,1,0];
A=[0,0,0,6;1,0,0,0;0,0,0,-2;0,0,5,0];
A=[1,1,3,1;0,0,0,1;0,1,0,1;0,0,0,5];
A=[1,0,0,0;1,-3,0,0;0,-4,0,0;0,0,2,0];
A=[1,-1,0,0;-3,-1,0,0;0,-4,0,0;0,0,2,0];
5. For the coupled first order differential equations characterized by the coefficient
matrix, obtain the particular solution sets and complete solutions using (1)
eigenvalues and eigenvectors (2) Laplace transforms and (3) ode45 methods
with the given set of forcing functions and initial values.
A=[1,1,-1;0,-1,0;1,0,1]; x0=[0 -1 -1];g(t)={‘cos(t)’;‘sin(t)’;‘exp(-t)’};
A=[1,-1,1;0,-1,0;1,0,1];x0=[0 1 -1];g(t)={‘t’;‘t^2’;‘exp(-t)’};
A=[1,1,1;-1,1,1;1,0,0];x0=[0 -1 1];g(t)={‘4’;‘t’;‘t*exp(t)’};
A=[-3,1,-1;-1,-1,-1;0,2,0];x0=[1 -1 -1];g(t)={‘exp(-2*t)’;‘4’;‘t’};
A=[1,1,0,0;1,0,1,1;1,0,0,1;0,0,1,0];x0=[0 1 -1 -1]; g(t)={‘t’;‘exp(-2*t)’;‘4’;‘t^2’};
A=[1,0,0,4;1,0,-1,-1;-1,0,0,1;2,0,0,3];x0=[0 -1 1 -1]; g(t)={‘5’;‘0’;‘t’;‘0’};
A=[0,-2,0,0;2,0,0,0;4,0,0,0;0,0,1,0];x0=[0 -1 -1 0]; g(t)={‘cos(2*t)’;‘sin(2*t)’
;‘t’;‘5’};
A=[0,0,0,6;1,0,0,0;0,0,0,-2;0,0,5,0];x0=[0 0 -1 0]; g(t)={‘t’;‘t^2’;‘t’;‘t+2’};
A=[1,-1,0,0;-3,-1,0,0;0,-4,0,0;0,0,2,0]; x0=[0 0 -1 0]; g(t)={‘t’;‘exp(-
2*t)’;‘exp(2*t)’;‘4’};
Appendices
Appendix A
A-1 Euler’s Method
Analytical solutions to differential equations might not always exist and it becomes
necessary to use numerical methods to obtain solutions to differential equations.
Numerical methods also offer a means to verify solutions obtained using other
approaches. One of the simplest methods relies on the Taylor series expansion for a
function and it can be used as a starting point for obtaining an approximate solution
to a differential equation. Consider the case of a first order differential equation
dy
= y=' f ( t , y ) , y ( 0=
) y0 . (A.1)
dt
In eqn. (A.1), t is the independent variable and f(.) depends on both t and the dependent
variable y. The initial condition is given as y0. For a small change in time ∆t, the Taylor
series provides
( ∆t )
2
y ( t + ∆=
t ) y ( t ) + y ' ( t ) ∆t + y '' ( t )
+ . (A.2)
2!
If the series is truncated by ignoring the terms in quadratic and higher order in ∆t,
eqn. (A.2) becomes
y ( t + ∆=
t ) y ( t ) + y ' ( t ) ∆t + O ( ∆t ) . (A.3)
386 Differential Equations: A Problem Solving Approach Based on MATLAB
The last term in eqn. (A.3) represents the error in limiting the expansion to the
linear term in ∆t. Ignoring the error, eqn. (A.3) becomes
y ( t + ∆=
t ) y ( t ) + y ' ( t )=
∆t y ( t ) + f ( t , y ) ∆t . (A.4)
If the time window where the solution exists is divided into n-segments, eqn. (A.4)
can be interpreted as follows
ym ( t )= ym −1 ( t ) + f ( t , ym −1 ) ∆t , m ≤ n . (A.5)
Thus, the solution to the differential equation can be obtained at different time instants
in [0, t] in steps of ∆t. It can be seen from eqn. (A.5), the accuracy of the solution will
depend on the step size and the nature of y(t). If y(t) is highly non-linear, the linear
approximation provided in eqn. (A.5) will be insufficient and error in the solution will
increase. Equation (A.5) represents the numerical solution based on Euler’s method.
The numerical approach to the solution of the differential equation can be improved
if there is a better way to estimate f(t,y) for each iteration. In other words, while Euler’s
method uses the local value of f(t,yn-1), an improved method would require that the
estimate of f(t,yn-1) is made by taking more samples of f(t,y) from the neighborhood.
Euler’s method uses uniform step sizes and if step sizes could be adjusted, the errors
are likely to be less because varying step sizes will model nonlinear functions better.
Another approach lies in using an improved average value of the function at each step.
One such method is the Runge-Kutta method. Depending on the number of terms
used for averaging, it is possible to have a 2nd order, 3rd order, 4th order method, etc.
The 4th order method which is extensively used (normally called the Runge-Kutta
method) is described below.
A-2 Runge-Kutta Method
The Runge-Kutta method uses a weighted average as the local estimate. Equation
(A.5) is modified as
ym ( t ) =ym −1 ( t ) + f ( t , y )av ∆t . (A.6)
Two step sizes (∆t=0.4 and 0.1) are used. The local truncation error (LTE) at each
step is given by
erk =yk ( analyt ) − yk ( numer ) , k =
1, 2,... . (A.10)
In eqn. (A.11), N is the total number of steps. A MATLAB® code that obtains the
solution using both Euler’s and Runge-Kutta methods and examination of the errors
is given below. MATLAB automatically chooses the appropriate number of step sizes
needed in ode45(.).
function euler_ode_demo
% dy/dt=3+2t-y, y(0)=2
% Comparison of Euler’s and Runge-Kutta methods. Two steps sizes are used
% for Euler’s while the step size is automatically chosen (adaptive sizing)
% by MATLAB. The local truncation errors and the mean square errors are
% compared. It is seen that while the error with Euler’s declines with
% reduction in step size, Runge-Kutta method uses the lowest number of
% steps and provides the most accurate estimate of the solution
% P M Shankar, August 2016
close all
tmin=0;%initial time
tMax=2;%maximum value of time
% test the error with two step sizes for Euler
dt1=0.4;
t1=tmin:dt1:tMax; % steps, size 0.4
dt2=.2;
t2=tmin:dt2:tMax; % steps, size 0.2
y0=2; % initial condition
y1(1)=y0; % initial condition restated
y2(1)=y0; % initial condition restated
388 Differential Equations: A Problem Solving Approach Based on MATLAB
N1=length(t1);N2=length(t2);
for k=2:N1 % step size 0.4
yy=ode_eulerfun1(t1(k-1),y1(k-1));
y1(k)=y1(k-1)+dt1*yy;
end;
for k=2:N2 % step size 0.1
yy=ode_eulerfun1(t2(k-1),y2(k-1));
y2(k)=y2(k-1)+dt2*yy;
end;
% Runge-Kutta (ODE45)
tm=[0:tMax]; % MATLAB chooses the step size
[T,YDE]=ode45(@ode_eulerfun1,tm,y0);
% now verify the accuracy of the methods
% Symbolic solution ----> dy/dt=3+t-y, y(0)=2
syms x y t
y=dsolve(‘Dy=3+2*t-y’,’y(0)=2’);
yys=MATLABFunction(y);
% disp([‘Analytical solution of dy/dt= 3+2t-y, y(0)=2 is y(t)=’ ,yyt])
% Convertion to MATLAB Function for plotting and error calculations
% create samples of analytical solution at appropriate time instants
ya1=yys(t1);% samples at step size 0.4
ya2=yys(t2); % samples at step size 0.1
yad=yys(T);% % samples at the instants generated by Runge-Kutta (ODE)
figure, plot(t1,ya1,t1,y1,‘k*’,t2,y2,‘bd’,T,YDE,‘rs’)
xlabel(‘time t’),ylabel(‘solution y(t)’)
leg1=[‘Euler’’s \Deltat = ‘,num2str(dt1)];
leg2=[‘Euler’’s \Deltat = ‘,num2str(dt2)];
leg3=[‘Runge-Kutta’];
legend(‘Analytical’,leg1,leg2,leg3,‘location’,‘best’)
text(0.78,2.52,’y(t) = ‘,’fontsize’,12)
text(1,2.5,[‘$’ latex(y) ‘$’],‘interpreter’,‘latex’,‘fontsize’,14)
N3=length(T);% number of samples from ODE
text(0.2,4.2,[leg1,’, N = ‘,num2str(N1)])
text(0.2,4,[leg2,’, N = ‘,num2str(N2)])
text(0.2,3.8,[leg3,’, N = ‘,num2str(N3)])
% Error calculations
Appendices 389
er1=y1-ya1;
er2=y2-ya2;
er3=YDE-yad;
MSE1=sum(er1.^2)/N1;
MSE2=sum(er2.^2)/N2;
MSEOD=sum(er3.^2)/N3;
tit=[‘Anylt Numer LTE’];
val1=[ya1;y1;er1]’;
val2=[ya2;y2;er2]’;
val3=[yad,YDE,er3];
figure,xlim([0,5]),ylim([0,5])
title(‘Error Analysis: Comparison of raw data’,‘backgroundcolor’,‘w’)
text(.5,4.5,tit,‘color’,‘b’)
text(3,4.5,tit,‘color’,‘b’)
text(1,1.2,tit,‘color’,‘b’)
text(.5,3.5,num2str(val1))
text(3,3,num2str(val2))
text(1,0.65,num2str(val3))
text(.5,4.8,[leg1,’, N = ‘,num2str(N1)],’color’,’r’,’fontweight’,’bold’)
text(3.3,4.8,[leg2,’, N = ‘,num2str(N2)],’color’,’r’,’fontweight’,’bold’)
text(1.1,1.5,[leg3,’, N = ‘,num2str(N3)],’color’,’r’,’fontweight’,’bold’)
%text(4.2,0.1,’p m shankar’,’color’,’g’)
axis off
figure,plot(t1,er1,’k*’,t2,er2,’bd’,T,er3,’rs’)
xlabel(‘time t’)
ylabel(‘Local Truncation Error [y_{Analyt}-y_{numerical}]’)
ylim([-.1,.1])
legend(leg1,leg2,leg3,’location’,’best’)
title(‘Error Analysis’)
text(0.2,.05,[leg1,’, MSE = ‘,num2str(MSE1)])
text(0.2,.04,[leg2,’, MSE = ‘,num2str(MSE2)])
text(0.2,.03,[leg3,’, MSE = ‘,num2str(MSEOD)])
end
function dy= ode_eulerfun1(t,y)
%dy/dt=3+2*t-y
dy=3+2*t-y;
end
390 Differential Equations: A Problem Solving Approach Based on MATLAB
0.2 0" O~ M 1 12 ,
"'" , "
Error A ... lyala: Compoorison '" raw d.l1JI
..-
, ,'"
2.4103 ,. ..0.01032
2.2187
2.4103
2.2 ..oD18731
u•
-
3.00193 ~ ~~m
2.7488 2.712 ..o.00(IlI12
3.7012 l .515 ..o.0IIII11M
.-
3.00193 3.0096 ..0.039129
.-.- .=. ..
4..co19 4.3296 ..o1J1Z297
$.13113 ~.o711! ..o1ll'i7!i1!i
3.31179
,~,
"m
3.6621
-0-0010199
<m_
4.04019 -0.1)3.4124
4.7342 ..0.03 1081
$.1:163 5.1074 -o.Q27l161
",,_Kulla, N • 3
, , ,
An)II N....... lTe
The example in eqn. (A.15) has been solved using the Runge-Kutta method and the
MATLAB script and results are given below. The numerical solution set is compared
to the analytical solution set obtained using dsolve(.).
function example_rungekutta_coupled
% define variables
close all
syms x_1(t) x_2(t)
xt=[x_1(t);x_2(t)];
D1y=diff(x_1,t);
D2y=diff(x_2,t);
A=[1,1;4,1]; % coefficient matrix
gt=[exp(-t);t]; % forcing functions
Dy=[D1y;D2y];% initial conditions
diffX=[Dy==A*xt+gt]; % create the differential equation set
[x1,x2]=dsolve(diffX,[x_1(0)==0;x_2(0)==-1]); % solve in MATLAB
x1=simplify(x1,‘steps’,100);
x2=simplify(x2,‘steps’,100);
mf1=MATLABFunction(x1); % create inline function solution x1(t)
mf2=MATLABFunction(x2);% create inline function solution x2(t)
tspan=[0 5]; % time span for numerical integration
[tt,yy]=ode45(@fun2f,tspan,[0; -1]);
% yy is the numerical solution in two columns. First column corresponds
% to x_1(t) and the second one to x_2(t)
plot(tt,mf1(tt),‘-k’,tt,yy(:,1),‘k*’,tt,mf2(tt),‘--r’,tt,yy(:,2),‘ro’)
legend(‘x_1(t)-Analyt’,‘x_1(t)-Runge-Kutta’,...
‘x_2(t)-Analyt’,‘x_2(t)-Runge-Kutta’,‘location’,‘best’)
xlabel(‘time’),ylabel(‘solution’)
title(‘Solutions(s): Analytical vs. Numerical’,‘color’,‘b’)
xx1=[x_1(t)==x1]; % create equation for display
xx2=[x_2(t)==x2];% create equation for display
% display the differential equations
text(0.5,-1e5,[‘$’ latex(feval(symengine,‘rewrite’,diffX,‘D’)) ‘$’],...
‘interpreter’,‘latex’,‘fontsize’,12,‘color’,‘b’)
% display the solutions
text(.5,-5e5,[‘$’ latex(xx1) ‘$’],‘interpreter’,‘latex’,‘fontsize’,16,‘color’,‘b’)
text(.5,-6e5,[‘$’ latex(xx2) ‘$’],‘interpreter’,‘latex’,‘fontsize’,16,‘color’,‘b’)
end
function dxdt=fun2f(t,x)
% create the function for numerical evaulation
dxdt=zeros(2,1);
dxdt(1,1)=x(1,1)+x(2,1)+exp(-t);
dxdt(2,1)= 4*x(1,1)+x(2,1)+t;
end
Appendices 393
h (t ) .
x3 '+ ax3 + bx2 + cx1 = (A.20)
Combining eqns. (A.19) and (A.20), the decomposition of the higher order equation
into three first order differential equations becomes
x1 ' = x2
x2 ' = x3 . (A.21)
− [ ax3 + bx2 + cx1 ] + h ( t )
x3 ' =
The coefficient matrix A is expressed as
0 1 0
A= 0 0 1 .
(A.22)
−c −b −a
In matrix notation (see Appendix E), the differential equation in eqn. (A.17) becomes
x1 ' 0 1 0 x1 0
x ' 0
= 2 0 1 x2 + 0 . (A.23)
x3 ' −c −b −a x3 h ( t )
The initial conditions become the vector
y0
X ( 0 ) = y1 . (A.24)
y2
As a specific example, consider the following 3rd order differential equation with
initial conditions
2 y '''+ 4 y ''+ 3 y '=
+ y cos(t ), y=
(0) 1, y =
'(0) 0, y ''(0)
= -1 (A.25)
The coefficient matrix A is
0 1 0
A= 0 0 1 . (A.26)
1 3
− − −2
2 2
The example has been worked out in MATLAB. The solution has been obtained using
the Runge-Kutta method and verified by comparing it to the solution obtained using
Appendices 395
dsolve(.) in MATLAB. Two different approaches exist for implementing the Runge-
Kutta method. One uses the coefficient matrix in eqn. (A.26). In the other case, the
direct conversion of higher order differential equation into appropriate first order
differential equations is carried out in MATLAB. This will be shown following the
discussion of the example of a second order differential equation.
A second order differential equation is
A2 y ''+ A1 y '+ A=
0y ( 0 ) y2 , y ' =
f (t ), y ''= ( 0 ) y1 . (A.27)
Proceeding similarly, the coefficient matrix becomes
0 1
A = A0 A . (A.28)
− − 1
A2 A2
The decomposition leads to
0 1 0
x1 ' x1
= A0 A + f ( t ) . (A.29)
x2 ' − A − 1 x2
2 A2 A2
The initial conditions become
y
X ( 0 ) = 0 . (A.30)
y1
Consider the example
te − t , y (0) =
y ''+ 4 y '+ 3 y = −1 .
1, y '(0) = (A.31)
The two examples, the 3rd order differential equation in eqn. (A.25) and the 2nd order
differential equation in eqn. (A.31) are solved in MATLAB. The analytical solutions
obtained using dsolve(.) are compared to the corresponding solutions obtained using
the Runge-Kutta method. All the steps in the MATLAB script are commented at the
appropriate lines of the script. The script also demonstrates the creation of symbolic
differential equations matching the given examples so that one can use the MATLAB
function odeToVectorfield(.) to create the inline function needed for the Runge-Kutta
method. For the case of the 3rd or equation, the external function based approach is
also used. The use of MATLABFunction(.) to convert the symbolic solution to an
inline form is also shown.
function higherorder_ode_example
Part 1: 3rd order differential equation and Part 2: 2nd order equation
Part 1: example of solution of a 3rd order differential equations using Runge-
Kutta method. Results are verified using dsolve(.) by plotting the results.
2y’’’+4y’’+3y’+y=cos(t), y(0)=1,y’(0)=0,y’’(0)=-1 There are two ways of generating
the function for ODE45 input. One is the traditional approach creating the function
externally and the other is based on odeToVectorField(.) which can decompose a
higher order differential equation into several first order ones. Both approaches are
implemented.
396 Differential Equations: A Problem Solving Approach Based on MATLAB
close all
A=[0,1,0;0,0,1;-1/2,-3/2,-2];%The coefficient matrix A
X0=[1;0;-1]; % initial conditions
tspan=[0 2]; [T1,yy2]=ode45(@higherorderf,tspan,X0);
% note that yy(:,1) is the solution and other columns are the first and
% second derivatives
% now get the analytical solution using dsolve for verification
syms t y
yt1=dsolve(‘2*D3y+4*D2y+3*Dy+y-cos(t)=0’,‘y(0)=1’,‘Dy(0)=0’,‘D2y(0)=-1’);
yt1=simplify(yt1,‘steps’,100);
% now verify the solution by plotting
yyt1=MATLABFunction(yt1);% create an inline function of the symbolic solution
plot(T1,yyt1(T1),‘k’,T1,yy2(:,1),‘r*’)
xlabel(‘time’),ylabel(‘Solution y(t)’),legend(‘Analyt’,‘Numerical’)
title(‘2y’’’’’’+4y’’’’+3y’’+y=cos(t), y(0)=1,y’’(0)=0,y’’’’(0)=-1’)
text(.2,.5,‘Using external function’)
% it is also possible to create an inline function using the following
% approach
clear y t
syms y(t)
% define the differentials
Dy=diff(y);D2y=diff(y,2);D3y=diff(y,3);
ff1=[2*D3y+4*D2y+3*Dy+y-cos(t)==0]; % create a symbolic differential equation
V1 = odeToVectorField(ff1);% break higher order DE into 3 first order ones
FF1 = MATLABFunction(V1,‘vars’, {‘t’,‘Y’});% create inline Function for ODE
[T2,yx1]=ode45(FF1,tspan,X0);
figure,plot(T2,yyt1(T2),‘k’,T2,yx1(:,1),‘r*’)
xlabel(‘time’),ylabel(‘Solution y(t)’),legend(‘Analyt’,‘Numerical’)
title(‘2y’’’’’’+4y’’’’+3y’’+y=cos(t), y(0)=1,y’’(0)=0,y’’’’(0)=-1’)
text(.2,.5,‘Using odeToVectorField’)
% part 2 example of a second order differential equation
clear all
% y”+4y’+3y=texp(-t),y(0)=1,y’(0)=-1;
y0=1;y1=-1;
syms y(t)
Dy=diff(y);D2y=diff(y,2); % define the differentials
ff2=[D2y+4*Dy+3*y-t*exp(-t)==0]; % create a symbolic differential equation
V2 = odeToVectorField(ff2);% break higher order DE into 3 first order ones
FF2 = MATLABFunction(V2,’vars’, {‘t’,‘Y’});% create inline Function for ODE
tspan=[0 2];
[T3,yx2]=ode45(FF2,tspan,[y0;y1]);
% get the solution using dsolve
yt2=dsolve(‘D2y+4*Dy+3*y-t*exp(-t)=0’,‘y(0)=1’,‘Dy(0)=-1’);
yt2=simplify(yt2,’steps’,100);
% now verify the solution by plotting
yyt2=MATLABFunction(yt2);% create an inline function of the symbolic solution
figure,plot(T3,yyt2(T3),‘k’,T3,yx2(:,1),‘r*’)
xlabel(‘time’),ylabel(‘Solution y(t)’),legend(‘Analyt’,‘Numerical’)
title(‘y’’’’+4y’’+3y=te^{-t}, y(0)=1,y’’(0)=-1’)
Appendices 397
function dy = higherorderf(t,x)
% external function for the 3rd order differential equation
dy=zeros(3,1);% this corresponds to the first order derivatives x1’,x2’,x3’
A=[0,1,0;0,0,1;-1/2,-3/2,-2];%The coefficient matrix A
ff=[0;0;cos(t)/2];
dy=A*x+ff;% three first order differential equations
end
398 Differential Equations: A Problem Solving Approach Based on MATLAB
•• 1-
, =..1
••
_0.1
~
.§ 0.6
•'" 0.5
•••
· 'L~~
.,o
... ~ OA M OA \ 12 1. lA lA 2
Appendix B
( t ) Y=
L y = (s) ∫ y ( t )e
− st
dt . (B.1)
0
In eqn. (B.1), L[] represents the Laplace operator and Y(s) is the Laplace transform
of y(t). Often, y(t) is defined to be in the ‘t’ domain and Y(s) is defined to be in the
‘s’ domain. Behavior of linear systems could be analyzed using Laplace transforms
by taking advantage of their properties which allow a differential equation to be
converted to an algebraic equation in the ‘s’ domain. Such an algebraic equation can
then be rearranged to obtain an expression for Y(s) which can be inverted to obtain
the solution to the differential equation. This concept is illustrated in Figure B1 below.
d n y (t )
Figure B.1 Use of Laplace Transforms for solving differential equation D n ( y ) = .
dt n
400 Differential Equations: A Problem Solving Approach Based on MATLAB
The usefulness of the Laplace transform arises from its properties, some of which
are listed below.
Linearity
L af ( t ) + bg ( t ) = aL f ( t ) + bL g ( t ) = aF ( s ) + bG ( s ) (B.2)
L t n f ( t ) = ( −1) F[
n]
(s)
n
(B.3)
dn
F[
n]
(s) = F (s)
ds n
. (B.4)
dn
f [ ] (t ) = n f (t )
n
dt
Differentiation
L f =
'
( t ) sF ( s ) − f ( 0 )
. (B.5)
L f [ ] (=
t ) s n F ( s ) − s n −1 f ( 0 ) − s n − 2 f [ ] ( 0 ) − − sf [ ] ( 0 ) − f [ ] ( 0 )
n 1 n−2 n −1
Use of the Laplace transform method requires that the differential equations are
given along with the initial conditions. This means that if the differential equation is
of nth order, there must be n initial values as seen from eqn. (B.5). The conceptual
approach to the solution of a second order differential equation will be described first
before examining differential equations of lower and higher orders and coupled first
order differential equations. It is assumed that all these differential equations are linear
with constant coefficients. A second order non-homogeneous differential equation
with constant coefficients is
'+ cy h ( t ) ; =
ay ''+ by = y ( 0 ) y0 , y=
' ( 0 ) y1 (B.8)
Applying the property in eqn. (B.5), the Laplace transform of the differential equation
in eqn. (B.8) becomes
a s 2Y ( s ) − sy0 − y1 + b sY ( s ) − y0 + cY ( s ) =
H ( s ) . (B.9)
The quantities P(s) and Q(s) are introduced to indicate that the transform of y(t) will be
the ratio of two polynomial functions in s. The ratio P(s)/Q(s) needs to be decomposed
into simpler forms of rational functions using the method of partial fractions so that
the Table of Laplace transforms may be used. Laplace and inverse Laplace transforms
are readily available in the Symbolic Toolbox of MATLAB.
Taking the inverse Laplace transforms (from the Laplace transform Table) leads to
( t ) y1 ( t ) + y2 ( t )
y= (B.15)
−1 1
y1 ( t ) L=
= −t
s + 1 e (B.16)
2 2 2 2 4t 2 − t 2 − t
y2 ( t ) = L−1 − − = e − te − e (B.17)
25 ( s − 4 ) 5 ( s + 1) 25 ( s + 1) 25
2
5 25
term2=f/ff;
disp(‘display the Laplace transform of term 2’)
disp(term2)
y2=ilaplace(term2);% inverse Laplace directly without decomposition
p = feval(symengine,‘partfrac’,term2,‘s’); % decompose into partial fractions
pretty(p) % only for display purposes
% get the solution using Laplace transform method
yLap=simplify(y1+y2,‘steps’,100);
disp(‘display the solution obtained using Laplace transforms’)
disp(yLap)
% solution using dsolve(.) in MATLAB
yd=dsolve(‘D2y-3*Dy-4*y=2*exp(-t)’,‘y(0)=1’,‘Dy(0)=-1’);
disp(‘display the solution obtained using dsolve’)
disp(yd)
% verify that the solutions match: find the difference between the two
% solutions
disp(‘Verify that the Laplace solution is correct: Obtain the symbolic difference between
the two solutions’)
disp(‘Difference will be 0 if the approach is correct’)
disp(simplify(yLap-yd)) % verify that the solution is correct; must be equal to 0
display the Laplace transform of term 1
-(s - 4)/(- s^2 + 3*s + 4)
1
-----
s+1
y1 =
exp(-t)
f=
2/(s + 1)
display the Laplace transform of term 2
-2/((s + 1)*(- s^2 + 3*s + 4))
2 2 2
---------- - ---------- - ----------
25 (s - 4) 2 25 (s + 1)
5 (s + 1)
display the solution obtained using Laplace transforms
(exp(-t)*(2*exp(5*t) - 10*t + 23))/25
display the solution obtained using dsolve
(23*exp(-t))/25 + (2*exp(4*t))/25 - (2*t*exp(-t))/5
Verify that the Laplace solution is correct: Obtain the symbolic difference between the two
solutions
Difference will be 0 if the approach is correct
0
404 Differential Equations: A Problem Solving Approach Based on MATLAB
A figure automatically generated form the MATLAB based results from Chapter 3
appears below.
=Y (s)
(s 3
− s 2 + 1)
+
s
(B.23)
s − 1
4
( s + 1) s 4 − 1
2
Taking the inverse Laplace transform and writing it as the sum of two terms gives
( t ) y1 ( t ) + y2 ( t ) .
y= (B.24)
Appendices 405
s3 − s 2 + 1
y1 ( t ) = L−1 4 . (B.25)
s −1
s
y2 ( t ) = L−1 2 (B.26)
( s + 1)( s − 1)
4
A figure automatically generated form the MATLAB based results from Chapter 3
appears below.
Rewriting the left side using the notion of an identity matrix I3 gives
In eqn. (B.34), A is the coefficient matrix, W(s) is the 3 x 1 matrix of the Laplace
transforms of x, y and z, F(s) is the [3 x 1] matrix of the Laplace transform of the
forcing functions and w0 is the [3x1] matrix with the initial conditions.
A11 A12 A13
A = A21 A22 A23 (B.35)
A31 A32 A33
X ( s )
W (s) = Y (s) (B.36)
Z ( s )
Fx ( s )
F ( s ) = Fy ( s ) (B.37)
Fz ( s )
x0
w0 = y0 (B.38)
z0
Pre-multiplying eqn. (B.34) by the inverse of the matrix ( sI − A ) , eqn. (B.34) becomes
W ( s ) = ( sI − A ) F ( s ) + ( sI − A ) w0
−1 −1
(B.39)
408 Differential Equations: A Problem Solving Approach Based on MATLAB
The solutions x(t), y(t) and z(t) are obtained by taking the inverse Laplace transform of
eqn. (B.39). The use of Laplace transforms in solving coupled first order equations will
now be demonstrated. Consider the following set of linear coupled first order equations
x ' =− x − 2 y + t , x ( 0 ) =−1
(B.40)
y ' = x − y + e−t , y ( 0 ) = 1
s −2
F (s) = −1 . (B.42)
( s + 1)
The initial conditions are
−1
w0 = (B.43)
1
The Laplace transform of the differential equation becomes
( s −2 − 1) ( s + 1) 1 + ( s − 1)
−1
− 2
X ( s ) s 2 + 2s + 3 s 2 + 2s + 3
= . (B.44)
Y ( s ) ( s −2 − 1) ( s + 1) 1 + ( s − 1)
−1
s 2 + 2 s + 3 + s 2 + 2s + 3
Taking the inverse Laplace transforms leads to
t et 7
x ( t ) = − − e − t cos
3 3 9
( 2t ) − 8 92 e −t
sin ( 2t ) + 19
(B.45)
t et 8
x ( t ) = + + e − t cos
3 3 9
( 2t ) − 187 e −t
sin ( 2t ) − 92
The results of the various steps and the solution set and verification of the solution
set appears with the appropriate MATLAB code below.
clear all;close all;clc
syms x(t) y(t) z(t) t s
A=[-1,-2;1,-1];% coefficient matrix
B=sym(s*eye(2)-A); % this sI-A
disp(‘B=sI-A’)
disp(‘ ’)
disp(B)
f=[t;exp(-t)];% forcing functions
F=laplace(f,t,s);
disp(‘Display the Laplace transform of the forcing functions’)
Appendices 409
disp(F)
w0=[-1;1];
disp(‘Display the initial conditions’)
disp(w0)
W=inv(B)*(F+w0);
disp(‘display the Laplace transform of x(t) and y(t) as a vector’)
disp(W)
w=ilaplace(W,s,t); % solution set
disp(‘Display the solution set using Laplace transforms’)
disp(w)
xt=w(1);
yt=w(2);
% get the solution using dsolve
[xtd,ytd]=dsolve(‘Dx=-x-2*y+t’,‘Dy=x-y+exp(-t)’,‘x(0)=-1’,‘y(0)=1’);
% verify that the solutions match: find the difference between the two
% solutions
disp(‘Display the solution set from dsolve’)
disp(simplify(xtd,‘steps’,100))
disp(simplify(ytd,‘steps’,100))
disp(‘Verify that the Laplace solution is correct: Obtain the symbolic difference between
the two solutions’)
disp(‘Difference will be [0;0] if the approach is correct’)
disp(simplify([xt-xtd;yt-ytd],‘steps’,100)) % must give a null vector if the solutions match
B=sI-A
[ s + 1, 2]
[ -1, s + 1]
Display the Laplace transform of the forcing functions
1/s^2
1/(s + 1)
Display the initial conditions
-1
1
display the Laplace transform of x(t) and y(t) as a vector
((1/s^2 - 1)*(s + 1))/(s^2 + 2*s + 3) - (2*(1/(s + 1) + 1))/(s^2 + 2*s + 3)
(1/s^2 - 1)/(s^2 + 2*s + 3) + ((1/(s + 1) + 1)*(s + 1))/(s^2 + 2*s + 3)
Display the solution set using Laplace transforms
t/3 - exp(-t) - (exp(-t)*(cos(2^(1/2)*t) + 11*2^(1/2)*sin(2^(1/2)*t)))/9 + 1/9
t/3 + (11*exp(-t)*(cos(2^(1/2)*t) - (2^(1/2)*sin(2^(1/2)*t))/22))/9 - 2/9
Display the solution set from dsolve
t/3 - exp(-t) - (exp(-t)*cos(2^(1/2)*t))/9 - (11*2^(1/2)*exp(-t)*sin(2^(1/2)*t))/9 + 1/9
t/3 + (11*exp(-t)*cos(2^(1/2)*t))/9 - (2^(1/2)*exp(-t)*sin(2^(1/2)*t))/18 - 2/9
Verify that the Laplace solution is correct: Obtain the symbolic difference between the two
solutions
Difference will be [0;0] if the approach is correct
0
0
Appendix C
C-1 Phase Planes
While D-field plots provide insight into the behavior of a first order differential
equation, an analogous display can be used to understand the stability of systems
described by a pair of coupled first order differential equations or a second order
differential equation. While D-field displays the directional changes in t-y(t) domain,
the phase plane plots display the directional changes in the fields in the x(t)-y(t) domain
where x(t) and y(t) are the solutions of a pair of coupled first order equations. For the
case of a second order homogeneous system, the phase plane plots display the changes
in the y(t)-y’(t) domain. These plots can point to the state of equilibrium that exists
in the system described by the two first order equations or a second order differential
equation. Because the analytical solutions are always available for the case of a pair of
homogeneous first order linear differential equations and second order homogeneous
linear systems, the generation of these plots is simple and straightforward. Consider
a pair of first order homogeneous differential equations
x1' ( t ) − x1 ( t ) + 2 x2 ( t )
= x ' ( t ) = . (C.1)
x2 ( t ) 2 x1 ( t ) + x2 ( t )
'
0 − x1 ( t ) + 2 x2 ( t )
x ' (=
t ) = . (C.3)
0 2 x1 ( t ) + x2 ( t )
The trajectories also suggest the nature of the critical point. This conclusion may be
drawn from the eigenvalues of the coefficient matrix. The MATLAB® code and results
are displayed below.
clear all;close all;
A=[-1,2;2,1];
[x1,x2]=meshgrid(-4:.5:4,-4:.5:4);
DX1=A(1,1)*x1+A(1,2)*x2;
DX2=A(2,1)*x1+A(2,2)*x2;
quiver(x1,x2,DX1,DX2,1),xlabel(‘x_1(t)’),ylabel(‘x_2(t)’)
hold on
syms x y t
[xt,yt]=dsolve(‘Dx=-x+2*y’,‘Dy=2*x+y’); % get the analytical solution
x1t=MATLABFunction(xt);
x2t=MATLABFunction(yt);
tt=0:.1:.5;
C=-4.5:1:4.5; % pick the unknown constants; use the same value for C1 and C2
L=length(C);
for k1=1:L
for k2=1:L
plot(x1t(C(k1),C(k2),tt),x2t(C(k1),C(k2),tt))
end;
end;
xlim([-4,4]),ylim([-4,4])
lambda=eig(sym(A))
lambda =
5^(1/2)
-5^(1/2)
412 Differential Equations: A Problem Solving Approach Based on MATLAB
One of the eigenvalues is positive indicating that the system is unstable as seen
by the trajectories moving away from the critical point [0,0]. Examining the plot also
demonstrates that the critical point is a ‘saddle point’.
It can be seen that the system is asymptotically stable as seen by the arrows moving
towards the center which is also the critical point. The stability is associated with the
fact that the real part of the eigenvalue is negative.
A phase portrait associated with a linear second order homogeneous differential
equation can be created similarly. The first step is to decompose the second order
differential equation into two first order ones as shown in Appendix B. This allows
the treatment of a second order differential equation as a pair of first order systems in
variables y(t) and y’(t). The rest of the procedure is similar to the one described above
in connection with the phase portraits of first order coupled systems.
The example below corresponds to the differential equation
y ''+ 2 y '+ 4 y =
0 . (C.5)
fy=MATLABFunction(y);
fdy=MATLABFunction(dy);
tt=0:.1:.5;
C=-4:1:4;
L=length(C);
for k1=1:L
for k2=1:L
plot(fy(C(k1),C(k2),tt),fdy(C(k1),C(k2),tt))
end;
end;
xlim([-4,4]),ylim([-4,4])
Appendix D
Thus, any column of the matrix A is [m x 1] matrix or Rm vector. If m=n, the matrix
in eqn. (D.1) is a square one. If a new matrix C is obtained by scaling A by a constant
c, each element of the matrix is scaled by c,
ca11 ca12 ca1n
ca
21 ca22 ca2 n
C = .
= cA . . . (D.3)
. . .
cam1 cam 2 camn
If there are two matrices, A of size [m x n] and B of size [r x p], the product AB
exists only when n=r and the resulting matrix will be of size [m x p]. Consider the
simple example with A being a [3 x 3] matrix and B being a [3 x 2] matrix. The product
AB will be of size [3 x 2] as shown clearly demonstrating the procedure requiring
multiplication and addition of elements.
3 4 5
A = 6 7 8 (D.4)
2 9 10
a b
B = c d (D.5)
e f
3* a + 4 * c + 5* e 3* b + 4 * d + 5* f
AB = 6 * a + 7 * c + 8* e 6 * b + 7 * d + 8* f (D.6)
2 * a + 9 * c + 10 * e 2 * b + 9 * d + 10 * f
The multiplication principle clearly suggests that AB ≠ BA. In eqn. (D.6), * represents
the product.
Two matrices A and B are equal only when they have the same sizes and there
exists an element-by-element match between A and B.
The addition and subtraction of matrices requires that the matrices be of equal
sizes and the sum or difference is obtained by taking an element-by-element subtraction
or addition. Let the matrix C be a [3 x 3] matrix
a1 b1 c1
C = d1 e1 f 1
(D.7)
g1 h1 k1
The sum or the difference of the two matrices, A and C will be
3 ± a1 4 ± b1 5 ± c1
A ± C = 6 ± d1 7 ± e1 8 ± f 1 . (D.8)
2 ± g1 9 ± h1 10 ± k1
Appendices 417
If the rows and columns of a matrix A are interchanged, the new matrix is its transpose,
expressed as AT. If a square matrix and its transpose are equal (element-by-element),
the matrix said to be symmetric. There are two other types of matrices that will be
seen in the study of differential equations. First one is a null matrix and the second
one is an identity matrix. If all the elements of a matrix are 0’s, the matrix is referred
to as a null matrix,
0 0 0
0 0 0
Z = . (D.9)
0 0 0
0 0 0
Therefore, if two matrices are equal, the difference of the two matrices will be a null
matrix. An identity matrix on the other hand is a square matrix where the elements
along the diagonals are 1’s. Rest of the elements are 0’s. An [n x n] identity matrix
is represented as In,
1 0 0 0
0 1 0 0
I4 = . (D.10)
0 0 1 0
0 0 0 1
A few other characteristics and properties associated with matrices also are useful. To
appreciate some of these features, consider the following matrix A
2 −3 2 5
A = 2 −2 −2 6 . (D.11)
2 −3 2 8
Matrices can be manipulated by performing row operations (no column operations!).
This principle comes from the fact that a set of linear equations are solved by adding,
subtracting or scaling the equations. For example eqn. (D.11) can be used to represent
a set of equations whose coefficients form the matrix A as in
2 x1 − 3 x2 + 2 x3 + 5 x4 =
b1
2 x1 − 2 x2 − 2 x3 + 6 x4 =b2 . (D.12)
2 x1 − 3 x2 + 2 x3 + 8 x4 =
b3
Equation (D.12) can be expressed as in the form of a matrix equation (also known as
a matrix-vector equation) as
Ax = b . (D.13)
In eqn. (D.13), x is a [4 x 1] matrix or R4 vector and b is a [3 x 1] matrix or R3 vector,
x1
x
x = 2 . (D.14)
x3
x4
418 Differential Equations: A Problem Solving Approach Based on MATLAB
b
1
b = b2 . (D.15)
b3
Square matrices have a few additional features and properties that are very useful
in the study of differential equations. For a square matrix, the determinant of a square
matrix is a single valued quantity. If P is a [2 x 2] matrix, its determinant is
a b
c d ⇒ det ( P ) =
P= ad − bc . (D.16)
But, the determinants of sizes larger than [2 x 2] require additional manipulations.
Consider the matrix Q given by
a b c
Q = d e f (D.17)
g h k
Its determinant is given by
Q a * [ e * k − f * h ] - b [ d * k − f * g ] + c [ d * h - e * g ] (D.18)
det ( Q ) ==
Note that in eqn. (D.20), W1j is the matrix obtained by removing the elements of
the 1st row and jth column of W. It should also be noted that a more general way of
representing eqn. (D.20) is
n
Equation (D.21) suggests that the det(W) can be evaluated using any one of the rows.
The results can be generalized to any row being replaced by a column in which case
the summation is carried over the rows. Equation (D.20) is also called a cofactor
expansion across the first row.
Another interesting and useful matrix arises from taking the product of a square
matrix with itself. If A is a square matrix, then the product of k (k being a positive
integer) copies of A is
Ak =
A * A
*A . (D.22)
k − products
Appendices 419
A− k
= (=
A )
−1 k
A−1 * A−1 * A−1
. (D.23)
k − products
Ax b (D.28)
In eqn. (D.28), A is called the coefficient matrix of size [m x n] and x [n x 1] matrix
and b [m x 1] matrix are vectors.
a11 a12 a1n
a a22 a2 n
21
A= . . . . (D.29)
. . .
am1 am 2 amn
x1
x
x = 2 (D.30)
xn
b1
b2
b= (D.31)
bm
Using these representations, the system of equations can also be expressed as
a11 a12 a1n b1
a x1
21 a22 a2 n b2
x
. . . 2 = . . (D.32)
.
. . . .
x
am1 am 2 amn n bm
Equations (D.28) and (D.32) are the matrix equations or matrix-vector equations
corresponding
to the system of equations in eqn. (D.27). By concatenation of A and
b leads to the augmented matrix D as
a11 a12 a1n b1
a a22 a2 n b2
21
D= . . . . (D.33)
. . . .
a am 2 amn bm
m1
Note that if m < n, the number of equations is less than the number of variables
(underdetermined system) and if m > n, the number of equations exceed the number
of variables (over determined system). Note that a unique solution for x can exist
(not assured) only if m > n. In other words, a unique solution may or may not exist
Appendices 421
if m > n and with m < n, no unique solutions will ever exist. It is also possible that
the system of equations is inconsistent and no solution ever exists. All these can be
understood by performing row operations. Note that if b is a null vector (all elements
are zeros), eqn. (D.32) represents a homogeneous system. Otherwise, the system is
a non-homogeneous one.
Consider a homogeneous system with a coefficient matrix A from eqn. (D.11),
x1
2 −3 2 5 0
x2 0
2 −2 −2 6 x = . (D.34)
2 −3 2 8 x 0
3
4
Creating the augmented matrix and performing row reduction operation leads to
2 −3 2 5 0 rref 1 0 −5 0 0
2 −2 −2 6 0 ⇒ 0 1 −4 0 0
. (D.35)
2 −3 2 8 0 0 0 0 1 0
It can be seen that the locations of the pivots in eqn. (D.35) are identical to those in eqn.
(D.26) and there is no pivot in the last column. The RREF shows the pivot locations
and those correspond to the basic variables (x1, x2 and x4) and x3 is the free variable.
To interpret these results, the augmented matrix in RREF can be converted into the
corresponding set of equations as
x1 + 0 x2 − 5 x3 + 0 x4 =
0
0 .
0 x1 + x2 − 4 x3 + 0 x4 = (D.36)
0 x1 + 0 x2 + 0 x3 + x4 =
0
Equation (D.36) can be rewritten in vector form as
x1 5
x 4
= 2 = x v x (D.37)
x3 1 3 3 3
x4 0
Equation (D.37) connects the pivots with the basic variables and the notion of the
free variable and basic variables are understood. The vector v3 is identified as the null
space of the matrix A. The null space of a matrix A is the set of all solutions of the
homogeneous equation Ax = 0 .
Consider the case where homogeneous
system in eqn. (D.34) is converted into a
non-homogeneous with a vector , b
x1
2 −3 2 5 0
x2 5 . (D.38)
2 −2 −2 6 x =
2 −3 2 8 x 3
3
4
422 Differential Equations: A Problem Solving Approach Based on MATLAB
x4 0 1
In eqn. (D.41), the vector ν 3 has remained the same and the solution is expressed in
terms of the solution of the homogeneous part with the addition of the vector p . It
is clear that if the RREF of a square coefficient matrix of size [n x n] has n pivots,
the corresponding homogeneous equation only has trivial solutions and there is no
null space for such a matrix. If there is a pivot in the last column of the RREF of an
augmented matrix, the system is inconsistent and no solutions exist.
Consider an augmented matrix D and its RREF shown below.
3 −7 −2 −7 rref 1 0 0 3
−3 5 1
D= 5 ⇒ 0 1 0 4 .
(D.42)
6 −4 0 2 0 0 1 −6
The augmented matrix in eqn. (D.42) corresponds to a non-homogeneous system. It
can be seen that there are three pivots and three variables and therefore, the variables
are all basic. The solution is
x1 3
x = 4
2 . (D.43)
x3 −6
The coefficient matrix in eqn. (D.42) is a [3 x 3] square matrix. The system of equations
in eqn. (D.42) has unique solutions. Such a system of equations can also be solved
using other approaches using the inverse of the matrix which is discussed next.
Appendices 423
D-2 Inverse of a matrix
Another important property of a matrix that becomes useful in solving coupled
differential equations is the inverse of a matrix introduced in eqn. (D23) and
eqn. (D.24). The inverse of a square matrix A exists only if
det ( A ) ≠ 0 . (D.44)
The matrix A and its inverse A-1 are related through the property (seen in eqn. (D.23))
Matrix inversion offers a simple means to solve a matrix vector equation such as
the one in eqn. (D.28). If A is a square matrix and determinant of A exists, multiplying
eqn. (D.28) from the left by A-1 leads to
A−1 Ax = A−1b . (D.51)
Using eqn. (D.45), eqn. (D.51) becomes
I n x = A−1b ⇒ x = A−1b . (D.52)
In other words, the solution to the matrix equation is obtained by taking the product
of A-1 with b .
The invertibility of matrix A also can be used in another way to obtain the solution
vector of the matrix equation in eqn. (D.28) using Cramer’s Rule. For the [n x n]
invertible matrix A, the unique solution consists of
det ( Ai ( b ) )
=xi = , i 1, 2, , n . (D.53)
det ( A )
In eqn. (D.53), the matrix Ai(b) is the matrix obtained by replacing the ith column of
A with the vector b .
A non-trivial solution exists for eqn. (D.56) only when the determinant of the matrix
on the left hand side is zero,
A − λ In =
0 . (D.57)
Equation (D.57) is called the characteristic equation associated with the matrix and
its solutions are referred to as the eigenvalues of the matrix A. For example, consider
a [2 x 2] matrix
1 3
A= . (D.58)
2 2
Appendices 425
λ 2 − 3λ − 4 = 0 ⇒ ( λ − 4 )( λ + 1) = 0 (D.60)
The solutions to eqn. (D.60) are the eigenvalues and in this case, the eigenvalues are
λ1=-1 and λ2=4. With the availability of eigenvalues, a solution to eqn. (D.56) can be
found. Equation (D.56) associated with the first eigenvalue is
1 − λ1 3 0
[ A − λ1 I n ]ν 0⇒
=
2 − λ1
v=
0 . (D.61)
2
2 3 0
2 3 v = 0 (D.62)
Note that in eqns. (D.61) and (D.62) v replaces x and the solution vector v is
identified as the eigenvector associated with the eigenvalue of λ1=-1. Writing eqn.
(D.62) using the concept of augmented matrices, the augmented matrix associated
with the matrix equation (D.61) is
3
2 3 0 rref 1 0
2 3 0 ⇒ 2 . (D.63)
0 0 0
Note that the first row of eqn. (D.63) corresponds to the linear equation
3
v1 + v2 =
0 . (D.64)
2
This leads to
3
v1 −
=
v 2 (D.65)
2
1
The eigenvector associated with λ1=-1 is therefore,
3
−
ν = 2 . (D.66)
1
The eigenvector is also obtained directly using the MATLAB® command null() as
shown below. The use of symbolic toolbox will yield the vector in rational form.
Both results are given.
426 Differential Equations: A Problem Solving Approach Based on MATLAB
v=null(sym([2,3;2,3]))
v=
-3/2
1
v=null([2,3;2,3])
v=
-0.8321
0.5547
Proceeding similarly, the eigenvector associated with λ2=4 becomes
1
ν = . (D.67)
1
Eigenvalues and eigenvectors can easily be obtained using MATLAB. The use of the
symbolic toolbox will make the numerical values appear as rational numbers.
[V,lambda]=eig(sym([1,3;2,2]))
V=
[ -3/2, 1]
[ 1, 1]
lambda =
[ -1, 0]
[ 0, 4]
If the symbolic toolbox is not used, the values appear in decimal notation as in
The two examples discussed so far dealt with matrices with distinct eigenvalues and
distinct eigenvectors. It must be noted that when complex eigenvalues exist, they
appear as a conjugate pair and are therefore always distinct.
1
−1
λ2 = −2; ν = 1 (D.75)
0
−1
λ3 = 1
−2; ν =
0
In this case, there exist a pair of equal eigenvalues equal to -2 (algebraic multiplicity
p=2); But, the corresponding eigenvectors are not distinct (geometric multiplicity
m=1). There is an additional eigenvalue of unity and a corresponding distinct
eigenvector. Consider the case of the following matrix
−3 −1 −6
2 −1 −4 .
A =− (D.76)
1 0 1
The corresponding eigenvalues and eigenvectors are
−2
λ1 = −2
−1; ν =
1
−2
λ2 = −2
−1; ν =
(D.77)
1
−2
λ3 = −2
−1; ν =
1
The defective matrix A has an algebraic multiplicity p=3 and geometric multiplicity
m=1. These matrices in eqn. (D.74) and eqn. (D.77) are also considered as defective
because m<p.
To accommodate defective matrices lacking distinct eigenvectors (we expect
each eigenvalue paired with an eigenvector), the concept of generalized eigenvectors
is needed. Generalized eigenvectors are solutions of
p
[ A − λ I n ] ν =0, p =2,3, . (D.78)
Appendices 429
Note that for p=1, eqn. (D.78) is identical to eqn. (D.61). Now, consider the matrix
in eqn. (D.72) which has an algebraic multiplicity of 2 (p) and geometric multiplicity
of 1. Equation (D.78) becomes
p
[ A − λ I ] ν =0, p =2 . (D.79)
This leads to
0 0 0
0 0 0 ν = 0
(D.83)
0 0 0
430 Differential Equations: A Problem Solving Approach Based on MATLAB
The corresponding eigenvectors (just as in the case of eigenvalues, these will also
form a conjugate pair) will be of the form
ν 1,2= ν ±= a ± jb . (D.91)
In eqn. (D.91), a and b are [2 x 1] and real,
a1 b1
= a = , b b (D.92)
a2 2
The general solution can be expressed as
x1 ( t ) α t a1 cos ( β t ) − b1 sin ( β t ) a1 sin ( β t ) + b1 cos ( β t )
x ( t ) =
= e C1 + C2
x2 ( t ) a2 cos ( β t ) − b2 sin ( β t ) a2 sin ( β t ) + b2 cos ( β t ) .
(D.93)
The case of equal eigenvalues should be treated no differently if the eigenvectors are
distinct and the solution will be similar to eqn. (D.89) with λ1,2=α.
On the other hand, if the coefficient matrix is defective with a single eigenvector,
the solution requires the use of generalized eigenvectors. We will examine solutions
of a set of equations when the coefficient matrix is defective following the discussion
of the case of generalized vectors for larger matrices to get a general description of
solutions.
A few examples to demonstrate the use of linear algebra are now provided along
with appropriate MATLAB codes and verification.
First consider a coefficient matrix
2 3
A= . (D.94)
3 −6
The corresponding homogeneous system is
x ' = Ax . (D.95)
The eigenvalues and eigenvectors are obtained from MATLAB as
1
λ1 =
−7, ν 1 =− 3
1 . (D.96)
3
=λ2 3,=ν2
1
The solution set corresponding to the linear system described by the coefficient matrix
in eqn. (D.94) is
1
− 3
=x ( t ) C1 3 e −7 t + C2 e3t . (D.97)
1
1
432 Differential Equations: A Problem Solving Approach Based on MATLAB
clear all;clc;
% example worked out and verification using dsolve(.)
A=[2,3;3,-6];
[V,D]=eig(sym(A))
DD=diag(D) % eigenvalues
v1=V(:,1) % eigenvector 1 corresponding to DD(1)
v2=V(:,2)% eigenvector 2 corresponding to DD(2)
clear A
syms x y t C2 C1
[xt,yt]=dsolve(‘Dx=2*x+3*y’,‘Dy=3*x-6*y’);
xr=symvar(xt); % find the symbolic variables
yr=symvar(yt); % % find the symbolic variables
xt=subs(xt,[xr(1),xr(2)],[C2,C1]); % replace the constants to match the text
yt=subs(yt,[yr(1),yr(2)],[C2,C1]);
X=[xt;yt];
disp(X)
V=
[ -1/3, 3]
[ 1, 1]
D=
[ -7, 0]
[ 0, 3]
DD =
-7
3
v1 =
-1/3
1
v2 =
3
1
3*C2*exp(3*t) - (C1*exp(-7*t))/3
C2*exp(3*t) + C1*exp(-7*t)
1 0
a ± jb = ± j . (D.103)
0 1
The solution set is
cos ( 3t ) 4t sin ( 3t )
=x ( t ) e 4t C1 + e C2 . (D.105)
− sin ( 3t ) cos ( 3t )
The MATLAB portion including verification using dsolve(.) appears below.
clear all;
A=[4,3;-3,4];
[V,D]=eig(sym(A))
DD=diag(D) % eigenvalues
v1=V(:,1) % eigenvector 1 corresponding to DD(1)
v2=V(:,2)% eigenvector 2 corresponding to DD(2)
clear A
syms x y t C2 C1
[xt,yt]=dsolve(‘Dx=4*x+3*y’,‘Dy=-3*x+4*y’)
xr=symvar(xt) % find the symbolic variables
yr=symvar(yt) % % find the symbolic variables
xt=subs(xt,[xr(1),xr(2)],[C2,C1]); % replace the constants to match the text
yt=subs(yt,[yr(1),yr(2)],[C2,C1]);
X=[xt;yt];
disp(X)
V=
[ j, -j]
[ 1, 1]
D=
[ 4 – 3j, 0]
[ 0, 4 + 3j]
DD =
4 – 3j
4 + 3j
v1 =
j
1
v2 =
-j
1
Appendices 435
xt =
C4*cos(3*t)*exp(4*t) + C3*sin(3*t)*exp(4*t)
yt =
C3*cos(3*t)*exp(4*t) - C4*sin(3*t)*exp(4*t)
xr =
[ C3, C4, t]
yr =
[ C3, C4, t]
C1*cos(3*t)*exp(4*t) + C2*sin(3*t)*exp(4*t)
C2*cos(3*t)*exp(4*t) - C1*sin(3*t)*exp(4*t)
2 4
( A − λ I2 )
2
u=0⇒ u =
0 . (D.108)
−1 −2
The generalized eigenvectors are
1 0
νg = . (D.109)
0 1
The solution to the set of equations represented by eqn. (D.106) will be presented
following a formal discussion of generalized eigenvectors and the fundamental matrix.
If n is even and all the eigenvalues are complex conjugate distinct pairs,
n/2
a cos ( β k t ) − b1k sin ( β k t ) a1k sin ( β k t ) + b1k cos ( β k t )
x ( t ) ∑ eα k t C1k 1k + C2 k
k =1 a2 k cos ( β k t ) − b2 k sin ( β k t ) a2 k sin ( β k t ) + b2 k cos ( β k t ) .
(D.111)
In eqn. (D.111), α k ± j β k represent the eigenvalues and a’s and b’s are the elements
of the eigenvectors.
When more than 2 coupled variables exist, the simple approach described earlier
requires generalization using the concept of the fundamental matrix, particularly when
the matrix is defective. Going back to the solution of a homogeneous system with
distinct eigenvectors, the solution in (D.89) can be expressed as
v v
x ( t ) =C1 x1 ( t ) + C2 x2 ( t ) =C1 eλ1t 11 + C2 eλ2t 12 . (D.112)
v21 v22
In other words, if two distinct eigenvectors exist,the solution set is a linear combination
of a fundamental set of vectors X 1 ( t ) and X 2 ( t ) . The fundamental matrix X(t)
associated with the coefficient matrix A is expressed as
X ( t ) = X 1 ( t ) X 2 ( t ) . (D.113)
In eqn. (D.113), x1 ( t ) and x2 ( t ) are given by
λ1t v11 v
= X 1 ( t ) e= v X 2 ( t ) eλ2t 12 . (D.114)
21 v22
This concept can be extended to a case of a coupled differential equation in n-variables
and the general solution set of the differential equation will be
n n
x ( t ) X=
= (t ) C
=
n
k 1=
n
k 1
∑C =
X ( t ) ∑ C eλ ν
. (D.115)n
nt
n
In eqn. (D.115), xn is the eigenvector associated with the eigenvalue λn and C is the
vector of constants. As discussed earlier, it is not necessary to have distinct eigenvalues.
But, eigenvectors must be distinct. For the case of n=2,
x (t )
x ( t ) = 1 . (D.116)
x2 ( t )
For the case of a pair of complex conjugate eigenvalues, the components of the
fundamental matrix x1 ( t ) and x2 ( t ) can be written using eqn. (D.104) as
α t a1 cos ( β t ) − b1 sin ( β t ) a sin ( β t ) + b1 cos ( β t )
X 1 ( t ) e= X 2 ( t ) eα t 1
a2 cos ( β t ) − b2 sin ( β t ) a2 sin ( β t ) + b2 cos ( β t )
(D.117)
Appendices 437
Note that when algebraic multiplicity is unity, eigenvectors are distinct. In this case,
only the first term in eqn. (D.119) will be retained because
( A − λ In ) v =
0 . (D.121)
Note also that n-distinct eigenvectors are obtained from eqn. (D.120) with p=1.
Several examples of coupled first order equations defined by the coefficient
matrix are examined as to whether the coefficient matrix is defective. As the size
of the coefficient matrix exceeds 3, the number of possibilities for the relationships
among the eigenvalues and eigenvectors become much more intricate and deliberate
processing is needed to identify the defective matrices and determine the algebraic
and geometric multiplicities of the specific eigenvalues. These examples were created
in MATLAB. Starting from the coefficient matrix, the results display eigenvalues and
eigenvectors, geometric and algebraic multiplicities if the matrix is defective, identify
the eigenvalues associated with the generalized eigenvectors and specific algebraic
multiplicity and generalized eigenvectors. Use of these generalized vectors can be
seen in Chapter 5.
A=[4,6,6;1,3,2;-1,-5,-2];
438 Differential Equations: A Problem Solving Approach Based on MATLAB
A=[0,1,2;-5,-3,-7;1,0,0];
Appendices 439
A=[1,-1;1,3];
440 Differential Equations: A Problem Solving Approach Based on MATLAB
1 + 2t 4t
x ( t ) =c1 x1 ( t ) + c2 x2 ( t ) =c1 + c2 1 − 2t (D.125)
− t
Consider the following coefficient matrix representing a set of coupled first order
differential equations,
1 0 0
A = 0 −2 −1 (D.126)
0 0 −2
The eigenvalues and eigenvectors are
1
λ1 1=
= v1 0 (D.127)
0
0
λ2,3 = 1
−2 v2,3 =
(D.128)
0
The coefficient matrix is therefore defective with the eigenvalue of -2 having an
algebraic multiplicity (p) of 2 and geometric multiplicity (m) of 1, requiring the need
for generalized eigenvectors. Generalized eigenvectors are obtained as solutions of
= 0 ⇒ ( A − ( −2 ) I 3 ) = 0
2
( A − λ I3 )
p
(D.129)
442 Differential Equations: A Problem Solving Approach Based on MATLAB
1
t
X 1 ( t ) = e 0
0
0 0 0
−2 t
) 1 e−2t
X 2 ( t ) e 1 + t ( A − (−2) I 3=
= 1
(D.131)
0
0 0
0 0 0 0 0
−2 t −2t −2t −t
X 3 ( t ) e 0 + t ( A − (−2) I 3=
= ) 0 e 0 += −t e
1
1 1 0 1
The solution to the coupled first order equations represented by the coefficient matrix is
0 c1e
t
1 0
t −2 t −2 t −2t −2 t
x=( t ) c1 X 1 ( t ) + c2 X 2 ( t ) + c3 X 3 =
( t ) c1e 0 + c2 e 1 + c3e −= t c2 e − c3te
0 0 1 c3 e −2t
(D.132)
Additional examples and applications will be seen in Chapters 3 and 5.
We can use the concept of the fundamental matrix to find the particular solution
to a non-homogeneous first order system,
If X(t) is the fundamental matrix, the solution given in eqn. (D.115) implies that
an analogous solution to the non-homogeneous part can be obtained by replacing the
constant C by a time dependent vector p p ( t ) as
x ( t ) = X ( t ) p ( t ) (D.134)
The solution in eqn. (D.140) is identified as the particular solution based on the
method of variation of parameters (similarity to the method based on Wronskian seen
in Chapters 2 and 4).
Suggested Readings
A number of excellent books and monographs devoted to the topic of differential equations and linear
algebra might provide supplementary information beyond what is covered in this book. Additionally,
several books are also available that describe the use of MATLAB® in differential equations and linear
algebra. A good source of information on the application of MATLAB is available within the help window
of MATLAB itself. A partial list of some of these resources is provided below for additional reading.
Index
I P
Identity matrix 87, 239, 240, 293 Partial fractions 401
Implicit solution 10, 18, 26, 29, 30, 45, 46, 77 Particular solution 2, 3, 10, 81, 119–127, 177,
Independent solutions 238, 239 179, 181, 182, 185, 189, 191, 192, 194, 200,
Independent variable 1, 5, 9, 17, 31, 77, 81 233, 234, 268, 270, 271, 273, 278–281, 283,
Integrating factor 2, 5, 9, 10, 17, 77, 78 285, 286, 289, 291, 294, 381, 382
Inverse Laplace transform 84, 98, 99, 122, 126, Phase portraits 2, 3, 89, 90, 97, 177, 178, 240–
187, 190, 191, 193, 195, 197, 240, 253, 255, 242, 245, 246, 248, 250, 253, 255, 257, 258,
257, 258, 262, 263, 266, 267, 269, 270, 272, 262, 277, 381
273, 284, 286, 290, 292, 295, 331 Pivot columns 419
Pivots 419
L
R
Laplace transforms 2–4, 81, 84, 98, 99, 121, 122,
126, 127, 177, 179–182, 185–188, 190, 191, Reduced Row echelon form 419
193, 195–197, 199, 200, 233, 235, 236, 240, Roots 2, 3, 34–36, 43, 44, 46, 81–84, 86–91, 97,
252–258, 262, 263, 266, 267, 269, 270, 272, 99, 119, 120, 122–124, 177–180, 182–185,
273, 281, 284, 286, 290, 292, 295, 296, 298, 188–191, 193, 195–200, 233, 234, 240, 252,
331 381, 382 254, 256, 261, 263, 265, 267, 298, 381
L’Hospital Rule 32 Row vectors 179, 182
Linear 1–6, 9, 17, 77, 81, 82, 85, 97, 119, 120, Runge-Kutta method 3, 26, 85, 88, 122, 182, 185,
123, 126, 127, 181, 236, 238, 274 187, 195, 196, 233, 381
Local Truncation Error 387
S
M
Saddle points 251
Matrix 3, 85–88, 186–188, 237–242, 245, 246, Second order differential equations 2, 81, 177,
248–250, 252–263, 265–276, 278–282, 284, 254
285, 287, 288, 290–293, 295, 296, 298, 331, Separable functions 2, 9, 18, 26, 77
382 Stable, unstable, semi stable equilibrium 32
Matrix equation 88, 188, 237, 281 Superposition principle 83
Matrix inverse 419 Symmetric matrix 248
Matrix vector equation 281 System of differential equations 258
Method of undetermined coefficients 2, 119–122, System of equations 420
124–126, 177, 179, 185
Method of variation of parameters 2, 3, 119, 121, T
123, 124, 126, 127, 177, 179, 185, 200, 268,
Taylor series 385
381
Transpose of a matrix 417
Multiplicity 185, 293, 331
Multiplicity, Algebraic 293, 331
U
Multiplicity, Geometric 331
Unique solution 185
N
V
Newton’s Law 77
Node 251 Vectors 26, 28, 44, 85, 122, 124, 126, 179, 180,
Non-homogeneous 2, 81, 82, 119, 121, 122, 126, 182, 183, 189, 191, 192, 194, 199, 234,
177, 181, 185, 236, 237, 268, 269, 271, 237–240, 274, 279, 280, 281
274–280, 325, 381
Null matrix 274 W
Null space 421
Numerical methods 3, 177 Wronskian 121, 123, 126, 185, 186, 189, 190,
192, 194, 233, 234
O
Z
Oscillatory solutions 242
Zero matrix 86, 186, 275