3

I want to construct the following state of a qubit using a quantum circuit: $\frac{-|0\rangle + |1\rangle}{\sqrt{2}}$

When I use the following qiskit code in Python:

```
q = QuantumRegister(1)
c = ClassicalRegister(1)
circuit = QuantumCircuit(q, c)
circuit.x(q[0])
circuit.z(q[0])
circuit.h(q[0])
backend = BasicAer.get_backend('statevector_simulator')
job = execute(circuit, backend)
amplitudes = job.result().get_statevector(circuit)
print(amplitudes)
```

I get `[ 0.70710678+0.00000000e+00j -0.70710678+8.65956056e-17j]`

. When I remove the Pauli-Z gate I get: `[ 0.70710678+0.00000000e+00j -0.70710678+8.65956056e-17j]`

, i.e. the same result.

However, using Quirk I get the expected output. With the IBM Quantum Experience, I'm not sure. I get `[ -0.707+0j, 0.707+0j ]`

and it says 'The qubit 0 is the one that is furthest to the right on the state.' So I guess it's also not the correct result.

I am using `qiskit==0.15.0`

and `qiskit-aqua==0.6.4`

, which I updated after having this problem in an older version, too.

I also tested the following circuit:

```
# setup the circuit as before
circuit.x(q[0])
circuit.z(q[0])
# get and print amplitudes
```

Which results in `[ 0.+0.0000000e+00j -1.+1.2246468e-16j]`

, as I had expected.

Thus I am guessing, that I miss something. Can anyone explain this behavior?

Qubit 0 does not mean the one in the |0> state, it means the 1st qubit (we count them from 0) so the result

`[-0.7, 0.7]`

is the same as the state you described. The order the coefficient are in is simply numerical order, so the 1st number is the 1st coefficient, 2nd is the 2nd and so on if you have more qubits. – met927 – 2020-02-11T10:23:05.710