0% found this document useful (0 votes)
36 views3 pages

Runge Kutta Method

Program to implement the Runge Kutta method of numerical analysis in C programming language.

Uploaded by

Khushal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
36 views3 pages

Runge Kutta Method

Program to implement the Runge Kutta method of numerical analysis in C programming language.

Uploaded by

Khushal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 3
B Example 10.15. Apply Runge-Kutta fourth order method to find an approximate value of y when x = 0.2 given that dyldx =x + y and y = 1 when x = 0. (Delhi, B. Tech., 2013 Sol. Here x, = 0,9 = 1,h = 0.2, fly, ¥o) = 1 hy = hefley, Yo) = 0.2 x1 = 0.2000 ahf (+ +h, Yo +h) = 0.2 x fl0.1, 1.1) = 0.2400 hg = hf (+ +3h % +3hs) = 0.2 x A.1, 1.12) = 0.2440 and hey = hflary + hy yo + hg) = 0.2 x 0.2, 1.244) = 0.2888 Pe Zth, + Qh, + Dhy + hy) = z ©, 0.4800 + 0.4880 + 0.2888) « ; x (1.4568) = 0.2428. Hence the required approximate value of y is 1.2 RUNGE-KUTTA METHOD (§ 10.7) lL) FLOW CHART cS Start 5) era pa | Define function f(x, y) Get values of x0, yO, h, xn k1 = h*f(x, y) 2 = h*f(x + h/2, y +k1/2) k3 = h*f(x + b/2, y+ 2/2) k4 =h*f(x +h, y + k8) k= (kl + (k2 + k3)*2 + (k4)*6 x=yth y=ytk Notes. x0 is starting value of x ie., x9 xn is the value of x for which y is to be determined (2) PROGRAM /* Runge Kutta Method */ #include float £(float x,float y) { return x+y*: } main() { float x0,y0,h,xn,x,y,k1,k2,k3,k4,k; printf ("Enter the values of x0,y0,” “h,xn\n") ; scanf (“tf $f $f %£”,&x0,&y0,&h, &xn) ; x = x0; y = yO; while (1) { if (x == xn) break; kl = hf (x,y); k2 = h*f (x+h/2,y+k1/2) ; k3 = h*f (x+h/2,y+k2/2) ; | k4 = hrf (xth,y+k3) ; k = (k1+(k2+k3)*2+k4) /6; x += hj y += kj printf("When x = %8.4£” “y = %8.4f\n",x,y); i als

You might also like