Eugeniusz Jakubas
programy źródłowe w Pascalu

Stąd można pobrać teksty źródłowe poniższych 57 programów w Pascalu pr-pascal.zip - 34 kB

16. Monotoniczność funkcji

Program Ekstrema_funkcji_Metoda_naturalna;
{$N+}
uses graph;
var karta,tryb,n,j,kolor:integer;
    x,y,Dx,y1,y2:extended;
function f(x:extended):extended;
begin
  f:=x*x/(2*x*x-x-2)
end;
begin
  karta:=detect; initGraph(karta,tryb,'');
  j:=20;
  setColor(darkGray);
  for n:=-320 div j to 320 div j do line(n*j+320,0,n*j+320,479);
  for n:=-240 div j to 240 div j do line(0,n*j+240,639,n*j+240);
  setColor(white); line(0,240,639,240); line(320,0,320,479);
  x:=-320/j; Dx:=0.00025;
  repeat
    x:=x+Dx;
    y:=f(x); y1:=f(x+Dx); y2:=f(x+2*Dx);
    if y1>y then kolor:=yellow else kolor:=lightRed;
    if abs(y)<240/j then putPixel(round((x+Dx)*j+320),round(-y1*j+240),kolor);
    if (y1<y) and (y1<y2) and (abs(y1)<240/j) then writeln('x=',x+Dx:18:14);
    if (y1>y) and (y1>y2) and (abs(y1)<240/j) then writeln('x=',x+Dx:18:14);
    if y*y1<0 then writeLn('x=',x+2*Dx:18:14);
  until x>320/j;
  readLn; closeGraph;
end.