Kopfbereich

Direkt zum Inhalt Direkt zur Navigation Direkt zum Kontakt

Inhalt

Maple-Beispiele

Rosette 1

anzahl:=9:
plot([cos(x)-cos(anzahl*x),sin(x)-sin(anzahl*x),x=0..2*Pi],numpoints=400, axes=NONE, scaling=CONSTRAINED);

Rosette 2

anzahl:=5:
plot([cos(x)+cos(anzahl*x),sin(x)+sin(anzahl*x),x=0..2*Pi],numpoints=400, axes=NONE, scaling=CONSTRAINED);

Sonnenblume

with(plots):
anzahl_blueten := 300:
konstante := 7:
radius := 10:
faktor := 1/2-1/2*sqrt(5): # Goldener Schnitt
divergenzwinkel := 360 * faktor * Pi / 180: # in Bogenmass
winkel := 0:
ergebnis := array(1..anzahl_blueten):
d_x := evalf(cos(divergenzwinkel)): # evalf: Auswertung als Fliesskomma-Wert
d_y := evalf(sin(divergenzwinkel)):
tmp_x := evalf(cos(winkel)):
tmp_y := evalf(sin(winkel)):
for bluete from 1 to anzahl_blueten do
ergebnis[bluete] := [radius * tmp_x, radius * tmp_y];
tmp_h := tmp_x * d_x - tmp_y * d_y: # Cosinus-Satz
tmp_y := tmp_y * d_x + tmp_x * d_y:
tmp_x := tmp_h:
radius := konstante * sqrt(bluete):
end do:
plot(ergebnis, x=-radius..radius, style=point,symbol=circle,title="Sonnenblume",scaling=CONSTRAINED,axes=none);

Spirale

with(plots):
anzahl_spiralen := 4:
anzahl_viertelkreise := 6:
goldener_schnitt := evalf(2/(1+sqrt(5))): # evalf: Auswertung als Fliesskomma-Wert
radius_faktor := 1:
anzahl_ecken := 32:
anzahl_ecken_viertelkreis := anzahl_ecken / 4:
spirale := array(1..anzahl_spiralen):
notloesung := array(1..(anzahl_spiralen*anzahl_ecken_viertelkreis*anzahl_viertelkreise)):
ellipse_radius := array(0..1):
hilfsvariable := 2 * Pi / anzahl_ecken:
d_x := evalf(cos(hilfsvariable)): # evalf: Auswertung als Fliesskomma-Wert
d_y := evalf(sin(hilfsvariable)):
for zaehler_i from 1 to anzahl_spiralen do
fibonacci_1 := 0:
fibonacci_2 := 1:
zaehler_index := 1:
spirale[zaehler_i] := array(1..(anzahl_ecken_viertelkreis*anzahl_viertelkreise)):
ungerade := 1: # 1 bedeutet zaehler_j ungerade, 0 bedeutet zaehler_j gerade
x_tmp1 := -1/2:
y_tmp1 := 1/2:
x_tmp2 := 0:
y_tmp2 := 0:
x_mitte_viertelkreis := 0:
y_mitte_viertelkreis := 0:
x_rand_viertelkreis := 1: # cos von 0 Grad
y_rand_viertelkreis := 0: # sin von 0 Grad
for zaehler_j from 1 to anzahl_viertelkreise do
hilfsvariable := x_tmp1 + 1/2:
x_mitte_viertelkreis := x_mitte_viertelkreis + (hilfsvariable - x_tmp2) * fibonacci_1:
x_tmp2 := hilfsvariable:
hilfsvariable := y_tmp1 - 1/2:
y_mitte_viertelkreis := y_mitte_viertelkreis + (hilfsvariable - y_tmp2) * fibonacci_1:
y_tmp2 := hilfsvariable:
# Cosinus-Satz mit d_x = cos(90 Grad) = 0 und d_y = sin(90 Grad) = 1
hilfsvariable := -y_tmp1:
y_tmp1 := x_tmp1:
x_tmp1 := hilfsvariable:
hilfsvariable := fibonacci_1 + fibonacci_2:
fibonacci_1 := fibonacci_2:
fibonacci_2 := hilfsvariable:
# print(cat("--- Spirale ",convert(zaehler_i,string),", Viertelkreis ",convert(zaehler_j,string))):
x_eckpunkt := x_rand_viertelkreis:
y_eckpunkt := y_rand_viertelkreis:
for zaehler_k from 1 to (anzahl_ecken_viertelkreis) do
ellipse_radius[0] := (fibonacci_2 - fibonacci_1) + fibonacci_1 * radius_faktor:
ellipse_radius[1] := fibonacci_2 * radius_faktor:
spirale[zaehler_i][zaehler_index] := [ellipse_radius[1-ungerade] * x_eckpunkt + x_mitte_viertelkreis, ellipse_radius[ungerade] * y_eckpunkt + y_mitte_viertelkreis]:
hilfsvariable := x_eckpunkt * d_x - y_eckpunkt * d_y: # Cosinus-Satz
y_eckpunkt := y_eckpunkt * d_x + x_eckpunkt * d_y:
x_eckpunkt := hilfsvariable:
zaehler_index := zaehler_index + 1:
end do:
# Cosinus-Satz mit d_x = cos(90 Grad) = 0 und d_y = sin(90 Grad) = 1
hilfsvariable := -y_rand_viertelkreis:
y_rand_viertelkreis := x_rand_viertelkreis:
x_rand_viertelkreis := hilfsvariable:
ungerade := 1-ungerade: # zaehler_j ist ungeradzahlig bzw. geradzahlig
end do:
radius_faktor := radius_faktor * goldener_schnitt:
end do:
# Umordnung
zaehler_index := 1:
zaehler_k := 1:
hilfsvariable := 1:
for zaehler_i from 1 to anzahl_spiralen do
for zaehler_j from 1 to (anzahl_viertelkreise*anzahl_ecken_viertelkreis) do
notloesung[zaehler_index] := spirale[zaehler_i][zaehler_k]:
zaehler_k := zaehler_k + hilfsvariable:
zaehler_index := zaehler_index + 1:
end do:
zaehler_k := zaehler_k - hilfsvariable:
hilfsvariable := -hilfsvariable:
end do:
# Ausgabe
for zaehler_i from 1 to anzahl_spiralen do
plot(spirale[zaehler_i],style=point,symbol=circle,title=cat("Spirale ",convert(zaehler_i,string)),scaling=CONSTRAINED);
end do;
plot(notloesung,title="alle Spiralen",scaling=CONSTRAINED,axes=none);

