0% found this document useful (0 votes)
27 views

LABORATOR 5 Andrei PETRE

The document describes numerical methods for solving differential equations: 1) Euler's method, modified Euler's method, and the Runge-Kutta method of order 4 are used to solve the differential equation y'=xy with initial value y0=2 and step size h=0.1. 2) The exact solution is also calculated for comparison. 3) The results of each numerical method are displayed for 10 steps from x=0.1 to x=1.

Uploaded by

Andrei Petre
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

LABORATOR 5 Andrei PETRE

The document describes numerical methods for solving differential equations: 1) Euler's method, modified Euler's method, and the Runge-Kutta method of order 4 are used to solve the differential equation y'=xy with initial value y0=2 and step size h=0.1. 2) The exact solution is also calculated for comparison. 3) The results of each numerical method are displayed for 10 steps from x=0.1 to x=1.

Uploaded by

Andrei Petre
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Andrei PETRE

LABORATOR V

y0 := 2
n := 51
:=

n+1

y = x y

( i)

echidistant := 10
i := 1 , 2 .. 10
i
x :=
i
echidistant

k := 2
h := 0.1

x =
i

0.1
0.2

SOLUTIA EXACTA

0.3

( x1) + 1

+ 1

y1 := e
k = 2.0094881871

0.4
0.5
0.6

( x2) + 1

+ 1

y2 := e
k = 2.0387517648

0.7
0.8
0.9

( x3) + 1

+ 1

y3 := e
k = 2.0889688954

( x4) + 1

+ 1

y4 := e
k = 2.161840252
( x5) + 1

+ 1

y5 := e
k = 2.2597689498

EULER - METODA LINIEI POLIGONALE

( x6) + 1

+ 1

y6 := e
k = 2.3860114191

P1 := y0 + ( 0.1) y0 h 2.0191171061893705829

( x7)

+ 1

y7 := e
k = 2.5448651345

P3 := P2 + ( 0.3) P2 h 2.1185517083761720368

P2 := P1 + ( 0.2) P1 h 2.0582449764377881361

+ 1

P4 := P3 + ( 0.4) P3 h 2.20178485521357137

( x8) + 1

+ 1

y8 := e
k = 2.7419158469

P5 := P4 + ( 0.5) P4 h 2.3103879835908040654

( x9) + 1

+ 1

y9 := e
k = 2.9843663126

P7 := P6 + ( 0.7) P6 h 2.6177697300366604161

( x10) + 1

+ 1

y10 := e
k = 3.2814743279

P9 := P8 + ( 0.9) P8 h 3.0801169976398239439

P6 := P5 + ( 0.6) P5 h 2.4476297161504158208

P8 := P7 + ( 0.8) P7 h 2.8262770144995876589

P10 := P9 + ( 1 ) P9 h 3.3881286974038063383

Andrei PETRE

y0 1 + h x

METODA EULER MODIFICATA


M1 :=
M2 :=
M3 :=
M4 :=
M5 :=
M6 :=

h
h

y0 + h x + y0 + ( x ) y0 = 2.029042691
1
1
2
2

h
h

M1 + h x + M1 + ( x ) M1 = 2.078886803705
2 2
2 2

h
h

M2 + h x + M2 + ( x ) M2 = 2.151209618463
2 3
3 2

h
h

M3 + h x + M3 + ( x ) M3 = 2.248382259535
2 4
4 2

h
h

M4 + h x + M4 + ( x ) M4 = 2.373616406781
2 5
5 2

h
h

M5 + h x + M5 + ( x ) M5 = 2.531147637806
2 6
6 2

( 1)

h
1 + ( x 1) = 2.029256264892
2
2

h
h

M7 := M6 + h x + M6 + ( x ) M6 = 2.726476737124
2 7
7 2

h
h

M8 := M7 + h x + M7 + ( x ) M7 = 2.966690113711
2 8
8 2

h
h

M9 := M8 + h x + M8 + ( x ) M8 = 3.260886064229
2 9
9 2

h
h

M10 := M9 + h x + M9 + ( x ) M9 = 3.620742852342
2 10
10 2

EULER IMBUNATATITA - METODA HEUN


H1 := y0 +

H2 := H1 +

H3 := H2 +

H4 := H3 +

