ACM 11 Problem Set 7

Problem 1

Part a

(* the simplest definition uses Map *)
colnorm[A_] := Total[Norm /@ Transpose[A]];

(* an alternative *)
colnorm[A_] := Total@Table[Norm[Transpose[A][[i]]], {i, 1, Length@Transpose@A}];

colnorm[HilbertMatrix[7]] //N

Part b

(* simplest *)
onetwonorm[A_]:= Max[Norm /@ Transpose[A]];

(* an alternative *)
onetwonorm[A_] := Max@Table[Norm[Transpose[A][[i]]], {i,1,Length@Transpose@A}];

onetwonorm[ToeplitzMatrix[{1,-3,4,6,2}]] //N

Part c

(* First, define the Fourier matrix *)
FourierMat = Table[(1/(Sqrt[6]))(E^(I π j k/3)),{j,1,6}, {k,1,6}];

(* simplest definition, using Map and an anonymous function *)
∞twonorm[A_] := Max[Norm[A .#] & /@ Tuples[{-1,1}, Length@Transpose@A]];

∞twonorm[FourierMat] //N

(* an alternative *)
∞twonorm[A_] := Module[{vects},
vects = Tuples[{-1,1}, Length@Transpose@A];
results = Table[Norm[A . vects[[i]]], {i,1,Length@vects}];
Max@results
];

 ∞twonorm[FourierMat]  //N
(* both of the above definitions work, but give a warning *)

(* here are two definitions of ∞twonorm that avoid the above warning (which occurs because Mathematica is attempting to use N to determine which of the two equal quantities Norm[A.x] and Norm[A.-x] is larger, even though they're actually equal) 
*) 
∞twonorm[A_] := Max[ 
Norm[A.#]& /@
Union[
Tuples[{-1,1}, Length@Transpose@A], SameTest->(#1 == #2 ∨#1==-#2&)
]
];

∞twonorm[FourierMat]//N

∞twonorm[A_] := Module[{vects},
vects = Tuples[{-1,1}, Length@Transpose@A];
vects = Union[vects, SameTest->(#1==#2∨#1==-#2&)];
results = Table[Norm[A.vects[[i]]], {i,1,Length@vects}];
Max@results
];

∞twonorm[FourierMat] //N

Problem 2

Part a

(* FullSimplify isn't helpful directly *)
(∑_(j=-n+1)^(n-1))(n-Abs[j])(E^(I j θ))//FullSimplify

(* apparently FullSimplify does work directly on the new expression-- I didn't notice this when writing up the homework *)
n+2(∑_(j=1)^(n-1))(n-j)Cos[j θ] //FullSimplify

(* using the sequence I recommended does work, but since FullSimplify works directly, it's overkill *)
n+2(∑_(j=1)^(n-1))(n-j)Cos[j θ] //TrigToExp // FullSimplify

Part b

F[θ_,n_] := ((Cos[n θ]-1)/(Cos[θ]-1));

Part c

Look at CoefficientList in the help, then the following code should make sense

polyint[p_,θ_] := Module[{n = Length@CoefficientList[p[x],x]-1},(1/(2π))Integrate[F[θ-φ,n](E^(I n (θ-φ)))p[(E^(I φ))],{φ,0,2π}]
];

Part d

p1[x_] := a (x^3)+b (x^2)+ c x + d;

Part e

polyint[p1,θ]

If we think of (e^(i θ))as x, it is clear that we computed  the product x ((dp)/(dx))

Part f

First we can try the naive approach

polyint[p1,θ] /. (E^(n_ I θ))->(x^n)

but this doesn't work, and even if it did, remember that because Mathematica does purely structural pattern matching, (e^(i θ)) wouldn't match. But why doesn't it work? Look at the FullForms

polyint[p1,θ] // FullForm
(E^(n_ I θ))//FullForm

Evidently the problem is that Mathematica represents i n_ θ as the product of i, the pattern n_, and θ, while it represents i n θ (where n is now a fixed number) as the product of θ and the complex number i n. Since the structure of the pattern is different from that of the expressions, we won't get any matches.

We try a different tack:

polyint[p1,θ] /. (E^(k_ θ))->(x^(Im[k]))