-
Notifications
You must be signed in to change notification settings - Fork 1
/
6-Lagrange.pas
54 lines (45 loc) · 983 Bytes
/
6-Lagrange.pas
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
PROGRAM Lagrange;
USES Crt;
VAR
n,i,j: WORD;
Xi: ARRAY[0..20] OF REAL;
Fi: ARRAY[0..20] of REAL;
M, x, a, eps, Lnx: REAL;
BEGIN
ClrScr;
Write('Vvedite stepenb mnogochlena n <= 20: ');
ReadLn(n);
WriteLn('Vvedite uzlovie tochki: ');
FOR i := 0 TO n DO
BEGIN
Write('x(', i, ') = ');
ReadLn(Xi[i]);
END;
WriteLn('Vvedite znacheniya funczii v tochkax: ');
FOR i := 0 TO n DO
BEGIN
Write('F(X', i,') = ');
ReadLn(Fi[i]);
END;
Write('Vvedite x, gde nuzhno naiti znachenie funczii: ');
ReadLn(x);
Write('Vvedite constantu: ');
ReadLn(M);
Lnx := 0;
eps := 1;
FOR i := 0 TO n DO
BEGIN
a := 1;
FOR j := 0 TO n DO
IF i <> j THEN
BEGIN
a := a * (x - Xi[j]) / (Xi[i] - Xi[j]);
eps := eps * (x - Xi[i]) / (i + 1);
END;
Lnx := Lnx + Fi[i] * a;
END;
eps := Abs(eps) * M;
WriteLn('Znachenie funczii v tochke x: ', Lnx);
WriteLn('Pogreshnost: ', eps);
ReadKey;
END.