Quantum Physics and Stuff

Let's get random together

Page 2 of 2

Entangλe conference

Hi! Today I will write about boring “computer science” stuff!
Just joking, it is not boring at all and I will try to keep it as simple as possible -I can just hear my best friends laughing at this statement, because every time I say something like “it is easy to see” or “as simple as possible” then it happens that a huge wicked formula appears, but it is not my fault 🙂 I can’t help it.
Ok, are you ready? Let’s start.

Last month I attended a workshop on Reversibility and product-forms in Markov Chains at the Ca’ Foscari University in Venice and I presented the Entangλe framework.
You can find the slides here.

What is Entangλe?
In the about me I wrote that I am currently working on model checking of quantum protocols so… this is one of my first output as a part of my Ph.D project.
To be completely honest I worked on it with my friend and, I hope, perspective talented colleague Leonardo and with my supervisors.

Anyways, Entangλe is a framework that links together Quipper , a programming language that wants to simplify the art of programming quantum protocols and QPMC , a model checker for quantum protocols. I will not focus here on the details of model checking or quantum programming, I prefer to post a very basic tutorial about them in the future.
Why have we decided to bridge these tools? But of course, because of the lack of a unique framework allowing, on the one hand the programming and the simulation of quantum programs and on the other their formal verification.
Entangλe needs some optimisation but it is fully working, even if a bit essential by now. You may find it on Github . It takes as input Quipper code and gives in output a QPMC model.

Let’s see an easy example. One of the first algorithms we have tested is the famous Grover’s Database Search.

Schematic circuit for Grover's Database Search 1

Schematic circuit for Grover’s Database Search 1

The aim of Grover’s algorithm is that of searching for the index x of an element in a N-dimensional unstructured space. We assume N = 2n, so that the indexes are represented by n-bit strings.

The algorithm solves the problem by considering a function f : {0, 1}n → {0, 1} such that f(x) = 1 if and only if x is a solution. This problem can be solved by a quantum computer more efficiently than by a classical one (even if the speedup is not astonishing in this case).

Anyway in a short tutorial I will show a better description of quantum algorithms. Let’s now focus on Entangλe.

For the experiment we decided to use a search space of size N = 4 with the oracle returning the string x = 3, i.e. in this case the oracle is a cc-not gate and the circuit looks like this:

Grover 's algorithm for N=4 search space <a href="http://www.amazon.co.uk/Quantum-Computation-Information-Anniversary-Edition/dp/1107002176"> 2

Grover ‘s algorithm for N=4 search space 2

How do we make it work with Entangλe? Ok, be sure to download it from Github . First of all you must install Quipper ! You can find all the essentials here in the Downloading-Installing sections.
Second, enter the entangle folder you have downloaded and open the Main.hs file, located in the src folder.

In the examples section of the Main.hs file you can type an example program, in this case will be our implementation of the Grover’s algorithm but you can also try something else!

grover_naive :: (Qubit, Qubit, Qubit) -> Circ (Bit, Bit)
grover_naive (q1,q2,q3) = do
    hadamard_at q1
    hadamard_at q2
    hadamard_at q3
    qnot_at q3 `controlled` [q1, q2]
    hadamard_at q1
    hadamard_at q2
    gate_X_at q1
    gate_X_at q2
    hadamard_at q2
    qnot_at q2 `controlled` q1
    hadamard_at q2
    gate_X_at q1
    gate_X_at q2
    hadamard_at q1
    hadamard_at q2
    hadamard_at q3
    measure (q1,q2)

Now, always in the Main.hs you have to modify the main putting after the full_out the name of the algorithm you want to translate into QPMC code:

 main = do
  full_out grover_naive

Now is time to compile it. Open the Terminal and be sure to be in the src folder and type

Lindas-MacBook-Air:src linda$ quipper ./Main.hs 

.
Once compiled you can run it by typing

