"); hg.document.close(); } function ptip(){ hg=window.open('','','toolbar=no,width=400,height=100,top=0,left=0'); hg.document.open(); hg.document.writeln(""); hg.document.writeln("Positive definite "); hg.document.close(); } function sclose(){ hg.window.close(); }  
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
3rd Order
1.0
0.9616
0.8622
0.7355
0.6099
0.5
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
 

Problems to Workout:
 
 
  Solve the IVP y' = x + y,  y(0) = 1 using fourth order RK method from x = 0 to 0.4 taking the steplength h = 0.1
 2
 3
 4
 5
 6