# How can I initialize a state with chosen amplitudes in Qiskit?

I was trying to initialize to an arbitrary state of n qubits with the initialize() from Qiskit but it doesn't generate a state with the same amplitudes passed as an argument, instead, it creates a state that when compared to the wanted state will have fidelity equals $$1$$. (described here)

My question is: Is there any method that can generate a state that will have numerically same wanted amplitudes ?

Edit: Just found the PrepareArbitraryState in Q# that does the same thing, they are based in the same paper but some results seen different between then. If someone could explain me the technical differences between then it will be perfect.

Edit(2): Here is the test cited in the Qiskit tutorial:

$$\left|\psi\right\rangle = \frac{i}{4}\left|000\right\rangle + \frac{1}{\sqrt{8}}\left|001\right\rangle + \frac{1+i}{4}\left|010\right\rangle + \frac{1+2i}{\sqrt{8}}\left|101\right\rangle + \frac{1}{4}\left|110\right\rangle$$

Applied to Q# (this result is the same as input and is what I want):

|0β©     5.970914908063292E-17 + 0.25000000000000017π


Applied to Qiskit (same as the cited tutorial, have fidelity(input, output) = 1, but it doesn't match with the Q# result and it is not what I want):

|0β©     2.50000000e-01 + 0.j

• If the state you want and the state you produce have fidelity 1, that means that they do have the same amplitudes, up to a common phase factor $e^{i\gamma}$. Since this is a global phase, it has no observable consequences. Commented Jun 8, 2020 at 6:45