You are on page 1of 7

NAME MUHAMMAD MAWIZ

SEAT NO PP-20048
BATCH 2020
DISCIPLINE POLYMER & PETROCHEMICAL ENGINEERING
SEMESTER FALL - 2022
COURSE TEACHER DR FAHEEM RAEES
COURSE CODE & TITLE APPLIED NUMERICAL METHOD (MT-471)

Problem definition

You are required to modify Four stage Runge-Kutta (R.K) method


for proper choice of weighting coefficients (ci) and the location of slope
computation i.e. parameters ( .

Four stage R.K. methods are defined in the following way in terms of
general coefficients.

, Such that .

Where, ℎ And
ℎ ℎ , . ‘h’ is width of
interval.

Test Problem

You have to test your modified coefficients on the following test


problem only,

, where ‘a’ is your roll number (last two digits) and


‘b’ is computed as follow based on your roll number,

You are required to obtain solution in the domain .


The initial condition is . The number of interval must be
selected as per scalability test for you problem
Step:1 Selection of parameters

The Runge-Kutta Method is used to calculate the solution of ordinary differential equations
numerically
Mathematically Runge-Kutta Method can be expressed as
𝑑𝑦
𝐿𝑒𝑡 = 𝑓(𝑡, 𝑦) ; 𝑦 ( 𝑡0 ) = 𝑦0
𝑑𝑡
So, the Runge-Kutta Method of order four is given as
𝑘1 = ℎ 𝑓( 𝑡𝑛 , 𝑦𝑛 ) ,
𝑘2 = ℎ 𝑓( 𝑡𝑛 + ℎ⁄2 , 𝑦𝑛 + 𝑘1 ⁄2)
𝑘3 = ℎ 𝑓( 𝑡𝑛 + ℎ⁄2 , 𝑦𝑛 + 𝑘2 ⁄2)
𝑘4 = ℎ 𝑓( 𝑡𝑛 + ℎ, 𝑦𝑛 + 𝑘3 )
1
𝑦𝑖+1 = 𝑦𝑖 + (𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 ) 𝑓𝑜𝑟 𝑖 = 0, 1, 2, 3, ... 𝑛
6

The above given scheme is for standard RK method of order IV, for the modified RK method we are
selecting some parameters and on these parameters the method will be modified
Four stages R.K. methods are defined in the following way in terms of general coefficients.

, Such that .

Where, ℎ And
ℎ ℎ , . ‘h’ is width of interval

C1 0.1 W1 0 theta 1 0
C2 0.3 W2 0.4 theta 2 0.4
C3 0.4 W3 0.6 theta 3 0.6
C4 0.2 W4 1 theta 4 1

The coefficients C1, C2, C3, C4 are selected on the basis of


While the parameters of W and theta is selected by keeping in mind that we need to compare it from
the standard values of RK method
In this problem we are comparing the result between the standard 4th order RK method and modified
4th order RK method

STEP:2 DEFINING OF DOMAIN

Now according to given conditions in the problem we have a (roll no) = 48 and b=1.23 and for our
step size (h) we are taking it as h=12, h/2=6, h/4=3, h/8=1.5, h/16=0.75
So, our differential equation would become
𝒅𝒚 𝟒𝟖𝒙 + 𝟏. 𝟐𝟑 𝒚
=
𝒅𝒙 𝟏. 𝟐𝟑𝒙 + 𝟒𝟖𝒚
We will be obtaining the result between the domain of (0 ≤ X ≤ 48).
STEP:3 COMPARISON OF STANDARD VS MODIFIED

RK RK MODIFIED
STANDARD FOR h
x Y Y' (Y-Y')2
0 39.0244 39.0244 0
12 41.1166 41.2906 0.030276
24 46.308 46.5964 0.08317456
36 53.6997 54.0389 0.11505664
48 62.5165 62.8669 0.12278016
RMSE 0.26506126

RK RK MODIFIED
STANDARD FOR h/2
x Y Y' (Y-Y')2
0 39.0244 39.0244 0
6 39.634 39.6793 0.002052
12 41.1163 41.2017 0.007293
18 43.3793 43.4968 0.013806
24 46.3073 46.4482 0.019853
30 49.7826 49.9388 0.024398
36 53.699 53.864 0.027225
42 57.9672 58.1365 0.028662
48 62.5158 62.6859 0.028934
RMSE 0.130053

X VS Y & Y' FOR h X VS Y & Y' FOR h/2


70 70

60 60
VALUES OF Y & Y'

50
50
VALUES OF Y & Y'

40
40
30
30
20
20
10
10 0
0 0 10 20 30 40 50 60
0 10 20 30 40 50 60 VALUES OF X
VALUES OF X
Series1 Series2 Series1 Series2
RK
RK
MODIFIED
STANDARD FOR h/4
x Y Y' (Y-Y')2
0 39.0244 39.0244 0
3 39.216 39.2275 0.000132
6 39.634 39.6566 0.000511
9 40.2709 40.3039 0.001089
12 41.1162 41.1587 0.001806
15 42.1571 42.208 0.002591
18 43.3793 43.4375 0.003387
21 44.7677 44.8322 0.00416
24 46.3073 46.377 0.004858
27 47.9836 48.0574 0.005446
30 49.7826 49.8597 0.005944
33 51.6916 51.7713 0.006352
36 53.6989 53.7804 0.006642
39 55.7939 55.8767 0.006856
42 57.9672 58.0507 0.006972
45 60.2103 60.2941 0.007022
48 62.5157 62.5996 0.007039
RMSE 0.064539

