#Homework 4 Due 2/4/24: #Ok to Post #1: Examples from p91-end: #Matrix Operations: with(linalg): A:=matrix(3,3,[1,4,2,5,6,3,5,5,2]); gaussjord(A); det(A); B:=inverse(A); nullspace(A); #Eigenvalues and Jordan Form: jordan(A, `Q`); print(Q); eigenvals(A); eigenvals(A^2); #Loops: for i from 1 to 10 do print(i^2-i+1); od: #--------------------------------------------- #2: 0-1 Matrix w/ #(rows), #(columns) both prime and "draw" initials such that the 1's show it and 0s are background; convert to one-dimensional vector #NOTE THAT p>8, q>11!!!! NameMat:=proc(p,q) local A, B, rowzero, colzero,r, c, C, F, d,K,H,v; A:=Matrix(8,11,[1, 0, 0, 0, 1, 0, 1, 0 ,0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); A: r:=p-8; B:=Matrix(r, 11, 0); c:=q-11; d:=p; C:=Matrix(p, c, 0); C; K:=<,>; H:=<>; print(H); v:= Vector(convert(H, list)); v: end: #--------------------------------------------- #3: Use RC with q=2, d=3,5,7 and 5<=n<=16 and K very big #HD(u,v): The Hamming distance between two words (of the same length) HD:=proc(u,v) local i,co: co:=0: for i from 1 to nops(u) do if u[i]<>v[i] then co:=co+1: fi: od: co: end: #RV(q,n): A random word of length n in {0,1,..,q-1} RV:=proc(q,n) local ra,i: ra:=rand(0..q-1): [seq( ra(), i=1..n)]: end: #RC(q,n,d,K): inputs q,n,d, and K and keeps picking K+1 (thanks to Nuray) random vectors #whenver the new vector is not distance <=d-1 from all the previous one RC:=proc(q,n,d,K) local C,v,i,c: C:={RV(q,n)}: for i from 1 to K do v:=RV(q,n): if min(seq(HD(v,c), c in C))>=d then C:=C union {v}: fi: od: C: end: for n from 5 to 16 do: print(nops(RC(2,n,3,1000))); od: print('c'); #The Maple output agrees with the Table in general across multiple #experiments. Typically, the Maple output value is lower than the #value given in the table, because the codes obtained by our procedure #are not necessarily optimal. In particular, for larger n, our codes #are much smaller. for n from 5 to 16 do: print(nops(RC(2,n,5,1000))); od: print('c'); #In most experiments, the low n results are close to or equal to the #results in the table. The results for large n are still much lower #than those in the table. There are more choices of words to add for n #large, and making multiple suboptimal choices could have a more #pronounced effect on the ultimate size of the code for n from 7 to 16 do: print(nops(RC(2,n,7,1000))); od: print('c'); # #--------------------------------------------- #4:How big are the binary Hamming codes? (What is their M?) Use the #Sphere Packing Bound. #We have the following parameters for the binary Hamming codes. #n=2^r-1, q=2, d=3, t=1. Plugging these into the Sphere Packing Bound, #we obtain after minor simplification that M is at most 2^{2^{r}-1}#[1+1/(2^r-1)].