Is there any systematic way to decompose a two-level unitary matrix into single-qubit and CNOT operations? - quantum-computing

I would like to make a quantum circuit from the following matrix.
matrix to be transformed into qubit operations
How can I decompose this matrix into qubit operations such as Rotation Y, Control-NOT and so on ?
FYI, I read a book named "Quantum Computation and Quantum Information" written by Nielsen & Chuang, in particular Section 4.5.

A universal method to decompose 2-qubit unitaries into primitive gates is sometimes referred to as "Krauss-Cirac decomposition". Here are several sources:
Optimal Quantum Circuits for General Two-Qubit Gates by Vatan and Williams,
Optimal Creation of Entanglement Using a Two–Qubit Gate by Kraus and Cirac.
“Explorations in Quantum Computing” by Williams, chapter 2.
As a side note, such questions are usually better received at Quantum Computing StackExchange.

Related

Generate 3 qubit W state using standard quantum gates

Starting from the state |000>, how can I generate the state (|100> + |010> + |001>)/sqrt(3) using only X,Y,Z,H,S,T,SWAP,TOFFOLI, rotation gates, QFT, and their controlled versions and any number of ancilla bits?
It is very painful to write quantum computing formulas on StackOverflow without formulas support, so I'll give you several links that cover this question quite extensively:
The same question on QuantumComputing StackExchange: https://quantumcomputing.stackexchange.com/questions/15506/three-qubits-w-state
A more general contstruction for N-qubit W state: https://quantumcomputing.stackexchange.com/questions/4350/general-construction-of-w-n-state
Superposition quantum kata has this task as one of its problems, and its workbook offers a very detailed description of the solution, as well as the Q# implementation.

What is the purpose of Hadamarding and then measuring messages during teleportation?