X VS Y & Y' FOR h/4


70

60
VALUES OF Y & Y'

50

40

30

20

10

0
0 10 20 30 40 50 60
VALUES OF X

Series1 Series2
RK
RK
MODIFIED
STANDARD FOR h/8
x Y Y' (Y-Y')2
0 39.0244 39.0244 0
1.5 39.0916 39.0945 8.41E-06
3 39.216 39.2217 3.249E-05
4.5 39.3971 39.4056 7.225E-05
6 39.634 39.6453 0.00012769
7.5 39.9257 39.9396 0.00019321 X VS Y & Y' FOR h/8
9 40.2709 40.2874 0.00027225
70
10.5 40.6683 40.6871 0.00035344
60
12 41.1162 41.1374 0.00044944

VALUES OF Y & Y'


50
13.5 41.6131 41.6364 0.00054289
40
15 42.1571 42.1825 0.00064516 30
16.5 42.7465 42.7737 0.00073984 20
18 43.3793 43.4083 0.000841 10
19.5 44.0536 44.0842 0.00093636 0
21 44.7677 44.7998 0.00103041 0 10 20 30 40 50 60
22.5 45.5195 45.553 0.00112225 VALUES OF X
24 46.3073 46.342 0.00120409 Series1 Series2

25.5 47.1292 47.165 0.00128164


27 47.9836 48.0203 0.00134689
28.5 48.8686 48.9061 0.00140625
30 49.7826 49.821 0.00147456
31.5 50.7241 50.7631 0.001521
33 51.6916 51.7312 0.00156816
34.5 52.6837 52.7237 0.0016
36 53.6989 53.7394 0.00164025
37.5 54.7361 54.7769 0.00166464
39 55.7939 55.835 0.00168921
40.5 56.8713 56.9126 0.00170569
42 57.9672 58.0087 0.00172225
43.5 59.0805 59.1221 0.00173056
45 60.2103 60.2519 0.00173056
46.5 61.3556 61.3973 0.00173889
48 62.5157 62.5574 0.00173889
RMSE 0.032159932
Similarly, we can obtain the graph of X VS Y & Y’ for h/16

X VS Y & Y' FOR h/16


70
60
VALUES OF Y & Y'

50
40
30
20
10
0
0 10 20 30 40 50 60
VALUES OF X

Series1 Series2

RESULT AND DISUSSION

From the above calculations and graphs we can clearly see that the RSME error starts
decreasing as soon as we decrease our step size and increase our intervals.
As we reduced the step size, selected coefficient and parameters starts giving better result

Step
RMSE
Size(h) RMSE VS Stepsize(h)
0.265061 12
0.3
0.130053 6
0.064539 3 0.25

0.03216 1.5 0.2


0.016055 0.75
RMSE

0.15

0.1

0.05

0
12 6 3 1.5 0.75
Step size(h)
MATLAB CODES

For standard RK method For modified RK method

clc; clear all clc; clear all


f=@(x,y)(48*x +1.23*y)/(1.23*x + 48*y); f=@(x,y)(48*x +1.23*y)/(1.23*x + 48*y);
a=input('\n Enter Roll No : '); a=input('\n Enter Roll No : ');
b=input('\n Enter You Domain : '); b=input('\n Enter You Domain : ');
x0=0;y0=a/b;xn=a; x0=0;y0=a/b;xn=a;
h=input('\n Enter Step length(h) : '); h=input('\n Enter Step length : ');
N=(xn-x0)/h; N=(xn-x0)/h;
display(N); display(N);
x(1)=0;y(1)=a/b; x(1)=0;y(1)=a/b;
for i=1:N disp('Enter_Co-efficient_values');
k1=h*f(x(i),y(i)); C1=input('\n Enter value of C1 : ');
k2=h*f(x(i)+0.5*h,y(i)+0.5*k1); C2=input('\n Enter value of C2 : ');
k3=h*f(x(i)+0.5*h,y(i)+0.5*k2); C3=input('\n Enter value of C3 : ');
k4=h*f(x(i)+h,y(i)+k3); C4=1-(C1+C2+C3);

y(i+1)=y(i)+0.16666667*(k1+2*k2+2*k3+k for i=1:N


4); k1=h*f(x(i),y(i));
x(i+1)=x(i)+h; k2=h*f(x(i)+0.5*h,y(i)+0.5*k1);
end k3=h*f(x(i)+0.5*h,y(i)+0.5*k2);
RK_values = y' k4=h*f(x(i)+h,y(i)+k3);
display(N);
y(i+1)=y(i)+C1*k1+C2*k2+C3*k3+C4*k
4;
x(i+1)=x(i)+h;
end
RK_values = y'
display(N);

You might also like