You are on page 1of 5

REZOLVAREA ECUAȚIILOR DIFERENȚIALE ORDINARE

2. Metoda Runge - Kutta de ordinul 4

Problema

dy
Se cunoaște o ecua\ie diferen\ial` de forma: = f ( x, y ) și o valoare y0 = y ( x0 ) .
dx
Se calculeaz` integrala y (x) sub forma unui ]ir de valori discrete ( xi , y i ) pentru
domeniul de defini\ie al integralei [x0, K x n ].

Principiul metodei

Se împarte intervalul [x 0 , x n ] într-un număr n de subintervale egale și se calculează


pasul de discretizare:

h = xi +1 − xi

Funcția y ( x ) se calculeaz` pas cu pas pentru domeniul [x 0 , x n ] plecând de la valorile


cunoscute folosind relațiile:

xi +1 = xi + h

1 
yi +1 = y i +  ⋅ (k i +1 / 1 + 2 ⋅ k i +1 / 2 + 2 ⋅ k i +1 / 3 + k i +1 / 4 ) ⋅ h
6 

în care:

k i +1 / 1 = f ( xi , y i )

 1 1 
k i +1 / 2 = f  xi + ⋅ h, y i + ⋅ k1 ⋅ h 
 2 2 

 1 1 
k i +1 / 3 = f  xi + ⋅ h, y i + ⋅ k 2 ⋅ h 
 2 2 

k i +1 / 4 = f (xi + h, y i + k 3 ⋅ h )

1
REZOLVAREA ECUAȚIILOR DIFERENȚIALE ORDINARE

Exemplu de calcul

Problemă:

Să se determine soluția ecuației diferențiale:

dy
dx
(
= y ⋅ x2 −1 )
pe domeniul [0L 2] și folosind pasul de discretizare de 0,5. Se cunoaște valoarea
inițială y (0) = 1 .

Date problemă:

dy
dx
(
= y ⋅ x2 −1 )

Domeniul de calcul: x = 0L 2

Condiția inițială: x 0 = 0
y0= 1

Pasul de discretizare: h = 0,5

Cerință:

y(x ) = ?

Rezolvare:

Formulele iterative de calcul sunt:

xi +1 = xi + h

2
REZOLVAREA ECUAȚIILOR DIFERENȚIALE ORDINARE

(
k i +1 / 1 = y i ⋅ xi − 1
2
)
  
2
 1 1 
k i +1 / 2 =  y i + ⋅ k i +1 / 1 ⋅ h  ⋅  xi + ⋅ h  − 1
 2   2  

  
2
 1 1 
k i +1 / 3 =  y i + ⋅ k i +1 / 2 ⋅ h  ⋅  xi + ⋅ h  − 1
 2   2  

[
k i +1 / 4 = ( y i + k i +1 / 3 ⋅ h ) ⋅ ( xi + h ) − 1
2
]
1 
yi +1 = y i +  ⋅ (k i +1 / 1 + 2 ⋅ k i +1 / 2 + 2 ⋅ k i +1 / 3 + k i +1 / 4 ) ⋅ h
6 

Calcul iterativ:

o Iterația 1.

x1 = x 0 + h = 0 + 0,5 = 0,5

( 2
)
k 1 / 1 = y 0 ⋅ x 0 − 1 = 1 ⋅ 0 2 − 1 = −1( )
  
2
 1 1 
k1 / 2 =  y 0 + ⋅ k1 / 1 ⋅ h  ⋅  x0 + ⋅ h  − 1 =
 2   2  
  
2
 1 1 
= 1 + ⋅ (−1) ⋅ 0,5  ⋅  0 + ⋅ 0,5  − 1 = −0,7031
 2   2  

  
2
 1 1 
k1 / 3 =  y 0 + ⋅ k1 / 2 ⋅ h  ⋅  x0 + ⋅ h  − 1 =
 2   2  
  
2
 1 1 
= 1 + ⋅ (−0,7031) ⋅ 0,5  ⋅  0 + ⋅ 0,5  − 1 = −0,7727
 2   2  

[
k1 / 4 = ( y 0 + k1 / 3 ⋅ h ) ⋅ ( x0 + h ) − 1 =
2
]
[
= (1 − 0,7727 ⋅ 0,5) ⋅ (0 + 0,5) − 1 = −0,4602
2
]
1 
y1 = y 0 +  ⋅ (k1 / 1 + 2 ⋅ k1 / 2 + 2 ⋅ k1 / 3 + k1 / 4 ) ⋅ h =
6 
1 
= 1 +  ⋅ (− 1 − 2 ⋅ 0,7031 − 2 ⋅ 0,7727 − 0,4602 ) ⋅ 0,5 = 0,6323
6 

3
REZOLVAREA ECUAȚIILOR DIFERENȚIALE ORDINARE

o Iterația 2.

x 2 = x1 + h = 0,5 + 0,5 = 1

( 2
) ( )
k 2 / 1 = y1 ⋅ x1 − 1 = 1 ⋅ 0,5 2 − 1 = −0,4743

  
2
 1 1 
k 2 / 2 =  y1 + ⋅ k 2 / 1 ⋅ h  ⋅  x1 + ⋅ h  − 1 = −0,2248
 2   2  

  
2
 1 1 
k 2 / 3 =  y1 + ⋅ k 2 / 2 ⋅ h  ⋅  x1 + ⋅ h  − 1 = −0,2521
 2   2  

[ 2
]
k 2 / 4 = ( y1 + k 2 / 3 ⋅ h ) ⋅ ( x1 + h ) − 1 = 0

1 
y 2 = y1 +  ⋅ (k 2 / 1 + 2 ⋅ k 2 / 2 + 2 ⋅ k 2 / 3 + k 2 / 4 ) ⋅ h = 0,5133
6 

o Iterația 3.

x3 = x 2 + h = 1 + 0,5 = 1,5

( 2
) ( )
k 3 / 1 = y 2 ⋅ x 2 − 1 = 1 ⋅ 12 − 1 = 0

  
2
 1 1 
k3 / 2 =  y 2 + ⋅ k 3 / 1 ⋅ h  ⋅  x 2 + ⋅ h  − 1 = 0,2888
 2   2  

  
2
 1 1 
k3 / 3 =  y 2 + ⋅ k 3 / 2 ⋅ h  ⋅  x 2 + ⋅ h  − 1 = 0,3294
 2   2  

[ 2
]
k 3 / 4 = ( y 2 + k 3 / 3 ⋅ h ) ⋅ ( x 2 + h ) − 1 = 0,8475

1 
y3 = y 2 +  ⋅ (k 3 / 1 + 2 ⋅ k 3 / 2 + 2 ⋅ k 3 / 3 + k 3 / 4 ) ⋅ h = 0,6870
6 

o Iterația 4.

x 4 = x3 + h = 1,5 + 0,5 = 2

( 2
) ( )
k 4 / 1 = y 3 ⋅ x3 − 1 = 1 ⋅ 1,5 2 − 1 = 0,8587

4
REZOLVAREA ECUAȚIILOR DIFERENȚIALE ORDINARE

  
2
 1 1 
k4 / 2 =  y 3 + ⋅ k 4 / 1 ⋅ h  ⋅  x3 + ⋅ h  − 1 = 1,8597
 2   2  

  
2
 1 1 
k 4 / 3 =  y 3 + ⋅ k 4 / 2 ⋅ h  ⋅  x3 + ⋅ h  − 1 = 2,3758
 2   2  

[ 2
]
k 4 / 4 = ( y 3 + k 4 / 3 ⋅ h ) ⋅ ( x3 + h ) − 1 = 5,6248

1 
y 4 = y 3 +  ⋅ (k 4 / 1 + 2 ⋅ k 4 / 2 + 2 ⋅ k 4 / 3 + k 4 / 4 ) ⋅ h = 1,9332
6 

Soluția problemei:

Valorile discrete ale funcției y (x) pe intervalul x = 0 L 2 :

i 0 1 2 3 4
xi 0 0,5 1 1,5 2
yi 1 0,6323 0,5133 0,6870 1,9332

You might also like