r/ExplainLikeAPro • u/notAlex • Sep 02 '13
ELAP: How do I program using a quantum computing language?
For instance, what would the nature of assembly language instructions be like in a quantum computing environment?
24
Upvotes
View all comments
12
u/The_Serious_Account Sep 02 '13 edited Sep 03 '13
Quantum algorithms are expressed in linear algebra. An n-qubit input is defined by a 2n dimensional vector of length 1. Your possible quantum operations are any unitary matrix (that is 2n by 2n to fit the vector) and your output is also a 2n dimensional vector of length 1 (this results from the matrix being unitary). The final requirement is that your output must be a basis vector. If it isn't, the vector will probabilistically collapse to one of the basis vectors. The closer it is to a basis vector, the more likely it is it will collapse to it. The 2n basis vectors corresponds to
2nclassical bits2n possible values. That is, n classical bits. Hence your output is not qubits, but regular bits.Simply put:
Where x is your input, U is your program - expressed as a unitary matrix. And y is your output.
Now, the question is how to construct the unitary matrix, U. There's a handful of matrices that are known as universal gates in the sense that you can construct any unitary matrices from them by putting them together in the right order. This is similar to a NAND-gate being universal.
tl;dr: Learn linear algebra.
Edit: sorry, fixed a mistake and added a bit