| Listing 3 : Grafische Analyse mit Geraden (GAGERADE.PAS) |
program GrafischeIteration_Gerade;
uses
crt,
graph;
const
xl=0; xr=10; yu=0; yo=10;
var
xmax, ymax : word;
mx, my : real;
i, xb, yb,
xbo, ybo : integer;
anz : longint;
ca, xa, x0,
x, y, c : real;
auswahl,
wahl, ok : char;
procedure eingabe;
begin
repeat
clrscr;
writeln('Welche Funktion der Art ');
writeln;
writeln('f(x) = m*x+c soll untersucht werden ? ');
writeln;
writeln;
write('Bitte Koeffizient m eingeben : ');readln(ca);
write('Bitte Koeffizient c eingeben : ');readln(c);
writeln;
write('Anfangswert der Iteration: ');readln(x0);
write('Anzahl der Iterationen: ');readln(anz);
mx:=639/(xr-xl);
my:=479/(yo-yu);
ymax:=479;
xmax:=639;
writeln;
write('Ist die Eingabe OK (j/n) ? : ');
ok:=readkey;
until ok='j';
end;
function fvon(x,m,c:real):real;
begin
fvon:=m*x+c;
end;
procedure grafik_ein;
var
gt,gm:integer;
begin
gt:=detect;
initgraph(gt,gm,'c:\bp\bgi');
end;
procedure Koordinatensystem_zeichnen;
begin
xbo:=round(-xl*mx);
ybo:=round(yo*my);
line(0,ybo,xmax,ybo);
line(xbo,0,xbo,ymax);
end;
procedure Schaubild_zeichnen;
begin
for xb:=0 to xmax do
begin
x:=xl+xb/mx; {x-links plus xb im Ma~stab}
y:=fvon(x,ca,c);
yb:=round((yo-y)*my);
{Ursprung minus (da Achse andersherum) y-Wert im Maßstab}
putpixel(xb,yb,4);
x:=xl + xb/mx;
y:=x; {1. winkelhalbierende }
yb:=round((yo-y)*my);
putpixel(xb,yb,3);
end;
xa:=x0;moveto(round(x0*mx)+xbo,ybo);
for i:=1 to anz do
begin
xa:=ca*xa+c;
yb:=ybo;
lineto(round(x0*mx)+xbo,ybo-round(xa*my));
lineto(xbo+round(xa*mx),ybo-round(xa*my));
x0:=xa;
end;
end;
begin
eingabe;
grafik_ein;
Koordinatensystem_zeichnen;
schaubild_zeichnen;
readln;
end.
|
| Listing 4 : Grafische Analyse mit der logistischen Parabel (GA_PARAB.PAS) |
program GrafischeIteration;
uses crt,graph;
const xl=0; xr=1; yu=0; yo=1;
var
[...]
procedure eingabe;
begin
repeat
clrscr;
writeln('Welche Funktion der Art ');
writeln;
writeln('f(x) = a*x(1-x) soll untersucht werden ? ');
writeln;
writeln;
write('Bitte Koeffizient a eingeben : ');
readln(ca);
writeln;
......
until ok='j';
end;
function fvon(x,c:real):real;
begin
fvon:=c*x*(1-x);
end;
procedure grafik_ein;
[...]
procedure Koordinatensystem_zeichnen;
[...]
procedure Schaubild_zeichnen;
begin
for xb:=0 to xmax do
begin
x:=xl+xb/mx; { x-links plus xb im Maßstab }
y:=fvon(x,ca);
....
end;
end;
begin
eingabe;
grafik_ein;
Koordinatensystem_zeichnen;
schaubild_zeichnen;
readln;
end.
|
| Listing 6 : Das Feigenbaumdiagramm (FEIGE.PAS) |
program Feige;
uses graph;
const
einschwingzeit = 200;
iterationszahl = 80;
startwert = 0.01;
var
xMin, xmax, yMin, yMax : real;
{ Grenzen }
xMf ,yMf : real;
{ Schrittweite }
function f(a,x:real):real;
{ berechnet den nächsten Wert }
begin
f:=a*x*(1-x);
end;
procedure Eingabe;
begin
write('Linke Parametergrenze (z.B. 3) : ');
readln(xMin);
write('Rechte Parametergrenze (z.B. 4) : ');
readln(xMax);
write('Untere Grenze der Werte (z.B. 0) : ');
readln(yMin);
write('Obere Grenze der Werte (z.B. 1) : ');
readln(yMax);
end;
procedure Grafik_ein;
var
gt, gm : integer;
{ Grafiktreiber und -modus }
begin
gt:=detect;
initgraph(gt,gm,'c:\bp\bgi');
xmf:=GetMaxX/(xMax-xMin);
ymf:=GetMaxY/(ymax-ymin);
end;
procedure Schaubild;
var
xs, ys : integer;
{ Bildschirmkoordinaten des aktuellen Punkts }
i : integer;
{ Z"hlervariable }
x, y : real;
{ Aktuell berechneter Punkt }
a : real;
{ Aktueller Wert f?r a }
ausgabe : string;
{ Zur Ausgabe }
begin
for xs:=0 to GetMaxX do
begin { f?r alle X-Werte }
a:=xmin+xs/xmf; { a berechnen }
x:=startwert;
for i:=1 to einschwingzeit do
x:=f(a,x); { nur berechnen, nicht anzeigen }
for i:=1 to iterationszahl do
begin { berechnen und anzeigen }
x:=f(a,x);
ys:=round((ymax-x)*ymf);
putpixel(xs,ys,lightgreen);
if (xs mod 100=0) then
begin
str(a:0:3,ausgabe);
outtextxy(xs,GetMaxY-20,ausgabe);
end;
end;
end;
end;
begin
Eingabe;
Grafik_ein;
Schaubild;
readln;
closegraph
end.
|
| Listing 7 : Ergänzung zu Listing 4 (Kap. 3) (2_ITER.PAS) |
procedure Schaubild_zeichnen;
begin
for xb:=0 to xmax do
begin
x:=xl+xb/mx; {x-links plus xb im Maßstab}
y1:= fvon(x,ca);
y2:= fvon(fvon(x,ca),ca); {<--f(f(x)) }
yb1:=round((yo-y1)*my);
yb2:=Round((yo-y2)*my);
putpixel(xb,yb1,4);
putpixel(xb,yb2,5);
y:=x;
yb1:=round((yo-y)*my);
putpixel(xb,yb1,3); {1. Winkelhalbierende}
if (xb Mod 100=0) Then begin
str(x:0:3,aa);outtextxy(xb,460,aa)
end;
end;
|
| Listing 8 : Ergänzung zu Listing 4 (Kap. 3) (6_ITER.PAS) |
procedure Schaubild_zeichnen;
begin
for xb:=0 to xmax do
begin
x:=xl+xb/mx; {x-links plus xb im Maßstab}
y1:= fvon(x,ca);
y2:= fvon(fvon(x,ca),ca); { f(f(x)) }
y3:= fvon(fvon(fvon(X,Ca),Ca),ca); { f(f(f(x))) }
y6:=fvon(fvon(fvon(fvon(fvon(fvon(x,ca),ca),ca),ca),ca),ca);
{f6(x)=f(f(f(f(f(f(x))))))}
yb1:=round((yo-y1)*my);
yb2:=Round((yo-y2)*my);
yb3:=Round((yo-y3)*my);
yb6:=round((yo-y6)*my);
putpixel(xb,yb1,3);
putpixel(xb,yb2,4);
putpixel(xb,yb3,5);
putpixel(xb,yb6,7);
y:=x;
yb1:=round((yo-y)*my);
putpixel(xb,yb1,3);
end;
end;
|
© 1997 by
J.Bentele
HTML File created by AK
viper@gus.bb.bw.schule.de