%% Solve Nonstiff Equation
% The van der Pol equation is a second-order ODE
% y''_1 - \mu \left( 1 - y_1^2\right) y'_1+y_1=0,
% where \mu > 0 is a scalar parameter. Rewrite this equation as a system of first-order ODEs by making the substitution y'_1 = y_2. The resulting system of first-order ODEs is
%
% \begin{array}{cl}
% y'_1 &= y_2\\
% y'_2 &= \mu (1-y_1^2) y_2 - y_1.\end{array}
% The function file vdp1.m represents the van der Pol equation using \mu = 1. The variables y_1 and y_2 are the entries y(1) and y(2) of a two-element vector dydt.
% function dydt = vdp1(t,y)
% %VDP1  Evaluate the van der Pol ODEs for mu = 1
% %
% %   See also ODE113, ODE23, ODE45.
%
% %   Jacek Kierzenka and Lawrence F. Shampine
% %   Copyright 1984-2014 The MathWorks, Inc.
%
% dydt = [y(2); (1-y(1)^2)*y(2)-y(1)];
% Solve the ODE using the ode78 function on the time interval [0 20] with initial values [2 0]. The resulting output is a column vector of time points t and a solution array y. Each row in y corresponds to a time returned in the corresponding row of t. The first column of y corresponds to y_1, and the second column corresponds to y_2.

[t,y] = ode78(@vdp1,[0 20],[2; 0]);

%
% Plot the solutions for y_1 and y_2 against t.

plot(t,y(:,1),'-o',t,y(:,2),'-o')
title('Solution of van der Pol Equation (\mu = 1) with ODE78');
xlabel('Time t');
ylabel('Solution y');
legend('y_1','y_2')

%
% Copyright 2021 The MathWorks, Inc.
%