Copyrights © 2012 Jatin Kotadiya. All Rights Reserved . Powered by Blogger.

Wednesday, October 31, 2012

Maths Solving Differential Equations

Numerical Methods for Solving Differential Equations

Euler's Method

 

Examples :
1).  y ' = x + 2y,  y(0) = 0  numerically, finding a value for the solution at x=1, and using steps of size h = 0.25.
Ans:
n
xn
yn
0
0.00
0.000000
1
0.25
0.000000
2
0.50
0.062500
3
0.75
0.218750
4
1.00
0.515625
2). y '  = 0.25 e2x - 0.5 x - 0.25,  y(0) = 0  numerically, finding a value for the solution at x=1, and using steps of size h = 0.25.
Ans:
x
y
0.00
0.000000
0.25
0.037180
0.50
0.179570
0.75
0.495422
1.00
1.097264


3). y '=x+y with y(0) =1 , h=0.1 , find the value of y(0.5).
Ans:                                         
x
y
0.1
1.1
0.2
1.22
0.3
1.362
0.4
1.5282
0.5
1.72102

4) P' = 0.2 * P with P(0) = 50. find the value of  p(0.3) when h=0.1
Ans:

tn
Pn
t0 = 0
P0 = 50
t1 = t0 + h = 0.1
P1 = P0 + 0.1(0.2P0) = 50 + 1 = 51
t2 = t1 + h = 0.2
P2 = P1 + 0.1(0.2P1) = 51 + 1.02 = 52.02
t3 = t2 + h = 0.3
P3 = P2 + 0.1(0.2P2) = 52.02 + 1.0404 = 53.0604

5). P(t) = 50 e0.2t , Let us approximate this solution on the interval [0,1] using a stepsize of h =0.1 find p(1) with P(0) = 50
Ans:      
t
Actual Solution
0
50.000
0.1
51.010
0.2
52.041
0.3
53.092
0.4
54.164
0.5
55.259
0.6
56.375
0.7
57.514
0.8
58.676
0.9
59.861
1
61.070


6) y' = y + t with y(0) = 3 take h=0.25 find the value when t=1                

Ans:                                                                                                       
tn
Euler solution yn
t0 = 0
y0 = 3
t1 = 0.25
y1 = y0 + h(y0 + t0 ) = 3 + 0.25(3 + 0) = 3.75
t2 = 0.5
y2 = y1 + h(y1 + t1 ) = 3.75 + 0.25(3.75 + 0.25) = 4.75
t3 = 0.75
y3 = y2 + h(y2 + t2 ) = 4.75 + 0.25(4.75 + 0.5) = 6.0625
t4 = 1
y4 = y3 + h(y3 + t3 ) = 6.0625 + 0.25( 6.0625 + 0.75) = 7.7656
7). Find y(0.5) if y is the solution of IVP   y' = -2x-y,   y(0) = -1 using Euler's                 method with step length 0.1. Also find the error in the approximation.
Solution:         f(x, y) = -2x - y,
y1 = y0 + h f(x0, y0) = -1 + 0.1* (-2*0 - (-1)) = -0.8999
y2 = y1 + h f(x1, y1) = -0.8999 + 0.1* (-2*0 - (-0.8999)) = -0.8299
y3 = y2 + h f(x2, y2) = -0.8299 + 0.1* (-2*0 - (-0.8299)) = -0.7869
y4 = y3 + h f(x3, y3) = -0.7869 + 0.1* (-2*0 - (-0.7869)) = -0.7683
y5 = y4 + h f(x4, y4) = -0.7683 + 0.1* (-2*0 - (-0.7683)) = -0.7715
8). Use Eulers method to solve for y[0.1] from y' = x + y + xyy(0) = 1  with  h = 0.01 also estimate how small  h would need to obtain four-decimal accuracy.
Solution :
f(x, y) = x + y + xy,
y1 = y0 + h f(x0, y0) = 1.0 + .01*(0 + 1 + 0*1) = 1.01
y2 = y1 + h f(x1, y1) = 1.01 + .01*(0.01 + 1.01 + 0.01*1.01) =1.02
y3 = y2 + h f(x2, y2) = 1.02 + .01*(0.02 + 1.02 + 0.02*1.02) =1.031
y4 = y3 + h f(x3, y3) = 1.031 + .01*(0.03 + 1.031 + 0.03*1.031) =1.042
y5 = y4 + h f(x4, y4) = 1.042 + .01*(0.04 + 1.042 + 0.04*1.042) = 1.053
y6 = y5 + h f(x5, y5) = 1.053 + .01*(0.05 + 1.053 + 0.05*1.053) = 1.065
y7 = y6 + h f(x6, y6) = 1.065 + .01*(0.06 + 1.065 + 0.06*1.065) = 1.076
y8 = y8 + h f(x7, y7) = 1.076 + .01*(0.07 + 1.076 + 0.07*1.076) = 1.089
y9 = y9 + h f(x8, y8) = 1.089 + .01*(0.08 + 1.089 + 0.08*1.089) = 1.101
y10 = y10 + h f(x9, y9) = 1.101 + .01*(0.09 + 1.101 + 0.09*1.101) = 1.114
9). Solve the differential equation y' = x/y, y(0)=1 by Euler's method to get y(1). Use the step lengths h = 0.1 and 0.2
Solution:       f(x, y) = x/y,
with h = 0.1
y1 = y0 + h f(x0, y0) = 1.0 + 0.1*0.0/1.0 = 1.00
y2 = y1 + h f(x1, y1) = 1.0 + 0.1*0.1/1.0 = 1.01
y3 = y2 + h f(x2, y2) = 1.01 + 0.1*0.2/1.01 = 1.0298
y4 = y3 + h f(x3, y3) = 1.0298 + 0.1*0.3/1.0298 = 1.0589
y5 = y4 + h f(x4, y4) = 1.0589 + 0.1*0.4/1.0589 = 1.0967
y6 = y5 + h f(x5, y5) = 1.0967 + 0.1*0.5/1.0967 = 1.1423
y7 = y6 + h f(x6, y6) = 1.1423 + 0.1*0.6/1.1423 = 1.1948
y8 = y7 + h f(x7, y7) = 1.1948 + 0.1*0.7/1.1948 = 1.2534
y9 = y8 + h f(x8, y8) = 1.2534 + 0.1*0.8/1.2534 = 1.3172
y10 = y9 + h f(x9, y9) = 1.3172 + 0.1*0.9/1.3172 = 1.3855
with h = 0.2
y1 = y0 + h f(x0, y0) = 1.0 + 0.2*0.0/1.0 = 1.0
y2 = y1 + h f(x1, y1) = 1.0 + 0.2*0.2/1.0 = 1.0400
y3 = y2 + h f(x2, y2) = 1.0400 + 0.2*0.4/1.0400 = 1.1169
y4 = y3 + h f(x3, y3) = 1.1169 + 0.2*0.6/1.1169 = 1.2243
y5 = y4 + h f(x4, y4) = 1.2243 + 0.2*0.8/1.2243 = 1.3550
10). Using Euler's method find the approximate solution of y' = (y - x)/(y + x), y(0) = 1.0 at x = 0.1 by taking h = 0.02
Solution:        f(x, y) = (y - x)/(y + x),
y1 = y0 + h f(x0, y0) = 1.0 + 0.02* ( (1.0 - 0.0)/(1.0 + 0.0) ) = 1.02
y2 = y1 + h f(x1, y1) = 1.02 + 0.02* ( (1.02 - .02)/(1.02 + .02) ) = 1.0392
y3 = y2 + h f(x2, y2) = 1.0392 + 0.02* ( (1.0392 - .04)/(1.0392 + .04) ) = 1.0577
y4 = y3 + h f(x3, y3) = 1.0577 + 0.02* ( (1.0577 - .06)/(1.0577 + .06) ) = 1.0756
y5 = y4 + h f(x4, y4) = 1.0756 + 0.02* ( (1.0756 - .08)/(1.0756 + .08) ) = 1.0928
11). Find y(0.8) with h = 0.1 from y' = y - 2x/y, y(0) = 1 using Euler's method
Solution:       f(x, y) = y - 2x/y
y1 = y0 + h f(x0, y0) = 1.0 + 0.1* ( 1.0- 2*0.0/1.0 ) =  1.1000
y2 = y1 + h f(x1, y1) = 1.1 + 0.1* ( 1.1- 2*0.1/1.1 )  = 1.1918
y3 = y2 + h f(x2, y2) = 1.1918 + 0.1* ( 1.1918- 2*0.2/1.1918 )  = 1.2774
y4 = y3 + h f(x3, y3) = 1.2774 + 0.1* ( 1.2774- 2*0.3/1.2774 )  = 1.3582
y5 = y4 + h f(x4, y4) = 1.3582 + 0.1* ( 1.3582- 2*0.4/1.3582 )  = 1.4351
y6 = y5 + h f(x5, y5) = 1.4351 + 0.1* ( 1.4351- 2*0.5/1.4351 )  = 1.5089
y7 = y6 + h f(x6, y6) = 1.5089 + 0.1* ( 1.5089- 2*0.6/1.5089 )  = 1.5803
y8 = y7 + h f(x7, y7) = 1.5803 + 0.1* ( 1.5803- 2*0.7/1.5803 )  = 1.6497


