summaryrefslogtreecommitdiff
path: root/50/CH4/EX4.22/ex_4_22.sce
blob: 972fd50589b294b66c69191216f786567da62b6a (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
// example: 4.22;
// piecewise quadratic interpolating polinomials:

X=[-3 -2 -1 1 3 6 7];
F=[369 222 171 165 207 990 1779];
//  we need to apply legranges interpolation in sub-ranges [-3 ,-1];[-1,3],[3,7];

 x=poly(0,"x");
 
  // 1) in the range [-3,-1]
  x=[-3 -2 -1];
  f=[369 222 171];
  n=2;
P2=lagrangefundamentalpoly(x,f,n);

 // 2) in the range [-1,3]
 x=[-1 1 3];
 f=[171 165 207];
n=2;
P2=lagrangefundamentalpoly(x,f,n) 

 // 3) in the range [3,7] 
  x=[3 6 7];
 f=[207 990 1779];
n=2;
P2=lagrangefundamentalpoly(x,f,n) 



// hence, we obtain the values of f(-2.5)=48;  f(6.5)=1351.5;