print(`PolygonProject.txt: A Maple Supplement for the procedure of Normalizing Iterated Polygons,`): print(`illustrating the results covered in that paper.`): print(`Last Edit: May 17, 2018`): print(`Use Help(); or Help(); for more information.`): Help:=proc() local EG, In, Out: EG:=()->print(`For example, try`): In:=()->print(`INPUT:`): Out:=()->print(`OUTPUT:`): if nargs=0 then print(`PolygonProject.txt contains the following procedures.`): print(`RandomGoodPoly, IterPolygon, ParEllipse, NormalFormEllipse, EllipseData, AnimateConvergence, Compare, PolygonSupport`): print(`Along with supporting procedures:`): print(`WeightedMatrix, WeightedMatrixVec, WeightedAvePolygon, NormRescale, EValRescale, Recenter `): print(`For help on a specific procedure, use Help().`): elif args[1]=RandomGoodPoly then print(`RandomGoodPoly(n)`): print(`Generates a random polygon on n vertices with centroid (0,0)`): In(): print(`n: a positive integer number of vertices`): Out(): print(`P: a list of n+1 pairs of numbers [x,y] representing the n points of the polygon,`): print(`where the n+1 entry is the same as the first.`): EG(): print(`RandomGoodPoly(15);`): elif args[1]=IterPolygon then print(`IterPolygon(P, N, {alpha:=1/2}, {output:="plot"}, {scaling:="eval"}) `): print(`Performs N averaging iterations on the polygon P.`): In(): print(`P: a polygon`): print(`N: number of iterations`): print(`alpha: optional keyword argument for the averaging parameter, 1/2 by default. This can be a number between 0 and 1, or a vector of non-negative real numbers with sum at most 1.`): print(`output: optional keyword argument, "plot" (default) or "list"`): print(`scaling: optional keyword argument, "eval" (default), "none", or "norm"`): Out(): print(`a plot of the final iteration or list of all iterations.`): EG(): print(`IterPolygon(RandomGoodPoly(10),20); `): elif args[1]=AnimateConvergence then print(`AnimateConvergence(P,N, {alpha:=1/2}, {scaling:="eval"}) `): print(`Displays N iterations of averaging on the polygon P.`): In(): print(`P: a polygon`): print(`N: number of iterations`): print(`alpha: optional keyword argument for the averaging parameter, 1/2 by default. This can be a number between 0 and 1, or a vector of non-negative real numbers with sum at most 1.`): print(`scaling: optional keyword argument, "eval" (default), "none", or "norm"`): Out(): print(`an animated plot showing the iterations, and, if scaling="eval" or "norm", the limiting ellipse.`): EG(): print(`AnimateConvergence(RandomGoodPoly(10),20);`): elif args[1]=ParEllipse then print(`ParEllipse(P,t, {alpha:=1/2}, {scaling:="eval"}) generates a parametric equation for the limiting ellipse`): print(`of polygon P using Theorem 2.2`): In(): print(`P: a polygon`): print(`t: a dummy variable to be used as the parameter of the equation`): print(`alpha: optional keyword argument for the averaging parameter, 1/2 by default. This can be a number between 0 and 1, or a vector of non-negative real numbers with sum at most 1.`): print(`scaling: optional keyword argument, "eval" (default), "none", or "norm"`): Out(): print(`a parametric equation for the limiting ellipse of the polygon P`): print(`with t as the parameter`): EG(): print(`ParEllipse(RandomGoodPoly(10),t);`): elif args[1]=NormalFormEllipse then print(`NormalFormEllipse(P, {alpha:= 1/2}, {scaling:="eval"}) finds the equation for the limiting ellipse of a polygon`): print(`in normal form`): In(): print(`P: a polygon`): print(`alpha: optional keyword argument for the averaging parameter, 1/2 by default. This can be a number between 0 and 1, or a vector of non-negative real numbers with sum at most 1.`): print(`scaling: optional keyword argument, "eval" (default), "none", or "norm"`): Out(): print(`a list [A,B,C] such that the equation of the limiting ellipse is`): print(`Ax^2+Bxy+Cy^2`): EG(): print(`NormalFormEllipse(RandomGoodPoly(10));`): elif args[1]=Compare then print(`Compare(P,N,{alpha:=1/2}, {scaling:="eval"}) computes the limiting ellipse empirically,`): print(`and then exactly and plots both on the same axes.`): In(): print(`P: a polygon`): print(`N: a number of iterations`): print(`alpha: optional keyword argument for the averaging parameter, 1/2 by default. This can be a number between 0 and 1, or a vector of non-negative real numbers with sum at most 1.`): print(`scaling: optional keyword argument, "eval" (default), "none", or "norm"`): Out(): print(`a plot of the polygon P after N iterations of averaging`): print(`along with the true limiting ellipse of P`): EG(): print(`Compare(RandomGoodPoly(10),30);`): elif args[1]=EllipseData then print(`EllipseData([A,B,C]) Determines the orientation and eccentricity of the ellipse`): print(`Ax^2 + Bxy + Cy^2 = 1.`): In(): print(`a list [A,B,C] of coefficients of the ellipse`): Out(): print(`the list [orientation, eccentricity, major axis, minor axis]`): EG(): print(`EllipseData([.25,.25,1]);`): elif args[1]=PolygonSupport then HelpS(): elif args[1]=WeigntedMatrix then print(`WeightedMatrix(n, alpha)`): print(`Generates the iterating matrix for the averaging procedure (implemented as a list of lists)`): print(`defined with a single averaging parameter alpha between 0 and 1`): In(): print(`n: a positive integer`): print(`alpha: an averaging parameter between 0 and 1`): Out(): print(`A: an n by n matrix corresponding to the iterating procedure`): EG(): print(`WeightedMatrix(10, 1/3);`): elif args[1]=WeightedMatrixVec then print(`WeightedMatrix(n, eta)`): print(`Generates the iterating matrix for the averaging procedure (implemented as a list of lists)`): print(`defined with a vector averaging parameter eta.`): In(): print(`n: a positive integer`): print(`eta: an vector averaging parameter of positive real numbers with sum at most 1`): Out(): print(`A: an n by n matrix corresponding to the iterating procedure`): EG(): print(`WeightedMatrix(10, [.4, .2, .1]);`): elif args[1]=WeightedAvePolygon then print(`WeightedAvePolygon(P, alpha)`): print(`Computes the polygon generated by averaging the polygon P under the procedure defined by alpha`): In(): print(`P: a polygon, as defined in the other methods`): print(`alpha: an averaging parameter, which can either be a single real number between 0 and 1 or a vector parameter`): Out(): print(`The polygon, as a list of n+1 points, corresponding to the average of P`): EG(): print(`WeightedAvePolygon(RandomGoodPoly(10), 1/3);`): elif args[1]=NormRescale then print(`NormRescale(P)`): print(`Normalizes the polygon P so that the x and y coordinates both have 2-norm equal to 1`): In(): print(`P: a polygon`): Out(): print(`A new polygon corresponding to P where the x and y coordinate vectors have 2-norm 1`): elif args[1]=EValRescale then print(`EValRescale(P,alpha)`): print(`Normalizes the polygon P by multiplying by the inverse of the magnitude of the second largest`): print(`eigenvalue of the iterating matrix corresponding to averaging parameter alpha`): In(): print(`P: a polygon`): print(`alpha: an averaging parameter, which can either be a single real number between 0 and 1 or a vector parameter`): Out(): print(`A new polygon corresponding to P where each component has been rescaled by the appropriate parameter`): elif args[1]=Recenter then print(`Recenter(P)`): print(`Computes the average of the x and y coordinates of the polygon, and modifies them so that the centroid is still (0,0)`): In(): print(`P: a polygon`): Out(): print(`The polygon P, shifted to have centroic (0,0)`): else print(`No such procedure exists.`): fi: end: HelpS := proc() local EG, In, Out: EG:=()->print(`For example, try`): In:=()->print(`INPUT:`): Out:=()->print(`OUTPUT:`): if nargs=0 then print(`PolygonSupport.txt contains the following procedures.`): print(`For help on a specific procedure, use HelpS().`): print(`Champs, EVC, Nor, CB, Coeffs `): elif args[1]=Champs then print(`Champs(L) `): print(`Takes a list L where each elements is a list whose first entry is a (complex) number`): print(`and finds the indices corresponding to the largest first entry in magnitude`): In(): print(`L: A list as described above`): Out(): print(`a set of indices corresponding to the entries with the largest first entry`): elif args[1]=EVC then print(`EVC(M) `): print(`Computes the list of [eigenvalue, eigenvector] in weakly decreasing order of the absolute value of the eigenvalue.`): In(): print(`M: a square matrix with full set of eigenvectors`): Out(): print(`A list of the eigenvalues and eigenvectors of M in weakly decreasing order`): EG(): print(`EVC(WeightedMatrix(7, 1/2));`): elif args[1]=Nor then print(`Nor(v)`): print(`Normalizes the vector v to have 2-norm equal to 1`): In(): print(`v: a vector of (complex) numbers`): Out(): print(`the vector v rescaled to have norm 1`): elif args[1]=CB then print(`CB(M,V)`): print(`Expresses the vector V as a linear combination of the eigenvectors of M`): In(): print(`M: a square matrix with a full set of eigenvectors`): print(`V: a vector with the same length as the size of M`): Out(): print(`the list of coefficients of the eigenvectors of M that add up to V, ordered by the method EVC`): elif args[1]=Coeffs then print(`Coeffs(V,M)`): print(`Finds the coefficients (if possible) of vectors in M that are needed to add up to V as a linear combination`): In(): print(`V: an n-component vector`): print(`M: a list of n-component vectors, not necessarily linearly independent or a spanning set (but it usually will be)`): Out(): print(`the list of coefficients needed to add the vectors in M (in the order given) and sum to V`): else print(`No such procedure exists.`): fi: end: