Example of the Runge – Kutta Method

Posted on Updated on

Example:

Use the 4th order Runge-Kutta method with h = 0.1 to find the

approximate solution for y(1.1), working to 4 decimal places, for the

initial value problem:

dy/dx = 2xy,   y(1) = 1

sol:

We have dy/dx = f(x,y) = 2xy.

If you require the 4th order approximation the formula will be:

y(x0 + h) = y(x0) + (1/6)[w1 + 2w2 + 2w3 + w4]

where:

w1 = h*f(x0.y0)               = 0.1(2)(1)(1)          = 0.2

w2 = h*f(x0 + h/2, y0 + w1/2) = 0.1(2)(1.05)(1.1)     = 0.231

w3 = h*f(x0 + h/2, y0 + w2/2) = 0.1(2)(1.05)(1.1155)  = 0.234255

w4 = h*f(x0 + h,   y0 + w3)   = 0.1(2)(1.1)(1.234255) = 0.2715361

and so:

y(1.1) = 1 + (1/6)[0.2 + 2(0.231) + 2(0.234255) + 0.2715361]

= 1.23367435

We can compare this with the exact solution to the problem.

dy/y  = 2x dx

and integrating:

ln(y) = x^2 + C

and y = 1 when x = 1

0 = 1 + C

and so  C = -1. Therefore:

ln(y) = x^2 – 1

y = e^(x^2-1)

When x = 1.1 this gives:

y = e^(1.1^2 -1)

= e^0.21

= 1.23367806

which is same as Runge-Kutta up to the 5th decimal place.

Edited by- : Dr. Ashwin I Mehta 

 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s