I was taking a look at Microsoft Quantum Development Kit Documentation when I've stumbled on the Teleportation technique tutorial. It says:
1. Entangling here and there by applying a Hadamard gate and CNOT gate.
2. Sending the message using a CNOT gate and a Hadamard gate.
3. Taking a measurement of the first and second qubits, message and here.
4. Applying a NOT gate or a Z gate, depending on the result of the measurement in step 3.
I understand that Hadamarding a qubit and then using CNOT on it and on other qubit entangles them and that's an important part of Teleportation. What I don't understand is how using CNOT on the message qubit and then Hadamarding it would help at all on the Teleportation process.
Why would I want my message qubit to enter in a superposition state? I don't want to get a random value out of my message, instead, I want it to be transmitted to another qubit.
I get that if a qubit A is collapsed to a message that I'd like to send and if a qubit B is initialized to |0>, CNOT(A, B) would transmit the message. However, what is the purpose of doing this operation if B is in a 50-50 superposition state? I mean, B's wave function would change from sqrt(1/2)|0> + sqrt(1/2)|1> to sqrt(1/2)|1> + sqrt(1/2)|0> How would that help in any way?
But the worst part for me is that the method above works just perfectly. There must be something very basic I'm missing. Thanks for reading.
The best way to understand simple quantum algorithms is to follow the math.
Applying a CNOT to the message qubit and Alice's part of the Bell pair entangles all three qubits, so that the information from the message qubit is distributed across the whole system. Applying a Hadamard gate to the former message qubit and then measuring it and the Alice's qubit makes sure that all the information is concentrated in Bob's qubit and the classical measurement results. But you have to do the math to see what are the states of the system between those operations and why do you have to apply the fixups that the algorithm prescribes.
I will not go into the math here (mostly because it's a huge pain to do so without TeX) - the link you gave does all the math in great detail. To augment the formulas, you can look for an interactive demo which shows the process of teleporting a specific state, such as this one.
One way to gain intuition is to not think about those gates as a processing step, but rater a measurement in the Bell basis. (That's how you measure two qubits in the bel basis CNOT + H on qubit 1 + measure)
If you think about it like that then the process is this: you take the qubit to be transmitted and measure it in the Bell basis with qubit A - "you measure the correlation between that qubit and qubit A". Then you take the "measured correlation" and apply "inversely" it to qubit B (which is entangled with A) giving you the original qubit again.

Is dimensionality reduction reversible?

I have implemented a dimentionality reduction algorithm using ENCOG, that takes a dataset (call it A) with multiple features and reduces it to a dataset (B) with only one feature (I need that for time series analisys).
Now my question is, I have a value from B - predicted by the time series analysis, can I convert it back to two dimensions like in the A dataset?
No, dimensionality reduction is not reversible in general. It loses information.
Dimensionality reduction (compression of information) is reversible in auto-encoders. Auto-encoder is regular neural network with bottleneck layer in the middle. You have for instance 20 inputs in the first layer, 10 neurons in the middle layer and again 20 neurons in the last layer. When you train such network you force it to compress information to 10 neurons and then uncompress again minimizing error in the last layer(desired output vector equals input vector). When you use well known Back-propagation algorithm to train such network it performs PCA - Principal Component Analysis. PCA returns uncorrelated features. It's not very powerful.
By using more sophisticated algorithm to train auto-encoder you can make it perform nonlinear ICA - Independent Component Analysis. ICA returns statistically independent features. This training algorithm searches for low complexity neural networks with high generalization capability. As a byproduct of regularization you get ICA.

How do I implement a set of qubits on my computer?

I would like to get familiar with quantum computing basics.
A good way to get familiar with it would be writing very basic virtual quantum computer machines.
From what I can understand of it, the, effort of implementing a single qubit cannot simply be duplicated to implement a two qubit system. But I don't know how I would implement a single qubit either.
How do I implement a qubit?
How do I implement a set of qubits?
Example Code
If you want to start from something simple but working, you can play around with this basic quantum circuit simulator on jsfiddle (about ~2k lines, but most of that is UI stuff [drawing and clicking] and maths stuff [defining complex numbers and matrices]).
State
The state of a quantum computer is a set of complex weights, called amplitudes. There's one amplitude for each possible classical state. In the case of qubits, the classical states are just the various states a normal bit can be in.
For example, if you have three bits, then you need a complex weight for the 000, 001, 010, 011, 100, 101, 110, and 111 states.
var threeQubitState = new Complex[8];
The amplitudes must satisfy a constraint: if you add up their squared magnitudes, the result is 1. Classical states correspond to one amplitude having magnitude 1 while the others are all 0:
threeQubitState[3] = 1; // the system is 100% in the 011 state
Operations
Operations on quantum states let you redistribute the amplitude by flowing it between the classical states, but the flows you choose must preserve the squared-magnitudes-add-up-to-1 property in all cases. More technically, the operation must correspond to some unitary matrix.
var myOperation = state => new[] {
(state[1] + state[0])/sqrt(2),
(state[1] - state[0])/sqrt(2),
state[2],
state[3],
state[4],
state[5],
state[6],
state[7]
};
var myNewState = myOperation(threeQubitState);
... and those are the basics. The state is a list of complex numbers with unit 2-norm, the operations are unitary matrices, and the probability of measuring a state is just its squared amplitude.
Etc
Other things you probably need to consider:
What kinds of operations do you want to include?
A 1-qubit operation is a 2x2 matrix and a 3-qubit operation is an 8x8 matrix. How do you convert a 1-qubit operation into an 8x8 matrix when applying it to a single qubit in a 3-qubit state? (Use the Kronecker Product.)
What kinds of tricks can you use to speed up the simulation? For example, if only a few states are non-zero, or if the qubits are not entangled, there's no need to do a full matrix multiplication.
How does the user tell the simulation what to do? How can you represent what's going on for the user? There's an awful lot of numbers flowing around...
I don't actually know the answer, but an interesting place to start reading about qubits is this article. It doesn't describe in detail how entangled qubits work, but it hints at the complexity involved:
If this is how complicated things can get with only two qubits, how
complicated will it get for 3 or 4, or 100? It turns out that the
state of an N-qubit quantum computer can only be completely defined
when plotted as a point in a space with (4^N-1) dimensions. That means
we need 4^N good old fashion classical numbers to simulate it.
Note that this is the maximum space complexity, which for example is about 1 billion numbers (2^30=4^15) for 15 qubits. It says nothing about the time complexity of a simulation.
The article that #Qwertie cites is a very good introduction. If you want to implement these on your computer, you can play with the libquantum simulator, which implements sophisticated quantum operations in a C library. You can look at this example to see what using the code is like.
The information is actually stored in the interaction between different Qbits, so no implementing 1 Qbit will not translate to using multiple. I'd think another way you could play around is to use existing languages like QCL or google QCP http://qcplayground.withgoogle.com/#/home to play around

Algorithm for voice comparison

Given two recorded voices in digital format, is there an algorithm to compare the two and return a coefficient of similarity?
I recommend to take a look into the HTK toolkit for speech recognition http://htk.eng.cam.ac.uk/, especially the part on feature extraction.
Features that I would assume to be good indicators:
Mel-Cepstrum coefficients (general timbre)
LPC (for the harmonics)
Given your clarification I think what you are looking for falls under speech recognition algorithms.
Even though you are only looking for the measure of similarity and not trying to turn speech into text, still the concepts are the same and I would not be surprised if a large part of the algorithms would be quite useful.
However, you will have to define this coefficient of similarity more formally and precisely to get anywhere.
EDIT:
I believe speech recognition algorithms would be useful because they do abstraction of the sound and comparison to some known forms. Conceptually this might not be that different from taking two recordings, abstracting them and comparing them.
From wikipedia article on HMM
"In speech recognition, the hidden
Markov model would output a sequence
of n-dimensional real-valued vectors
(with n being a small integer, such as
10), outputting one of these every 10
milliseconds. The vectors would
consist of cepstral coefficients,
which are obtained by taking a Fourier
transform of a short time window of
speech and decorrelating the spectrum
using a cosine transform, then taking
the first (most significant)
coefficients."
So if you run such an algorithm on both recordings you would end up with coefficients that represent the recordings and it might be far easier to measure and establish similarities between the two.
But again now you come to the question of defining the 'similarity coefficient' and introducing dogs and horses did not really help.
(Well it does a bit, but in terms of evaluating algorithms and choosing one over another, you will have to do better).
There are many different algorithms - the general name for this task is Speaker Identification - start with this Wikipedia page and work from there: http://en.wikipedia.org/wiki/Speaker_recognition
I'm not sure this will work for soundfiles, but it gives you an idea how to proceed i hope. That is a basic way how to find a pattern (image) in another image.
You first have to calculate the fft of both the soundfiles and then do a correlation. In formular it would look like (pseudocode):
fftSoundFile1 = fft(soundFile1);
fftConjSoundFile2 = conj(fft(soundFile2));
result_corr = real(ifft(soundFile1.*soundFile2));
Where fft= fast Fourier transform, ifft = inverse, conj = conjugate complex.
The fft is performed on the sample values of the soundfiles.
The peaks in the result_corr vector will then give you the positions of high correlation.
Note that both soundfiles must in this case be of the same size-otherwise you have to place the shorter one into a file of max(soundFileLength) vector.
Regards
Edit: .* means (in matlab style) a component wise mult, you must not do a vector mult!
Next Edit: Note that you have to operate with complex numbers - but there are several Complex classes out there so I think you don't have to bother about this.

Resources