1.6 Numerical Computation

1.6 Numerical Computation

<p>§1.6 Numerical Computation</p><p>For most of initial value problem</p><p> dx  f (t, x) , x(t )  x (6.1) dt 0 0 we cannot find a closed form for the solution x(t) . Hence it is important to find the numerical solution of I.V.P. (6.1) . In the matlab there are several ODE solver for the</p><p>I.V.P.(6.1) in vector form, i.e., a system of ordinary differentiatial equations,</p><p> x1(t)  f1 (t, x1 , x2 ,, xn )</p><p> x2 (t)  f 2 (t, x1 , x2 ,, xn )</p><p>⋮ (6.2)</p><p> xn (t)  f n (t, x1 , x2 ,, xn )</p><p> xi(t0 )  xi0 , i  1,2,,n Let</p><p> f1 (t, x)   x1 (t)       f 2 (t, x) x(t)   ⋮  , f (t, x)   ⋮       xn (t)    f n (t, x)</p><p>Then (6.2) can be written in vector form  dx    f (t, x) , dt   x(t0 )  x0 . We recommend two most popular ODE solvers in the Matlab, ode45 and ode23s. ode45 is an explicit one-step Runge-Kutter (4th to 5th order) solver. Suitable for nonstiff problems that require moderate accuracy. This is typically the first solver to try on a new problem. Ode23s is suitable for stiff problem where lower accuracy is acceptable.</p><p>Example 6.1: Write the well-known van der pol equation x  (x 2 1)x  x  0 into a system of ODE.</p><p>Let x1  x , x2  x . Then</p><p> x1  x2</p><p>2 x2  (1 x1 )x2  x1 .</p><p>In the following we show how to use the Matlab ODE solvers and sketch the graph.</p><p>Example 6.2: Use ode45 solver to solve</p><p> y  w  asin y , y(0)  2 / w , 0  t  100</p><p> clear all</p><p> format long</p><p> global w a</p><p> w  input(‘Please input w  ’);</p><p> a  w  0.001;</p><p> t0  0 ; tf  100 ;</p><p> y0  2* pi / w ;</p><p>[t y]=ode45(‘test1’, [t0 tf],y0);</p><p> plot(t, y)</p><p> x label ('t') ;</p><p> y label (' y') ; Xmin=0;</p><p>Xmax=85;</p><p>Ymin=0;</p><p>Ymax=16;</p><p> axis([Xmin,Xmax,Ymin,Ymax]);</p><p> disp(‘finish’)</p><p> function dy=test1(t,y)</p><p> global w a</p><p> dy  w  a *sin( y) ;</p><p>Example 6.3: Solve the Van der Pol equation</p><p> x  (x 2 1)x  x  0 , x(0)  2 , x(0)  0 , 0  t  20 .</p><p> function ydot =vdpol(t , y ) %VDPOL van der Pol equation.</p><p>% ydot =VDPOL(t , y )</p><p>% ydot(1)  y(2)</p><p>% ydot(2)  mu(1 y(1)^2) * y(2)  y(1)</p><p>% mu  2</p><p> mu  2 ;</p><p> ydot  [y(2);mu *(1 y(1)^2) * y(2)  y(1)];</p><p>Note that the input arguments are t and y but that the function does not use t . Note also that the output ydot must be a column vector.</p><p>Given the above ODE file, this set of ODEs is solved using the following commands.</p><p>>> t span =[0 20]; % time span to integrate over</p><p>>> y 0=[2; 0]; % initial conditions (must be a column)</p><p>>> [t,y]= ode45(@vdpol, t span, y 0);</p><p>>> size(t ) % number of time points</p><p> ans =</p><p>333 1</p><p>>>size( y ) % (i)th column is y (i) at t (i)</p><p> ans =</p><p>333 2</p><p>>> plot(t , y (:,1),t , y (:,2), ‘- -’)</p><p>>> x label(‘time’)</p><p>>> title(‘Figure 24.1: van der Pol Solution’) Figure 24.1: van der Pol Solution</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us