# I was solving matrix of beam splitter in python but got stuck in understanding the library

What does this command physically mean?

block_diag([[1]], BSunitaries[2], [[1]])


Can any one tell me in matrix form?

Source

BSunitaries contains the unitaries for each of the beamsplitters so you first extract the information for this specific unitary by using BSunitaries[2].
block_diag creates a block diagonal matrix because you need UBS2 to be a 4x4 unitary so block_diag([[1]], BSunitaries[2], [[1]]) is basically adding a '1' in the top left and a '1' in the bottom right. If you print(block_diag([[1]], [[2,3],[4,5]], [[1]])) you'll get an idea of how this looks.
• But the problem is I don't get the exact entries when calculating UBS2 by hand. my input state is |1101> while the BS2 is getting an output from BS1 and BS3. UBS1 is formed somehow by BS1 tensored [(1,0),(0,0)] + BS2 tensored [(0,0),(0,1)] but this method failed when I calculate it for UBS2. for UBS2 the 4x4 square matrix will look as follows, p = |00><00| + |01><01| + |01><10| + |10><01| + |10><10| + |11><11| in general we have a11, a22, a23, a32, a33, a44 as non-zero entries. Now one thing I want to know is how to get these entries by matrix formulism? Commented Oct 17, 2022 at 8:20