blob: af9a6e10283760bc9b017a92ff4ec7de04fa3c28 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
//Example 15.16
//Fourth Order Runge Kutta Method
//Page no. 528
clc;clear;close;
deff('y=f(x,y)','y=x-y')
y=1;x=1;h=0.1;
K1=h*f(x,y);
K2=h*f(x+h/2,y+K1/2);
K3=h*f(x+h/2,y+K2/2);
K4=h*f(x+h,y+K3);
disp(K4,'K4 =',K3,'K3 =',K2,'K2 =',K1,'K1 =')
y1=y+(K1+2*K2+2*K3+K4)/6
printf('\ny(1.1) = %.8f\n\n',y1)
|