summaryrefslogtreecommitdiff
path: root/1673/CH1/EX1.4/1_4.sce
blob: 16fde3b5eebaf2016dbb304cf1560308ccf7512d (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
//example 1.4
//best approximation
//page 10
clc;clear;close;
A_X=1/3;//the actual number
X1=0.30;
X2=0.33;
X3=0.34;
A_E1=abs(A_X-X1);
A_E2=abs(A_X-X2);
A_E3=abs(A_X-X3);
if(A_E1<A_E2)
if(A_E1<A_E3)
    B_A=X1;
end 
end
if(A_E2<A_E1)
if(A_E2<A_E3)
    B_A=X2;
end
end
if(A_E3<A_E2)
if(A_E3<A_E1)
    B_A=X3;
end
end
printf('the best approximation of 1/3 is %.2g ',B_A);