summaryrefslogtreecommitdiff
path: root/1332/CH15/EX15.26/15_26.sce
blob: d2c699293e4a0b9bab1eba09b312ef3b8e0d7d99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//Example 15.26
//Multi Valued Method
//Page no. 553
clc;clear;close;

deff('y=f1(x,y)','y=2*x^2-y')
h=0.1;x=0;y=-1;
deff('y=f2(x,y)','y=4*x-f1(x,y)')
deff('y=f3(x,y)','y=4-f2(x,y)')
B=[1,1,1,1;0,1,2,3;0,0,1,3;0,0,0,1];
y0=[y;h*f1(x,y);h^2*f2(x,y)/2;h^3*f3(x,y)/6]
y01=y0;
r=[0;1;3/4;1/6]

disp(r,'If r = ')
printf('\n\n-------------------------------------------------------------------------\nx = 0\t\t\tx = 0.1\t\t\t\tx = 0.2\n\t')
for i=1:2
    y11=B*y01
    s(i)=h*(f1(x+h,y11(1)))-y11(2)
    y1=y11+s(i)*r
    if i==2 then
        break
    end
    y2=y1;
    y22=y11;
    y01=y1
end
printf('\t   (s = %.5g)\t\t   (s = %.9f)\n-------------------------------------------------------------------------\n   Y0\t\t   Y`i\t\t   Y1\t\t   Y`2\t\t   Y2\n-------------------------------------------------------------------------\n',s(1),s(2))
for i=1:4
    printf('%.5f \t%.5f \t%.5f \t%.5f \t%.5f\n',y0(i),y22(i),y2(i),y11(i),y1(i))
end
y0=[y;h*f1(x,y);h^2*f2(x,y)/2;h^3*f3(x,y)/6]
y01=y0;
r=[5/12;1;3/4;1/6]
disp(r,'If r = ')
printf('\n\n-------------------------------------------------------------------------\nx = 0\t\t\tx = 0.1\t\t\t\tx = 0.2\n\t')
for i=1:2
    y11=B*y01
    s(i)=h*(f1(x+h,y11(1)))-y11(2)
    y1=y11+s(i)*r
    if i==2 then
        break
    end
    y2=y1;
    y22=y11;
    y01=y1
end
printf('\t   (s = %.5g)\t\t   (s = %.9f)\n-------------------------------------------------------------------------\n   Y0\t\t   Y`i\t\t   Y1\t\t   Y`2\t\t   Y2\n-------------------------------------------------------------------------\n',s(1),s(2))
for i=1:4
    printf('%.5f \t%.5f \t%.5f \t%.5f \t%.5f\n',y0(i),y22(i),y2(i),y11(i),y1(i))
end