Modified Euler’s Method:
By using this formula:
yi+1
= yi+ h/2 (y'i + y'i+1)

= yi + h/2(f(xi, yi) + f(xi+1, yi+1))

Example 1:
Find   y(1.0)   accurate  upto  four decimal places using Modified Euler's method by solving the IVP  y' = -2xy2,  y(0) = 1 with step lengh 0.2.
Solution:        f(x, y) = -2xy2
y' = -2*x*y*y,  y[0.0] = 1.0 with h = 0.2
Given y[0.0] = 1.0
y(1) = y(0) + .5*h*((-2*x*y*y)(0) + (-2*x*y*y)(1)
y[0.20] = 1.0   y[0.20] = 0.9599999988079071   y[0.20] = 0.9631359989929199   
y[0.20] = 0.9628947607919341   y[0.20] = 0.9629133460803093 
y(2) = y(1) + .5*h*((-2*x*y*y)(1) + (-2*x*y*y)(2)
y[0.40] = 0.8887359638083165   y[0.40] = 0.8626358081578545   
y[0.40] = 0.8662926943348495   y[0.40] = 0.8657868947404332   
y[0.40] = 0.865856981554814 
y(3) = y(2) + .5*h*((-2*x*y*y)(2) + (-2*x*y*y)(3)
y[0.60] = 0.7458966289094106   y[0.60] = 0.7391085349039348   
y[0.60] = 0.7403181774980547   y[0.60] = 0.7401034281837107   
y[0.60] = 0.7401415785278189 
y(4) = y(3) + .5*h*((-2*x*y*y)(3) + (-2*x*y*y)(4)
y[0.80] = 0.6086629119889084   y[0.80] = 0.6151235687114084   
y[0.80] = 0.6138585343771569   y[0.80] = 0.6141072871136244   
y[0.80] = 0.6140584135348263 
y(5) = y(4) + .5*h*((-2*x*y*y)(4) + (-2*x*y*y)(5)
y[1.00] = 0.49340256427369866   y[1.00] = 0.5050460713552334   
y[1.00] = 0.5027209825340415   y[1.00] = 0.5031896121302805   
y[1.00] = 0.5030953322323046   y[1.00] = 0.503114306721248 
 
Example 2:
Find  in  [0,3] by solving the initial value problem y' = (x - y)/2,  y(0) = 1.  Compare solutions for h = 1/2, 1/4 and 1/8.
Solution:        f(x, y) = (x - y)/2
Case(i)y' = (x - y)/2,  y(0) = 1.0 with h = 1/2
Given  y[0.0] = 1.0
  y(1) = y(0) + .5*h*(((x-y)/2)(0) + ((x-y)/2)(1)
y[0.50] = 0.75   y[0.50] = 0.84375   y[0.50] = 0.83203125   y[0.50] = 0.83349609375   y[0.50] = 0.83331298828125   y[0.50] = 0.8333358764648438   
 

y(2) = y(1) + .5*h*(((x-y)/2)(1) + ((x-y)/2)(2)
y[1.00] = 0.7499997615814209   y[1.00] = 0.8229164183139801   y[1.00] = 0.8138018362224102   y[1.00] = 0.8149411589838564   y[1.00] = 0.8147987436386757   y[1.00] = 0.8148165455568233   
 
 y(3) = y(2) + .5*h*(((x-y)/2)(2) + ((x-y)/2)(3)
y[1.50] = 0.8611107402377911   y[1.50] = 0.9178236877476991   y[1.50] = 0.9107345693089606   y[1.50] = 0.9116207091138029   y[1.50] = 0.9115099416381975   y[1.50] = 0.9115237875726483   
 
 y(4) = y(3) + .5*h*(((x-y)/2)(3) + ((x-y)/2)(4)
y[2.00] = 1.0586415426231315   y[2.00] = 1.1027516068990952   y[2.00] = 1.0972378488645997   y[2.00] = 1.0979270686189118   y[2.00] = 1.0978409161496228   y[2.00] = 1.0978516852082838   
 
 y(5) = y(4) + .5*h*(((x-y)/2)(4) + ((x-y)/2)(5)
y[2.50] = 1.3233877543069634   y[2.50] = 1.357695577403087   y[2.50] = 1.3534070995160716   y[2.50] = 1.3539431592519484   y[2.50] = 1.3538761517849638   
 
 y(6) = y(5) + .5*h*(((x-y)/2)(5) + ((x-y)/2)(6)
y[3.00] = 1.6404133957887526   y[3.00] = 1.6670972872799508   y[3.00] = 1.663761800843551   y[3.00] = 1.664178736648101   y[3.00] = 1.6641266196725322   
Case(ii)y' = (x - y)/2,  y(0) = 1.0 with h = 1/4
Given  y[0.0] = 1.0
 
y(1) = y(0) + .5*h*(((x-y)/2)(0) + ((x-y)/2)(1)
y[0.250] = 0.875   y[0.250] = 0.8984375   y[0.250] = 0.89697265625   y[0.250] = 0.897064208984375   
 
 y(2) = y(1) + .5*h*(((x-y)/2)(1) + ((x-y)/2)(2)
y[0.500] = 0.816176176071167   y[0.500] = 0.8368563205003738   y[0.500] = 0.8355638114735484   y[0.500] = 0.835644593287725   
 
 y(3) = y(2) + .5*h*(((x-y)/2)(2) + ((x-y)/2)(3)
y[0.750] = 0.7936846013712966   y[0.750] = 0.8119317853121117   y[0.750] = 0.8107913363158108   y[0.750] = 0.8108626143780796   
 
 y(4) = y(3) + .5*h*(((x-y)/2)(3) + ((x-y)/2)(4)
y[1.000] = 0.8032508895617894   y[1.000] = 0.8193513439328768   y[1.000] = 0.8183450655346838   y[1.000] = 0.8184079579345709   
 
 y(5) = y(4) + .5*h*(((x-y)/2)(4) + ((x-y)/2)(5)
y[1.250] = 0.8411035237646307   y[1.250] = 0.8553098052268149   y[1.250] = 0.8544219126354284   y[1.250] = 0.8544774059223901   
 
 y(6) = y(5) + .5*h*(((x-y)/2)(5) + ((x-y)/2)(6)
y[1.500] = 0.9039146953929605   y[1.500] = 0.9164496480303976   y[1.500] = 0.9156662134905579   y[1.500] = 0.9157151781492978   
 
 y(7) = y(6) + .5*h*(((x-y)/2)(6) + ((x-y)/2)(7)
y[1.750] = 0.9887481031258607   y[1.750] = 0.9998083540466274   y[1.750] = 0.9991170883640794   y[1.750] = 0.9991602924692387   
 
 y(8) = y(7) + .5*h*(((x-y)/2)(7) + ((x-y)/2)(8)
y[2.000] = 1.093012893186083   y[2.000] = 1.1027719368752444   y[2.000] = 1.1021619966446718   y[2.000] = 1.1022001179090826   
 
 y(9) = y(8) + .5*h*(((x-y)/2)(8) + ((x-y)/2)(9)
y[2.250] = 1.2144230184137998   y[2.250] = 1.223033938221066   y[2.250] = 1.2224957557331118   y[2.250] = 1.222529392138609   
 
 y(10) = y(9) + .5*h*(((x-y)/2)(9) + ((x-y)/2)(10)
y[2.500] = 1.3509613786303571   y[2.500] = 1.3585592480824138   y[2.500] = 1.3580843812416603   y[2.500] = 1.3581140604192075   
 
 y(11) = y(10) + .5*h*(((x-y)/2)(10) + ((x-y)/2)(11)
y[2.750] = 1.5008481797867843   y[2.750] = 1.5075521813920236   y[2.750] = 1.5071331812916962   y[2.750] = 1.5071593687979665   
 
 y(12) = y(11) + .5*h*(((x-y)/2)(11) + ((x-y)/2)(12)
y[3.000] = 1.6625130155689716   y[3.000] = 1.6684283103508373   y[3.000] = 1.6680586044269707   y[3.000] = 1.6680817110472124   
Case(iii)y' = (x - y)/2,  y(0) = 1.0 with h = 1/8
Given    y[0.0] = 1.0   
 y(1) = y(0) + .5*h*(((x-y)/2)(0) + ((x-y)/2)(1)
y[0.1250] = 0.9375   y[0.1250] = 0.943359375   y[0.1250] = 0.94317626953125   
 
 y(2) = y(1) + .5*h*(((x-y)/2)(1) + ((x-y)/2)(2)
y[0.2500] = 0.8920456171035767   y[0.2500] = 0.8975498788058758   y[0.2500] = 0.8973778706276789   
 
 y(3) = y(2) + .5*h*(((x-y)/2)(2) + ((x-y)/2)(3)
y[0.3750] = 0.8569217930155446   y[0.3750] = 0.8620924634176603   y[0.3750] = 0.8619308799675942   
 
y(4) = y(3) + .5*h*(((x-y)/2)(3) + ((x-y)/2)(4)
y[0.5000] = 0.8315024338597582   y[0.5000] = 0.836359730596966   y[0.5000] = 0.8362079400739283   
 
 y(5) = y(4) + .5*h*(((x-y)/2)(4) + ((x-y)/2)(5)
y[0.6250] = 0.8151993908072874   y[0.6250] = 0.8197623062048026   y[0.6250] = 0.8196197150986302   
 
 y(6) = y(5) + .5*h*(((x-y)/2)(5) + ((x-y)/2)(6)
y[0.7500] = 0.8074601603787794   y[0.7500] = 0.8117465357129019   y[0.7500] = 0.8116125864837106   
 
 y(7) = y(6) + .5*h*(((x-y)/2)(6) + ((x-y)/2)(7)
y[0.8750] = 0.8077657241223026   y[0.8750] = 0.8117923193808908   y[0.8750] = 0.8116664882790599   
 
 y(8) = y(7) + .5*h*(((x-y)/2)(7) + ((x-y)/2)(8)
y[1.0000] = 0.8156285192196802   y[1.0000] = 0.8194110786347212   y[1.0000] = 0.8192928736530011   
 
 y(9) = y(8) + .5*h*(((x-y)/2)(8) + ((x-y)/2)(9)
y[1.1250] = 0.8305905320862623   y[1.1250] = 0.8341438456947754   y[1.1250] = 0.8340328046445094   
 
 y(10) = y(9) + .5*h*(((x-y)/2)(9) + ((x-y)/2)(10)
y[1.2500] = 0.852221507509997   y[1.2500] = 0.8555594689839763   y[1.2500] = 0.8554551576879144   
 
 y(11) = y(10) + .5*h*(((x-y)/2)(10) + ((x-y)/2)(11)
y[1.3750] = 0.8801172663274216   y[1.3750] = 0.883252927298937   y[1.3750] = 0.8831549378935771   
 
y(12) = y(11) + .5*h*(((x-y)/2)(11) + ((x-y)/2)(12)
y[1.5000] = 0.9138981250585888   y[1.5000] = 0.9168437461524608   y[1.5000] = 0.9167516954932773   
 
 y(13) = y(12) + .5*h*(((x-y)/2)(12) + ((x-y)/2)(13)
y[1.6250] = 0.9532074113216032   y[1.6250] = 0.95597451009519   y[1.6250] = 0.9558880382585153   
 
 y(14) = y(13) + .5*h*(((x-y)/2)(13) + ((x-y)/2)(14)
y[1.7500] = 0.9977100692219482   y[1.7500] = 1.000309465199494   y[1.7500] = 1.0002282340751956   
 
 y(15) = y(14) + .5*h*(((x-y)/2)(14) + ((x-y)/2)(15)
y[1.8750] = 1.0470913492635905   y[1.8750] = 1.049533206241223   y[1.8750] = 1.049456898210672   
 
 y(16) = y(15) + .5*h*(((x-y)/2)(15) + ((x-y)/2)(16)
y[2.0000] = 1.1010555776593376   y[2.0000] = 1.1033494434461277   y[2.0000] = 1.1032777601402906   
 
 y(17) = y(16) + .5*h*(((x-y)/2)(16) + ((x-y)/2)(17)
y[2.1250] = 1.1593250002283733   y[2.1250] = 1.161479843978849   y[2.1250] = 1.1614125051116466   
 
 y(18) = y(17) + .5*h*(((x-y)/2)(17) + ((x-y)/2)(18)
y[2.2500] = 1.221638696360544   y[2.2500] = 1.2236629436446282   y[2.2500] = 1.2235996859170006   
 
 y(19) = y(18) + .5*h*(((x-y)/2)(18) + ((x-y)/2)(19)
y[2.3750] = 1.2877515588009272   y[2.3750] = 1.289653124548429   y[2.3750] = 1.2895937006188196   
 
 y(20) = y(19) + .5*h*(((x-y)/2)(19) + ((x-y)/2)(20)
y[2.5000] = 1.357433335265581   y[2.5000] = 1.359219654714051   y[2.5000] = 1.3591638322312865   
 
 y(21) = y(20) + .5*h*(((x-y)/2)(20) + ((x-y)/2)(21)
y[2.6250] = 1.4304677281411309   y[2.6250] = 1.4321457859080915   y[2.6250] = 1.432093346602874   
 
 y(22) = y(21) + .5*h*(((x-y)/2)(21) + ((x-y)/2)(22)
y[2.7500] = 1.5066515487479644   y[2.7500] = 1.5082279061411892   y[2.7500] = 1.508178644972651   
 
 y(23) = y(22) + .5*h*(((x-y)/2)(22) + ((x-y)/2)(23)
y[2.8750] = 1.5857939228601574   y[2.8750] = 1.5872747435327825   y[2.8750] = 1.5872284678867632   
 
 y(24) = y(23) + .5*h*(((x-y)/2)(23) + ((x-y)/2)(24)
y[3.0000] = 1.6677155443756573   y[3.0000] = 1.66910661842644   y[3.0000] = 1.669063147362353   
 Example 3:
Find y(0.1) for y' = (x – y)/2,  y(0) = 1 correct upto four decimal places.
Solution:        f(x, y) = (x – y)/2
Case(i)y' = (x - y)/2,  y(0) = 1.0 with h = 1/2
Given
y[0.0] = 1.0
 
Euler Solution:      y(1) = y(0) + h*((x-y)/2)(1)
y[0.50] = 0.75
Modified Euler iterations:y(1) = y(0) + .5*h*(((x-y)/2)(0) + ((x-y)/2)(1)
y[0.50] = 0.75   y[0.50] = 0.84375   y[0.50] = 0.83203125   y[0.50] = 0.83349609375   y[0.50] = 0.83331298828125   y[0.50] = 0.8333358764648438   
 
Euler Solution:      y(2) = y(1) + h*((x-y)/2)(2)
y[1.00] = 0.7499997615814209
Modified Euler iterations:y(2) = y(1) + .5*h*(((x-y)/2)(1) + ((x-y)/2)(2)
y[1.00] = 0.7499997615814209   y[1.00] = 0.8229164183139801   y[1.00] = 0.8138018362224102   y[1.00] = 0.8149411589838564   y[1.00] = 0.8147987436386757   y[1.00] = 0.8148165455568233   
 
Euler Solution:      y(3) = y(2) + h*((x-y)/2)(3)
y[1.50] = 0.8611107402377911
Modified Euler iterations:y(3) = y(2) + .5*h*(((x-y)/2)(2) + ((x-y)/2)(3)
y[1.50] = 0.8611107402377911   y[1.50] = 0.9178236877476991   y[1.50] = 0.9107345693089606   y[1.50] = 0.9116207091138029   y[1.50] = 0.9115099416381975   y[1.50] = 0.9115237875726483   
 
Euler Solution:      y(4) = y(3) + h*((x-y)/2)(4)
y[2.00] = 1.0586415426231315
Modified Euler iterations:y(4) = y(3) + .5*h*(((x-y)/2)(3) + ((x-y)/2)(4)
y[2.00] = 1.0586415426231315   y[2.00] = 1.1027516068990952   y[2.00] = 1.0972378488645997   y[2.00] = 1.0979270686189118   y[2.00] = 1.0978409161496228   y[2.00] = 1.0978516852082838   
 
Euler Solution:      y(5) = y(4) + h*((x-y)/2)(5)
y[2.50] = 1.3233877543069634
Modified Euler iterations:y(5) = y(4) + .5*h*(((x-y)/2)(4) + ((x-y)/2)(5)
y[2.50] = 1.3233877543069634   y[2.50] = 1.357695577403087   y[2.50] = 1.3534070995160716   y[2.50] = 1.3539431592519484   y[2.50] = 1.3538761517849638   
 
Euler Solution:      y(6) = y(5) + h*((x-y)/2)(6)
y[3.00] = 1.6404133957887526
Modified Euler iterations:y(6) = y(5) + .5*h*(((x-y)/2)(5) + ((x-y)/2)(6)
y[3.00] = 1.6404133957887526   y[3.00] = 1.6670972872799508   y[3.00] = 1.663761800843551   y[3.00] = 1.664178736648101   y[3.00] = 1.6641266196725322   
Case(ii)y' = (x - y)/2,  y(0) = 1.0 with h = 1/4
Given
y[0.0] = 1.0
 
Euler Solution:      y(1) = y(0) + h*((x-y)/2)(1)
y[0.250] = 0.875
Modified Euler iterations:y(1) = y(0) + .5*h*(((x-y)/2)(0) + ((x-y)/2)(1)
y[0.250] = 0.875   y[0.250] = 0.8984375   y[0.250] = 0.89697265625   y[0.250] = 0.897064208984375   
 
Euler Solution:      y(2) = y(1) + h*((x-y)/2)(2)
y[0.500] = 0.816176176071167
Modified Euler iterations:y(2) = y(1) + .5*h*(((x-y)/2)(1) + ((x-y)/2)(2)
y[0.500] = 0.816176176071167   y[0.500] = 0.8368563205003738   y[0.500] = 0.8355638114735484   y[0.500] = 0.835644593287725   
 
Euler Solution:      y(3) = y(2) + h*((x-y)/2)(3)
y[0.750] = 0.7936846013712966
Modified Euler iterations:y(3) = y(2) + .5*h*(((x-y)/2)(2) + ((x-y)/2)(3)
y[0.750] = 0.7936846013712966   y[0.750] = 0.8119317853121117   y[0.750] = 0.8107913363158108   y[0.750] = 0.8108626143780796   
 
Euler Solution:      y(4) = y(3) + h*((x-y)/2)(4)
y[1.000] = 0.8032508895617894
Modified Euler iterations:y(4) = y(3) + .5*h*(((x-y)/2)(3) + ((x-y)/2)(4)
y[1.000] = 0.8032508895617894   y[1.000] = 0.8193513439328768   y[1.000] = 0.8183450655346838   y[1.000] = 0.8184079579345709   
 
Euler Solution:      y(5) = y(4) + h*((x-y)/2)(5)
y[1.250] = 0.8411035237646307
Modified Euler iterations:y(5) = y(4) + .5*h*(((x-y)/2)(4) + ((x-y)/2)(5)
y[1.250] = 0.8411035237646307   y[1.250] = 0.8553098052268149   y[1.250] = 0.8544219126354284   y[1.250] = 0.8544774059223901   
 
Euler Solution:      y(6) = y(5) + h*((x-y)/2)(6)
y[1.500] = 0.9039146953929605
Modified Euler iterations:y(6) = y(5) + .5*h*(((x-y)/2)(5) + ((x-y)/2)(6)
y[1.500] = 0.9039146953929605   y[1.500] = 0.9164496480303976   y[1.500] = 0.9156662134905579   y[1.500] = 0.9157151781492978   
 
Euler Solution:      y(7) = y(6) + h*((x-y)/2)(7)
y[1.750] = 0.9887481031258607
Modified Euler iterations:y(7) = y(6) + .5*h*(((x-y)/2)(6) + ((x-y)/2)(7)
y[1.750] = 0.9887481031258607   y[1.750] = 0.9998083540466274   y[1.750] = 0.9991170883640794   y[1.750] = 0.9991602924692387   
 
Euler Solution:      y(8) = y(7) + h*((x-y)/2)(8)
y[2.000] = 1.093012893186083
Modified Euler iterations:y(8) = y(7) + .5*h*(((x-y)/2)(7) + ((x-y)/2)(8)
y[2.000] = 1.093012893186083   y[2.000] = 1.1027719368752444   y[2.000] = 1.1021619966446718   y[2.000] = 1.1022001179090826   
 
Euler Solution:      y(9) = y(8) + h*((x-y)/2)(9)
y[2.250] = 1.2144230184137998
Modified Euler iterations:y(9) = y(8) + .5*h*(((x-y)/2)(8) + ((x-y)/2)(9)
y[2.250] = 1.2144230184137998   y[2.250] = 1.223033938221066   y[2.250] = 1.2224957557331118   y[2.250] = 1.222529392138609   
 
Euler Solution:      y(10) = y(9) + h*((x-y)/2)(10)
y[2.500] = 1.3509613786303571
Modified Euler iterations:y(10) = y(9) + .5*h*(((x-y)/2)(9) + ((x-y)/2)(10)
y[2.500] = 1.3509613786303571   y[2.500] = 1.3585592480824138   y[2.500] = 1.3580843812416603   y[2.500] = 1.3581140604192075   
 
Euler Solution:      y(11) = y(10) + h*((x-y)/2)(11)
y[2.750] = 1.5008481797867843
Modified Euler iterations:y(11) = y(10) + .5*h*(((x-y)/2)(10) + ((x-y)/2)(11)
y[2.750] = 1.5008481797867843   y[2.750] = 1.5075521813920236   y[2.750] = 1.5071331812916962   y[2.750] = 1.5071593687979665   
 
Euler Solution:      y(12) = y(11) + h*((x-y)/2)(12)
y[3.000] = 1.6625130155689716
Modified Euler iterations:y(12) = y(11) + .5*h*(((x-y)/2)(11) + ((x-y)/2)(12)
y[3.000] = 1.6625130155689716   y[3.000] = 1.6684283103508373   y[3.000] = 1.6680586044269707   y[3.000] = 1.6680817110472124   
Case(iii)y' = (x - y)/2,  y(0) = 1.0 with h = 1/8
Given
y[0.0] = 1.0
 
Euler Solution:      y(1) = y(0) + h*((x-y)/2)(1)
y[0.1250] = 0.9375
Modified Euler iterations:y(1) = y(0) + .5*h*(((x-y)/2)(0) + ((x-y)/2)(1)
y[0.1250] = 0.9375   y[0.1250] = 0.943359375   y[0.1250] = 0.94317626953125   
 
Euler Solution:      y(2) = y(1) + h*((x-y)/2)(2)
y[0.2500] = 0.8920456171035767
Modified Euler iterations:y(2) = y(1) + .5*h*(((x-y)/2)(1) + ((x-y)/2)(2)
y[0.2500] = 0.8920456171035767   y[0.2500] = 0.8975498788058758   y[0.2500] = 0.8973778706276789   
 
Euler Solution:      y(3) = y(2) + h*((x-y)/2)(3)
y[0.3750] = 0.8569217930155446
Modified Euler iterations:y(3) = y(2) + .5*h*(((x-y)/2)(2) + ((x-y)/2)(3)
y[0.3750] = 0.8569217930155446   y[0.3750] = 0.8620924634176603   y[0.3750] = 0.8619308799675942   
 
Euler Solution:      y(4) = y(3) + h*((x-y)/2)(4)
y[0.5000] = 0.8315024338597582
Modified Euler iterations:y(4) = y(3) + .5*h*(((x-y)/2)(3) + ((x-y)/2)(4)
y[0.5000] = 0.8315024338597582   y[0.5000] = 0.836359730596966   y[0.5000] = 0.8362079400739283   
 
Euler Solution:      y(5) = y(4) + h*((x-y)/2)(5)
y[0.6250] = 0.8151993908072874
Modified Euler iterations:y(5) = y(4) + .5*h*(((x-y)/2)(4) + ((x-y)/2)(5)
y[0.6250] = 0.8151993908072874   y[0.6250] = 0.8197623062048026   y[0.6250] = 0.8196197150986302   
 
Euler Solution:      y(6) = y(5) + h*((x-y)/2)(6)
y[0.7500] = 0.8074601603787794
Modified Euler iterations:y(6) = y(5) + .5*h*(((x-y)/2)(5) + ((x-y)/2)(6)
y[0.7500] = 0.8074601603787794   y[0.7500] = 0.8117465357129019   y[0.7500] = 0.8116125864837106   
 
Euler Solution:      y(7) = y(6) + h*((x-y)/2)(7)
y[0.8750] = 0.8077657241223026
Modified Euler iterations:y(7) = y(6) + .5*h*(((x-y)/2)(6) + ((x-y)/2)(7)
y[0.8750] = 0.8077657241223026   y[0.8750] = 0.8117923193808908   y[0.8750] = 0.8116664882790599   
 
Euler Solution:      y(8) = y(7) + h*((x-y)/2)(8)
y[1.0000] = 0.8156285192196802
Modified Euler iterations:y(8) = y(7) + .5*h*(((x-y)/2)(7) + ((x-y)/2)(8)
y[1.0000] = 0.8156285192196802   y[1.0000] = 0.8194110786347212   y[1.0000] = 0.8192928736530011   
 
Euler Solution:      y(9) = y(8) + h*((x-y)/2)(9)
y[1.1250] = 0.8305905320862623
Modified Euler iterations:y(9) = y(8) + .5*h*(((x-y)/2)(8) + ((x-y)/2)(9)
y[1.1250] = 0.8305905320862623   y[1.1250] = 0.8341438456947754   y[1.1250] = 0.8340328046445094   
 
Euler Solution:      y(10) = y(9) + h*((x-y)/2)(10)
y[1.2500] = 0.852221507509997
Modified Euler iterations:y(10) = y(9) + .5*h*(((x-y)/2)(9) + ((x-y)/2)(10)
y[1.2500] = 0.852221507509997   y[1.2500] = 0.8555594689839763   y[1.2500] = 0.8554551576879144   
 
Euler Solution:      y(11) = y(10) + h*((x-y)/2)(11)
y[1.3750] = 0.8801172663274216
Modified Euler iterations:y(11) = y(10) + .5*h*(((x-y)/2)(10) + ((x-y)/2)(11)
y[1.3750] = 0.8801172663274216   y[1.3750] = 0.883252927298937   y[1.3750] = 0.8831549378935771   
 
Euler Solution:      y(12) = y(11) + h*((x-y)/2)(12)
y[1.5000] = 0.9138981250585888
Modified Euler iterations:y(12) = y(11) + .5*h*(((x-y)/2)(11) + ((x-y)/2)(12)
y[1.5000] = 0.9138981250585888   y[1.5000] = 0.9168437461524608   y[1.5000] = 0.9167516954932773   
 
Euler Solution:      y(13) = y(12) + h*((x-y)/2)(13)
y[1.6250] = 0.9532074113216032
Modified Euler iterations:y(13) = y(12) + .5*h*(((x-y)/2)(12) + ((x-y)/2)(13)
y[1.6250] = 0.9532074113216032   y[1.6250] = 0.95597451009519   y[1.6250] = 0.9558880382585153   
 
Euler Solution:      y(14) = y(13) + h*((x-y)/2)(14)
y[1.7500] = 0.9977100692219482
Modified Euler iterations:y(14) = y(13) + .5*h*(((x-y)/2)(13) + ((x-y)/2)(14)
y[1.7500] = 0.9977100692219482   y[1.7500] = 1.000309465199494   y[1.7500] = 1.0002282340751956   
 
Euler Solution:      y(15) = y(14) + h*((x-y)/2)(15)
y[1.8750] = 1.0470913492635905
Modified Euler iterations:y(15) = y(14) + .5*h*(((x-y)/2)(14) + ((x-y)/2)(15)
y[1.8750] = 1.0470913492635905   y[1.8750] = 1.049533206241223   y[1.8750] = 1.049456898210672   
 
Euler Solution:      y(16) = y(15) + h*((x-y)/2)(16)
y[2.0000] = 1.1010555776593376
Modified Euler iterations:y(16) = y(15) + .5*h*(((x-y)/2)(15) + ((x-y)/2)(16)
y[2.0000] = 1.1010555776593376   y[2.0000] = 1.1033494434461277   y[2.0000] = 1.1032777601402906   
 
Euler Solution:      y(17) = y(16) + h*((x-y)/2)(17)
y[2.1250] = 1.1593250002283733
Modified Euler iterations:y(17) = y(16) + .5*h*(((x-y)/2)(16) + ((x-y)/2)(17)
y[2.1250] = 1.1593250002283733   y[2.1250] = 1.161479843978849   y[2.1250] = 1.1614125051116466   
 
Euler Solution:      y(18) = y(17) + h*((x-y)/2)(18)
y[2.2500] = 1.221638696360544
Modified Euler iterations:y(18) = y(17) + .5*h*(((x-y)/2)(17) + ((x-y)/2)(18)
y[2.2500] = 1.221638696360544   y[2.2500] = 1.2236629436446282   y[2.2500] = 1.2235996859170006   
 
Euler Solution:      y(19) = y(18) + h*((x-y)/2)(19)
y[2.3750] = 1.2877515588009272
Modified Euler iterations:y(19) = y(18) + .5*h*(((x-y)/2)(18) + ((x-y)/2)(19)
y[2.3750] = 1.2877515588009272   y[2.3750] = 1.289653124548429   y[2.3750] = 1.2895937006188196   
 
Euler Solution:      y(20) = y(19) + h*((x-y)/2)(20)
y[2.5000] = 1.357433335265581
Modified Euler iterations:y(20) = y(19) + .5*h*(((x-y)/2)(19) + ((x-y)/2)(20)
y[2.5000] = 1.357433335265581   y[2.5000] = 1.359219654714051   y[2.5000] = 1.3591638322312865   
 
Euler Solution:      y(21) = y(20) + h*((x-y)/2)(21)
y[2.6250] = 1.4304677281411309
Modified Euler iterations:y(21) = y(20) + .5*h*(((x-y)/2)(20) + ((x-y)/2)(21)
y[2.6250] = 1.4304677281411309   y[2.6250] = 1.4321457859080915   y[2.6250] = 1.432093346602874   
 
Euler Solution:      y(22) = y(21) + h*((x-y)/2)(22)
y[2.7500] = 1.5066515487479644
Modified Euler iterations:y(22) = y(21) + .5*h*(((x-y)/2)(21) + ((x-y)/2)(22)
y[2.7500] = 1.5066515487479644   y[2.7500] = 1.5082279061411892   y[2.7500] = 1.508178644972651   
 
Euler Solution:      y(23) = y(22) + h*((x-y)/2)(23)
y[2.8750] = 1.5857939228601574
Modified Euler iterations:y(23) = y(22) + .5*h*(((x-y)/2)(22) + ((x-y)/2)(23)
y[2.8750] = 1.5857939228601574   y[2.8750] = 1.5872747435327825   y[2.8750] = 1.5872284678867632   
 
Euler Solution:      y(24) = y(23) + h*((x-y)/2)(24)
y[3.0000] = 1.6677155443756573
Modified Euler iterations:y(24) = y(23) + .5*h*(((x-y)/2)(23) + ((x-y)/2)(24)
y[3.0000] = 1.6677155443756573   y[3.0000] = 1.66910661842644   y[3.0000] = 1.669063147362353   



R-K second order:
1). y '=x+y with y(0) =1 , h=0.1 , find the value of y(0.5).
1.     
and               :
R-K 4th order:
Example 1:
Find   y(1.0)  using RK method of order four by solving the IVP  y' = -2xy2,  y(0) = 1 with step length 0.2. Also compre the solution obtained with RK methods of order three and two.
Solution
Given y' = -2*x*y*y,     y[0] = 1.0
(Using RK method of order 4)   with step length = 0.2
K1 = -0.0   K2 = -0.040000001192092904   K3 = -0.03841600109815598 
K4 = -0.07397150516004751 
y[0.20] = 0.9615327483765758
K1 = -0.07396362030033653   K2 = -0.10257533554202282   K3 = -0.09942553577510745 
K4 = -0.11891661890710704
y[0.40] = 0.8620524180696251
K1 = -0.11890150298349086   K2 = -0.12883389087826705   K3 = -0.12724447323187424 
K4 = -0.12958625565317425
y[0.60] = 0.7352783369268004
K1 = -0.12975221972783935   K2 = -0.12584296464465622   K3 = -0.1265778509537273 
K4 = -0.11856521365315237
y[0.80] = 0.6097518261638406
K1 = -0.11897513618897959   K2 = -0.10900467458369312   K3 = -0.11098872146906143 
K4 = -0.09950585680741567
y[1.00] = 0.5000071953135232
Comparison of the solution with RK method of orders two, three and four:
 

x = 0.0
x = 0.2
x = 0.4
x = 0.6
x = 0.8
x = 1.0
2nd Order
1.0
0.9600
0.8603
0.7350
0.6116
0.5033
4th Order
1.0
0.9615
0.8620
0.7350
0.6098
0.5
Analytical 
Solution
1.0
 0.9615
0.8621
0.7353
0.6098
0.5

Example 2:
Find  y  in  [0,3] by solving the initial value problem y' = (x - y)/2,  y(0) = 1 using RK method of order four with  h = 1/2 and 1/4.
Solution
Given y' = (x-y)/2,     y[0.000] = 1.0
(Using RK method of order 4)    with step-length = 0.5
K1 = -0.25   K2 = -0.15625   K3 = -0.16796875 
K4 = -0.0830078125
y[0.500] = 0.83642578125
K1 = -0.0841064453125   K2 = -0.0110931396484375   K3 = -0.020219802856445312 
K4 = 0.04594850540161133
y[1.000] = 0.8196284770965576
K1 = 0.045092880725860596   K2 = 0.10195627063512802   K3 = 0.09484834689646959 
K4 = 0.1463807940017432
y[1.500] = 0.9171422953950241
K1 = 0.14571442615124397   K2 = 0.19000012288233847   K3 = 0.18446441079095166 
K4 = 0.22459832345350605
y[2.000] = 1.1036825982202458
K1 = 0.22407935044493854   K2 = 0.2585694316393212   K3 = 0.2542581714900234 
K4 = 0.2855148075724327
y[2.500] = 1.3595574922662559
K1 = 0.28511062693343603   K2 = 0.3119717985667565   K3 = 0.30861415211259147 
K4 = 0.3329570889052882
y[3.000] = 1.6694307617991593
 
Given y' = (x-y)/2,     y[0.0000] = 1.0
(Using RK method of order 4)    with step-length = 0.25
K1 = -0.125   K2 = -0.1015625   K3 = -0.10302734375   K4 = -0.08087158203125
y[0.2500] = 0.897491455078125
K1 = -0.08093643188476562   K2 = -0.06025290489196777   K3 = -0.06154562532901764 
K4 = -0.04199322871863842
y[0.5000] = 0.8364036682372292
K1 = -0.04205045852965365   K2 = -0.023797304871550296   K3 = -0.02493812697518176 
K4 = -0.007683192657755938
y[0.7500] = 0.8118695824237503
K1 = -0.007733697802968786   K2 = 0.00837465830971676   K3 = 0.007367886052673911 
K4 = 0.022595316440446975
y[1.0000] = 0.8195940336507935
K1 = 0.02255074579365081   K2 = 0.03676632418154763   K3 = 0.03587785053230408 
K4 = 0.0493160144771128
y[1.2500] = 0.8557865519338713
K1 = 0.049276681008266085   K2 = 0.061821888445249454   K3 = 0.06103781298043799 
K4 = 0.07289695438571134
y[1.5000] = 0.9171020583080967
K1 = 0.07286224271148792   K2 = 0.08393335254201992   K3 = 0.08324140817761168 
K4 = 0.09370706668928647
y[1.7500] = 1.0005885301147697
K1 = 0.09367643373565379   K2 = 0.10344665662717542   K3 = 0.10283601769645534 
K4 = 0.11207193152359687
y[2.0000] = 1.103640815765855
K1 = 0.11204489802926812   K2 = 0.12066709190243885   K3 = 0.12012820478536568 
K4 = 0.12827887243109742
y[2.2500] = 1.2239598764051842
K1 = 0.12825501544935197   K2 = 0.13586407698376748   K3 = 0.1353885106378665 
K4 = 0.14258145161961866
y[2.5000] = 1.3595168167905574
K1 = 0.14256039790118033   K2 = 0.14927537303235655   K3 = 0.14885568708665806 
K4 = 0.15520343701534808
y[2.7500] = 1.5085211426496503
K1 = 0.1551848571687937   K2 = 0.1611108035957441   K3 = 0.1607404319440597 
K4 = 0.16634230317578624
y[3.0000] = 1.669392747887015
 
Example 3:
Using RK method of order four find y(0.1) for y' = x - y2,  y(0) = 1.
Solution
Given y' = x-y*y,     y[0.00] = 1.0
(Using RK method of order 4)    with step-length = 0.1
K1 = -0.10000000149011612 
K2 = -0.08525000105425715 
K3 = -0.08665669017834754 
K4 = -0.07341960110462278
y[0.10] = 0.9137945024900086
 
Example 4:
Using RK method of order four find y at x = 1.1 and 1.2 by solving y' = x2 + y2 ,  y(1) = 2.3
Solution
Given y' = x*x+y*y,     y[1.00] = 2.3
(Using RK method of order 4)    with step-length = 0.1
K1 = 0.628999987438321 
K2 = 0.7938110087671021 
K3 = 0.83757991687511 
K4 = 1.1054407603556848
y[1.10] = 3.1328703854960227
K1 = 1.102487701987972 
K2 = 1.4895197934605002 
K3 = 1.6358516854539997 
K4 = 2.4180710557439085
y[1.20] = 4.761420671422837

0 comments:

Post a Comment