# How can I invert the least significant bit of a certain term of a superposed state?

Say I have

$$\dfrac{1}{\sqrt{2}}\bigl(|1\rangle|221\rangle|0\rangle + |3\rangle|73\rangle|2\rangle\bigr).$$

How can I change that into

$$\dfrac{1}{\sqrt{2}}\bigl(|1\rangle|221\rangle|1\rangle + |3\rangle|73\rangle|2\rangle\bigr)?$$

• What do you mean by a certain term? If it is what it I think you are saying then you are not following linearity. But I just want to clarify. – AHusain Mar 14 at 22:28

## 2 Answers

Assuming that your last spin is of dimension 3, why not just apply the unitary $$\left(\begin{array}{ccc} 0 & 1 & 0 \\ 1 & 0 & 0 \\ 0 & 0 & 1 \end{array}\right)?$$

• How is this achieving what the op has in his example – bilanush Mar 15 at 13:26
• It is a unitary which changes 0 to 1, and leaves 2 unchanged. That is all the OP needed to solve his example. – DaftWullie Mar 15 at 15:59

The first register the way you write it is about two qubits if not more. In the state, it is either 01 (1) or 11 (3). Then I would just use a X/NOT controlled by the two qubits of the register and only applied when the control is 01. This is done by Toffoli where you use X gate in between the first qubit so the control is applied when it is 0.