Sie sind auf Seite 1von 38

Runge-Kutta

4th Order Method


Numerical Solution of
Differential Equations

Niño Lester R. Ibunes, CE-2


Mapua Institute of Technology
• When we say numerical methods, we are
numerically estimating the trajectory of the
solution of the differential equation by solving
some of the solution’s points (xn,yn).
2.5

2
1.93

1.64
1.5
1.42
1.25
1.11
1 1.00

0.5

0
0 0.1 0.2 0.3 0.4 0.5 0.6
• Numerical methods mean that they are only
approximations and thus do not coincide
completely with the particular solution.

• So far, Runge Kutta is the most accurate


approximation amongst all other numerical
methods.
• Recall from Math14 – Analytic Geometry, the
point slope form of a line
y  yo  m( x  xo )
y  yo  m( x  xo )
yi 1  yi  m( x  xi ) • Initial Points (x,y)

yi 1  yi   ( x  xi ) • m=Φ

yi 1  yi  h • h = ∆x = step size
• General form:
• According to this
yi+1 = yi + Φh equation, the slope
estimate of φ is used to
extrapolate from an old
value yi to a new value
yi+1 over a distance h.

• This formula can be


applied step by step to
compute out into the
future and, hence, trace
out the trajectory of the
solution.

• Source: Numerical Methods (6th Edition) by Chapra


• General form:
• The smaller the value for
yi+1 = yi + Φh ∆x (step size), the more
accurate the estimation
will be.

• Source: Numerical Methods (6th Edition) by Chapra


Some Numerical Methods in
Solving Differential Equations

• Source: Numerical Methods (6th Edition) by Chapra


Some Numerical Methods in
Solving Differential Equations

• Source: Numerical Methods (6th Edition) by Chapra


Some Numerical Methods in
Solving Differential Equations

• Source: Numerical Methods (6th Edition) by Chapra


Some Numerical Methods in
Solving Differential Equations

• Source: Numerical Methods (6th Edition) by Chapra


Some Numerical Methods in
Solving Differential Equations

• Source: Numerical Methods (6th Edition) by Chapra


Some Numerical Methods in
Solving Differential Equations

• Source: Numerical Methods (6th Edition) by Chapra


• Source: Wikipedia.com
• This method is devoted to solving differential
equations of the form

y '  f ( x, y )

• Source: Numerical Methods (6th Edition) by Chapra


• Source: Numerical Methods (6th Edition) by Chapra
Steps in Solving Differential Equations by
RK 4th Order Method
• Identify f(x,y)
• Identify initial values (xi,yi)
• Decide for the value of h
• Solve for
– K1
– K2
– K3
– K4
– yi+1
– xi+1 = xi + h = xi + Δx
• Recognize (xi+1, yi+1) as a point
on the solution
• Solve for (xn, yn) with initial
values (xn-1, yn-1)
• Example 1
• page 48; Exercise 1 (Elementary
Differential Equations, Rainville,
Bedient, Bedient)

Solve the differential


equation by Runge-Kutta
Method for which y = 1 and
x = 0. ∆x = 0.1,
0 ≤ x ≤ 1. Show its graph.

y'  x  y
• Approximate graphical solution to y'  x  y by RK 4th order Method.

1.8 1.80
OUTPUT
1.6 1.58
  X Y
(X0, Y0) 0 1 1.4 1.40

(X1,Y1) 0.1 1.110342 1.24


1.2
(X2, Y2) 0.2 1.242805 1.11
1 1.00
(X3, Y3) 0.3 1.399717
(X4, Y4) 0.4 1.583648 0.8

(X5, Y5) 0.5 1.797441


0.6

0.4

0.2

0 0.00
0 0.1 0.2 0.3 0.4 0.5 0.6

• Source: Numerical Methods (6th Edition) by Chapra


Initial Values, x = 0 , y = 1
1 = 0 + c(1) – 1
c=2
Therefore, the solution is

y  2e x  x  1

• Source: wolframalpha.com
True Value VS RKM Value
2 RKM VALUE
  X Y
1.8 (X0, Y0) 0 1
(X1,Y1) 0.1 1.110342
1.6
(X2, Y2) 0.2 1.242805
(X3, Y3) 0.3 1.399717
1.4
(X4, Y4) 0.4 1.583648
1.2 (X5, Y5) 0.5 1.797441
RKM Value
True Value
1

0.8
TRUE VALUE
0.6   X Y
(X0, Y0) 0 1.000000
0.4 (X1,Y1) 0.1 1.110342
(X2, Y2) 0.2 1.242806
0.2 (X3, Y3) 0.3 1.399718
(X4, Y4) 0.4 1.583649
0
0 0.1 0.2 0.3 0.4 0.5 0.6 (X5, Y5) 0.5 1.797443
TRUE VALUE RKM VALUE TAYLOR METHOD VALUE
  X Y   X Y   X Y
