15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5 Differential Equations<br />

The <strong>MATLAB</strong> kneeode Demo. The <strong>MATLAB</strong> kneeode demo solves the “knee<br />

problem” by imposing a nonnegativity constraint on the numerical solution.<br />

The initial value problem is<br />

ε *y' = (1-x)*y - y^2, y(0) = 1<br />

For 0 < ε < 1, the solution <strong>of</strong> this problem approaches null isoclines y = 1 -<br />

x and y = 0 for x < 1 and x > 1 respectively. The numerical solution, when<br />

computed with default tolerances, follows the y = 1 - x isocline for the whole<br />

interval <strong>of</strong> integration. Imposing nonnegativity constraints results in the<br />

correct solution.<br />

Here is the code that comprises the kneeode demo:<br />

function kneeode<br />

%KNEEODE The "knee problem" with Nonnegativity constraints.<br />

% Problem parameter<br />

epsilon = 1e-6;<br />

y0 = 1;<br />

xspan = [0, 2];<br />

% Solve without imposing constraints<br />

options = [];<br />

[x1,y1] = ode15s(@odefcn,xspan,y0,options);<br />

% Impose nonnegativity constraint<br />

options = odeset('NonNegative',1);<br />

[x2,y2] = ode15s(@odefcn,xspan,y0,options);<br />

figure<br />

plot(x1,y1,'b.-`,x2,y2,'g-')<br />

axis([0,2,-1,1]);<br />

title('The "knee problem"');<br />

legend('No constraints','nonnegativity')<br />

xlabel('x');<br />

ylabel('solution y')<br />

5-40

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!