28.01.2013 Views

Runge-Kutta Method - Clarkson University

Runge-Kutta Method - Clarkson University

Runge-Kutta Method - Clarkson University

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

If we have a higher order differential equation, we first break it down into a set of first order<br />

differential equations by defining intermediate variables. For example, a second order differential<br />

equation is written as a set of two first order differential equations by defining y′ as some new<br />

variable. Once that is done for the given differential equation of order m , let us call our set of<br />

j<br />

dependent variables Y , where j runs from 1 to m . Then, we can write<br />

1 2 3 ( )<br />

j j m<br />

Y′ = f xY , , Y , Y , �Y, j= 1, 2, 3, �m<br />

where<br />

j<br />

f are known functions of their arguments.<br />

Integration by the <strong>Runge</strong>-<strong>Kutta</strong> method is just as straightforward as it is for a single equation. Here<br />

is the recipe.<br />

xn+ 1 xn h = +<br />

Yn+ Yn 1<br />

6<br />

k 2k 2k<br />

k<br />

= + + + +<br />

j j<br />

k1 = hf<br />

1 2 3 m<br />

xn, Yn, Yn , Yn , � Yn<br />

( )<br />

( )<br />

j j j j j j<br />

1 1 2 3 4<br />

1 2 3<br />

m<br />

j j⎛ h 1 k1 2 k1 3 k1 m k ⎞ 1<br />

k2 = hf ⎜xn + , Yn + , Yn + , Yn + , � Yn<br />

+ ⎟<br />

⎝ 2 2 2 2 2 ⎠<br />

1 2 3<br />

m<br />

j j⎛ h 1 k2 2 k2 3 k2 m k ⎞ 2<br />

k3 = hf ⎜xn + , Yn + , Yn + , Yn + , � Yn<br />

+ ⎟<br />

⎝ 2 2 2 2 2 ⎠<br />

j j 1 1 2 2 3 3 m m<br />

k = hf x + hY , + k, Y + k , Y + k , � Y + k<br />

( n n n n n )<br />

4 3 3 3 3<br />

j<br />

When calculating k i , you need to evaluate them for every value of j at a given level i before<br />

j<br />

proceeding to the next level. That is, you would first calculate all the k1 , j = 1, 2, 3�<br />

m before<br />

j<br />

calculating k 2 .<br />

To assure that you have produced a working code that yields correct results, try your program on a<br />

third order linear ordinary differential equation with constant coefficients for which you can write an<br />

analytical solution. Compare the results from the numerical and analytical solutions. Determine the<br />

right value of h to use to get sufficient accuracy in your numerical solution by trial and error. This<br />

will give you some experience before trying the homework. Here is an example problem.<br />

y′′′ + 2y′′ − y′ − 2y = 0 with<br />

( ) ′ ( ) ′′ ( )<br />

y 0 = 4, y 0 =− 3, y 0 =<br />

7<br />

2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!