# How do we ensure that the states input to a quantum algorithm are what we want them to be?

In various quantum algorithms like quantum Fourier transform we see that our input states are forced to be specified states. But we know that the main property of quantum computers is that the state of a specified qubit is not recognizable unless we measure it and this process is completely random. My question is: Can we force a qubit in a quantum computer to get our specific states? If yes, how...

the state of a specified qubit is not recognizable unless we measure it and this process is completely random.

This is not quite true. In most physical implementations of quantum computers, the initial state is $$|0\rangle^{\otimes n}$$, which can be achieved through some specific physical procedures. Let's assume that we are able to get this initial state all the time (in reality, some times we might start with a different state due to noise or error in the computer, but those cases can be corrected).

Now, let's suppose you have a $$2$$-qubit quantum computer. Thus, your initial state is $$|00\rangle$$. There is nothing random about this, when you measure (assuming an ideal setup, i.e., no noise or error in measurement) you will always get $$|00\rangle$$. Now, let's suppose you apply Hadamard gates to both qubits. This gives you the state:

$$\frac{1}{2}\left(|00\rangle+|01\rangle+|10\rangle+|11\rangle\right)$$

Although you don't know with certainty which basis state you are going to get when measuring, you know with certainty that the state of the sytem is the one above. Furthermore, measurement is not completely random, you will get each basis states roughly the same amount of times for a large amount of measurements.

So, to get a register to a state $$|\psi\rangle$$, you have to define a unitary $$U$$ such that $$U|0\rangle^{\otimes n}=|\psi\rangle$$. (You can generalize this to $$U|\phi\rangle = |\psi\rangle$$, but here we are taking the initial state to be all $$|0\rangle$$'s.)

Let's briefly look at the QFT since this is the example that you gave. Suppose you want to get the number $$4$$ in the Fourier basis. First of all, notice that you'll need $$3$$ qubits since the binary representation of $$4$$ is $$100$$. To do this, take your initial state $$|000\rangle$$ and apply an $$X$$ gate to the first qubit. This will give you $$|100\rangle$$, which you will input to the QFT circuit and get your desired output.

• Thank you I got the answer. just one more in Fourier transform we have input in the time domain, for example, we have some samples of a sin function in the input and in the output, we want to have the frequency domain answer, in this case, how can we give our specific input states to QFT....? for example 0.7.....? Sep 22, 2021 at 16:24
• The quantum Fourier transform is a unitary transformation of a Hilbert space, which maps say $n$-qubits to $n$-qubits en.wikipedia.org/wiki/Quantum_Fourier_transform. It is not the same transformation that maps between time and frequency domains like in the definition here en.wikipedia.org/wiki/Fourier_transform. Sep 22, 2021 at 16:46