This book provides an introduction to the theory of dynamical systems with the aid of MATLAB,the Symbolic Math Toolbox TM , the Image Processing Toolbox TM , and Simulink TM.. Note that
Trang 2Stephen Lynch
Dynamical Systems with Applications using MATLAB®
Trang 3Stephen Lynch
Department of Computing and Mathematics, Manchester Metropolitan University School of
Computing, Mathematics & Digital Technology, Manchester, UK
DOI 10.1007/978-3-319-06820-6
Springer Cham Heidelberg New York Dordrecht London
Library of Congress Control Number: 2014941703
Mathematics Subject Classification (2010): 37-01, 49K15, 78A60, 28A80, 80A30, 34H10, 34K18,70K05, 34C07, 34D06, 92B20, 94C05
© Springer International Publishing Switzerland 2014
This work is subject to copyright All rights are reserved by the Publisher, whether the whole or part
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed Exempted from this legal reservation arebrief excerpts in connection with reviews or scholarly analysis or material supplied specifically forthe purpose of being entered and executed on a computer system, for exclusive use by the purchaser ofthe work Duplication of this publication or parts thereof is permitted only under the provisions of theCopyright Law of the Publisher’s location, in its current version, and permission for use must always
be obtained from Springer Permissions for use may be obtained through RightsLink at the CopyrightClearance Center Violations are liable to prosecution under the respective Copyright Law
The use of general descriptive names, registered names, trademarks, service marks, etc in this
publication does not imply, even in the absence of a specific statement, that such names are exemptfrom the relevant protective laws and regulations and therefore free for general use
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal responsibilityfor any errors or omissions that may be made The publisher makes no warranty, express or implied,with respect to the material contained herein
Printed on acid-free paper
Springer is part of Springer Science+Business Media (www.birkhauser-science.com)
Trang 5Since the first printing of this book in 2004, MATLAB ® ; has evolved from MATLAB version 6 toMATLAB version R2014b, where presently, the package is updated twice a year Accordingly, thesecond edition has been thoroughly updated and new material has been added In this edition, thereare many more applications, examples, and exercises, all with solutions, and new sections on seriessolutions of ordinary differential equations, perturbation methods, normal forms, Gröbner bases, andchaos synchronization have been added There are also new chapters on image processing and binaryoscillator computing
This book provides an introduction to the theory of dynamical systems with the aid of MATLAB,the Symbolic Math Toolbox TM , the Image Processing Toolbox TM , and Simulink TM It is writtenfor both senior undergraduates and graduate students Chapter 1 provides a tutorial introduction toMATLAB—new users should go through this chapter carefully whilst those moderately familiar andexperienced users will find this chapter a useful source of reference Chapters 2 – 7 deals with
discrete systems, Chaps. 8 – 17 are devoted to the study of continuous systems using ordinary
differential equations and Chaps. 18 – 21 deal with both continuous and discrete systems Chapter 22
lists three MATLAB-based examinations to be sat in a computer laboratory with access to MATLABand Chap. 23 lists answers to all of the exercises given in the book It should be pointed out thatdynamical systems theory is not limited to these topics but also encompasses partial differential
equations, integral and integro-differential equations, stochastic systems, and time-delay systems, forinstance References [1–5] given at the end of the Preface provide more information for the interestedreader The author has gone for breadth of coverage rather than fine detail and theorems with proofsare kept at a minimum The material is not clouded by functional analytic and group theoretical
definitions and so is intelligible to readers with a general mathematical background Some of thetopics covered are scarcely covered elsewhere Most of the material in Chaps. 7, 10, 11, 15–19, and
21 is at postgraduate level and has been influenced by the author’s own research interests There ismore theory in these chapters than in the rest of the book since it is not easily accessed anywhere else
It has been found that these chapters are especially useful as reference material for senior
undergraduate project work The theory in other chapters of the book is dealt with more
comprehensively in other texts, some of which may be found in the references section of the
corresponding chapter The book has a very hands-on approach and takes the reader from the basictheory right through to recently published research material
MATLAB is extremely popular with a wide range of researchers from all sorts of disciplines, ithas a very user-friendly interface and has extensive visualization and numerical computation
capabilities It is an ideal package to adopt for the study of nonlinear dynamical systems; the
numerical algorithms work very quickly, and complex pictures can be plotted within seconds TheSimulink accessory to MATLAB is used for simulating dynamical processes It is as close as one canget to building apparatus and investigating the output for a given input without the need for an actualphysical model For this reason, Simulink is very popular in the field of engineering Note that thelatest student version of MATLAB comes with a generous additional ten toolboxes including the
Symbolic Math Toolbox, the Image Processing Toolbox, and Simulink
The first chapter provides an efficient tutorial introduction to MATLAB New users will find thetutorials will enable them to become familiar with MATLAB within a few hours Both engineeringand mathematics students appreciate this method of teaching and I have found that it generally works
Trang 6well with one staff member to about twenty students in a computer laboratory In most cases, I havechosen to list the MATLAB program files at the end of each chapter, this avoids unnecessary
cluttering in the text The MATLAB programs have been kept as simple as possible and should rununder later versions of the package The MATLAB program files and Simulink model files (includingupdates) can even be downloaded from the Web at http://www.mathworks.com/matlabcentral/
fileexchange/authors/6536 Readers will find that they can reproduce the figures given in the text, andthen it is not too difficult to change parameters or equations to investigate other systems Readers may
be interested to hear that the MATLAB and Simulink model files have been downloaded over 30,000times since they were uploaded in 2002 and that these files were selected as the MATLAB CentralPick of the Week in July 2013
Chapters 2 – 7 deal with discrete dynamical systems Chapter 2 starts with a general introduction
to iteration and linear recurrence (or difference) equations The bulk of the chapter is concerned withthe Leslie model used to investigate the population of a single species split into different age classes.Harvesting and culling policies are then investigated and optimal solutions are sought Nonlineardiscrete dynamical systems are dealt with in Chap. 3 Bifurcation diagrams, chaos, intermittency,Lyapunov exponents, periodicity, quasiperiodicity, and universality are some of the topics
introduced The theory is then applied to real-world problems from a broad range of disciplines
including population dynamics, biology, economics, nonlinear optics, and neural networks Chapter 4
is concerned with complex iterative maps; Julia sets and the now-famous Mandelbrot set are plotted.Basins of attraction are investigated for these complex systems As a simple introduction to optics,electromagnetic waves and Maxwell’s equations are studied at the beginning of Chap. 5 Complexiterative equations are used to model the propagation of light waves through nonlinear optical fibers
A brief history of nonlinear bistable optical resonators is discussed and the simple fiber ring
resonator is analyzed in particular Chapter 5 is devoted to the study of these optical resonators andphenomena such as bistability, chaotic attractors, feedback, hysteresis, instability, linear stabilityanalysis, multistability, nonlinearity, and steady states are discussed The first and second iterativemethods are defined in this chapter Some simple fractals may be constructed using pencil and paper
in Chap. 6 , and the concept of fractal dimension is introduced Fractals may be thought of as
identical motifs repeated on ever-reduced scales Unfortunately, most of the fractals appearing innature are not homogeneous but are more heterogeneous, hence the need for the multifractal theorygiven later in the chapter It has been found that the distribution of stars and galaxies in our universe ismultifractal, and there is even evidence of multifractals in rainfall, stock markets, and heartbeat
rhythms Applications in materials science, geoscience, and image processing are briefly discussed.Chapter 7 provides a brief introduction to the Image Processing Toolbox TM which is being usedmore and more by a diverse range of scientific disciplines, especially medical imaging The fastFourier transform is introduced and has a wide range of applications throughout the realms of
science
Chapters 8 – 17 deal with continuous dynamical systems Chapters 8 and 9 cover some theory ofordinary differential equations and applications to models in the real world are given The theory ofdifferential equations applied to chemical kinetics and electric circuits is introduced in some detail.The memristor is introduced and one of the most remarkable stories in the history of mathematics isrelayed Chapter 8 ends with the existence and uniqueness theorem for the solutions of certain types
of differential equations A variety of numerical procedures are available in MATLAB when solvingstiff and nonstiff systems when an analytic solution does not exist or is extremely difficult to find Thetheory behind the construction of phase plane portraits for two-dimensional systems is dealt with in
Trang 7Chap. 9 Applications are taken from chemical kinetics, economics, electronics, epidemiology,
mechanics, and population dynamics The modeling of the populations of interacting species is
discussed in some detail in Chap. 10 and domains of stability are discussed for the first time Limitcycles, or isolated periodic solutions, are introduced in Chap. 11 Since we live in a periodic
world, these are the most common type of solution found when modeling nonlinear dynamical
systems They appear extensively when modeling both the technological and natural sciences
Hamiltonian, or conservative, systems and stability are discussed in Chaps. 12, and 13 is concernedwith how planar systems vary depending upon a parameter Bifurcation, bistability, multistability, andnormal forms are discussed
The reader is first introduced to the concept of chaos in continuous systems in Chaps. 14 and 15 ,where three-dimensional systems and Poincaré maps are investigated These higher-dimensionalsystems can exhibit strange attractors and chaotic dynamics One can rotate the three-dimensionalobjects in MATLAB and plot time series plots to get a better understanding of the dynamics involved.Once again, the theory can be applied to chemical kinetics (including stiff systems), electric circuits,and epidemiology; a simplified model for the weather is also briefly discussed Chapter 15 dealswith Poincaré first return maps that can be used to untangle complicated interlacing trajectories inhigher-dimensional spaces A periodically driven nonlinear pendulum is also investigated by means
of a nonautonomous differential equation Both local and global bifurcations are investigated in
Chap. 16 The main results and statement of the famous second part of David Hilbert’s sixteenthproblem are listed in Chap. 17 In order to understand these results, Poincaré compactification isintroduced The study of continuous systems ends with one of the author’s specialities—limit cycles
of Liénard systems There is some detail on Liénard systems, in particular, in this part of the book, butthey do have a ubiquity for systems in the plane
A brief introduction to the enticing field of neural networks is presented in Chap. 18 Imaginetrying to make a computer mimic the human brain One could ask the question: In the future will it bepossible for computers to think and even be conscious? The human brain will always be more
powerful than traditional, sequential, logic-based digital computers and scientists are trying to
incorporate some features of the brain into modern computing Neural networks perform through
learning and no underlying equations are required Mathematicians and computer scientists are
attempting to mimic the way neurons work together via synapses; indeed, a neural network can bethought of as a crude multidimensional model of the human brain The expectations are high for futureapplications in a broad range of disciplines Neural networks are already being used in machine
learning and pattern recognition (computer vision, credit card fraud, prediction and forecasting,
disease recognition, facial and speech recognition), the consumer home entertainment market,
psychological profiling, predicting wave over-topping events, and control problems, for example.They also provide a parallel architecture allowing for very fast computational and response times Inrecent years, the disciplines of neural networks and nonlinear dynamics have increasingly coalescedand a new branch of science called neurodynamics is emerging Lyapunov functions can be used todetermine the stability of certain types of neural network There is also evidence of chaos, feedback,nonlinearity, periodicity, and chaos synchronization in the brain
Chapter 19 is devoted to the new and exciting theory behind chaos control and synchronization.For most systems, the maxim used by engineers in the past has been “stability good, chaos bad,” butmore and more nowadays this is being replaced with “stability good, chaos better.” There are
exciting and novel applications in cardiology, communications, engineering, laser technology, andspace research, for example
Trang 8Chapter 20 focuses on binary oscillator computing, the subject of UK, International and
Taiwanese patents The author and his coinventor, Jon Borresen, came up with the idea when
modeling connected biological neurons Binary oscillator technology can be applied to the design ofarithmetic logic units (ALUs), memory, and other basic computing components It has the potential toprovide revolutionary computational speedup, energy saving, and novel applications and may beapplicable to a variety of technological paradigms including biological neurons, complementarymetal–oxide–semiconductor (CMOS), memristors, optical oscillators, and superconducting materials.The research has the potential for MMU and industrial partners to develop super fast, low-powercomputers and may provide an assay for neuronal degradation for brain malfunctions such as
Alzheimer’s, epilepsy, and Parkinson’s disease!
Examples of Simulink models, referred to in earlier chapters of the book, are presented in Chap.
21 It is possible to change the type of input into the system, or parameter values, and investigate theoutput very quickly This is as close as one can get to experimentation without the need for expensiveequipment
Three examination-type papers are listed in Chap. 22 and a complete set of solutions is listed inChap. 23
Both textbooks and research papers are presented in the list of references The textbooks can beused to gain more background material, and the research papers have been given to encourage furtherreading and independent study
This book is informed by the research interests of the author which are currently nonlinear
ordinary differential equations, nonlinear optics, multifractals, neural networks, and binary oscillatorcomputing Some references include recently published research articles by the author along with aninternational patent
The prerequisites for studying dynamical systems using this book are undergraduate courses inlinear algebra, real and complex analysis, calculus, and ordinary differential equations; a knowledge
of a computer language such as C or Fortran would be beneficial but not essential
Recommended Textbooks
1 M.P Coleman, An Introduction to Partial Differential Equations with MATLAB , 2nd edn.
Chapman and Hall/CRC Applied Mathematics and Nonlinear Science (Chapman and Hall/CRC, NewYork, 2013)
2 B Bhattacharya, M Majumdar, Random Dynamical Systems: Theory and Applications
(Cambridge University Press, Cambridge, 2007)
3 R Sipahi, T Vyhlídal, S Niculescu, P Pepe (eds.), Time Delay Systems: Methods,
Applications and New Trends Lecture Notes in Control and Information Sciences (Springer, New
York, 2012)
4 V Volterra, Theory of Functionals and of Integral and Integro-Differential Equations
(Dover Publications, New York, 2005)
5 J Mallet-Paret, J Wu, H Zhu, Y Yi, Infinite Dimensional Dynamical Systems (Fields
Institute Communications) (Springer, New York, 2013)
Instructors may be interested in two new features in MATLAB, namely, Cody Coursework TM andMATLAB apps Instructors can automate grading of MATLAB coursework assignments using CodyCoursework; this is a free resource available to use for faculty who have an active site licence
MATLAB apps enable the user to perform computational tasks interactively and many of the
Trang 9toolboxes come with apps More details can be found on the relevant MathWorks web pages.
I would like to express my sincere thanks to MathWorks for supplying me with the latest versions
of MATLAB and its toolboxes Thanks also go to all of the reviewers from the editions of the Mapleand Mathematica books Special thanks go to Birkhäuser and Springer publishers Finally, thanks to
my family, especially my wife, Gaynor, and our children, Sebastian and Thalia, for their continuinglove, inspiration, and support
Stephen Lynch Manchester, UK
Trang 101 A Tutorial Introduction to MATLAB
1.1 Tutorial One: The Basics and the Symbolic Math Toolbox (1 h) 1.2 Tutorial Two: Plots and Differential Equations (1 h)
1.3 MATLAB Program Files or M-Files
1.4 Hints for Programming
1.5 MATLAB Exercises
References
2 Linear Discrete Dynamical Systems
2.1 Recurrence Relations
2.2 The Leslie Model
2.3 Harvesting and Culling Policies
2.4 MATLAB Commands
2.5 Exercises
References
3 Nonlinear Discrete Dynamical Systems
3.1 The Tent Map and Graphical Iterations
3.2 Fixed Points and Periodic Orbits
3.3 The Logistic Map, Bifurcation Diagram, and Feigenbaum Number 3.4 Gaussian and Hénon Maps
3.5 Applications
3.6 MATLAB Program Files
3.7 Exercises
Trang 114 Complex Iterative Maps
4.1 Julia Sets and the Mandelbrot Set
4.2 Boundaries of Periodic Orbits
4.3 MATLAB Commands
4.4 Exercises
References
5 Electromagnetic Waves and Optical Resonators
5.1 Maxwell’s Equations and Electromagnetic Waves
5.2 Historical Background
5.3 The Nonlinear SFR Resonator
5.4 Chaotic Attractors and Bistability
5.5 Linear Stability Analysis
5.6 Instabilities and Bistability
5.7 MATLAB Commands
5.8 Exercises
References
6 Fractals and Multifractals
6.1 Construction of Simple Examples
6.2 Calculating Fractal Dimensions
6.3 A Multifractal Formalism
6.4 Multifractals in the Real World and Some Simple Examples 6.5 MATLAB Commands
6.6 Exercises
Trang 127 The Image Processing Toolbox
7.1 Image Processing and Matrices
7.2 The Fast Fourier Transform
7.3 The Fast Fourier Transform on Images
7.4 Exercises
References
8 Differential Equations
8.1 Simple Differential Equations and Applications
8.2 Applications to Chemical Kinetics
8.3 Applications to Electric Circuits
8.4 Existence and Uniqueness Theorem
9.4 Linearization and Hartman’s Theorem
9.5 Constructing Phase Plane Diagrams
9.6 MATLAB Commands
9.7 Exercises
References
Trang 1413.3 Multistability and Bistability
13.4 MATLAB Commands
13.5 Exercises
References
14 Three-Dimensional Autonomous Systems and Chaos
14.1 Linear Systems and Canonical Forms
14.2 Nonlinear Systems and Stability
14.3 The Rössler System and Chaos
14.4 The Lorenz Equations, Chua’s Circuit, and the Belousov–Zhabotinski Reaction 14.5 MATLAB Commands
14.6 Exercises
References
15 Poincaré Maps and Nonautonomous Systems in the Plane
15.1 Poincaré Maps
15.2 Hamiltonian Systems with Two Degrees of Freedom
15.3 Nonautonomous Systems in the Plane
15.4 MATLAB Commands
15.5 Exercises
References
16 Local and Global Bifurcations
16.1 Small-Amplitude Limit Cycle Bifurcations
16.2 Gröbner Bases
16.3 Melnikov Integrals and Bifurcating Limit Cycles from a Center
16.4 Bifurcations Involving Homoclinic Loops
Trang 1516.5 MATLAB and MuPAD Commands
17.3 Global Results for Liénard Systems
17.4 Local Results for Liénard Systems
19.2 Controlling Chaos in the Logistic Map
19.3 Controlling Chaos in the Hénon Map
19.4 Chaos Synchronization
19.5 MATLAB Commands
Trang 1619.6 Exercises
References
20 Binary Oscillator Computing
20.1 Brain-Inspired Computing
20.2 Oscillatory Threshold Logic
20.3 Applications and Future Work
Trang 1723.3 Chapter 3 23.4 Chapter 4 23.5 Chapter 5 23.6 Chapter 6 23.7 Chapter 7 23.8 Chapter 8 23.9 Chapter 9 23.10 Chapter 10 23.11 Chapter 11 23.12 Chapter 12 23.13 Chapter 13 23.14 Chapter 14 23.15 Chapter 15 23.16 Chapter 16 23.17 Chapter 17 23.18 Chapter 18 23.19 Chapter 19 23.20 Chapter 20 23.21 Chapter 21 23.22 Chapter 22
Index
Trang 18© Springer International Publishing Switzerland 2014
Stephen Lynch, Dynamical Systems with Applications using MATLAB®, DOI 10.1007/978-3-319-06820-6_1
1 A Tutorial Introduction to MATLAB
Stephen Lynch1
Department of Computing and Mathematics, Manchester Metropolitan University School of
Computing, Mathematics & Digital Technology, Manchester, UK
Aims and Objectives
To provide a tutorial guide to MATLAB
To give practical experience in using the package
To promote self-help using the online help facilities
To provide a concise source of reference for experienced users
On completion of this chapter the reader should be able to
use MATLAB and the Symbolic Math Toolbox;
produce simple MATLAB programs;
access some MATLAB commands and programs over the World Wide Web
It is assumed that the reader is familiar with either the Windows or UNIX platform This book was
prepared using MATLAB R2014b, but most programs should work under earlier and later versions ofthe package
The commands and programs listed have been chosen to allow the reader to become familiar withMATLAB and the Symbolic Math Toolbox within a few hours They provide a concise summary ofthe type of commands that will be used throughout this book New users should be able to start ontheir own problems after completing this tutorial, and experienced users should find this chapter anexcellent source of reference Of course, there are many MATLAB textbooks on the market for thosewho require further applications or more detail Note that from version 5, the Symbolic Math
Toolbox is powered by the MuPAD symbolic engine, and nearly all Symbolic Math Toolbox
functions work the same way as in previous versions The Symbolic Math Toolbox provides tools forsolving and manipulating symbolic math expressions and performing variable-precision arithmetic.The toolbox contains hundreds of MATLAB symbolic functions that leverage the MuPAD engine fortasks such as differentiation, integration, simplification, transforms, and equation solving See theonline MATLAB Help pages if you require further information
If you experience any problems, there are several options for you to take There is an excellentindex within MATLAB, there are thousands of textbooks, see references [1–10], for example, andMATLAB program files (or M-files) can be downloaded from the MATLAB Central File Exchange
at the link
http://www.mathworks.com/matlabcentral/fileexchange/
Trang 19Download the zipped M-files and extract the relevant M-files from the archive onto your
computer Since 2002, the author’s files associated with the first edition of this book have been
downloaded over 30,000 times by users from all over the world
To start MATLAB, simply double-click on the MATLAB icon In the UNIX environment, onetypes MATLAB as a shell command The author has used the Windows platform in the preparation ofthis material When MATLAB starts up, by default three windows are displayed entitled CurrentFolder, Command Window, and Workspace Figure 1.1 shows a typical screen when running
MATLAB Each of the windows appearing in Fig. 1.1 will now be described:
Fig 1.1 The MATLAB user interface
Current Folder This window shows the current folder where files are listed Note that when typing
in the Command Window, the command pwd also displays the MATLAB current folder
Command Window This is where the user types in MATLAB commands followed by the
RETURN or ENTER key on the keyboard If you do not want to see the result (e.g., you would notwant to see a list of numbers from 1 to 1,000), then use the semicolon delimiter
Workspace The workspace consists of the set of variables built up during a session of using the
MATLAB software and stored in memory
The Command Window is where the MATLAB commands are typed and executed, and this iswhere the user can use MATLAB just like a graphing calculator When in the Command Window,command lines may be returned to and edited using the up and down arrow keys If you do make a
typing error, MATLAB will give an error: message and even point to the mistake in the code Do not
re-type the line, simply use the up arrow key and edit your mistake To clear the Command Windowsimply type >> clc after the command prompt
By clicking on New Script in the top left corner of the MATLAB user interface (see Fig. 1.1) anew program file can be typed in the MATLAB editor In this chapter, each MATLAB program isdisplayed between horizontal lines and kept short to aid in understanding; the output is also included.Take care, the MATLAB files (also known as M-files or script files ) will only run if they are in thecurrent working directory Ensure that the files you are working with are in your Current Folder Any
Trang 20results obtained with MATLAB should be verified by experiment where possible.
Some Well-Known Pitfalls of MATLAB
Array indices start with 1 and not 0 In some programs a translation may be required to start
indices with zero
MATLAB allows use of variable names of pre-defined functions For example, you can set rand =
1 which means that you cannot subsequently use the rand command Readers should use the whichcommand to check variable names
Take care with element-wise and matrix-matrix multiplication
Some functions such as max, min, sort, sum, mean, etc., behave differently for complex and realdata
In MATLAB it is better (though not easier) to use matrix or vector operations instead of loops inprograms
Without the Symbolic Math Toolbox, MATLAB gives approximate answers
The reader should also be aware that even when the programs run successfully the output may not
be correct The following phenomena can greatly affect the results obtained for nonlinear dynamicalsystems:
Chaos and sensitivity to initial conditions
Using the correct numerical solver for your particular problem
Feedback, especially in the case of the second iterative method which is defined later in this book
Trang 211.1 Tutorial One: The Basics and the Symbolic Math Toolbox (1 h)
There is no need to copy the comments, they are there to help you Click on the MATLAB icon andcopy the command after the >> prompt Press Return at the end of a line to see the answer or use a semicolon to suppress the output You can interrupt a computation at any time by holding Ctrl+C.
This tutorial should be run in the Command Window
MATLAB commands Comments
>> % This is a comment % Helps when writing
% programs.
>> 3^2*4-3*2^5*(4-2) % Simple arithmetic.
>> sqrt(16) % The square root.
>> % Vectors and Matrices.
>> u=1:2:9 % A vector u=(1,3,5,7,9).
>> v=u.^2 % A vector v=(1,9,25,49,81).
>> A=[1,2;3,4] % A is a 2 by 2 matrix.
>> A’ % The transpose of matrix A.
>> det(A) % The determinant of a matrix.
>> B=[0,3,1;0.3,0,0;0,0.5,0] % B is a 3 by 3 matrix.
>> eig(B) % The eigenvalues of B.
>> % List the eigenvectors and eigenvalues of B.
>> real(z1) % The real part.
>> imag(z1) % The imaginary part.
>> exp(i*z1) % Returns a complex number.
>> % The Symbolic Math Toolbox.
>> sym(1/2)+sym(3/4) % Symbolic evaluation.
>> % Double precision floating point arithmetic.
>> simplify(z/(x-y)) % Symbolic simplification.
>> % Symbolic solution of algebraic equations.
>> [x,y]=solve(’x^2-x’,’2*x*y-y^2’)
>> syms x mu
>> f=mu*x*(1-x) % Define a function.
>> subs(f,x,1/2) % Substitute for x, gives f(1/2).
Trang 22>> fof=subs(f,x,f) % A function of a function.
>> laplace(x^3) % Laplace transform.
>> ilaplace(6/s^4) % Inverse Laplace transform.
>> syms x w
>> fourier(-2*pi*abs(x)) % Fourier transform.
>> ifourier(4*pi/w^2) % Inverse Fourier transform.
>> % End of Tutorial 1.
1.2 Tutorial Two: Plots and Differential Equations (1 h)
More involved plots will be dealt with in Sect. 1.3 You will need the Symbolic Math Toolbox formost of the commands in this section
>> % Contour plot on a grid of 50 by 50
Trang 23Symbolic Solutions to Ordinary Differential Equations (ODEs) If an analytic solution cannot
be found, the message “Warning: Explicit solution could not be found” is shown
>> % The D denotes differentiation with respect to t
Numerical Solutions to ODEs These methods are usually used when an analytic solution cannot
be found—even though one may exist! Below is a Table 1.1 lists some initial value problem solvers
in MATLAB See the on-line MATLAB index for more details or type >> help topic.
Table 1.1 There are other solvers, but the solvers listed below should suffice for the material covered in this book
Solver O.D.E Method Summary
ode45 Nonstiff Runge–Kutta Try this first
ode23 Nonstiff Runge–Kutta Crude tolerances
ode113 Nonstiff Adams Multi-step solver
ode15s Stiff Gears method If you suspect stiffness
ode23s Stiff Rosenbrock One step solver
>> % Set up a 1-D system with initial condition 50,
>> % and run for 0<t<100
>> deq1=@(t,x) x(1)*(.1-.01*x(1));
>> [t,xa]=ode45(deq1,[0 100],50);
>> plot(t,xa(:,1))
>> % A 2-D system with initial conditions [.01,0],
>> % and run for 0<t<50
Trang 241.3 MATLAB Program Files or M-Files
Sections 1.1 and 1.2 illustrate the use of the Command Window and its interactive nature Moreinvolved tasks will require more lines of code, and it is better to use MATLAB program files or M-files Each program is displayed between horizontal lines and kept short to aid in understanding; theoutput is also included
Function M-Files The following M-file defines the logistic function.
% Program 1 - The logistic function
% Save the M-file as fmu.m
The for end Loop For repetitive tasks.
% Program 2 - The Fibonacci sequence
% Save the M-file as Fibonacci.m
Nmax=input(’Input the number of terms of the Fibonacci
Conditional Statements If then elseif else end, etc.
% Program 3 - The use of logical expressions
% Save this M-file as test1.m
integer=input(’Which integer do you wish to test?’)
Trang 25disp([’The integer is positive.’])
The integer is negative
Fig 1.2 A multiple plot with text
Graphic Programs Multiple plots with text (Fig. 1.2)
% Program 4 - Two curves on one graph
% Save the M-file as plot1.m
% Tex symbols can be plotted within a figure window.clear all
fsize=15;
x=0:.1:7;
figure;
plot(x,2*x./5,x,-x.^2/6+x+7/6)
text(1,2,’\leftarrow curve 1’,’Fontsize’,fsize)
text(2.6,1,’\leftarrow line 1’,’Fontsize’,fsize)
Labeling Solution Curves Solutions to the pendulum problem (Fig. 1.3)
% Program 5 - Solution curves to different ODEs
% Save M-file as deplot1.m
Trang 26plot(t,xa(:,1),’r’); % Plot a red curve.
clear
deqn=@(t,x) [x(2);-2*x(2)-25*x(1)];
[t,xb]=ode45(deqn,[0 10],[1 0]);
plot(t,xb(:,1),’b’); % Plot a blue curve
legend(’harmonic motion’,’damped motion’)
Fig 1.3 Harmonic and damped motion of a pendulum
Echo Commands Useful when debugging a program.
% Program 6 - Use echo to display command lines
% Save the M-file as poincare.m
1.4 Hints for Programming
The MATLAB language contains very powerful commands, which means that some complex
programs may contain only a few lines of code Of course, the only way to learn programming is to sitdown and try it yourself This section has been included to point out common errors and give advice
on how to troubleshoot Remember to check the help and index pages in MATLAB and the Web if the
Trang 27(b)
1
following does not help you with your particular problem
Common Typing Errors The author strongly advises new users to run Tutorials One and Two in
the Command Window environment, this should reduce typing errors
Be careful to include all mathematics operators
When dealing with vectors put a full stop (.) in front of the mathematical operator
Make sure brackets, parentheses, etc match up in correct pairs
Remember MATLAB is case-sensitive
Check the syntax, enter help followed by the name of the command.
Programming Tips The reader should use the M-files in Sect. 1.3 to practice simple
programming techniques Note that MATLAB has a built in code analyzer and appears in the top rightcorner of the message bar Red indicates syntax errors were detected Orange indicates warnings oropportunities for improvement, but no errors, were detected, and green indicates no errors, warnings,
or opportunities for improvement were detected For more information and examples, the readershould check the MathWorks document center for checking code for errors and warnings
It is best to clear values at the start of a large program
Use the figure command when creating a new figure.
Preallocate arrays to prevent MATLAB from having to continually re-size arrays—for example,use the zeros command An example is given in Program 2 above
Vectorize where possible Convert for and while loops to equivalent vector or matrix
operations
If a program involves a large number of iterations, for example 50,000, then run it for threeiterations first of all and use the echo command
If the computer is not responding hold Ctrl+C and try reducing the size of the problem.
Click on the green play Run in the M-file Window, MATLAB will list any error messages.
Find a similar M-file in a book or on the Web, and edit it to meet your needs
Make sure you have the correct packages, for example, the symbolic commands will not work ifyou do not have the Symbolic Math Toolbox
Check which version of MATLAB you are using
1.5 MATLAB Exercises
Evaluate the following:
;
312;
Trang 28the eigenvalues and eigenvectors of B.
;
Trang 31Solve the following differential equations:
, given that y(1) = 1;
, given that y(2) = 3;
, given that y(0) = 1;
Trang 32(e)
9
10
, given that x(0) = 1 and ;
, given that x(0) = 1 and
Carry out one hundred iterations on the recurrence relation
given that (a) x 0 = 0. 2 and (b) x 0 = 0. 2001 List the final ten iterates in each case
Type “help while” after the >> prompt to read information on the while command Use a whileloop to program Euclid’s algorithm for finding the greatest common divisor of two integers Useyour program to find the greatest common divisor of 12,348 and 14,238
3. D.G Duffy, Advanced Engineering Maths with MATLAB, 3rd edn (CRC Press, New York, 2010)
4. A Gilat, MATLAB: An Introduction with Applications, 5th edn (Wiley, New York, 2014)
5. B.R Hunt, R.L Lipman, J.M Rosenberg, A Guide to MATLAB: For Beginners and Experienced Users, 3rd edn (Cambridge
University Press, Cambridge, 2014)
6. H Moore, MATLAB for Engineers, 2nd edn (Prentice-Hall, Upper Saddle River, 2008)
7. R Pratab, MATLAB: Getting Started with MATLAB: A Quick Introduction for Scientists and Engineers (Oxford University
Press, Oxford, 2009)
8. M Shahin, Explorations of Mathematical Models in Biology with MATLAB (Wiley-Blackwell, New York, 2014)
9. A Siciliano, Matlab: Data Analysis and Visualization (World Scientific, Singapore, 2008)
10 A.K Tyagi, MATLAB and Simulink for Engineers (Oxford University Press, London, 2012)
Trang 33© Springer International Publishing Switzerland 2014
Stephen Lynch, Dynamical Systems with Applications using MATLAB®, DOI 10.1007/978-3-319-06820-6_2
2 Linear Discrete Dynamical Systems
Stephen Lynch1
Department of Computing and Mathematics, Manchester Metropolitan University School ofComputing, Mathematics & Digital Technology, Manchester, UK
Aims and Objectives
To introduce recurrence relations for first- and second-order difference equations
To introduce the theory of the Leslie model
To apply the theory to modeling the population of a single species
On completion of this chapter, the reader should be able to
solve first- and second-order homogeneous linear difference equations;
find eigenvalues and eigenvectors of matrices;
model a single population with different age classes;
predict the long-term rate of growth/decline of the population;
investigate how harvesting and culling policies affect the model
This chapter deals with linear discrete dynamical systems, where time is measured by the number
of iterations carried out and the dynamics are not continuous In applications this would imply that thesolutions are observed at discrete time intervals
Recurrence relations can be used to construct mathematical models of discrete systems They arealso used extensively to solve many differential equations which do not have an analytic solution; thedifferential equations are represented by recurrence relations (or difference equations) that can besolved numerically on a computer Of course one has to be careful when considering the accuracy ofthe numerical solutions Ordinary differential equations are used to model continuous dynamicalsystems later in the book
The bulk of this chapter is concerned with a linear discrete dynamical system that can be used tomodel the population of a single species As with continuous systems, in applications to the realworld, linear models generally produce good results over only a limited range of time The Lesliemodel introduced here is useful when establishing harvesting and culling policies Nonlinear discretedynamical systems will be discussed in the next chapter
The Poincaré maps introduced in Chap. 15, for example, illustrates how discrete systems can beused to help in the understanding of how continuous systems behave
Trang 342.1 Recurrence Relations
This section is intended to give the reader a brief introduction to difference equations and illustrate
the theory with some simple models
First-Order Difference Equations
A recurrence relation can be defined by a difference equation of the form
(2.1)
where x n+1 is derived from x n and n = 0, 1, 2, 3, … If one starts with an initial value, say, x 0, then
iteration of (2.1) leads to a sequence of the form
In applications, one would like to know how this sequence can be interpreted in physical terms
Equations of the form (2.1) are called first-order difference equations because the suffices differ by
one Consider the following simple example
Trang 35Applying the recurrence relation given in (2.2)
and the pattern in general is
of the geometric sequence is n This concludes the proof of Theorem 1 Note that if | m | < 1, then
as n → ∞. □
Second-Order Linear Difference Equations
Recurrence relations involving terms whose suffices differ by two are known as second-order linear
difference equations The general form of these equations with constant coefficients is
(2.3)
Theorem 2.
The general solution of the second-order recurrence relation (2.3 ) is
where k 1 ,k 2 are constants and λ 1 ≠ λ 2 are the roots of the quadratic equation If
λ 1 = λ 2 , then the general solution is of the form
Note that when λ 1 and λ 2 are complex, the general solution can be expressed as
where A and B are constants When the eigenvalues are complex , the solution oscillates and is real.
Proof.
The solution of system (2.2) gives us a clue where to start Assume that x n = λ n k is a solution,
where λ and k are to be found Substituting, (2.3) becomes
or
Assuming that λ n k ≠ 0, this equation has solutions if
Trang 36where λ 1 ≠ λ 2 are the roots of the characteristic equation.
If λ 1 = λ 2, then the characteristic equation can be written as
Therefore, b = 2a λ 1 and Now assume that another solution is of the form kn λ n
Solve the following second-order linear difference equations:
, given that x 0 = 1 and x 1 = 2;
, given that x 0 = 1 and x 1 = 3;
, given that x 0 = 1 and x 1 = 2
Solution.
The characteristic equation is
which has roots at λ 1 = 3 and The general solution is therefore
The constants k 1 and k 2 can be found by setting n = 0 and n = 1 The final solution is
Trang 37(iii)
The characteristic equation is
which has a repeated root at λ 1 = 2 The general solution is
Substituting for x 0 and x 1, gives the solution
The characteristic equation is
Substituting for λ 1 and λ 2 the general solution becomes
Example 3.
Suppose that the national income of a small country in year n is given by , where S n , P n , and G n represent national spending by the populous, private investment, and government
spending, respectively If the national income increases from 1 year to the next, then assume that
consumers will spend more the following year; in this case, suppose that consumers spend of theprevious year’s income, then An increase in consumer spending should also lead to
increased investment the following year; assume that Substitution for S n then gives
Finally, assume that the government spending is kept constant Simplemanipulation then leads to the following economic model
(2.5)
where I n is the national income in year n and G is a constant If the initial national income is G
Trang 38where I n is the national income in year n and G is a constant If the initial national income is G
dollars and 1 year later is dollars, determine
a general solution to this model;
the national income after 5 years; and
the long-term state of the economy
Solution.
The characteristic equation is given by
which has solutions and Equation (2.5) also has a constant term G Assume that the solution involves a constant term also; try I n = k 3 G, then from (2.5)
Given that I 0 = G and , simple algebra gives and k 2 = 3 When n = 5, I 5 = 2.
856G, to three decimal places.
As n → ∞, I n → 3G, since | λ 1 | < 1 and | λ 2 | < 1 Therefore, the economy stabilizes in the long
term to a constant value of 3G This is obviously a very crude model.
A general n-dimensional linear discrete population model is discussed in the following sections using
matrix algebra
2.2 The Leslie Model
The Leslie model was developed around 1940 to describe the population dynamics of the female
Trang 39portion of a species For most species the number of females is equal to the number of males, and thisassumption is made here The model can be applied to human populations, insect populations, andanimal and fish populations The model is an example of a discrete dynamical system As explainedthroughout the text, we live in a nonlinear world and universe; since this model is linear, one wouldexpect the results to be inaccurate in the long term However, the model can give some interestingresults, and it incorporates some features not discussed in later chapters The following
characteristics are ignored—diseases, environmental effects, and seasonal effects The book [8]provides an extension of the Leslie model, investigated in this chapter and most of the [1–7] citedhere, where individuals exhibit migration characteristics A nonlinear Leslie matrix model for
predicting the dynamics of biological populations in polluted environments is discussed in [7]
Assumptions:
The females are divided into n age classes ; thus, if N is the theoretical maximum age attainable by a
female of the species, then each age class will span a period of equally spaced, days, weeks,
months, years, etc The population is observed at regular discrete time intervals which are each equal
to the length of one age class Thus, the kth time period will be given by Define to be the
number of females in the ith age class after the kth time period Let b i denote the number of female
offspring born to one female during the ith age class, and let c i be the proportion of females which
continue to survive from the ith to the (i + 1)st age class.
In order for this to be a realistic model the following conditions must be satisfied:
Obviously, some b i have to be positive in order to ensure that some births do occur and no c i are
zero; otherwise, there would be no females in the (i + 1)st age class.
Working with the female population as a whole, the following sets of linear equations can be
derived The number of females in the first age class after the kth time period is equal to the number
of females born to females in all n age classes between the time t k−1 and t k ; thus,
The number of females in the (i + 1)st age class at time t k is equal to the number of females in the
ith age class at time t k−1 who continue to survive to enter the (i + 1)st age class; hence,
Equations of the above form can be written in matrix form, and so
or
Trang 40(b)
(c)
where and the matrix L is called the Leslie matrix
Suppose that X (0) is a vector giving the initial number of females in each of the n age classes, then
Therefore, given the initial age distribution and the Leslie matrix L, it is possible to determine the
female age distribution at any later time interval
Example 4.
Consider a species of bird that can be split into three age groupings: those aged 0–1 year, those aged1–2 years, and those aged 2–3 years The population is observed once a year Given that the Lesliematrix is equal to
the number of females in each age group after