summaryrefslogtreecommitdiff
path: root/50/CH4/EX4.32/ex_4_32.sce
blob: 81c43db58e81403dd094561c2db2e514b38b49c4 (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
// example 4.32
// obtain the linear polinomial approximation to the function f(x)=x^1/2

// let P(x)=a0*x+a1


// for n=1;
// hence I(c0,c1)= integral (x^1/2-(c1*x+c0))^2 in the interval [0,1]


printf('dI/dc0 = -2*(2/3-c0-c1/2)=0')

printf('dI/dc1 =-2*(2/5-c0/2-c1/3) =0')

// hence

printf('[1 1/2;1/2 1/3]*[c0 ;c1]=[-4/3; -4/5]')

//  hence solving for c0 and c1;


// the first degree square approximation P(x)=4*(1+3*x)/15;

// for n=2;

// hence I(c0,c1,c2)= integral (x^1/2-(c2*x^2+c1*x+c0))^2 in the interval [0,1]


printf('dI/dc0 = (2/3-c0-c1/2-c2/2)=0')

printf('dI/dc1 =(2/5-c0/2-c1/3-c2/4) =0')

printf('dI/dc2 =(2/7-c0/3-c1/4-c2/5) =0')


// hence

printf('[1 1/2 1/2;1/2 1/3 1/4;1/3 1/4 1/5]*[c0 ;c1;c2]=[-2/3; -2/5;-2/7]')

//  hence solving for c0,c1 and c2;


// the first degree square approximation P(x)=(6+48*x-20*x^2)/35;