7

Firstly simply rewrite probability amplitudes of returned states as columns of a matrix: $$ U = \begin{pmatrix} \frac{1}{\sqrt{2}} & \frac{1-i}{2} \\ \frac{1+i}{2} & -\frac{1}{\sqrt{2}} \end{pmatrix} $$ Now do some algebra $$ U = \frac{1}{\sqrt{2}} \begin{pmatrix} 1 & \frac{1-i}{\sqrt{2}} \\ \frac{1+i}{\sqrt{2}} & -1 \end{pmatrix} = \frac{1}{...


5

Prepare a qubit in state $|\psi\rangle=\mathrm{cos}\frac{\theta}{2}|0\rangle+\mathrm{e}^{i\phi}\mathrm{sin}\frac{\theta}{2}|1\rangle$, given the angles $\psi$ and $\theta$. Let's start with a qubit in the $|0\rangle$ state, as is customary for Q#. You can use one of the general library operations to prepare the state, such as PrepareArbitraryState. Or you ...


4

The outcome is $-i\left| 11 \right\rangle $. Here is how I obtained it. $$ \left| 01 \right\rangle \xrightarrow{\text{X}} \left| 11 \right\rangle \xrightarrow{\text{Y}} -i\left| 10 \right\rangle \xrightarrow{\text{CNOT}} -i\left| 11 \right\rangle \xrightarrow{\text{SWAP}} -i\left| 11 \right\rangle $$ $X$ gate changes 0 to 1, and 1 to 0: $$ X \left| 0 \...


4

Just to expand on the detail of why writing out the columns works: Start by writing the action of the unitary: \begin{align*} U|0\rangle=\frac{1}{\sqrt{2}}|0\rangle+\frac{1+i}{2}|1\rangle \\ U|1\rangle=\frac{1-i}{2}|0\rangle-\frac{1}{\sqrt{2}}|1\rangle \end{align*} Before proceeding, it's always worth checking that both sides are correctly normalised. In ...


4

Assuming you've got Toffoli and single-qubit rotations, you can implement the following: This basically works because if either of the controls is not $|1\rangle$, the Toffoli does nothing and the two single-qubit unitaries cancel each other. Whereas, if both controls are $|1\rangle$, then the net gate on the target qubit is $$ (\cos\frac{\pi}{8}I+i\sin\...


3

Consider some simpler cases, $(j,j+1)$ for general $j$. Then you can do you want with plugging in $j=i$, $j=i+1$, $j=i+3$ and $j=i+4$ and concatenating the circuits appropriately and then simplifying. So how to do $(j,j+1)$? That is conjugate to $(0,1)$, so just consider that for now. $(0,1)$ would be NOT but controlled on making sure all the higher places ...


3

A general controlled unitary Let $CU$ denote the 'controlled' version of the $n$-qubit unitary $U$: \begin{equation} CU = |0\rangle\langle0|\otimes I_{t} + |1\rangle\langle1|\otimes U_{t}, \end{equation} where the operation acts on a Hilbert space $\mathcal{H}_{c}\otimes \mathcal{H}_{t}$, with $c$ denoting the control qubit and $t$ denoting the target ...


3

On hardware, the number of moments is the relevant metric. That is why cirq focuses on that. To compute circuit depth in cirq, create a new circuit using just the operations. It defaults to packing them as tightly as possible, so the number of moments will be the depth. depth = len(cirq.Circuit(my_circuit.all_operations()))


3

How about I approach your question from computer science perspective. A bit can be only $0$ or only $1$. A qubit can be only $0$, or only $1$, or a combination (superposition) of $0$ and $1$. We denote a zero bit as $0$ and zero qubit as $\vert 0 \rangle$. We also denote a bit of value one as $1$ and a qubit of value one as $\vert 1 \rangle$. Keep in mind ...


2

First you need eigenvalues; $$X=\begin{pmatrix} 0&1 \\ 1&0\end{pmatrix}$$ so you need to solve equation $$\begin{vmatrix}0-\lambda &1 \\ 1 &0-\lambda\end{vmatrix}=0$$ or $$\lambda^2-1=0$$ which gives eigenvalues $$\lambda_{1,2}=\pm 1$$ Since $X$ is Hermitian, eigenvalues are real. Now you can find eigenvectors; for example, for the first ...


2

If you use $\theta = \pi$, you get the following: $$ Rz(\pi)\begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix} = \begin{bmatrix} e^{-i \pi/2} & 0 \\ 0 & e^{i \pi/2} \end{bmatrix} \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix} = \begin{bmatrix} -i & 0 \\ 0 & i \end{bmatrix} \begin{bmatrix} \frac{1}{\...


2

In your question, there is missing a key ingredient, which is: a superposition in which basis? All pure (quantum) states are representable with only one non-zero coefficient in its native basis, and all pure states can be represented as a superposition in a different basis. Answer of @Martin Vesely gives you intuition how to represent $|1\rangle$ in a ...


2

$|1\rangle$ is not in superposition, it is simply state 1. After measurement you will get 1 with 100 % probability. However, generaly, qubit can be represented as $|q\rangle = a|0\rangle + b|1\rangle$, where $a,b \in \mathbb{C}$. So, you can think of $|1\rangle$ as a superposition with $a=0$ and $b=1$. Concerning second question, $|1\rangle = \begin{...


2

The more elegant approach is to view $R_z(\phi)$ as a linear transformation acting on the basis $\{|0\rangle, |1\rangle\}$. $|0\rangle$ is mapped to $e^{i\phi/2}|0\rangle$ and $|1\rangle$ is mapped to $e^{-i\phi/2}|1\rangle$ by the transformation. As, $|+\rangle = \frac{1}{\sqrt 2}(|0\rangle +|1\rangle)$ it'd be mapped to $R_z(\phi)|+\rangle = \frac{1}{\sqrt ...


2

Summarization based on discussion with user met927: Transpiled circuit form depends on used backend - it is different for simulator and real quantum processor: On simulator, the $\mathrm{CH}$ gate is transpiled to the circuit shown above On real quantum processor, the gate is implemented with two $\mathrm{U2}$ gates and $\mathrm{CNOT}$ (i.e. like in the ...


2

A brute force solution :). You can also obtain CCH via qiskit's basic gates with help of get_controlled_circuit method. from qiskit import * from qiskit.aqua.utils.controlled_circuit import get_controlled_circuit q_reg = QuantumRegister(3, 'q') qc_h = QuantumCircuit(q_reg) qc_ch = QuantumCircuit(q_reg) qc_cch = QuantumCircuit(q_reg) qc_h.h(q_reg[0]) ...


1

Based on paper Five Two-Bit Quantum Gates are Sucient to Implement the Quantum Fredkin Gate provided by Norbert Schuch, I realized that there is a more efficient implementation in terms of number of gates. Here is a result: Matrix of CNOT acting on $|q_1\rangle$ controlled by $|q_2\rangle$ is \begin{equation} CNOT_{2}= \begin{pmatrix} 1 & 0 & 0 &...


1

The return from result.data(qc) is information about the result of running the circuit qc. In your example, there are 2 pieces of information returned - the statevector and the counts. The statevector is a way of describing the state of the qubit, and the result contains the statevector from the end of the circuit. Each of the arrays in the overall array ...


1

On IBM Q the Rz gate is defined as \begin{equation} Rz(\theta) = \begin{pmatrix} 1 & 0 \\ 0 & \mathrm{e}^{i\theta} \end{pmatrix} \end{equation} If you put $\theta = \pi$ then the matrix turns to \begin{equation} Rz(\pi) = \begin{pmatrix} 1 & 0 \\ 0 & \mathrm{e}^{i\pi} \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix} =...


1

Just think where $|+\rangle$ and $|-\rangle$ states on the Bloch sphere ($x$ axis):


1

Intraphoton entanglement uses the degrees of freedom from one photon only to create entanglement. So, here either polarization and linear momentum or polarization and angular momentum can be used to create entanglement. Interphoton entanglement is the entanglement created between 2 spatially separated photons. So, naturally latter is less stable than former. ...


Only top voted, non community-wiki answers of a minimum length are eligible