% Evaluate the van der Pol ODE for µ=0.2 and µ=1, then plot the outcomes. 
%
% The van der Pol equation (y_1)"-µ*(1-(x_1)^2)*y'+(y_1)=0 is equivalent 
%    to a system of coupled first-order differential equations
%       (y_1)'=(y_2)
%       (y_2)'=µ*[1-(y_1)^2]*(y_2)-(y_1).
%
%   The ODEs commands are as follows:


x0=[0.1 0.1];
[t,Q] = ode45('vdpeq1',[0 100],x0); 

subplot(221);
plot(t,Q(:,1),'-',t,Q(:,2),'r-.');
xlabel('time t');
ylabel('solution y_1 and y_2');
title('van der Pol with \mu=0.2');
axis([0 100 -2.5 2.5]);

subplot(222);
plot(Q(:,1),Q(:,2));
xlabel('y_1');
ylabel('y_2');
title('van der Pol with \mu=0.2');
axis([-2.5 2.5 -2.5 2.5]);

x0=[1 0];%x0=[0.9 0.9];
[t,W] = ode45('vdpeq2',[0 30],x0); 
subplot(223);
plot(t,W(:,1),'-',t,W(:,2),'r-.');
xlabel('time t');
ylabel('solution y_1 and y_2');
title('van der Pol with \mu=1');
axis([0 30 -3 3]);

subplot(224);
plot(W(:,1),W(:,2));
xlabel('y_1');
ylabel('y_2');
title('van der Pol with \mu=1')
axis([-2.1 2.1 -3 3]);

        % Alternately, µ can be taken equal to µ=10, 
        % so the ODE command could be as follows:  
        %   [t,W] = ode15s('vdpeq3',[0 100],x0); 
        % with x0=[2 0];

        
% "Complex and Chaotic Nonlinear Dynamics. 
% Advances in Economics and Finance, 
% Mathematics and Statistics" 
% T.Vialar, Springer 2009
% Copyright(c).