New answers tagged

2

$V$ is the square root of $X$. That is, \begin{align*} V = \sqrt X = \frac{1}{2}\left( {\begin{array}{*{20}{c}} {1 + i}&{1 - i}\\ {1 - i}&{1 + i} \end{array}} \right) \end{align*} It is implemented in Qiskit with the name $SX$. So, the circuit in your question is easy to implement: from qiskit import QuantumCircuit from qiskit.circuit.library import ...


2

I don't remember what is the V-gate, sorry, but I created something that you can easily change so you can put any gate you like. The idea is to create the gate and then use the ControlledGate to create the control you like. I also put on there an example of how to create a control from an already existing gate, notice you can put more than 1 control. from ...


3

Feedback is not allowed and no ancilla qubits are used. Here's a relative-phase-error no-ancilla $C^n X$ construction with a T count of $12n \pm O(1)$. I think it's easiest to understand as $3n \pm O(1)$ Toffoli gates with $O(1)$ other gates: (Verification circuit in Quirk) (The left hand side might not look like it only has relative phase error, but you ...


2

What your calculation conveys is that if you get any of the measurement results 01, 10 or 11, the output state is $Z|\psi\rangle$. If that happens, you apply $Z$ and your state is back to the one you started with. So, repeat the circuit and , if you get the answer 00, you've accomplished the process you want. If not, apply another $Z$ and repeat. Each ...


6

(This answer uses ancillae and feedback) Does anyone know if there has been any improvement on the decomposition of the general n-qubits control X with phase differences in terms of elementary gates up to this day? [...] And also what is the theoretical lower bound? About a week ago I would have told you it's probably not possible to do better than a T ...


1

You don't need to use any ancillas at all. Just add in the controls as a list and a target and you should be good. Take this as an example of 9 control bits


2

Short answer, tensor product is not commutative. Therefore, in the general case, $A \otimes B \not = B \otimes A$. By calculating the matrices $I \otimes X$ and $X \otimes I$, you'll see the difference. Applying $X$ to qubit 0 corresponds to the following matrix: $$ I \otimes X = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} \otimes \begin{pmatrix} 0 &...


5

As mentioned in the other answer, the Hadamard gate is a pi rotation (180 degree) around the $X + Z$ axis. That is, it is a 180 degree rotation around the purple axis indicated in the below figure: And the $Rx(\pi/2)$ follows by a $Rz(\pi/2)$ then follow by $Rx(\pi/2)$ does exactly this rotation as well. To have better visualization of this, suppose I ...


2

Any gate in the circuit can be seen as an element of SU(2), ignoring the global phase. Hence Hadamard gate can be changed into $$\sqrt{1/2}\begin{pmatrix} i & i\\ i & -i \end{pmatrix}.$$ And any element of SU(2) $\begin{pmatrix} a & b\\ -b^* & a^* \end{pmatrix}$can be changed into SO(3) with the formula below, which you can find it in some ...


0

I think I found why the target unitary needs to be a TwoQubitWeylDecomposition class as the .a, .b, and .c attributes allow for the access of the second np.mod((d[:3]+d[3])/2, 2*np.pi). This argument is needed for the TwoQubitBasisDecomposer(), and so the target unitary needs to be a TwoQubitWeylDecomposition. I hope this helps. :)


2

qsel is an esoteric programming language similar to Ook! or whitespace. All it's doing is requiring you to decompose the circuit into the gateset [CS, H] and then representing the circuit with a ridiculous format. This is possible because [CS, H] is universal and because anything and everything can be efficiently encoded into a binary system that uses two ...


4

The @epelaaez explanation is on the spot on how noise works. In this answer I would like to focus more on how to reduce that noise. For that, let's introduce the notion of the Qiskit transpiler. The transpiler adapts the circuit to run it in the backend. The circuit that you are running in ibmq_16_melbourne is the following: from qiskit import transpile ...


2

That’s just how real quantum computers work. The QASM simulator is able to simulate ideal conditions where there is no noise in your qubits/circuit. However, you cannot avoid noise when running on real hardware. Here you can find information about the specific device you’re talking about. You want to look into T1, T2 and the readout and CNOT error rate. Very ...


2

Looking at the list of the intrinsic gates available in Q#, and keeping in mind that we need a gate with the first column being $\begin{bmatrix} \alpha \\ \beta \end{bmatrix}$, you can notice that the gate with all real coefficients is the Ry gate. Now you need to find $\theta$ such that $\cos\frac{\theta}{2}=\alpha$ and $\sin\frac{\theta}{2}=\beta$. We can ...


1

First, note that the input (in vector form) will be $\begin{bmatrix} 1 \\ 0 \end{bmatrix}$. And you want the output to be $\begin{bmatrix} \alpha \\ \beta \end{bmatrix}$. Therefore, the matrix that represents the gate you want needs to have the vector you want as output on the first column. To see what the second column needs to be, let’s look at the general ...


