summaryrefslogtreecommitdiff
path: root/260/CH9/EX9.3/9_3.sce
blob: 8928547ee74d3b2249fb63ea54ed413e96dbc57d (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
52
53
54
55
56
//Eg-9.2
//pg-388

clear
clc

a=[1 0 -1 1];
fz=poly(a,'z','c');
r=roots(fz);


//bounds
lb=1;
ub=3;
//using x=2z-b-a/b-a ---using fact that x=z-2 fx roots are obtained from subtracting 2 from fz 
s=r-2;

fx=poly(s,'x',['roots']);
disp(fx)
m=coeff(fx);

for i=1:4
    t0=m(1)*1+1/2*m(3);
    t1=m(2)*1+3/4*m(4);
    t2=1/2*m(3);
    t3=1/4*m(4);
    
end

//considering order greater than 1
fx1=poly([t0 t1],'x','c');
r=roots(fx1);
s=r+2;
fz1=poly(s,'z',['roots']);
fz2=35/4*fz1;



error1=fz-fz2;

//order>2
f2z=poly([15/2 -45/4 5],'z','c');
error2=fz-f2z;


//plotting f vs z
z=.5:.5:3.5;
plot(z,horner(fz,z));
set(gca(),"auto_clear","off")
plot(z,horner(fz2,z));
plot(z,horner(f2z,z));


//errors e vs z
plot(z,horner(error1,z));
plot(z,horner(error2,z));