# How to represent a sine function in the statevector $|\psi\rangle = sin(kx)$

Is there a quantum circuit that encodes the statevector so that the coefficients of the statevector $$|\psi\rangle$$ corresponds to a discrete representation of $$sin(kx)$$ in $$[0,1]$$? In particular, I'd like to have a set of gates that scales and works for all qubit number $$n$$. I'd be happy with $$sin(x)$$ but ideally, I'm looking for higher frequencies multiples as well.

By statevector I am referring to the set of probabilities $$(\psi_1,\psi_2,...,\psi_N)$$ associated with $$|00...0\rangle$$, $$|00...1\rangle$$,...,$$|11...1\rangle$$ that one gets when reading the output. Please note that I am thinking in the framework of variational algorithms. In these cases, given a qubit register $$|\textbf{q}\rangle=|q_1\rangle \otimes ... \otimes |q_n\rangle$$, we encode vectors as $$\begin{equation} |\psi\rangle=\sum_{k=0}^{N-1} \psi_k |\text{binary(k)}\rangle \end{equation}$$

It is this vector in particular whose entries $$\psi_i$$ I want to encode to represent a sine. For example, for 3 qubits this vector will have $$N=8$$ entries. If you divide [0,1] uniformly in $$[x_0, ...,x_{N-1}]$$, I am looking for an unitary such that $$\psi_i=sin(x_i)$$. (Or I guess would be more correct to say $$sin(2\pi x_i)$$)

If possible, I'm looking for both theoretical explanation and practical circuit implementation that I could run and test (not just "theoretically there is an oracle..." etc.). Also, among the possible set of unitaries, clearly the shallower and less connected, the better.

If the question isn't clear please ask for clarification in the comments - I'll be happy to improve it.

• So you're effectively after something that's the imaginary component of a state $U_{QFT}|0\rangle$, from the quantum Fourier transform? May 17 at 14:45
• No, as far as I understood when computing QFT your outputs are the projection along the $sin(kx)$ basis, whereas here I would like to assemble a state vector whose coefficients are a discrete representation of a sine function May 17 at 19:03

It's worth noting that the Fourier transform implements $$|\Psi\rangle=U_{QFT}|0\rangle=\frac{1}{\sqrt{2^n}}\sum_{j=0}^{2^n-1}e^{2\pi i\frac{j}{2^n}}|j\rangle,$$ so for some particular choice of frequency, what you're effectively asking for is, up to normalisation, $$\text{Im}(|\Psi\rangle).$$
Now, there's a neat way to do this. There's a standard proof that demonstrates that only-real-amplitude quantum computation is just as powerful as quantum computation (see definition 1 in this paper) - you add a single ancilla qubit whose 0/1 value represents whether the amplitude is real or imaginary. So, if you implement the quantum Fourier transform using this circuit construction, and you measure that ancilla qubit, if you find it to be in the $$|1\rangle$$ state, you've created exactly the state you want. I believe this happens with probability $$1/2$$, so repeat until success is a very reasonable strategy. Alternatively, you could apply amplitude amplification, but that will make your circuit much more complicated.
• Hi, thanks for your answer. Correct me if I am wrong, but when you apply a QFT, aren't the entry of $\psi$ the coefficient associated with the amplitude of each frequency? I am looking for something a bit different. I'll expand the question with more context May 17 at 15:00
• Yes, this is exactly what my answer covers (incidentally, the $\psi_k$ are probability amplitudes, not probabilities). May 18 at 6:36