# Why is cos and sin used in plotting this phase portrait

I'm plotting the phase portrait of the following system of ODE:

$\frac{dx}{dt} = x + 3 y$

$\frac{dy}{dt} = -5 x + 2 y$

The code I have in matlab:

function d=dxdt1(t,x)
d=[ x(1)+3*x(2); -5*x(1)+2*x(2) ];


Then the following plots a number of trajectories

figure(1)
hold on
for theta=[0:10]*pi/5
x0=1e-5*[cos(theta);sin(theta)];
[t,x]=ode45(@dxdt1,[0 8],x0);
plot(x(:,1),x(:,2))
end


As you can see, the code that plots each trajectory references the function dxdt1 defined earlier.

QUESTION

I don't understand the use of pi, cos and sin in this code. Namely it seems that the domain is cos and sin of 1...10 * pi.

I don't see why it's necessary to use cos and sin in the domain instead of just a simple continuous interval such as from -50 to 50.

Any help on this one?

The output of the code:

• Maybe those initial conditions make the phase portrait look nicer and more like a spiral. Make $x_0$ something like [1, -1] and see what happens. – Moo Jul 9 '16 at 0:02

## 1 Answer

It's not necessary at all. All it does is decide the initial condition for each of the curves in the plot. So, what sin, cos, pi allow the code authors to do is to make ten starting points evenly spaced around a small circle centred on the origin.

Note the /5 there. That makes the theta go, not from $0$ to $10\pi$, but from $0$ to $2\pi$. Then taking sine and cosine of theta makes a circle, and 1e-5 makes the circle small (radius $10^{-5}$).

• Thanks for the reply, very insightful. i think in my post I was confusing the initial conditions with something else. – Imme22009 Jul 9 '16 at 15:37