%
% solving the van der Pol equation using the matlab function
% bvp5c.
%
% Written by Ming Gu for Math128B, Spring 2010
BV.a = 0;
BV.b = 2;
BV.alpha=0;
BV.beta = 1;
BV.mu   = 1.2;
N = 100;
h = (BV.b-BV.a)/(N+1);
x = BV.a+(0:(N+1))'*h;
y = (0:(N+1))'/(N+1);
slninit.x = x;
slninit.y = [y, y]';
mu = BV.mu;
options = bvpset('AbsTol',1e-9);
SOL = bvp5c(@(x,y)vanderPol2(x,y,mu),@(ya,yb)bcfun(ya,yb,BV),slninit,options);
figure(1);
clf;
[ii,jj] = sort(SOL.x);
plot(ii,SOL.y(1,jj),'b.-');
title(strvcat(['Solution to Van der Pol Equuation on [', num2str(BV.a),', ', num2str(BV.b),']'], ...
              ['With Boundary condition y(',num2str(BV.a),')=',num2str(BV.alpha),',  y(',num2str(BV.b),')=',num2str(BV.beta)], ...
              ['Parameter mu =', num2str(BV.mu), '; AbsTol = ', num2str(options.AbsTol)]));

