# How do I create an inverse identity gate?

Is it possible for me to construct a gate that inverse everything ($$|0\rangle \rightarrow -|0\rangle, |1\rangle \rightarrow -|1\rangle$$, etc. basically like a $$-I$$ gate) from the basic $$X, Y, Z, CX,...$$ gates, for any number of qubits? How do I do so if it's possible?

Thank you!

As a general rule, you wouldn't bother constructing this: it is just a global phase that has no observable consequence.

If you really insist on doing this, introduce an ancilla qubit in the $$|1\rangle$$ state and apply a $$Z$$ gate to it.

PS "inverse identity gate" is a really bad name for it. The identity operation is its own inverse.

• The answer to this question (quantumcomputing.stackexchange.com/questions/2477/…) also gives a construction that does not need ancilla. It's construction is $\hat P_h(\theta)=\hat U_1(\theta)\hat X\hat U_1(\theta)\hat X$, and in your case, replace $\theta$ with $\frac{\pi}{2}$ Nov 24 '20 at 11:43
• They seem to be using "inverse" in the sense of additive inverse, but there really isn't much meaning to the additive inverse in QM. "Negation gate" would probably be a better phrasing. Nov 24 '20 at 20:18

You might be interested in controlled version of $$-I$$. Despite the fact that you can neglect global phase in case of non-controlled gates, you cannot do so in case of controlled version.

The controled gate $$-I$$ is described by matrix $$\begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & -1 & 0\\ 0 & 0 & 0 & -1\\ \end{pmatrix}$$.

This gate set a phase to $$\pi$$ (note that $$\mathrm{e}^{i\pi} = -1$$) if control qubit is in state $$|1\rangle$$.

To implement the gate simply put $$Z$$ gate on first qubit (i.e. control qubit) and nothing (i.e. identity operator) on second qubit (i.e. target qubit). You can check that the matrix above is really equal to $$Z \otimes I$$ and hence the proposed construction really implements the requested gate.