2

Is it possible to construct such a black-box gate ?? No, the gate you're describing isn't possible. It's not unitary. You can't condition on amplitude thresholds, you can only condition on orthogonal states.


1

The columns of a unitary matrix must be orthonormal! So, in this case, since you know the image of $|0\rangle$ under $U$, it must be that $U|1\rangle$ is the unit vector orthogonal to $U|0\rangle=a|0\rangle+b|1\rangle$ in $\mathbb{C}^2$.


5

An explicit construction that you can use to apply any power of an unknown unitary $U$ for which you have a circuit, is to perform phase estimation of $U$ applied to the current state $|\psi\rangle$, apply a phase gradient to the phase estimation register where the strength of the phase estimation determins the power of the gate, then uncompute the phase ...


5

Basically what you want is an application of phase estimation. Take a look at this paper. To give a very crude summary. Imagine you have an eigenvector $|\lambda\rangle$ of a unitary $U$, and the eigenvalue is of the form $e^{2\pi ip/2^t}$. If you did phase estimation on that state, using a register of $t$ qubits, you'd have $$ |\lambda\rangle|p\rangle $$ If ...


3

I didn't go through the attached pdf. But if you want to find a unitary matrix $U$ that maps a quantum state $|\psi \rangle$ to $|\phi\rangle$ then you can use the Householder transformation as I commented. Here the two vectors have the same length (they are unit vectors) because we are thinking of them as a quantum state, so there will always exist a ...


2

In QAOA you do not implement Hamiltonian $H$ itself but gate defined as $U = \mathrm{e}^{iHt}$. Since Hamiltonian $H$ is always Hermitian, operator $U$ is always unitary. You can see proof of this here. Concerning implementation of QAOA circuits, I would recommed this article. It contains discussion how to convert QUBO to Hamiltonian and in the appendix, ...


2

