Does anyone know how you can obtain a new state |z> from two pre-existing states |x> and |y> using the Tensor product in Q#? i.e. |z> = |x> ⊗|y> ?

Thanks in advance for the help!

Edit: for clarity, the states that I am working with are

$|x\rangle = \frac{1}{\sqrt{2}} \sum^{3}_{j=0} \sin \frac{\pi (j + 0.5)}{4} |j\rangle$

$|y\rangle = \sum^{1}_{i=0} b_i |i\rangle$

where the $b_i$'s are just real numbers.

  • $\begingroup$ Could you clarify what you mean by obtaining a "new state"? What do you want to do with these qubits? In Q# you are working with Qubit objects, not states. So if you have two Qubit objects and they are not entangled, then essentially they are already in a tensor product state. $\endgroup$ – Ryan Shaffer May 20 at 14:28
  • $\begingroup$ Hi Ryan, thanks for your reply! So I used two Qubit objects : Qubit[2] and Qubit[1] and used the PrepareArbitraryState operation in order to map those qubits to the states |x> and |y> (I edited the question so you can see how my states look like). Now I want to encode in a new variable of type Qubit[] the result of the tensor product between |x> and |y>. $\endgroup$ – Martin May 20 at 15:06
  • $\begingroup$ Hi Martin, I've posted an answer below, hopefully that helps to clarify. You could also make a new Qubit[3] array and put all three qubits in there. Just putting them in an array is enough, you don't need to do anything special. $\endgroup$ – Ryan Shaffer May 20 at 16:00

If you have an array of Qubit objects, and you prepare the individual qubits into arbitrary states, then the array effectively contains the tensor product of all of the original qubits.

To quickly illustrate what I mean:

using (qubits = Qubit[2]) {
    // do something to prepare qubits[0] individually
    // do something to prepare qubits[1] individually

    // now the state of "qubits" is the tensor product of the two
    // individual qubit states that you prepared

This also generalizes if you're preparing groups of qubits within the array that you allocated.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.