program polinomlagrniutona; uses crt; const n=11; x : array [0..n] of real=(0.180,0.185,0.190,0.195,0.200,0.205,0.210,0.215,0.220,0.225,0.230,0.235); y : array [0..n] of real=(5.61543,5.46693,5.32634,5.19304, 5.06649,4.94619,4.83170,4.72261,4.61855,4.51919,4.42422,4.33337); y1 : array [0..n] of real=(5.61543,5.46693,5.32634,5.19304, 5.06649,4.94619,4.83170,4.72261,4.61855,4.51919,4.42422,4.33337); y2 : array [0..n] of real=(5.61543,5.46693,5.32634,5.19304, 5.06649,4.94619,4.83170,4.72261,4.61855,4.51919,4.42422,4.33337); var x1 : array [0..n] of real; d,d1,u : array [1..n] of real; i,j,k : integer; p,l,z,a,b,h,t,nn : real; f : boolean; c : char; begin clrscr; f:=true; for i:=1 to n do begin for j:=i to n do begin d[j]:=y1[j]-y1[j-1]; end; for j:=i to n do y1[j]:=d[j]; end; for i:=1 to n do begin for j:=i to n do begin d1[j]:=y2[j]-y2[j-1]; end; for j:=i to n do y2[j]:=d1[j]; u[i]:=d1[n]; end; repeat clrscr; writeln('1. Вычисление в отдельных точках (Л)'); writeln('2. Уплотнение массива (Л)'); writeln('3. Метод Ньютона "вперед"'); writeln('4. Метод Ньютона "назад"'); writeln('5. Выход'); c:=readkey; case ord(c) of 49 : begin clrscr; writeln('Введите заданный аргумент'); readln(z); l:=0; for i:=0 to n do begin p:=1; for j:=0 to n do begin if i<>j then p:=p*(z-x[j])/(x[i]-x[j]); end; l:=l+y[i]*p; end; writeln('x=',z:8:4,' f(x)=',l:10:7); repeat until keypressed; end; 50 : begin clrscr; writeln('Уплотнение:'); for k:=0 to n-1 do begin z:=(x[k]+x[k+1])/2; write('x=',z:8:4); l:=0; for i:=0 to n do begin p:=1; for j:=0 to n do if i<>j then p:=p*(z-x[j])/(x[i]-x[j]); l:=l+y[i]*p; end; writeln(' f(x)=',l:10:7); end; repeat until keypressed; end; 51 : begin a:=x[0]; b:=x[n]; h:=(b-a)/n; x1[0]:=a; for k:=1 to n do x1[k]:=x1[0]+k*h; writeln('Введите z'); readln(z); t:=(z-x1[0])/h; nn:=y[0]; p:=1; for i:=1 to n do begin p:=(p/i)*(t-i+1); nn:=nn+d[i]*p; end; writeln('N(',z:6:5,')=',nn:6:5); repeat until keypressed; end; 52 : begin a:=x[0]; b:=x[n]; h:=(b-a)/n; x1[n]:=b; { for k:=1 to n do x1[k]:=x1[0]+k*h;} writeln('Введите z'); readln(z); t:=(z-x1[n])/h; nn:=y[n]; p:=1; for i:=1 to n do begin p:=(p/i)*(t+i-1); nn:=nn+u[i]*p; end; writeln('N(',z:6:5,')=',nn:6:5); repeat until keypressed; end; 53 : f:=false; 27 : f:=false; end; until f=false; end.