$X \otimes Z = \begin{pmatrix} 0 & 1\\ 1 & 0 \end{pmatrix} \otimes \begin{pmatrix} 1 & 0\\ 0 & -1 \end{pmatrix} = \begin{pmatrix} 0 \cdot \begin{pmatrix} 1 & 0\\ 0 & -1 \end{pmatrix} & 1\cdot \begin{pmatrix} 1 & 0\\ 0 & -1 \end{pmatrix}\\ 1 \cdot \begin{pmatrix} 1 & 0\\ 0 & -1 \end{pmatrix} & 0 \cdot \begin{...


1

Dirac notations, as far as I have seen, concerns quantum states (kets) and their complex conjugates (bras). For gates, you could simply use the capitalized letter that represents the particular gate. For example, $H$ for Hadamard gate, $X$ for bit flip, and so on. Please note that, when you apply two quantum gates on the same quantum state, the notation ...


3

One thing you can do is zero noise extrapolation. The idea of the technique is to deliberately add noise to your circuit (by stretching the duration of the pulses of your circuit: Extending the computational reach of a noisy superconducting quantum processor or by adding extra gates that do nothing: Option Pricing using Quantum Computers) and then ...


4

Yes, as long as you change the order of the gates without changing the qubits on which each gate acts. Proof: All phase gates are represented by diagonal unitary matrices. If $A$ has a diagonal matrix then controlled-$A$ also has a diagonal matrix. Therefore, all gates in your set of gates have diagonal matrices. Conclusion follows from the fact that ...


1

For information, the reported errors for single and 2 qubit gates for each backend are measured using randomized benchmarking (look at the qiskit textbook https://qiskit.org/textbook/ch-quantum-hardware/randomized-benchmarking.html) Another good source of information is available in the community tutorials notebooks https://github.com/qiskit-community/qiskit-...


3

I'm going to label my 3 parties by A, B, C (just to be awkward). If we consider a bipartition of A|BC, we know that a general state can be written in the form $$ U_A\otimes I_{BC}(\alpha|0\rangle_A|\psi_0\rangle_{BC}+\beta|1\rangle_A|\psi_1\rangle_{BC}) $$ where $|\psi_i\rangle$ are mutually orthogonal and may be entangled. This is just the Schmidt ...


3

If you want to be more precise about it, quantum (pure, ket) states are elements of complex projective spaces, $\mathbb{CP}^n$. This is the set of equivalence classes of elements of $\mathbb C^{n+1}$ modulo multiplication by complex scalars. So "gates" should really be described as maps between such equivalence classes. This is the projective ...


3

Two states that are the same up to a global phase are physically indistinguishable; some even go as far as to say that they are exactly the same state. Any $U_{1}$ and $U_{2} = e^{i\alpha}U_{1}$ will thus give physically indistinguishable states, meaning that there is nothing that $U_{2}$ can do that $U_{1}$ cannot. Would a quantum processor restricted to ...


20

I'd say it's far more common for quantum algorithms to use billions of gates than thousands. And that's assuming you're ignoring Clifford gates as well as error correction overhead! If you want to count those, add in another factor of a million. For example... According to Table III of https://arxiv.org/abs/2011.03494 , quantum chemistry algorithms looking ...


1

When we make a measurement we project the state of the qubit to the z-basis (i.e 0 or 1) so in general it is not possible to measure a global phase. That said, Measuring such global phases is an important subroutine in many quantum algorithms such as Shor's algorithm. This can be done using the Quantum phase estimation algorithm. For details, check https://...


1

First note that your $P(\theta)$ and $R_z(\theta)$ gates are the same up to a global phase, so you will not be able to distinguish them. Now, according to qiskit.pulse.ShiftPhase documentation: The qubit phase is tracked in software, enabling instantaneous, nearly error-free Z-rotations by using a ShiftPhase to update the frame tracking the qubit state. So ...


6

Qiskit supports translating to different continuous basis sets by specifying the basis_gates in the transpile method. So in your case you could just do >>> from qiskit import QuantumCircuit, transpile >>> from qiskit.circuit import Parameter >>> circuit = QuantumCircuit(1) >>> circuit.ry(Parameter('theta'), 0) >>> ...


1

Where does that single evaluation of $f(x)$ actually occur? Is it in the construction of $U_f$? $U_f$ is an implementation of $f$ in quantum gates. The evaluation of $f$ occurs in the course of applying the gates making up $U_f$ to the qubits. What is $U_f$ in this case? I realize it depends on $f$, but how can we build it using at most one evaluation of $...


9

First, note that the Controlled-X gate can be written as: $$ CX = |0\rangle \langle 0| \otimes I + |1 \rangle \langle 1| \otimes X $$ This tells us that the first qubit is the controlled, and the second qubit is the target. And when the controlled qubit is $|0\rangle$ we do nothing hence the Idenity operator. When the controlled-qubit is a $|1\rangle$ we ...


1

There's a bunch of single Clifford gate types that you can use. $R_y(\theta) = \sqrt{X} \sqrt{X} \sqrt{X} R_z(\theta) \sqrt{X}$ where $\sqrt{X} = HSH$ is a 90 degree rotation around X. $R_y(\theta) = C_{XYZ} R_z(\theta) C_{XYZ} C_{XYZ}$ where $C_{XYZ} = (iI + X + Y + Z)/2$ is a 120 degree rotation around X+Y+Z. $R_y(\theta) = H_{YZ} R_z(\theta) H_{YZ}$ where ...


3

The phase gate $$S=\begin{pmatrix}1&0\\0&i\end{pmatrix}=\sqrt{\sigma_z}$$ satisfies $$S\sigma_x S^\dagger=\sigma_y,$$ where $\sigma_i$ are the Pauli matrices. So, once you know that $R_x=H R_z H$, you can immediately find $$R_y=SH R_z HS^\dagger.$$ You can also do $$R_y=-S^\dagger H R_z HS.$$


0

You can use the KAK decomposition method described here. And if you are using Qiskit, this method is implemented in TwoQubitBasisDecomposer class. z = cmath.rect(1, np.pi / 4) # e^(iπ/4) # Your two-qubit entangling gate as numpy array: basis_unitary = 0.5 * np.array([ [1j*z, z, z, -1j*z], [1/z, 1j/z, -1j/z, 1/z], [1/z, -1j/z, 1j/z, 1/z], [-...


3

This is wrong for sure. And according to the book reviews on Amazon, this book is "unreliable", "riddled with errors", and "someone studying for the first time will get confused"


4

Here's a simple example if you're looking for a quick hack: import pennylane as qml import numpy as np def RXX(theta): rxx = np.array([ [np.cos(theta/2), 0, 0, -1j*np.sin(theta/2)], [0, np.cos(theta/2), -1j*np.sin(theta/2), 0], [0, -1j*np.sin(theta/2), np.cos(theta/2), 0], [-1j*np.sin(theta/2), 0, 0, np.cos(theta/2)] ]...


2

In this tutorial in PennyLane, they guide you to create a custom gate (Rxx gate) https://pennylane.ai/blog/2021/05/how-to-add-custom-gates-and-templates-to-pennylane/ After creating it you can simply use these code to add it: dev = qml.device('default.qubit', wires=3) dev.operations.add("RXX")


3

If your inputs are bits $b_1, ..., b_n$ and you can only use NOT gates and CNOT gates, then your outputs are always parities. Your outputs are always of the form $c_0 + \sum_{k=1}^n c_k b_k$ where $c_k \in \{0, 1\}$ are bits you can pick and also all arithmetic is modulo 2. For example, you can output $\lnot b_1$ and you can output $b_1 + b_3$ but you can't ...


Top 50 recent answers are included