einfache Beispiel-Anweisungen

# ist der Beginn eines Kommentars# wichtig: jede Befehlszeile endet mit einem Semikolon (;)
# Bruch kürzen, / steht fuer "geteilt durch"
35/49;
5/7
# Gleichung g nach x auflösen, * steht fuer mal
g:=(3+x)*2-8*(2*x-5)=16+x;
g := 46 - 14 x = 16 + x
solve(g,x);
2
# Probe: 46-14*2 ergibt 46-28=18, rechte Seite 16+2=18, ist also richtig
# Hilfe zu Befehlen: Fragezeichen davorsetzen, z.B. ? plot
# Die Gerade 3*x+2 zeichnen fuer x-Werte zwischen -5 und 5, fuer y zw. -3 und 3:
plot(3*x+2,x=-5..5,y=-3..3,scaling=constrained,title='Gerade');
# Parabel 1/2*x^2-2*x+1 (einhalb mal x quadrat minus 2 mal x plus 1), ^ ist hoch, ^2 ist quadrat
plot(1/2*x^2-2*x+1,x=-4..6,y=-1..7,scaling=constrained,title='Parabel');
# Was ergibt (a+b) * (a+b)? Der Befehl expand rechnet es aus.
expand((a+b)*(a+b));
2 2
a + 2 a b + b
expand((a+b)*(a-b));
2 2
a - b
# Kann Maple (a^2+2*a*b+b^2) / (a^2-b^2) kürzen, indem (a+b) gekürzt wird?
(a^2+2*a*b+b^2) / (a^2-b^2);
2 2
a + 2 a b + b
---------------
2 2
a - b
simplify(%);
a + b
-----
a - b
# Primfaktoren in der Zahl 48 finden mit ifactor
ifactor(48);
4
(2) (3)
# 2 hoch 4 steht fuer 2*2*2*2
# Quadratische Gleichung lösen: x quadrat + p mal x + q = 0
x^2+p*x+q=0;
2
x + p x + q = 0
solve(%,x);
2 2
- 1/2 p + 1/2 sqrt(p - 4 q), - 1/2 p - 1/2 sqrt(p - 4 q)
# x1 ist minus p halbe + ein halb mal die Wurzel aus (p quadrat - 4*q)
# ich kenne das so: minus p halbe plus minus Wurzel aus ((p halbe) zum quadrat - q)
# Pythagoras im rechtwinkligen Dreieck: a quadrat + b quadrat = c quadrat
# Ich habe ein rechtwinkliges Dreieck mit Seiten von 12cm und 5cm. Wie lange ist die andere?
12^2+5^2;
169
sqrt(169);
13
# Ich habe die oben die Wurzel aus 169 mit sqrt (square root, Quadratwurzel) gezogen.
# Sinuskurve zwischen - 2 Pi und 2 Pi:
plot(sin(x),x=-2*Pi..2*Pi,y=-1..1,scaling=constrained,title='Sinuskurve');
# Ist 61 eine Primzahl? (Kann man sie nur durch sie selbst und durch 1 teilen?)
isprime(61);
true
# true: wahr
# Und 48?
isprime(48);
false
# false: falsch
# Was ist der groesste gemeinsame Teiler von 36 und 24?
# Die Antwort ist praktisch fuer das Kuerzen von Bruechen.
# gcd steht fuer greatest common (gemeinsam) divisor (Teiler)
gcd(36,24);
12
gcd(144,180);
36
# 144 und 180 kürzen:
144/180;
4/5
# 4*36 ist 144 und 5 *36 ist 180. ok.
# Pi auf 20 Stellen ausrechnen:
evalf[20](Pi);
3.1415926535897932375
# 2/7 auf 12 Stellen ausrechnen, die 0 vor dem Komma laesst Maple weg.
evalf[12](2/7);
.285714285714
Letzte Aktualisierung ( Montag, 30. März 2009 )