-
Notifications
You must be signed in to change notification settings - Fork 1
/
8-Newton.pas
57 lines (49 loc) · 1.08 KB
/
8-Newton.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
55
56
PROGRAM Newton;
USES Crt;
VAR
n,i,j: WORD;
Xi: ARRAY[0..20] OF REAL;
Fi: ARRAY[0..20] of REAL;
x, a, Lnx, M, eps: 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 := Fi[0];
WriteLn;
WriteLn('Ln(x0) = ', Lnx);
a := 1;
eps := 1;
FOR i := 1 TO n DO
BEGIN
a := a * (x - Xi[i-1]);
FOR j := n DOWNTO i DO
BEGIN
Fi[j] := (Fi[j] - Fi[j-1]) / (Xi[j] - Xi[j-i]);
END;
Lnx := Lnx + Fi[i] * a;
WriteLn('Ln(x', i, ') = ', Lnx);
eps := eps * a / (i + 1);
END;
eps := Abs(eps) * M * Abs(x - Xi[n]);
WriteLn;
WriteLn('Znachenie funczii v tochke x: ', Lnx:10:10);
WriteLn('Pogreshnost: ', eps);
ReadKey;
END.