

Quantum Computing Playground - ch0wn
https://qcplayground.withgoogle.com

======
StavrosK
I have no idea what's going on with this programming language. At all.

~~~
ivan_ah
Me neither, but after playing with the 2D+Phase view it is starting to make
sense to me now [see below for improvised mini tutorial].

I've studied quantum computing previously, but never thought about plotting
the state space and visualizing it... very cool. Like all things programming,
we all knew that sooner or later it was going to be done in the browser.

A. Hilbert space

    
    
        // The quantum state of an eight-qubit register:
        VectorSize 8
        // this defines a 256-dimenstional quantum states space:
        //   a_0|0> + a_1|1> + a_2|2> + ... + a_255|255>
        // where a_i are complex coefficients
        // you can "see" these coefficients and thus "see"
        // quantum states in the 2D+Phase view. 
        // The color/intensity of the bottom left corner 
        // represents a_0 the bottom right corner is a_15
        // and so on until top right corner a_255.
    
    
        // Note this 256 dimensional vector space is the "logical"
        // space we work in, while the "physical" space consists
        // of eight individual qubits addressed by zero-based index.
    
        // The arguments Quantum gates act on individual qubits 
        // 0 = least significant qubit
        // 1 =
        // ..
        // 7 = most significant qubit
    
    
        // The qubit register is initialized to the all-zeros
        // qubits state: |00000000>, which means each of the 
        // means a_0=1, and a_i=0 for all other i.
    
    
    

B. Quantum gates

    
    
        // SigmaX(n) := 1 ⊗ ... ⊗ 1  ⊗ (|1><0| + |0><1|) ⊗ 1 ⊗ ... ⊗ 1
        //              \__8-n-1__/                         \____n____/
        //
        // the NOT gate "toggles" the n^th qubit in the register
        // while leaving all other qubits unchanged (1 = identity trans).
        //
        // Note that applying the operation on the physical qubits
        // allows us to address the large quantum state space.
        // For example, applying \sigma_X gates on the three 
        // least significant qubits is written as:
        SigmaX 2
        SigmaX 1
        SigmaX 0
        // this combination of operations transforms the sate
        // |00000000> to the the state |00000111>, which is
        // in the "logical" quantum space corresponds to having
        // prepared state with a_7=1 and all other a_i=0.
        //
        // There are other gates like the SigmaY, SigmaZ, and Hadamard [1]
    
    

Okay so who cares?

    
    
        // well, it's kind of neat that you can access and compute 
        // in such a large state space (see [2] for the def'n of ⊗)
        // sure it's difficult to interact with quantum systems
        // (state preparation and measurement), but damn the space
        // is big so it's worth checking out what kind of computing
        // you can do in there that you can't do with ordinary bits.
        //
        // An eight-bit classical register can represent any integer
        // between 0 and 255, a eight-qubit quantum register can
        // represent any state in the vector space \mathbb{C}^{256}.
    
    

There are already several useful things you can do in the quantum world:

    
    
        // Then there are multi-qubit quantum gates.
        // The qubits on which they act are specified as a range
        //
        // QFT 0, 8      // totally written by pythonistas...
    
    
    

[1]
[https://en.wikipedia.org/wiki/Quantum_gate](https://en.wikipedia.org/wiki/Quantum_gate)
[2]
[https://en.wikipedia.org/wiki/Kronecker_product](https://en.wikipedia.org/wiki/Kronecker_product)

~~~
StavrosK
Ah, thank you for the explanation! It sounds like I (unsurprisingly) need to
read a bit more about the theory before I can program in it.

------
IIAOPSW
The interface needs work. Sadly we don't exist in the 2^n dimensions needed to
really understand the state space so all representations will be clunky.

It looks like the rows represent qubits and the colors represent phase. Maybe.
I haven't quite figured it out either.

------
michaelsbradley
I recently read a paper, published last year, which suggests that the qubit
concept is problematic and that a different processing model is needed for
quantum computing:

 _On The Fundamental Flaws of Qubit Concept for General Purpose Quantum
Computing_

[http://www.ijesi.org/papers/Vol%283%2910/F031059070.pdf](http://www.ijesi.org/papers/Vol%283%2910/F031059070.pdf)

See also:

 _Quantum computing circuits_

[http://www.google.com/patents/US20130057314](http://www.google.com/patents/US20130057314)

