![]() |
Eugeniusz Jakubas |
Stąd można pobrać teksty źródłowe poniższych 57 programów w Pascalu pr-pascal.zip - 34 kB
6. Ekstrema funkcji
Program Ekstrema_funkcji_Metoda_naturalna; {$N+} uses graph; var karta,tryb,n:integer; x,y,Dx,y1,y2:extended; function f(x:extended):extended; begin f:=x+3/4-2*sin(x)-0.065 end; begin karta:=detect; initGraph(karta,tryb,''); setColor(darkGray); for n:=1 to 32 do line(n*20,0,n*20,479); for n:=1 to 24 do line(0,n*20,639,n*20); setColor(white); line(0,240,639,240); line(320,0,320,479); x:=-16; Dx:=0.1; repeat x:=x+Dx; y:=f(x); y1:=f(x+Dx); y2:=f(x+2*Dx); if (y1<y) and (y1<y2) then Dx:=Dx/10; if (y1>y) and (y1>y2) then Dx:=Dx/10; if (Dx<1e-17) or ((y=y1)and(Dx<0.1)) then begin if abs(y)<12 then writeln('x=',x:22:18,', f(x)=',y:22:18); Dx:=0.1; end; if abs(y)<12 then putPixel(round(x*20+320),round(-y*20+240),yellow); until x>16; readLn; closeGraph; end. |
![]() |