> # aufgabe 16 > restart; > with(linalg): Warning, new definition for norm Warning, new definition for trace > # trigonometrische Polynome > # Umwandlung in ein komplexes Polynom > reellkomplex:=proc(a,b) > # Vektor a enthaelt die Kosinuskoeffizienten von p in aufsteigender Reihenfolge > # Vektor b enthaelt die Sinuskoeffizienten von p > # Vektor c enthaelt (c0,c1,...,c_n,c_(-n),... c_(-1)). > local n,c,k; > #option trace; > n:=vectdim(b); > c:=vector(2*n+1); > c[1]:= a[1]/2; > for k from 1 to n do > c[k+1]:= (a[k+1]-I*b[k])/2; > c[2*n+2-k]:=(a[k+1]+I*b[k])/2 > od; > evalm(c) > end: > a:=vector(4,[0,2,3,5]); > b:=vector(3,[2,8,6]); a := [0, 2, 3, 5] b := [2, 8, 6] > c:=reellkomplex(a,b); c := [0, 1 - I, 3/2 - 4 I, 5/2 - 3 I, 5/2 + 3 I, 3/2 + 4 I, 1 + I] > #Umwandlung eines trigonometrischen Polynoms in komplexer Schreibweise in reelle Schreibweise > komplexreell:=proc(c) > # Vektor c enthaelt (c0,c1,...,c_n,c_(-n),... c_(-1)) > # Vektor a enthaelt die Kosinuskoeffizienten von p (a0,a1,...,a_n) > # Vektor b enthaelt die Sinuskoeffizienten von p (b1,...,b_n) > local n,n1,k ; > global a,b; > n:=vectdim(c): > if type(n,even) then > RETURN(`Die Dimension des Vektors c muss ungerade sein!`) > else > n1:=round((n-1)/2); > a:=vector(n1+1); b:=vector(n1); > if Im(c[1])=0 then a[1]:= 2*c[1] else RETURN(`Das Polynom ist nicht reell!`) fi; > for k from 1 to n1 do > if Im(c[k+1]+c[n+1-k])=0 then a[k+1]:=Re(c[k+1]+c[n+1-k]) else > RETURN(`Das Polynom ist nicht reell!`) fi; > if Im(I*(c[k+1]-c[n+1-k]))=0 then b[k]:=Re(I*(c[k+1]-c[n+1-k])) else > RETURN(`Das Polynom ist nicht reell!`) fi > od; > RETURN(`Das Polynom ist reell mit Koeffizentenvektoren a,b`) > fi; > end: > komplexreell(c); > print(a,b); Das Polynom ist reell mit Koeffizentenvektoren a,b [0, 2, 3, 5], [2, 8, 6] > c1:=vector(7,[1,1-I,2+I,2-I,3+I,3-I,5]); c1 := [1, 1 - I, 2 + I, 2 - I, 3 + I, 3 - I, 5] > komplexreell(c1); > print(a,b); Das Polynom ist nicht reell! [2, a[2], a[3], a[4]], [b[1], b[2], b[3]] > c2:=vector(6,[1,2,3,4,5,6]); komplexreell(c2); c2 := [1, 2, 3, 4, 5, 6] Die Dimension des Vektors c muss ungerade sein! >