Lindas-MacBook-Air:src linda$ ./Main 

and you will have as a result the converted code.

Easy!

Now you can copy the generated code

qmc
const matrix A1 = [...];
.
. // I have shortened here because we are dealing with 8x8 matrices :)
.
const matrix A14 = [...];
module test
  s: [0..14] init 0;
  [] (s = 0) -> <> : (s' = 1);
  [] (s = 1) -> <> : (s' = 2);
  [] (s = 2) -> <> : (s' = 3);
  [] (s = 3) -> <> : (s' = 4);
  [] (s = 4) -> <> : (s' = 5);
  [] (s = 5) -> <> : (s' = 6);
  [] (s = 6) -> <> : (s' = 7);
  [] (s = 7) -> <> : (s' = 8);
  [] (s = 8) -> <> : (s' = 9) + <> : (s' = 10);
  [] (s = 9) -> <> : (s' = 11) + <> : (s' = 12);
  [] (s = 10) -> <> : (s' = 13) + <> : (s' = 14);
  [] (s = 11) -> (s' = 11);
  [] (s = 12) -> (s' = 12);
  [] (s = 13) -> (s' = 13);
  [] (s = 14) -> (s' = 14);
endmodule

and use it to test some interesting formulas using the QPMC model checker here! When you save the module be sure to use the prism-qmc model type or it will not work.

That’s it, for now. There are many open challenges and the code must be optimised so stay tuned and if you are interested remember, collaborations are always welcome 🙂

Spin and angular momentum common misunderstandings

This is a pretty divulgative post -no difficult math I promise- but I think that people lacking a short introduction to Quantum Mechanics tend to look at the concept of intrinsic spin with imprecision. Probably I will not be too formal now so if you are experts in this field forgive me, this is just supposed to be sort of an introductory post.
The tendency is to conceptually link intrinsic spin to orbital angular momentum, that implies a rotation of the particle. On the other hand someone claims that spin is just a number. Who is right?

In classical mechanics (herein CM) angular momentum refers to the rotation motion of an object around a fixed point i.e. particles constrained to move in a circular path with a fixed radius around a point, or a fixed axis i.e. bodies rotating about fixed axis that passes through a point at the center of them. This model represents the orbital angular momentum

L = \textbf{q} \times \textbf{p}

where q and p are the position and momentum vectors.

In quantum mechanics (herein QM), as we use discrete quantities we need to quantise the angular momentum. This can be done using the correspondence rules for writing q and p in operatorial form. This way we obtain the angular momentum operator \hat{L} whose components may be obtained using the following commutation relation:

 [ \hat{L}_i, \hat{L}_j ] = i \hbar \varepsilon_{ijk} \hat{L}_k

*This result is related to the CM where we use the Poisson brackets to get the components of the angular momentum:

 \{ L_i, L_j \}_{PB} = \varepsilon_{ijk} L_k

In QM there are different operators whose algebra satisfies the commutation relation above so it is common to substitute the angular momentum operator with a more general operator \hat{J} called the total angular momentum operator.

As I said different operators have the same algebra of angular momentum operators but not all of them are actually the same thing. If we measure the total angular momentum of a particle we can get different results, i.e. the eigenvalues \hbar m_i where  m_i = \dots -1, - \frac{1}{2},0, \frac{1}{2}, 1, \frac{3}{2}, \dots , and these results can assume only integer or half-integer values.

In the integer values case these operators represent the orbital angular momentum, i.e. \hat{L}_i. As an example suppose that a particle in the state \psi(\varphi) performs a rotation around the z-axis. This rotation is represented by the unitary operator e^{- \frac{i}{\hbar} \hat{J}_z \theta} .
Recall that the operator is diagonalised i.e.

e^{- \frac{i}{\hbar} \hat{J}_z \theta}\psi(\varphi) =  e^{- \frac{i}{\hbar} \hbar m \theta}\psi(\varphi)

If the number m is an integer, for a complete rotation through \theta the state \psi(\varphi) will not change, i.e. the wave function is single valued under rotation, meaning that after a complete rotation the particle returns in the same state:

 \psi(\varphi) = \psi(\varphi + 2 \pi)

It is obvious that we are talking of orbital angular momentum; just think in our “classical” world, after a complete rotation we always return at the starting point, try it yourself. Easy right?

Ok, now let’s consider the half integer values case. This cases are a bit more tricky to be associated to some physical phenomena. Using the same setting as the previous example (same wavefunction and rotation operator) suppose that the number m is half-integer, let’s say m = \frac{1}{2}. If we perform a complete rotation through \theta = 2 \pi the state \psi(\varphi) will change. Let’s perform a simple calculation just to be sure:

 \begin{aligned} e^{- \frac{i}{\hbar} \hat{J}_z \theta} \psi(\varphi) &= e^{- \frac{i}{\hbar} \hbar \frac{1}{2} 2\pi }\psi(\varphi) \\ &= - \psi(\varphi + 2\pi) \end{aligned}

Wait, what? The wave function is double valued under rotation so after a complete rotation the state is not the same as at the beginning. It does not come back to the same state! It is just like saying that before the rotation we are looking mr. electron in the eyes and then, after a complete rotation, he shows us his back!

This pretty surprising fact means that half-integer values cannot be related to orbital angular momentum, and thinking of a possible classical counterpart becomes slightly difficult. We are not talking about rotations!

If half-integer values do not correspond to rotations what do they mean? What are they related to?

One answer came from an experiment made by Stern and Gerlach in which they discovered, by sendig a beam of particles through a magnetic field, that some particles not only have charge but they are also “sensitive” to magnetic fields. Indeed, after passing between two magnets the beam splitted into two (or more, depending on the particles analysed) beams.
This curious result had been explained by assuming that some particles have an intrinsic angular momentum (corresponding to an intrinsic magnetic moment) called spin, whose components can take only discrete values.
The observable associated to this phenomenon is not the orbital angular momentum  \hat{L} but the spin, or intrinsic angular momentum  \hat{S} that has its same algebra.

 [ \hat{S}_i, \hat{S}_j ] = i \hbar \varepsilon_{ijk} \hat{S}_k

Misunderstandings may arise from the fact that we are talking about magnetic moments and intrinsic magnetic moments. The first are generated by rotations whilst the second are not.

So why people insist that angular momentum is the classical counterpart of quantum spin? An answer to this question is that we need analogies with something familiar to understand pretty complicated concepts.

Same algebra and similar concepts of magnetic moments may cause people to actually confuse these two observables but we have to be careful and not always try to find a classical analogy for the phenomena we observe in quantum physics. Sometimes a simple mathematical description is enough and other ways bring us far from understanding the behaviour of quantum things 🙂

We have also to realise that understanding spin is all about understanding the meaning of intrinsic.

So, spin and angular momentum are actually very different. Angular momentum is a spatial property while spin is an intrinsic property associated to a particle and it cannot be addressed in terms of position and momentum, it is something that the particle has independently of its spatial description.
Let’s consider a person, Bob, running in a park; we can measure Bob’s spatial properties like position and momentum but we can also associate a number to his intrinsec properties i.e. Bob likes to run with a red hanky in his pocket. Then to this Bob’s intrinsic behaviour we associate a number. Spin is a quantum number associated to an intrinsic property of the system, to a behaviour that only some particles have, that has no classical counterpart but, luckily, can be measured 🙂

Hopefully, after reading this post, you should better understand the difference between spin and rotations and why we cannot say that the electron rotates. I tried to show how some misunderstanding may arise and a little background.

This is far from a whole lecture on spin which I will put in the Introduction to Quantum Mechanics part, and for which we cannot escape mathematics unfortunately, but I promise I will put only the minimum required in order to understand.

Newer posts »