B1: Bra-Ket Notated Gate

Time Limit: 3 seconds

Memory Limit: 512 MiB

Score: 100 points

Problem Statement

Implement the operation defined by the following matrix AA on a quantum circuit qc\mathrm{qc} with 11 qubit.

A=∣1⟩⟨0∣+∣0⟩⟨1∣A = \ket{1}\bra{0}+\ket{0}\bra{1}

Constraints

  • In this problem, the state with different global phase will not be considered correct.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
 
def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
 
    return qc

Hints

Open

A quantum state ∣ψ⟩=a0∣0⟩+a1∣1⟩\ket{\psi} = a_0 \ket{0} + a_1 \ket{1} can be represented as a column vector

∣ψ⟩=a0∣0⟩+a1∣1⟩=(a0a1).\ket{\psi}=a_0\ket{0}+a_1\ket{1}=\begin{pmatrix}a_0\\a_1\end{pmatrix}.

The adjoint ⟨ψ∣\bra{\psi} of a quantum state ∣ψ⟩=a0∣0⟩+a1∣1⟩\ket{\psi}=a_0\ket{0}+a_1\ket{1} is defined as

⟨ψ∣=∣ψ⟩†=(a0∗a1∗).\bra{\psi} = \ket{\psi}^{\dagger} = \begin{pmatrix}a_0^* & a_1^*\end{pmatrix}.

For quantum states ∣ψ⟩=(a0a1)\ket{\psi}=\begin{pmatrix}a_0\\a_1\end{pmatrix} and ⟨ϕ∣=(b0∗b1∗)\bra{\phi}=\begin{pmatrix}b_0^* & b_1^*\end{pmatrix}, the inner product ⟨ϕ∣ψ⟩\braket{\phi|\psi} is defined as

⟨ϕ∣ψ⟩=(b0∗b1∗)(a0a1)=b0∗a0+b1∗a1.\braket{ \phi | \psi } = \begin{pmatrix} b_0^* & b_1^* \end{pmatrix} \begin{pmatrix} a_0 \\ a_1 \end{pmatrix} = b_0^* a_0 + b_1^* a_1.

Manipulating a quantum state is equivalent to multiplying a column vector by a unitary matrix from the left.

The outer product ∣ψ⟩⟨ϕ∣\ket{\psi}\bra{\phi} of quantum states ∣ψ⟩=(a0a1)\ket{\psi}=\begin{pmatrix}a_0\\a_1\end{pmatrix} and ⟨ϕ∣=(b0∗b1∗)\bra{\phi}=\begin{pmatrix}b_0^* & b_1^*\end{pmatrix} is defined as

∣ψ⟩⟨ϕ∣=(a0a1)(b0∗b1∗)=(a0b0∗a0b1∗a1b0∗a1b1∗)\ket{\psi} \bra{\phi} = \begin{pmatrix} a_0 \\ a_1 \end{pmatrix} \begin{pmatrix} b_0^* & b_1^* \end{pmatrix} = \begin{pmatrix} a_0 b_0^* & a_0 b_1^* \\ a_1 b_0^* & a_1 b_1^*\end{pmatrix}

For arbitrary quantum state ∣ω⟩\ket{\omega}, the following equation holds:

(∣ψ⟩⟨ϕ∣)∣ω⟩=∣ψ⟩⟨ϕ∣ω⟩=⟨ϕ∣ω⟩∣ψ⟩(\ket{\psi} \bra{\phi}) \ket{\omega} = \ket{\psi} \braket{ \phi | \omega } = \braket{ \phi | \omega } \ket{\psi}

Please sign in to submit your answer.