#OK to post homework #Joseph Koutsoutis, 02-16-2025, Assignment 6 read `C6.txt`: #1 AllHM2 := proc(K) local a,b,c,d,matrices: matrices := {}: for a from 1 to K do: for b from 1 to K do: for c from 1 to K do: for d from 1 to K do: matrices := matrices union {[[a, b+I*c], [b-I*c, d]]}: od: od: od: od: matrices: end: #2 RealSV2 := proc(K) local a,b,k,vectors: vectors := {}: for a from 1 to K do: for b from 1 to K do: k := sqrt(a^2 + b^2): vectors := vectors union {[a / k, b / k]}: od: od: vectors: end: #3 UncertaintyContest := proc(K) local matrices, vectors, A, B, V, smallest, biggest, ratio: matrices := AllHM2(K): vectors := RealSV2(K): smallest := [none, infinity]: biggest := [none, 0]: for A in matrices do: for B in matrices do: if Com(A,B) <> [[0,0], [0,0]] then: for V in vectors do: ratio := CheckUP(A,B,V): if ratio <> FAIL then: if ratio < smallest[2] then smallest := [[A,B,V], ratio]: fi: if ratio > biggest[2] then biggest := [[A,B,V], ratio]: fi: fi: od: fi: od: od: smallest, biggest: end: #UncertaintyContest(2) outputted # [[[[1, 2 + I], [2 - I, 2]], [[2, 2 + I], [2 - I, 1]], [sqrt(2)/2, sqrt(2)/2]], 0.6249999982], # [[[[1, 1 + I], [1 - I, 1]], [[1, 1 + 2*I], [1 - 2*I, 2]], [(2*sqrt(5))/5, sqrt(5)/5]], 6.519202426] #UncertaintyContest(3) outputted # [[[[1, 2 + I], [2 - I, 3]], [[3, 2 + I], [2 - I, 1]], [sqrt(2)/2, sqrt(2)/2]], 0.4999999972], # [[[[1, 2 + 3*I], [2 - 3*I, 3]], [[2, 3 + 2*I], [3 - 2*I, 2]], [(3*sqrt(13))/13, (2*sqrt(13))/13]], 51.69472778] #where we note that simplify(CheckUP([[1, 2 + I], [2 - I, 3]], [[3, 2 + I], [2 - I, 1]], [sqrt(2)/2, sqrt(2)/2])) #outputs 1/2 if the evalf is removed.