214 C H A P T E R 5 Numerical Solution ofInitial -Value Problems 2. Theinitial -value problem y=—y+1— j,for1-l-3),for0(0)=-2;actual solution .y(/)=— 3+2(1+e-2,)_ l. d.y=(f+2/3)y3-f)\for0?i£tu2012 Cc«£»fcLearn in*.AIR.(huRocncd Mayr*xbecopied ,canned ,o*daplicaied.»whole o»mpan.Doctoelectronic rifhu.*wcthird pony contcac may besuppreved Trent theeBook and/orcCh deemed CutanyMpprcucd content dec>notimtctlaly alTca theoverall leamir*experience .C'cttitape Learnmp re\me»thertpht 10renxyve additional conceal atanytime i iwtoeqjcni npht »rotrictionc require It5.7 Methods forSystems ofEquations 215 forsystems canbefound byexamining theeasier problem andthen logically modifying it totreat themore complicated situation . Anmth-order system offirst-order initial -value problems hastheform dui dt du2 Itf\(*,U\,U2, ^**1»**2»   »**m)» fora0bechosen and seth=(b— a)/N.Partition theinterval [a,b] into Nsubintervals with themesh points t j=a+jh foreach j=0,1,...,N. Use thenotation w yforeach j=0,1,. . .,Na n d i=1,2,. . .,mtodenote an approximation to!*,(*,);thatis,w yapproximates theithsolution U j(t)ofthesystem atthe y'thmesh point t j.Fortheinitial conditions ,set wi,0=oi. W2,O=C*2,....wm>0=ofm. Figure 5.4gives anillustration ofthisnotation . Copyright 2012 Cengagc Learn in*.AIRights Reserved May r*xbecopied .scanned .orduplicated .inwhole orinpar.Doc toelectronic rights .some third puny content may besuppressed rrom theeBook aml/oreChaptcnnl .Editorial review h*> deemed Cutanysuppressed content does nottnaxrUXy alTcct theioera .1learning experience .('engage [.camon reserves theright 10remove additional conceal atanytime ifsubvcqjem rights restrictions require It216 CHAPTER 5 Numerical Solution ofInitial-Value Problems Figure 5.4 1 1 1 1 —>\ nmy -  "23--"«\ (a)=U'(0"’ 'i, y, :s ^1- u2(a)=a2i  a~*o*\hh1 a~*o hh* a— tot\*2h* Suppose thatthevalues w2jt  ,wm.jhave been computed .Weobtain w\j+\, W2j+u-  »wm,j+ibyfirstcalculatings foreach i=1,2,...,m, k\j=hfi(tjtW\tj%W2J Wmj ), andthen finding ,foreach i, , h 1, 1, 1,\*2.»=hfiitj +-,Wij+-k\titW 2,j+2*1.2.   »Wm,j+2*1.1«) Wenext determine alltheterms *3.i=hfi ^tj+ W\j+“ *2.1,w2,j+2^2.2.   .WmJ+-jk2,m and,finally ,calculate alltheterms *4,i=hfi(tj+h,W\j+*3.1."2.;+*3.2.   ."m./+*3.m)- Combining these values gives Theprogram RK04SY57 implements the Rungc-Kutta method of order 4forsystems ."i,y+1=wiJ+ ^[*l,i+2*2.I+ <+*4.i] foreach i=1,2,...m. Note thatallthevalues*1.1,*1.2*-- .*i.mmust becomputed before anyoftheterms oftheform*2,/canbedetermined .Ingeneral ,each*/.1**/.2»   .*/.mmust becomputed before anyoftheexpressions*/+itl. Example 1Kirchhoff ’sLaw states thatthesum ofallinstantaneous voltage changes around aclosed electrical circuit iszero.This implies thatthecurrent ,/(/),inaclosed circuit containing a resistance ofRohms ,acapacitance ofCfarads ,aninductance ofLhenrys ,andavoltage source ofE(t)volts must satisfy theequation LI\t)+RI(t)+^jI(t)dt=E(t). Thecurrents I\(t)andl2{t)intheleftandright loops ,respectively ,ofthecircuit shown in Figure 5.5arcthesolutions tothesystem ofequations 2/,(0+6[/1(0-/2(0]+2/i'(0=12, LJi2(t)dt+4/2(0+6[/2(0-/1(»)]=0. Copyright 2012 Cengagc Learn in*.AIRights Reserved May rotbecopied ,canned ,ocimplicated ,inwhole orinpar.Doctocjectronie right..some third pur.ycontent may besupplied rican theeBook and/orcChapccnM .Editorial review h*> deemed Cutany Mjppic-cdcontent does notmaxrUXy alTcct theiAera .1learning experience .('engage [.camonreserve,theright 10remove additional eonteatatanytime iisubvcqjem right,restriction,require It.Figure 5.55.7 Methods forSystems ofEquations 217 211 0.5F K i— ^11.(0 6(I 412 12V— 2H Suppose that theswitch inthecircuit isclosed attime t=0.This implies that/,(0) and/2(0)=0.Solve for/((/)inthefirstequation ,differentiate thesecond equation ,and substitute forI[(t)toget /,'=/,(f,/,,/2)=-4/,+3/2+6,with/,(0)=0, /2=/2O.h J i )=0.6/,'-0.2/2=-2.4/,+I.6/2+3.6,with/2(0)=0. Theexact solution tothissystem is /,(t)=-3.375 e-2'+1.87V0-*+1.5 and /2(r)=-2.25e“ 2'+2.25e-°-4'. Wewillapply theRunge -Kutta method oforder 4tothissystem with h=0.1.Since Who=/.(0)=0andw2.o=/2(0)=0, *1.1=*/ifo.W1.0,*2.0)=o.l/,(0,0,0)=0.1[-4(0)+3(0)+6]=0.6, *i.2=hf2(to,wi.o,w2.o)=0.1/2(0.0,0)=0.1[-2.4(0)+1.6(0)+3.6]=0.36, *2.1=*/i(to+2^’wi.o+2*1.1*w2.o+2*i.2 ^=0*1/i(0.05,0.3,0.18 ) *2,2=hf20.1[— 4(0.3)+3(0.18 )+6]=0.534 , 1(to+ ^*»W|,o+-*1.1 »^2,0+2*1.2 ^0.1/2(0.05,0.3,0.18 ) 0.1[— 2.4(0.3)+1.6(0.18)+3.6]=0.3168 . Generating theremaining entries inasimilar manner produces *3f,=(0.1)/,(0.05 ,0.267 ,0.1584 )=0.54072 , *3.2=(0.1)/2(0.05 ,0.267 ,0.1584 )=0.321264 , *4.1=(0.1)/,(0.1,0.54072 ,0.321264 )=0.4800912 , *4.2=(0.1)/2(0.1,0.54072 ,0.321264 )=0.28162944 . Copyright 2012 Cengagc Learning .AIRights Reversed May notbecopied ,canned ,orduplicated .inwhole orinpar.Doctoelectronic rights.xvnc third pur.ycontent may bevuppftv *drrom theeBook amtar cCh deemed Cutanysuppressed content does nottnaxrUXy alTect theoverall learning experience .Ccagagc [.camonreserve*theright 10remose additional conteatatanytime iisubseqjcnt right*restriction*require It218 C H A P T E R 5 Numerical Solution ofInitial-Value Problems Asaconsequence , /1(0.1)«wu=wi ,o+ +2*2,I+2*3.1+*4.i] =0+-[0.6+2(0.534 )+2(0.54072 )+0.4800912 ]=0.53825526 and /2(0.1)%w2,i=w2,o+g[*i,2+2*2.2+2*3,2+^4.2]=0.3196263 . Theremaining entries inTable 5.15 aregenerated inasimilar manner . Table 5.15t j W UW2J \h(t j)-w2j\ 0.0 0 0 0 0 0.1 0.5382550 0.3196263 0.8285 xlO'50.5803 x10“ 5 0.2 0.9684983 0.5687817 0.1514 x1040.9596 x10~5 0.3 1.310717 0.7607328 0.1907 x1040.1216 x104 0.4 1.581263 0.9063208 0.2098 x10~40.1311 x104 0.5 1.793505 1.014402 0.2193 xlO"40.1240 x10~4 Any ofthemethods implemented inMATLAB canbeused forsystems ofdifferential equations .Forexample ,touseode45tosolve oursystem given inExample 1wefirstdefine theright -hand sides using anM-filecalled F.mthatcontains thestatements function dy=F(t,y) dy=zeros (2,1); dy(1)=-4*y(1)+3*y(2)+6; dy(2)=-2 . 4*y(l)+l.6*y(2)+3 . 6; Then make theright -hand sideofthesystem ofdifferential equations known toMATLAB with FF=OF Wenow define thetvalues atwhich wewant toapproximate thesolutions tspan =[00.1 0.2 0.30.4 0 . 5] The following command computes thesolution tothesystem atthegiven values oft.The initial conditions I\(0)=0and/2(0)=0aregiven as[00]. [T,YY]=ode45(FF,tspan ,[00]) The MATLAB response places thetvalues inthearray Tand theapproximate solution values inYY,with theapproximations forI\(t)inthefirstcolumn and/2(f)inthesecond . 0 0.100000000000000 0.200000000000000 0.300000000000000 0.400000000000000 0.5000000000000000 0.538263922676270 0.968513005638230 1.310736555252393 1.581284356153020 1.7935270443890290 0.319632054268176 0.568791683477228 0.760744806883952 0.906333359733513 1.014415449337470 Copyright 2012 Cengagc Learn in*.AIRights Reversed Mayr*xbecopied.scanned .ocimplicated ,inwhole orinpar.Doctocjectronie rlghtv.some third pur.ycontent may besupplied ftem theeBook and/orcChapccriM .Editorial review h*> deemed Cutanysuppressed content does notnuxtlaly alTcct theioera .1learning experience .('engage [.camonreserves theright 10remove additional eonteatatanytime iisuhvcqjcM rights restrictions require It5.7 Methods forSystems ofEquations 219 Higher -Order Differential Equations Many important physical problems — forexample ,electrical circuits andvibrating systems — involve initial -value problems whose equations have order higher than 1.New techniques arenotrequired forsolving these problems .Byrelabeling thevariables wecanreduce ahigher -order differential equation intoasystem offirst-order differential equations and then apply oneofthemethods wehave already discussed . Ageneral mth-order initial -value problem hastheform /">(»)=/(»,*/y—'o, fora'(0)=— 0.6 intoasystem offirstorder initial -value problems ,andusetheRunge -Kutta method oforder 4with h=0.1toapproximate thesolution . Solution Let wi(f)=y(f)and 112(f)=/(/).This transforms thesecond -order equation intothesystem *<5(0=«2(f)» u'2(t)=e2tsinf-2u\(t)+2u2(t), with initial conditions wj(0)=-0.4,u2(0)=— 0.6. Copyrifht 2012 Cc«£»fcLearn !#*.AIRights Reversed May notbecopied ,canned ,ordedicated .»whole oempar.Doc toelectronic rtghtv .xvtic third pur.yconcern .may bevuppftved riom theeBook amtar eOncxcnnl .Editorial roiew h*> deemed Cutanysuppressed content does notimtetlaly alTecc theoverall learning experience .Ccagagc [.cammu reserve*theRIGHTK >remote additional contort atanytimeiivubveqjcnt rights restrictions require It220 C H A P T E R 5 Numerical Solution ofInitial-Value Problems The initial conditions give wio=— 0.4and w2io=— 0.6.The Runge -Kutta method oforder 4forsystems described onpage 216with j=0give *i.i=Vi(lb,wit0,w2,o)=hw 2,o=-0.06 , *1.2=V2fo>.wi.o,w2.o)=hlf*sin/o-2w1>0+2w2>0]=-0.04 , *2.1=Vl *2*[*2.0+-*1.2( h 1 1.\Uo+2»wi.o+2*1.1 »w2.o+2*1.2J= ,2=*/2 ^*0+ Wi,o+-*1.1»2,0+2*1>2 ^ =hj^*005*sin(r0+0.05 )-2 ^wi.0+ ^*1,1 ^+2 ^w2,0+ ^*1.2 ^j-0.062 , =-0.03247644757 , *3,1=*w2,o+ ^*2,2-0.06162832238 , e2(r0-o.o5)sin^+Q05)-2 ^wi.o+ ^*2.1 ^+2 ^w2,o+2*2-2)] *3,2=h =-0.03152409237 , *4.1=h[w2.o+*3.2]=-0.06315240924 , and *4.2=*[e2(tQ+0A)sin(lb+0.1)-2(w, t0+*3.1)+2(w2.0+*3.2)]=-0.02178637298 . So Wj.i=W|,o+— (*1,1+2AT2.1+2*3.1“ H*4,1)=— 0.4617333423 and6 W2.1=w2.o+|(*,.2+2*2.2+2*3.2+*«)=-0.6316312421 . The value wj.iapproximates wj(0.1)=y(0.1)=0.2e2(OI)(sin0.1— 2cos0.1),and W2.1approximates «2(0.1)=>'(0.1)=0.2^2(0,)(4sin0.1— 3cos0.1). The setofvalues w\jand w>2jtfor7=0,1,. ..»10,arepresented inTable 5.16 and arecompared totheactual values of«i(/)=0.2^2,(sint — 2cos/)and«2(r)=«!(/)= 0.2e21(4sin/— 3cos/). Table 5.16 tj yitj)=u1(tj)WUy%)=u2(tj)” 2J 0.0 deemed Cut ait)vupprc"Cdconteendocs notmaterial yalTcct themcra’Iteamireexperience .('engage Learn reserve!theright n>remove additional conceal atanytime i!vuhvcqjcM right,restrictions require It.5.7 Methods forSystems ofEquations 221 Other one-stepapproximation methods canbeextended tosystems .IftheRunge -Kutta - Fehlberg method isextended ,then each component ofthenumerical solution w\j,w2j>.. wmjmust beexamined foraccuracy .Ifanyofthecomponents failtobesufficiently accurate , theentire numerical solution must berecomputed . Themulti step methods andpredictor -corrector techniques canalso beextended easily tosystems .Again ,iferror control isused,each component must beaccurate .Theextension oftheextrapolation technique tosystems canalso bedone ,butthenotation becomes quite involved . E X E R C I S E S E T 5 . 7 1. Use theRunge -Kutta method oforder 4forsystems toapproximate thesolutions ofthefollowing systems offirst-order differential equations andcompare theresults totheactual solutions . a.u\=3i*|4-2M2— (2/2+lie2',f o r O ?i£tu2012 Cc«£»fcLearn in*.AIR.(huRocncd Mayr*xbecopied ,canned ,o*daplicaied.»whole o»mpan .Doctoelectronic rifhu.*wcthird pony contcac may besoppre ^tedftem theeBook and/orcCh deemed CutanyMpprcucd content dee>notnuxtiily alTect theoverall leamir*experience .C'cnitapc [.camon roentt thety-ht»renxyve additional conceal atanytime i itutoeqjroi nght »rotrictionc require It222 C H A P T E R 5 Numerical Solution ofInitial -Value Problems Forthisreason ,weassume thatthebirth rate(predator )iskyXi(0*2(0-’Thedeath rateofthepredator willbetaken assimply proportional tothenumber ofpredators alive atthetime;thatis,death rate (predator )=kiX 2(t). Since xj(0andxj(0represent thechange intheprey andpredator populations ,respectively , with respect totime ,theproblem isexpressed bythesystem ofnonlinear differential equations *J(0=*i*i(0-Mi(0*2(0and*2(0=Mi(0*2(0-*4*2(0. UseRunge -Kutta oforder 4forsystems tosolve thissystem for0 deemed Cutanysuppressed content does notmaterial yalTcct theovera’.Ilearning experience .('engage l.cammureserves theright 10remove additional conceal atanytime ifsubsequent nghts restrictions require It