The program

We transform the second order differential equation to a system of two first order differential equations

To resolve this system, we use the 4th order Runge-Kutta method

The complete matlab program is shown above :


fichier instab.m

x(1)=input('enter the initial position x(1)= ');

y(1)=input('enter the initial velocity y(1)= ');

f =input('enter the forcing amplitude f= ');

w =input('enter the forcing frequency w= ');

b =input('enter the dampening constant b = ');

N =input('enter the nombre of iterations N = ');

z(1)=f;

t(1)=0;

h=pi/(50*w); % Time step which allows us to do 100 times

k=1;

% Variables to extract values to plot the poincar section

xx(1)=x(1);

yy(1)=y(1);

%Mean loop to resolve with the Runge-Kutta method

for i = 1 : N

end

%position vs time plot

figure(1);

plot(t,x);

xlabel('time');

ylabel('position');

title('position vs time');

%velocity vs time plot

figure(2);

plot(t,y);

xlabel('time');

ylabel('velocity');

title('velocity vs time');

%The phase space plot(2d)

figure(3);

plot(x,y);

xlabel('position');

ylabel('velocity');

title('phase space');

%The true phase space plot(3d)with the forcing term

figure(4);

plot3(x,y,z);

xlabel('position');

ylabel('velocity');

zlabel('forcing');

title('three dimensionnal phase space')

%The poincare section plot

figure(5);

plot(xx,yy,'go');%plot only a green circle at the data point

%without tracing a line between them

title('poincaré section');

xlabel('position');

ylabel('velocity');



fichier fx.m

function fonct1= fx(y)
fonct1=y;



Fichier fy.m

function fonct2= fy(x,y,t,f,b,w)
fonct2= x - x^3 - b*y + f*cos(w*t);



 

This program permit us to make different plots:

-Position vs time x(t)

-Velocity vs time y(t)

-The phase space velocity vs position y=f(x)

-The true phase space which is three dimensionnal by adding the forcing term z(t)=f*cos(wt)

-The poincaré section