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:


and eigenvalues are


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_] := 
        {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.

  • $\begingroup$ Your function takes x,y as arguments, but does not show how one gets G from x,y. $\endgroup$ Mar 9, 2018 at 23:22

1 Answer 1


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.

  • $\begingroup$ Thank you, that's a nice solution! $\endgroup$
    – ViniLL
    Mar 13, 2018 at 4:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.