# Assigning eigenkets to particular eigenspace depending on eigenvalues of system inside a module

I am writing a module, in which the Observable and State is given, so I need to write a function/module QuantumMeasurement, that will return a state of the quantum system resulting from the measurement. There are various inputs, so I need to write this function in a way, that will consider the system with different eigenvalues, let's say it can be {1,1,2,2} or {1,2,3,4}. Therefore the system will be divided in different number of eigenspaces, where each of them will consist of particular number of eigenkets.

So I need some kind of list of those eigenspaces, where each eigenket will be linked to correlated eigenvalue. Suppose eigenkets are:

{
{{I/2,1/2,0,1/Sqrt[2]}},
{{-(1/2),-(I/2),1/Sqrt[2],0}},
{{-(I/2),-(1/2),0,1/Sqrt[2]}},
{{1/2,I/2,1/Sqrt[2],0}}}
}


and eigenvalues are

{1,1,2,2}


Therefore it will be two eigenspaces, each of them consisting of two eigenkets[1,2] for the first eigenspace, and eigenkets[3,4] for the second eigenspace. How to assign those eigenkets to correllated eigenspace in order to use call this list later in the code?

That's what I have so far

Qmeasurement[x_, y_] :=
Module[
{eikets = {}},
{eigenvalues, eigenkets} = Eigensystem[G];
For[j = 1, j <= Length[eigenkets], j++,
ortho = Orthogonalize[{eigenkets[[j]]}
]
]


This is kind of preparation, where I am make the kets orthogonal in order to use them later on. I was thinking to use PositionIndex for my problem, but I am not sure how to properly assign it. Please post any suggestions, any help is appreciated.

• Your function takes x,y as arguments, but does not show how one gets G from x,y. – J. M. will be back soon Mar 9 '18 at 23:22

## 1 Answer

One way to group the eigenkets into orthogonal eigenspaces is like this:

eigenspaces = Table[
Pick[eigenkets, Thread[eigenvalues == λ]],
{λ, Union[eigenvalues]}]


In the above, we are using Union to find the unique eigenvalues, and Pick to find all of the eigenkets whose position in the list is the same as the position of the eigenvalues.

There are several ways to make our eigenspaces orthonormal. Here is one way.

orthospaces = Orthogonalize /@ eigenspaces


Another way is to use Orthogonalize[ Pick[ ... ]] in the Table command.

Before writing the quantum measurement function it would be good to do some sample measurement calculations step-by-step. After you calculate all the possible measurement results, the probabilities of each and the resulting states, you will have a better idea what the function must do. And, you will already have some sample calcs to check the function against.

• Thank you, that's a nice solution! – ViniLL Mar 13 '18 at 4:19