2 (

( )

y0 +

x + h y0 + h x y0 = 2.029122488219
( 1)
( 1 )

x H1 +
2 2

x + h H1 + h x H1 = 2.079086154711
( 2)
( 2 )

H2 +

x + h H2 + h x H2 = 2.151582815222
( 3)
( 3 )

x H3 +
2 4

x + h H3 + h x H3 = 2.248996447246
( 4)
( 4 )

x + h H4 + h x H4 = 2.374554631896
( 5)
( 5 )

H6 := H5 +

x + h H5 + h x H5 = 2.532513977895
( 6)
( 6 )

H7 := H6 +

x + h H6 + h x H6 = 2.728403407051
( 7)
( 7 )

H8 := H7 +

x + h H7 + h x H7 = 2.969347032782
( 8)
( 8 )

H9 := H8 +

x + h H8 + h x H8 = 3.264493725576
( 9)
( 9 )

2 (

( )

H5 := H4 +

( )

x H4 +
2 5

( )

x H5 +
2 6

( )

x H6 +
2 7

( )

x H7 +
2 8

( )

x H8 +
2 9

H10 := H9 +

( )

x
2 10

H9 +

x + h H9 + h x H9 = 3.625589724194
( 10)
( 10 )
2

Andrei PETRE

RUNGE-KUTTA de ordinul 4

( 0)

K11 := x

y0 = 0

K12 := x +

K13 := x +

y0 + K11 = 0.094295204764
2
2

y0 + K12 = 0.094517494405
2
2

K14 := x + h
0

( y0 + h K13 ) = 0.192074512382
y := y0 +
1

( 1)

K1 := x

K3 := x +

y 1 + K1 = 0.291805709116
2
2

y 1 + K2 = 0.292526350533
2
2

K4 := x + h
1

( 2)

K11 := x

) (y1 + h K3) = 0.395082844036

K31 := x +

y := y +

y := y +

( K1 + 2 K2 + 2 K3 + K4) = 2.0387587587

y2 + K21 = 0.502114255298
2
2

( 3)

y := y +

y2 + K11 = 0.500827914068
2
2

K41 := x + h

K12 := x

y := y +

y = 0.3950849999372

K21 := x +

( K11 + 2 K12 + 2 K13 + K14 ) = 2.0094949985

y = 0.192078646368

K2 := x +

) (y2 + h K31) = 0.612069828267

K11 + 2 K21 + 2 K31 + K41 = 2.0889760781

y = 0.61207155519
3

h
h

K22 := x + y + K12 = 0.726738125731


3
3
2
2

h
h

K32 := x + y + K22 = 0.728703906265


3
3
2
2

K42 := x + h
3

( 4)

K13 := x

) (y3 + h K32) = 0.849341009058

K12 + 2 K22 + 2 K32 + K42 = 2.161847688593

y = 0.8493414883071
4

h
h

K23 := x + y + K13 = 0.976531750752


4
4
2
2

h
h

K33 := x + y + K23 = 0.979349073662


4
4
2
2

K43 := x + h
4

) (y4 + h K33) = 1.114638693206

K13 + 2 K23 + 2 K33 + K43 = 2.259776719099

Andrei PETRE

( 5)

K14 := x

y = 1.1146357944422
5

K24 := x +

K34 := x +

y5 + K14 = 1.258688148705
2
2

y5 + K24 = 1.2626034224
2
2

K44 := x + h
5

( 6)

K15 := x

) (y5 + h K34) = 1.417354412226

K35 := x +

) (y6 + h K35) = 1.769021493158

) (y8 + h K37) = 2.680490056171

K17 + 2 K27 + 2 K37 + K47 = 2.984376327407

K38 := x +

y9 + K18 = 2.959498284931
2
2

y9 + K28 = 2.972742337358
2
2

K48 := x + h
9

y = 2.6803955618886

y8 + K27 = 2.425563783537
2
2

K16 + 2 K26 + 2 K36 + K46 = 2.74192515983

K28 := x +

y8 + K17 = 2.41574443686
2
2

K47 := x + h

( 9)

K18 := x

y := y +

y = 2.1839635576685

K37 := x +

K15 + 2 K25 + 2 K35 + K45 = 2.544873837271

) (y7 + h K36) = 2.184014331003

K27 := x +

y7 + K26 = 1.971150675252
2
2

( 8)

y7 + K16 = 1.963883524953
2
2

K46 := x + h
K17 := x

K36 := x +

y = 1.7689966221403
h

y := y +

K26 := x +

K14 + 2 K24 + 2 K34 + K44 = 2.386019608247

y6 + K25 = 1.588900084039
2
2

( 7)

y6 + K15 = 1.583544017739
2
2

K45 := x + h
K16 := x

y := y +

y = 1.4173440447352

K25 := x +

y := y +

) (y9 + h K38) = 3.281650561143

10

:= y +
9

h
6

K18 + 2 K28 + 2 K38 + K48 = 3.281485116868

Andrei PETRE

( xi) ( + 1)

+ 1
e
k =
2.0094881871
2.0387517648
2.0889688954
2.161840252
2.2597689498
2.3860114191
2.5448651345
2.7419158469
2.9843663126
3.2814743279

You might also like