(X0, Y0) 0 1.00000 (X0, Y0) 0 1 (X0, Y0) 0 1
(X1,Y1) 0.1 1.11034 (X1,Y1) 0.1 1.110342 (X1,Y1) 0.1 1.110342
(X2, Y2) 0.2 1.24281 (X2, Y2) 0.2 1.242805 (X2, Y2) 0.2 1.242805
(X3, Y3) 0.3 1.39972 (X3, Y3) 0.3 1.399717 (X3, Y3) 0.3 1.399716
(X4, Y4) 0.4 1.58365 (X4, Y4) 0.4 1.583648 (X4, Y4) 0.4 1.583988
(X5, Y5) 0.5 1.79744 (X5, Y5) 0.5 1.797441 (X5, Y5) 0.5 1.797396

True Value VS RKM Value VS Taylor M. Value


2

1.8

1.6

1.4

1.2 RKM Value


True Value
1 Taylor M. Value
0.8

0.6

0.4

0.2

0
0 0.1 0.2 0.3 0.4 0.5 0.6
True Value VS RKM Value
TRUE VALUE
50000
  X Y
(X0, Y0) 0 1.000000
45000 (X1,Y1) 1 3.436564
(X2, Y2) 2 11.778112
(X3, Y3) 3 36.171074
40000 (X4, Y4) 4 104.196300
(X5, Y5) 5 290.826318
(X6, Y6) 6 799.857587
35000 (X7, Y7) 7 2185.266317
(X8, Y8) 8 5952.915974
(X9, Y9) 9 16196.167855
30000
(X10, Y10) 10 44041.931590
RKM Value
True Value
25000

RKM VALUE
20000   X Y
(X0, Y0) 0 1
(X1,Y1) 1 3.416667
15000
(X2, Y2) 2 11.67014
(X3, Y3) 3 35.73163
10000 (X4, Y4) 4 102.6065
(X5, Y5) 5 285.4342
(X6, Y6) 6 782.3011
5000 (X7, Y7) 7 2129.69
(X8, Y8) 8 5780.578
(X9, Y9) 9 15670.11
0 (X10, Y10) 10 42455.96
0 2 4 6 8 10 12
• Example 2
– page 57; Exercise 1 (Elementary
Differential Equations, Rainville,
Bedient, Bedient)

Solve the differential


equation by Runge-Kutta
Method for which y = 1 and
x = 0. Compute the
approximate values of y for
x = 0.1, 0.2, 0.3, 0.4, 0.5

y'  y  x 2 2
• Approximate graphical solution to y '  y 2  x 2 by RK 4th order Method.

2.5

2
1.93 OUTPUT
  X Y
1.64
(X0, Y0) 0 1
1.5
1.42 (X1,Y1) 0.1 1.110758
1.25 (X2, Y2) 0.2 1.246981
1.11
1 1.00 (X3, Y3) 0.3 1.417477
(X4, Y4) 0.4 1.637312
(X5, Y5) 0.5 1.933628
0.5

0 0.00
0 0.1 0.2 0.3 0.4 0.5 0.6
• Source: wolframalpha.com
• Source: wolframalpha.com
• Example 3
Solve the differential
equation by Runge-Kutta
Method for which y = -1 and
x = 0. Compute the
approximate values of y for
x = 0.1, 0.2, 0.3, 0.5, 1.0

y'  x  y2
• Approximate graphical solution to y '  x 2  y by RK 4th order Method.

0 0.00
0 0.2 0.4 0.6 0.8 1 1.2

-0.5
OUTPUT
  X Y
-1 -1.00 (X0, Y0) 0 -1
-1.10
(X1,Y1) 0.1 -1.10483
-1.22
-1.34 (X2, Y2) 0.2 -1.2186
-1.5 (X3, Y3) 0.3 -1.34014
-1.60
(X4, Y4) 0.5 -1.60128
(X5, Y5) 1 -2.28153
-2

-2.28

-2.5
Initial Values, x = 0 , y = -1
-1 = 0 + 0 + c(1) – 2
c=1
Therefore, the solution is

y  ex  x2  2x  2

• Source: wolframalpha.com
True Value VS RKM Value
0.00000 RKM Value
0 0.2 0.4 0.6 0.8 1 1.2
  X Y
(X0, Y0) 0 -1
(X1,Y1) 0.1 -1.10483
-0.50000
(X2, Y2) 0.2 -1.2186
(X3, Y3) 0.3 -1.34014
(X4, Y4) 0.5 -1.60128
-1.00000 (X5, Y5) 1 -2.28153
True Value
RKM Value

TRUE VALUE
-1.50000
  X Y
(X0, Y0) 0 -1.00000
(X1,Y1) 0.1 -1.10483
-2.00000 (X2, Y2) 0.2 -1.21860
(X3, Y3) 0.3 -1.34014
(X4, Y4) 0.5 -1.60128
(X5, Y5) 1 -2.28172
-2.50000
END

Das könnte Ihnen auch gefallen