Program Pochodna;
uses Graph;
var karta,tryb,n,siatka,j:integer;
x,y:real;
function f(x:real):real;
begin
f:=sin(x);
end;
function g(x:real):real;
begin
g:=(f(x+0.000001)-f(x))/0.000001;
end;
begin
karta:=detect; initGraph(karta,tryb,'');
j:=36;
setColor(darkGray); rectangle(0,0,639,479);
for n:=-320 div j to 320 div j do
begin
line(320+n*j,0,320+n*j,479);
line(0,240+n*j,639,240+n*j);
end;
setcolor(white);
line(0,240,639,240); line(630,235,639,240);
line(630,245,639,240); outtextxy(630,250,'X');
line(320,0,320,479); line(315,9,320,0);
line(320,0,325,9); outtextxy(330,8,'Y');
x:=-320/j;
repeat
x:=x+1/j/2;
y:=240-f(x)*j;
setColor(lightBlue); setFillStyle(1,lightBlue);
if abs(y)<480 then
fillEllipse(round(x*j+320),round(y),1,1);
y:=240-g(x)*j;
setColor(lightRed); setFillStyle(1,lightRed);
if abs(y)<480 then
fillEllipse(round(x*j+320),round(y),1,1);
until x>320/j;
readln; closeGraph;
end.
|
 |