,,,
" " , , , , , , . "" , . , . , . . Pascal. 25 , , .
(). . - ( ), , .
, , - , . . . , . ; .
, , , .
:
1. .
2. .
, .. :
1. .
2. .
:
.
1. .
. . () - , . , , , ( ) , . .
,
.
, :
.
() , .
2.
:
i | ||
0 | ||
1 | ||
2 | ||
.. | .. | .. |
n |
, (1)
.
N=n+1.
, , , . .
:
n ,
, .
.
,
. , , , .
, ,.
, , . .
.
:
,
,
, - - :
. (3)
, , - .
. n-
,
.. - , .
, (1) - . (1) , .
■ | |||||
- :
. (1)
. (1):
, , , .
, . yi, i=0,1,n. N n (n=N-1) . N n (2). .
(1) . k- . Y.
(3) :
(4)
(2) - , .. - . k- . , , .
(4), (2).
(5)
(1) .
- .
.
.
:
Function POlinom(n: integer; d:real; x,y :per):real;
var
l:real;
k,i:integer;
p: real;
begin
L:=y[0];
P:=1;
for k:=1 to n do begin
P:=P*(D-X[k-1]);
for i:=0 to (n-k) do begin
Y[i]:=(y[i+1]-y[i])/(x[i+k]-x[i]);
end;
L:=L+P*y[0];
end;
Polinom:=l;
end;
n
x[i],y[i]
D , l
1.
. , . , ; .
- , , . , ; (, ); . , .
, . . . , , . : , .
. , : , , . , . , .
. , ; 5 6 1012 . , . .
: .
. . , . , .
. . , , . , ; .
- , .
2.
. 1971 , . . , .
, , . , .
:
1.
2. ,
3.
4.
5.
6.
7.
8.
:
Program -
Uses
Begin
End
:= -
Crt - (Cathod ray tube - - ) . , , , .
Graph , , , ,
Var
Writeln, Write
Readln, Read
If <> then <>
For <>:=<..> to <..> do <>
Repeat <> until <> -
Clrscr
Initgraph
Closegraph
Line (x1, y1, x2, y2)
Putpixel (x, y, c) (x, y)
Readkey
Outtextxy (x, y, st) st, (x,y)
Getmaxx max x
Goto
+ -
- -
* -
/ -
n , ;
i, j ;
- ;
D , ;
L
k, step ;
u ;
.
Niton.exe. . Enter.
(1/0)?, 1 Enter. Enter. p n (N=n+1), (N-1) Enter. , Enter.
. x . x . x.
. . Enter.
? 1, 0 Enter.
program interpol;
uses crt,graph;
const
MAXCOUNT=30;
type
per = array [0..MAXCOUNT] of real;
var
X,y :per;
n,i :integer;
l,D,f :real;
label Lp, Lt;
{ }
Procedure Titul;
begin
Clrscr;
GoToXY(23,2);
Writeln( ');
GoToXY(22,3);
Writeln(' ');
GoToXY(28,4);
Writeln(' ');
GoToXY(14,8);
Writeln(' .');
GoToXY(27,9);
Writeln(' .');
GoToXY(34,12);
Writeln(' #7');
GoToXY(24,17);
Writeln(' . 220371 A.M.');
GoToXY(20,19);
Writeln(' , K.T.H. B.B.');
GoToXY(33,23);
Writeln(', 2008 g.');
readkey;
clrscr;
end;
{ }
Procedure help;
begin
clrscr;
writeln ( f(x) ' +
+ . (xi, yi) .');
writeln (' N=n+1. ');
writeln (' n ( (x[0],y[0]) ) +
+' . (x[0]..x[n]).');
writeln ( .');
readkey;
clrscr;
end;
{ }
procedure Enter(var X,y: per);
var
i: integer;
label mp;
begin
mp: for i:=0 to n do
begin
write('X[',i,'] = '); readln(x[i]);
write('y[',i,'] = '); readln(y[i]);
end;
for i:=0 to n-1 do
if x[i+1]-x[i]<=0 then
begin
writeln ('. .');
goto mp
end;
end;
{ }
procedure Print(n: integer; X,y: per); var
i: integer;
begin
for i:=0 to n do
begin
write(x[i]:12:6);
end;
writeln;
for i:=0 to n do
begin
write(y[i]:12:6);
end;
writeln;
end;
{ }
Function Polinom(n: integer; d:real; X,y :per):real;
var
l:real;
k,i:integer;
p: real;
begin
L:=y[0];
P:=1;
for k:=1 to n do begin
P:=P*(D-X[k-1]);
for i:=0 to (n-k) do begin
Y[i]:=(y[i+1]-y[i])/(x[i+k]-x[i]);
end;
L:=L+P*y[0];
end;
POlinom:=l;
end;
{ }
procedure Grafik(n: integer; D :real ; X,Y: per; L:real);
const
step=10;
var
driver,mode: integer;
i:longint;
st:string;
u,k:integer;
begin
writeln(' ');
readln(u);
k:=26;
driver:=detect;
initgraph (driver,mode,'');
setcolor (1);
line (320,0,320,480);
line (0,240,640,240);
for i:=0 to 32 do begin
setlineStyle (1,0,0);
line (0,i*k+6,640,i*k+6);
line (i*k+8,0,i*k+8,480);
end;
setcolor (3);
outtextxy (310,15,'y');
outtextxy (620,240,'x');
for i:=0 to getmaxx div (2*k) do
begin
str (i*u,st);
outtextxy(getmaxx div 2+i*(k),getmaxy div 2+step,st);
str (-i*u,st);
outtextxy (getmaxx div 2-i*k,getmaxy div 2+step,st);
end;
for i:=1 to getmaxy div (2*k) do
begin
str (-i*u,st);
outtextxy (getmaxx div 2+step,getmaxy div 2+i*k,st);
str (i*u,st);
outtextxy (getmaxx div 2+step,getmaxy div 2-i*k,st);
end;
d:=-u*12;
repeat
d:=d+0.002;
putpixel (round(320+d*k/u),round(240+(-POlinom(n,d,x,y))*k/u),10);
until d>u*12;
readkey;
end;
{ }
begin
TextMode(3);
TextBackground(1);
TextColor(14);
Titul;
writeln (' ?? (-1,-0)');
read (f);
if f=1 then help else
lp:clrscr;
writeln(' n (N=n+1)');
read(n);
Enter(X,y);
Print(n,X,y);
repeat
lt:Writeln('BbBedite X (ot ',x[0]:4:2,' do ',x[n]:4:2,')');
read(d);
if d<x[0] then begin
writeln('. x ',x[0]:4:2);
goto lt; end;
if d>x[n] then begin
writeln('. x ',x[n]:4:2);
goto lt; end;
writeln(Polinom (n,d,X,y):6:3);
writeln(' X?(-1,-0)');
read(f)
until f=0;
Grafik(n,D,X,Y,l);
readkey;
CloseGraph;
clrscr;
writeln(' ? (-1,-0)');
read(f);
if f=1 then goto lp else end.
0 | 1 | 2 | 3 | 4 | |
0 | 0.5 | 0.866 | 1 | 0.866 |
, . , . , m m-1 , m . .
, . , . , , .
Turbo Pascal 7.0 . . , .
1. / .. .: , 1982.
2. /.. ., 1987.
3. / .. .: . ., 1998.
4. /.. ., 1992.
5. / .. .: , 1987.
6. 7.0/.. ., 1998.
7. /.. .: - , 1962.
8. / .. .: 1996
9. .A. Turbo Pascal - .: , 2002.- 496 ,
" " , , ,
Copyright (c) 2024 Stud-Baza.ru , , , .