# OK to post homework # James Betti, 9 Feb 2025, Assignment 4 UM := proc(α,β,γ,δ) local Ry,Rz,A; Ry := t->[[cos(t/2),-sin(t/2)],[sin(t/2),cos(t/2)]]; Rz := t->[[exp(-I*t/2),0],[0,exp(I*t/2)]]; A := evalm(exp(I*α)*multiply(Rz(β),Ry(γ),Rz(δ))); [[A[1,1],A[1,2]],[A[2,1],A[2,2]]]; # multi-index -> list of lists end: # Form a random 2 by 2 unitary matrix using Box 1.1 of Nielsen–Chuang. RUM := proc(K) local ra: ra := rand(-K..K); UM(ra(),ra(),ra(),ra()); end: # Modified IsUM to call `simplify` and `evalc`. IsUMSimp:=proc(A) local n,i,j,P; n := nops(A); P := multiply(A,CT(A)); P := simplify(evalc([seq([seq(P[i,j],j=1..n)],i=1..n)])); evalb(P=[seq([0$(i-1),1,0$(n-i)],i=1..n)]); end: IsUMSimp(RUM(20)); # should be true IsUMSimp(UM(a,b,c,d)); # should be true