604 CHAPTER 31. NUMERICAL SOLUTIONS FOR SYSTEMS

either y(1) or y(2). In the line which has ode45, if you type ode45(f,[0,2],[0;1]), thenMATLAB will decide on the step size for you.

Then, when you have what you want, you ought to type “clear all” and then “enter”and then type clf and then “enter” to get rid of any figures. This is so you can do some-thing else without closing MATLAB and starting it over again. MATLAB remembers thefunctions which have been defined and so unless you do this, it may think you are referringto something other than what you want if you do another computation without closing itdown.

You are not limited to systems which have two variables. For example, suppose youwanted to get a solution to x

yz

′

=

 −x3 + x− yz− y+ sin(z)

x

 ,

 xyz

(0) =

 011

Then you would enter something like the following.

>> f=@(t,y)[-y(1)ˆ3+y(1)-y(2);y(3)-y(2)+sin(y(3));y(1)];[t,x]=ode45(f,[0:.05:2],[0;1;1]);plot(t,x)

Of course the solution to the initial value problem is a space curve. Suppose you wanted tosee the graph of this space curve. Try this

>> f=@(t,y)[-y(1)ˆ3+y(1)-sin(y(2));y(3)-y(2)+sin(y(3));y(1)];[t,x]=ode45(f,[0:.05:30],[0;-1;1]);

plot3(x(:,1),x(:,2),x(:,3),’LineWidth’,2)

31.3 Stability of Equilibrium PointsRecall the simple case discussed earlier in which you are considering y′ = f (y) ,y(a) = 0.This is summarized in the following picture

f ′(a)> 0unstable

a

f ′(a)< 0stable

a

f ′(a) = 0semi-stable

a

The stability is determined by the sign of f ′ (a). However, if f ′ (a) = 0, then the equi-librium point can be stable from one side and not from the other. In the example of theabove, it is stable from the left and unstable from the right. This is because if y is closeto a but less than a, the derivative y′ is positive so the solution to the differential equationincreases. If y is close to a but larger than a, then y′ > 0 and so the solution moves awayfrom a. Similar considerations show why the other two claims are so, stable if f ′ (a) < 0and unstable if f ′ (a)> 0.

However, the situation is even more complicated when f ′ (a) = 0. You could have fbe strictly increasing through (a,0) in which case, you would have that the equilibrium