This resource function is obsolete. Use the paclet Wolfram/QuantumFramework instead.

Function Repository Resource:

QuantumDiscreteOperator

Source Notebook

Represent a discrete quantum operator

Contributed by: Jonathan Gorard (with modifications by Ruhi Shah and Taufiq Murtadho)

ResourceFunction["QuantumDiscreteOperator"][<|b11e11,b12e12,|>,order,QuantumBasis[]]

represents a discrete quantum operator with (tensor products of) basis elements bij and associated matrix elements eij, applied to the qudits indexed by order, defined with respect to a specified QuantumBasis.

ResourceFunction["QuantumDiscreteOperator"][mat,order,QuantumBasis[]]

represents a discrete quantum operator with matrix representation mat, applied to the qudits indexed by order, defined with respect to a specified QuantumBasis.

ResourceFunction["QuantumDiscreteOperator"]["name",order,pic]

represents a named discrete quantum operator "name", applied to the qudits indexed by order, with respect to the quantum mechanical picture pic.

ResourceFunction["QuantumDiscreteOperator"][{"name",d},order,pic]

represents a d-dimensional version of a named discrete quantum operator "name", applied to the qudits indexed by order, with respect to the quantum mechanical picture pic.

ResourceFunction["QuantumDiscreteOperator"][ResourceFunction["QuantumDiscreteOperator"][],QuantumBasis[]]

transforms a specified ResourceFunction["QuantumDiscreteOperator"] into a new QuantumBasis.

ResourceFunction["QuantumDiscreteOperator"][ResourceFunction["QuantumDiscreteOperator"][],pic]

transforms a specified ResourceFunction["QuantumDiscreteOperator"] into the new quantum mechanical picture pic.

Details

The QuantumBasis object is produced by the resource function QuantumBasis. When a QuantumBasis object is not specified, the default is taken to be QuantumBasis["Computational"].
When an order order is not specified, the default is taken to be Range[arity], where arity designates the arity of the ResourceFunction["QuantumDiscreteOperator"].
The permitted values of pic in ResourceFunction["QuantumDiscreteOperator"][,pic] are "Schrodinger" (default—may also be written "Schroedinger" or "Schrödinger"), "Heisenberg", "Interaction" and "PhaseSpace".
ResourceFunction["QuantumDiscreteOperator"][<|b11e11,b12e12,|>,d,order] and ResourceFunction["QuantumDiscreteOperator"][mat,d,order] are used to represent a discrete quantum operator in the computational basis, specified by the Association <|b11e11,b12e12,|> or the matrix mat, consisting of qudits of dimensionality d (when d is not specified, the default is taken to be 2).
The Association <|b11e11,b12e12,|> has keys given by (tensor products of) named basis elements bij and values given by matrix elements eij (i.e. entries in the corresponding matrix representation). The order order is always a list of positive integers.
ResourceFunction["QuantumDiscreteOperator"][]["prop"] gives the property "prop" of the specified discrete quantum operator. Possible properties include:
"Operator"association <|b11e11,b12e12,|> of tensor products of basis names and matrix elements
"Basis"which QuantumBasis the operator is defined with respect to
"Picture"which quantum mechanical picture the operator is defined with respect to
"BasisElements"list of basis elements bi
"MatrixRepresentation"matrix representation mat of the operator
"OrderedMatrixRepresentation"matrix representation adjusted according to the order of the operator, assuming an input state containing Max[order] qudits (subsystems)
{"OrderedMatrixRepresentation",n}matrix representation adjusted according to the order of the operator, assuming an input state containing n qudits (subsystems)
"Arity"arity of the operator
"Dimensions"dimensionality of each qudit (subsystem) in the input state for the operator
"Order"order in which the operator should be applied to qudits (subsystems) in the input state
"HermitianQ"whether the operator is Hermitian (self-adjoint)
"UnitaryQ"whether the operator is unitary (an automorphism of Hilbert space)
"Eigenvalues"eigenvalues of the matrix representation of the operator
"Eigenvectors"eigenvectors of the matrix representation of the operator
"Properties"list of all property names
A ResourceFunction["QuantumDiscreteOperator"] (in the Schrodinger picture) can act on a QuantumDiscreteState (also in the Schrodinger picture) using ResourceFunction["QuantumDiscreteOperator"][][QuantumDiscreteState[]], returning the resulting QuantumDiscreteState. Likewise for ResourceFunction["QuantumDiscreteOperator"] objects acting on ResourceFunction["QuantumDiscreteOperator"], QuantumMeasurementOperator, QuantumHamiltonianOperator or QuantumCircuitOperator objects in the Heisenberg picture, etc.
When applied to a QuantumCircuitOperator object, ResourceFunction["QuantumDiscreteOperator"] will return another ResourceFunction["QuantumDiscreteOperator"] object (i.e. ResourceFunction["QuantumDiscreteOperator"] always returns the operator representation of the resulting circuit).
ResourceFunction["QuantumDiscreteOperator"] can also be applied to QuantumMeasurement objects in order to evolve the corresponding states.
A QuantumDiscreteState, QuantumMeasurementOperator, QuantumMeasurement, QuantumHamiltonianOperator or QuantumCircuitOperator object can be created with the corresponding resource functions.
ResourceFunction["QuantumDiscreteOperator"]["name"] or ResourceFunction["QuantumDiscreteOperator"][{"name",n}] represents an (n-qudit, unless otherwise specified) named discrete quantum operator. Possible named operators include:
{"XRotation",ang}rotation by an angle ang around the x axis of the Bloch sphere
{"YRotation",ang}rotation by an angle ang around the y axis of the Bloch sphere
{"ZRotation",ang}rotation by an angle ang around the z axis of the Bloch sphere (equivalent to a PHASE gate)
"S"S-gate (equivalent to a π/2 PHASE gate)
"T"T-gate (equivalent to a π/4 PHASE gate)
"CNOT"CNOT gate for qubits (controlled NOT - equivalent to a CX gate)
{"CNOT",d}CNOT gate for d-dimensional qudits
"CPHASE"CPHASE gate for qubits (controlled π PHASE gate)
{"CPHASE",d}CPHASE gate for d-dimensional qudits
"CX"CX gate for qubits (controlled Pauli-X gate - equivalent to a CNOT gate)
{"CX",d}CX gate for d-dimensional qudits
"CY"CY gate for qubits (controlled Pauli-Y gate)
"CZ"CZ gate for qubits (controlled Pauli-Z gate)
{"CZ",d}CZ gate for d-dimensional qudits
{"ControlledU",mat}controlled-U gate for qubits (apply operator with matrix representation mat with first qubit as a control)
{"ControlledU",mat,d}controlled-U gate for d-dimensional qudits
{"ControlledU",ResourceFunction["QuantumDiscreteOperator"][]}controlled-U gate for qubits (apply specified ResourceFunction["QuantumDiscreteOperator"] with first qubit as a control)
{"ControlledU",ResourceFunction["QuantumDiscreteOperator"][],d}controlled-U gate for d-dimensional qudits
"Fourier"QFT gate for qubits (quantum Fourier transform)
{"Fourier",d}QFT gate for d-dimensional qudits
"InverseFourier"IQFT gate for qubits (inverse quantum Fourier transform)
{"InverseFourier",d}IQFT gate for d-dimensional qudits
"SWAP"SWAP gate for qubits (swap two qubits)
{"SWAP",d}SWAP gate for d-dimensional qudits
"RootSWAP"square root of the SWAP gate for qubits (half swap two qubits)
{"RootSWAP",d}square root of the SWAP gate for d-dimensional qudits
"SUM"SUM gate for qubits (half-adder for qubits - equivalent to a CNOT gate)
{"SUM",d}SUM gate for d-dimensional qudits
"PauliX"Pauli-X gate for qubits (equivalent to a π rotation around the x axis of the Bloch sphere)
{"PauliX",d}Pauli-X gate for d-dimensional qudits
"PauliY"Pauli-Y gate for qubits (equivalent to a π rotation around the y axis of the Bloch sphere)
"PauliZ"Pauli-Z gate for qubits (equivalent to a π rotation around the z axis of the Bloch sphere)
{"PauliZ",d}Pauli-Z gate for d-dimensional qudits
"RootNOT"square root of the Pauli-X gate for qubits (half NOT operation on one qubit)
{"RootNOT",d}square root of the Pauli-X gate for d-dimensional qudits
"Hadamard"Hadamard gate for qubits (equivalent to a QFT gate on one qubit)
"Toffoli"Toffoli gate on 3 qubits (equivalent to a π/2 Deutsch gate)
{"Toffoli",n}Toffoli gate on n qubits
"CSWAP"controlled SWAP gate for qubits (Fredkin gate)
{"XX",ang}XX gate for x axis rotation angle ang (Ising coupling gate)
{"YY",ang}YY gate for y axis rotation angle ang (Ising coupling gate)
{"ZZ",ang}ZZ gate for z axis rotation angle ang (Ising coupling gate)
{"Deutsch",ang}Deutsch gate for rotation angle ang on 3 qubits
"RandomUnitary"random unitary operator for qubits (Gaussian unitary ensemble)
{"RandomUnitary",d}random unitary operator for d-dimensional qudits

Examples

Basic Examples (7) 

Create a discrete quantum operator from a matrix representation in the computational basis (default):

In[1]:=
operator = ResourceFunction["QuantumDiscreteOperator"][{{1, -1}, {1, 1}}]
Out[1]=

Return its operator association:

In[2]:=
operator["Operator"]
Out[2]=

Apply the operator to the first qubit (default) of a two-qubit discrete quantum state in the computational basis:

In[3]:=
state = ResourceFunction["QuantumDiscreteState"][{1, -1, I, -I}]
Out[3]=
In[4]:=
operator[state]
Out[4]=

Apply the operator instead to the second qubit of the state:

In[5]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][{{1, -1}, {1, 1}}, {2}]
Out[5]=
In[6]:=
operator2[state]
Out[6]=

Create a discrete quantum operator from a matrix representation in a specified basis (Pauli-X) and return its matrix representation:

In[7]:=
operator = ResourceFunction[
   "QuantumDiscreteOperator"][{{(1 + I)/2, (I - 1)/2}, {(I - 1)/
      2, (1 + I)/2}}, ResourceFunction["QuantumBasis"]["PauliX"]];
operator["MatrixRepresentation"]
Out[7]=

Return its operator association:

In[8]:=
operator["Operator"]
Out[8]=

Show that the operator is unitary, but not Hermitian:

In[9]:=
operator["UnitaryQ"]
Out[9]=
In[10]:=
operator["HermitianQ"]
Out[10]=

Return the ordered matrix representation (assuming a state of size 2):

In[11]:=
operator[{"OrderedMatrixRepresentation", 2}]
Out[11]=

Return the ordered matrix representation (assuming a state size of 3):

In[12]:=
operator[{"OrderedMatrixRepresentation", 3}]
Out[12]=

Return the ordered matrix representation (assuming a state of size 2) assuming that the operator is applied instead to the second qubit of the state:

In[13]:=
operator2[{"OrderedMatrixRepresentation", 2}]
Out[13]=

Create a discrete quantum operator by explicitly specifying an association of matrix elements in a given (tensor product) basis and return its matrix representation:

In[14]:=
operator = ResourceFunction[
   "QuantumDiscreteOperator"][<|TensorProduct[Ket[0], Ket[0]] -> I, TensorProduct[Ket[0], Ket[1]] -> -1, TensorProduct[Ket[1], Ket[0]] -> -I, TensorProduct[Ket[1], Ket[1]] -> 1|>, {1}];
operator["MatrixRepresentation"]
Out[15]=

Return its basis element association:

In[16]:=
operator["BasisElements"]
Out[16]=

Return its operator association:

In[17]:=
operator["Operator"]
Out[17]=

Create a CNOT gate for qubits (default), with the third qubit being the control and the fourth qubit being "active":

In[18]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["CNOT", {3, 4}];
operator["Operator"]
Out[18]=

Create a CNOT gate for 3-dimensional qudits, with the second qudit being the control and the first qudit being "active":

In[19]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][{"CNOT", 3}, {2, 1}];
operator2["Operator"]
Out[19]=

Create an XX Ising coupling gate with rotation angle π/3, applied to qubits 5 and 2:

In[20]:=
operator3 = ResourceFunction["QuantumDiscreteOperator"][{"XX", Pi/3}, {5, 2}];
operator3["Operator"]
Out[20]=

By default, all discrete quantum operators are created in the Schrodinger picture:

In[21]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary"]
Out[21]=
In[22]:=
operator["Picture"]
Out[22]=

Operators in the Schrodinger picture can be applied to QuantumDiscreteState objects:

In[23]:=
state = ResourceFunction["QuantumDiscreteState"]["RandomPure"]
Out[23]=
In[24]:=
operator[state]
Out[24]=

However, they cannot be applied to other operators (i.e. QuantumDiscreteOperator objects, QuantumMeasurementOperator objects, QuantumHamiltonianOperator objects or QuantumCircuitOperator objects). Doing so will return unevaluated:

In[25]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary"]
Out[25]=
In[26]:=
operator[operator2]
Out[26]=

On the other hand, operators created in the Heisenberg picture cannot be applied to QuantumDiscreteState objects (will return unevaluated):

In[27]:=
operator3 = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", "Heisenberg"]
Out[27]=
In[28]:=
operator3[state]
Out[28]=

However, they can be applied to other operators in the Heisenberg picture (i.e. QuantumDiscreteOperator objects, QuantumMeasurementOperator objects, QuantumHamiltonianOperator objects or QuantumCircuitOperator objects):

In[29]:=
operator4 = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", "Heisenberg"];
operator3[operator4]
Out[29]=
In[30]:=
measurement = ResourceFunction["QuantumMeasurementOperator"]["RandomHermitian", "Heisenberg"];
operator3[measurement]
Out[30]=
In[31]:=
hamiltonian = ResourceFunction["QuantumHamiltonianOperator"]["RandomHermitian", "Heisenberg"];
operator3[hamiltonian]
Out[31]=
In[32]:=
circuit = ResourceFunction[
    "QuantumCircuitOperator"][{ResourceFunction[
      "QuantumDiscreteOperator"]["RandomUnitary", "Heisenberg"]}, "Heisenberg"];
operator3[circuit]
Out[32]=

By default, all discrete quantum operators are assumed to apply to tensor products of 2-dimensional subsystems (i.e. qubits):

In[33]:=
operator = ResourceFunction[
  "QuantumDiscreteOperator"][{{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}, {0, 0, 1, 0}}]
Out[33]=
In[34]:=
operator["Operator"]
Out[34]=

Create a discrete quantum operator with the same matrix representation applying to a single 4-dimensional subsystem (i.e. qudit) instead:

In[35]:=
operator2 = ResourceFunction[
  "QuantumDiscreteOperator"][{{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}, {0, 0, 1, 0}}, 4]
Out[35]=
In[36]:=
operator2["Operator"]
Out[36]=

Create a discrete quantum operator in the computational basis (default):

In[37]:=
operator = ResourceFunction[
   "QuantumDiscreteOperator"][{{(1 + I)/2, (I - 1)/2}, {(I - 1)/
      2, (1 + I)/2}}];
operator["Operator"]
Out[37]=
In[38]:=
operator["Basis"]
Out[38]=

Transform the operator to the Fourier basis:

In[39]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][operator, ResourceFunction["QuantumBasis"]["Fourier"]];
operator2["Operator"]
Out[39]=
In[40]:=
operator2["Basis"]
Out[40]=

Transform the operator back to the computational basis:

In[41]:=
operator3 = ResourceFunction["QuantumDiscreteOperator"][operator2, ResourceFunction["QuantumBasis"]["Computational"]];
operator3["Operator"]
Out[41]=
In[42]:=
operator3["Basis"]
Out[42]=

The initial and final operators are the same:

In[43]:=
operator["MatrixRepresentation"] == operator3["MatrixRepresentation"]
Out[43]=

Scope (21) 

Represent the RootSWAP gate in the Heisenberg picture:

In[44]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["RootSWAP", "Heisenberg"]
Out[44]=
In[45]:=
operator["Basis"]
Out[45]=

Transform the operator to the interaction picture:

In[46]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][operator, "Interaction"]
Out[46]=
In[47]:=
operator2["Basis"]
Out[47]=

Represent a 2-qubit random unitary operator in the computational basis:

In[48]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {1, 2}];
operator["Operator"]
Out[48]=
In[49]:=
operator["Basis"]
Out[49]=

Represent the same operator in the Pauli-X basis instead:

In[50]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][operator, ResourceFunction["QuantumBasis"]["PauliX", 2]];
operator2["Operator"]
Out[50]=
In[51]:=
operator2["Basis"]
Out[51]=

Operators in the Schrodinger picture can be applied to QuantumDiscreteState objects that are also in the Schrodinger picture:

In[52]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {1, 2}]
Out[52]=
In[53]:=
state = ResourceFunction["QuantumDiscreteState"][{"RandomPure", 2}];
state["Picture"]
Out[53]=
In[54]:=
operator[state]
Out[54]=

However, they cannot be applied to other operators in the Schrodinger picture (returns unevaluated):

In[55]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {1, 2}]
Out[55]=
In[56]:=
operator[operator2]
Out[56]=

Likewise, operators in the "PhaseSpace" picture can be applied to QuantumDiscreteState objects in the "PhaseSpace" picture:

In[57]:=
operator3 = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {1, 2}, "PhaseSpace"]
Out[57]=
In[58]:=
state2 = ResourceFunction["QuantumDiscreteState"][{"RandomPure", 2}, "PhaseSpace"];
state2["Picture"]
Out[58]=
In[59]:=
operator3[state2]
Out[59]=

But they cannot be applied to other operators in the phase space picture (returns unevaluated):

In[60]:=
operator4 = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {1, 2}, "PhaseSpace"]
Out[60]=
In[61]:=
operator3[operator4]
Out[61]=

On the other hand, operators in the Heisenberg picture cannot be applied to QuantumDiscreteState objects in the Heisenberg picture:

In[62]:=
operator5 = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {1, 2}, "Heisenberg"]
Out[62]=
In[63]:=
state3 = ResourceFunction["QuantumDiscreteState"][{"RandomPure", 2}, "Heisenberg"];
operator5[state3]
Out[63]=

But they can be applied to other operators in the Heisenberg picture:

In[64]:=
operator6 = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {1, 2}, "Heisenberg"]
Out[64]=
In[65]:=
operator5[operator6]
Out[65]=

Finally, operators in the Interaction picture can be applied to both QuantumDiscreteState objects in the Interaction picture:

In[66]:=
operator7 = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {1, 2}, "Interaction"]
Out[66]=
In[67]:=
state4 = ResourceFunction["QuantumDiscreteState"][{"RandomPure", 2}, "Interaction"];
operator7[state4]
Out[67]=

And also to other operators in the Interaction picture:

In[68]:=
operator8 = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {1, 2}, "Interaction"]
Out[68]=
In[69]:=
operator7[operator8]
Out[69]=

In general, the quantum mechanical pictures of a QuantumDiscreteOperator and the object that it is being applied to must match.


Represent a rotation gate for qubit number 3 with angle π/3 around the x axis of the Bloch sphere:

In[70]:=
operator = ResourceFunction[
   "QuantumDiscreteOperator"][{"XRotation", Pi/3}, {3}];
operator["Operator"]
Out[70]=

Represent a rotation gate for qubit number 3 with angle π/3 around the y axis of the Bloch sphere:

In[71]:=
operator2 = ResourceFunction[
   "QuantumDiscreteOperator"][{"YRotation", Pi/3}, {3}];
operator2["Operator"]
Out[71]=

Represent a rotation gate for qubit number 3 with angle π/3 around the z axis of the Bloch sphere:

In[72]:=
operator3 = ResourceFunction[
   "QuantumDiscreteOperator"][{"ZRotation", Pi/3}, {3}];
operator3["Operator"]
Out[72]=

Represent an S-gate (a π/2 phase change gate) for qubit number 2:

In[73]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["S", {2}];
operator["Operator"]
Out[73]=

Represent a T-gate (a π/4 phase change gate) for qubit number 2:

In[74]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"]["T", {2}];
operator2["Operator"]
Out[74]=

Represent a CNOT gate (a controlled NOT gate) on qubits for control qubit 2 and "active" qubit 3:

In[75]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["CNOT", {2, 3}];
operator["Operator"]
Out[75]=

Represent a CNOT gate (a controlled NOT gate) on 3-dimensional qudits for control qudit 2 and "active" qudit 3:

In[76]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][{"CNOT", 3}, {2, 3}];
operator2["Operator"]
Out[76]=

Represent a CPHASE gate (a controlled π phase change gate) on qubits for control qubit 3 and "active" qubit 4:

In[77]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["CPHASE", {3, 4}];
operator["Operator"]
Out[77]=

Represent a CPHASE gate (a controlled π phase change gate) on 3-dimensional qudits for control qudit 3 and "active" qudit 4:

In[78]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][{"CPHASE", 3}, {3, 4}];
operator2["Operator"]
Out[78]=

Represent a CX gate (a controlled Pauli-X gate—equivalent to a CNOT) on qubits for control qubit 1 and "active" qubit 2:

In[79]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["CX", {1, 2}];
operator["Operator"]
Out[79]=

Represent a CX gate (a controlled Pauli-X gate - equivalent to a CNOT) on 3-dimensional qudits for control qudit 1 and "active" qudit 2:

In[80]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][{"CX", 3}, {1, 2}];
operator2["Operator"]
Out[80]=

Represent a CY gate (a controlled Pauli-Y gate) for control qubit 1 and "active" qubit 2:

In[81]:=
operator3 = ResourceFunction["QuantumDiscreteOperator"]["CY", {1, 2}];
operator3["Operator"]
Out[81]=

Represent a CZ gate (a controlled Pauli-Z gate) on qubits for control qubit 1 and "active" qubit 2:

In[82]:=
operator4 = ResourceFunction["QuantumDiscreteOperator"]["CZ", {1, 2}];
operator4["Operator"]
Out[82]=

Represent a CZ gate (a controlled Pauli-Z gate) on 3-dimensional qudits for control qudit 1 and "active" qudit 2:

In[83]:=
operator5 = ResourceFunction["QuantumDiscreteOperator"][{"CZ", 3}, {1, 2}];
operator5["Operator"]
Out[83]=

Represent a controlled-U gate (with U being a random 2-by-2 unitary matrix) on qubits for control qubit 2 and "active" qubit 3 and 2:

In[84]:=
mat = Orthogonalize[RandomReal[1, {2, 2}] + I*RandomReal[1, {2, 2}]]
Out[84]=
In[85]:=
operator = ResourceFunction[
   "QuantumDiscreteOperator"][{"ControlledU", mat}, {2, 3}];
operator["Operator"]
Out[85]=

Represent a controlled-U gate (with U being a random 3-by-3 unitary matrix) on 3-dimensional qudits for control qudit 2 and "active" qudit 3:

In[86]:=
mat2 = Orthogonalize[RandomReal[1, {3, 3}] + I*RandomReal[1, {3, 3}]]
Out[86]=
In[87]:=
operator2 = ResourceFunction[
   "QuantumDiscreteOperator"][{"ControlledU", mat2, 3}, {2, 3}];
operator2["Operator"]
Out[87]=

Construct a controlled-U gate on qubits (with the same 2-by-2 matrix as before), for controlled qubit 2 and "active" qubit 3, directly using the operator form of the matrix:

In[88]:=
operator3 = ResourceFunction["QuantumDiscreteOperator"][mat, {3}]
Out[88]=
In[89]:=
operator4 = ResourceFunction[
  "QuantumDiscreteOperator"][{"ControlledU", operator3}, {2, 3}]
Out[89]=
In[90]:=
operator4["Operator"]
Out[90]=

Construct a controlled-U gate on 3-dimensional qudits (with the same 3-by-3 matrix as before), for controlled qudit 2 and "active" qudit 3, directly using the operator form of the matrix:

In[91]:=
operator5 = ResourceFunction["QuantumDiscreteOperator"][mat2, {3}]
Out[91]=
In[92]:=
operator6 = ResourceFunction[
  "QuantumDiscreteOperator"][{"ControlledU", operator5, 3}, {2, 3}]
Out[92]=
In[93]:=
operator6["Operator"]
Out[93]=

Represent a single-qubit QFT gate (quantum Fourier transform) for qubit number 3:

In[94]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["Fourier", {3}];
operator["Operator"]
Out[94]=

Represent a two-qubit QFT gate (quantum Fourier transform) for qubits 3 and 4:

In[95]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"]["Fourier", {3, 4}];
operator2["Operator"]
Out[95]=

Represent a single-qudit QFT gate (quantum Fourier transform) on 3-dimensional qudits for qudit number 3:

In[96]:=
operator3 = ResourceFunction["QuantumDiscreteOperator"][{"Fourier", 3}, {3}];
operator3["Operator"]
Out[96]=

Represent a two-qudit QFT gate (quantum Fourier transform) on 3-dimensional qudits for qudits 3 and 4:

In[97]:=
operator4 = ResourceFunction[
   "QuantumDiscreteOperator"][{"Fourier", 3}, {3, 4}];
operator4["Operator"]
Out[97]=

Represent a single-qubit IQFT gate (inverse quantum Fourier transform) for qubit number 3:

In[98]:=
operator5 = ResourceFunction["QuantumDiscreteOperator"]["InverseFourier", {3}];
operator5["Operator"]
Out[98]=

Represent a two-qubit IQFT gate (inverse quantum Fourier transform) for qubits 3 and 4:

In[99]:=
operator6 = ResourceFunction["QuantumDiscreteOperator"][
   "InverseFourier", {3, 4}];
operator6["Operator"]
Out[99]=

Represent a single-qudit IQFT gate (inverse quantum Fourier transform) on 3-dimensional qudits for qudit number 3:

In[100]:=
operator7 = ResourceFunction[
   "QuantumDiscreteOperator"][{"InverseFourier", 3}, {3}];
operator7["Operator"]
Out[100]=

Represent a two-qudit IQFT gate (inverse quantum Fourier transform) on 3-dimensional qudits for qudits 3 and 4:

In[101]:=
operator8 = ResourceFunction[
   "QuantumDiscreteOperator"][{"InverseFourier", 3}, {3, 4}];
operator8["Operator"]
Out[101]=

Represent a SWAP gate on qubits (swaps two qubits) for qubits 1 and 2:

In[102]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["SWAP", {1, 2}];
operator["Operator"]
Out[102]=

Represent a SWAP gate on 3-dimensional qudits (swaps two qudits) for qudits 1 and 2:

In[103]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][{"SWAP", 3}, {1, 2}];
operator2["Operator"]
Out[103]=

Represent the square root of a SWAP gate on qubits (half swaps two qubits) for qubits 1 and 2:

In[104]:=
operator3 = ResourceFunction["QuantumDiscreteOperator"]["RootSWAP", {1, 2}];
operator3["Operator"]
Out[104]=

Represent the square root of a SWAP gate on 3-dimensional qudits (half swaps two qudits) for qudits 1 and 2:

In[105]:=
operator4 = ResourceFunction["QuantumDiscreteOperator"][{"RootSWAP", 3}, {1, 2}];
operator4["Operator"]
Out[105]=

Represent a SUM gate on qubits (a half-adder for qubitssimilar to a CNOT gate) for qubits 2 and 3:

In[106]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["SUM", {2, 3}];
operator["Operator"]
Out[106]=

Represent a SUM gate on 3-dimensional qudits (a half-adder for qudits—similar to a CNOT gate) for qudits 2 and 3:

In[107]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][{"SUM", 3}, {2, 3}];
operator2["Operator"]
Out[107]=

Represent a Pauli-X gate (a π rotation around the x axis of the Bloch sphere) on qubits for qubit number 3:

In[108]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["PauliX", {3}];
operator["Operator"]
Out[108]=

Represent a Pauli-X gate on 3-dimensional qudits for qudit number 3:

In[109]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][{"PauliX", 3}, {3}];
operator2["Operator"]
Out[109]=

Represent a Pauli-Y gate (a π rotation around the y axis of the Bloch sphere) on qubits for qubit number 3:

In[110]:=
operator3 = ResourceFunction["QuantumDiscreteOperator"]["PauliY", {3}];
operator3["Operator"]
Out[110]=

Represent a Pauli-Z gate (a π rotation around the z axis of the Bloch sphere) on qubits for qubit number 3:

In[111]:=
operator4 = ResourceFunction["QuantumDiscreteOperator"]["PauliZ", {3}];
operator4["Operator"]
Out[111]=

Represent a Pauli-Z gate on 3-dimensional qudits for qudit number 3:

In[112]:=
operator5 = ResourceFunction["QuantumDiscreteOperator"][{"PauliZ", 3}, {3}];
operator5["Operator"]
Out[112]=

Represent the square root of a NOT gate on qubits (half a Pauli-X rotation) for qubit number 3:

In[113]:=
operator6 = ResourceFunction["QuantumDiscreteOperator"]["RootNOT", {3}];
operator6["Operator"]
Out[113]=

Represent the square root of a NOT gate on 3-dimensional qudits (half a Pauli-X rotation) for qudit number 3:

In[114]:=
operator7 = ResourceFunction["QuantumDiscreteOperator"][{"RootNOT", 3}, {3}];
operator7["Operator"]
Out[114]=

Represent a Hadamard gate (a single-qubit quantum Fourier transform) for qubit number 1:

In[115]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["Hadamard", {1}];
operator["Operator"]
Out[115]=

Represent a Toffoli gate (a π/2 Deutsch gate) on 3 qubits for qubits 2, 3 and 4:

In[116]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["Toffoli", {2, 3, 4}];
operator["Operator"]
Out[116]=

Represent a Toffoli gate on 4 qubits for qubits 2, 3, 4 and 5:

In[117]:=
operator2 = ResourceFunction[
   "QuantumDiscreteOperator"][{"Toffoli", 4}, {2, 3, 4, 5}];
operator2["Operator"]
Out[117]=

Represent a CSWAP (controlled SWAP gate, otherwise known as a Fredkin gate) for qubits 3, 4 and 5:

In[118]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["CSWAP", {3, 4, 5}];
operator["Operator"]
Out[118]=

Represent an XX gate for qubit 4 (an x axis Ising coupling gate) with angle π/3:

In[119]:=
operator = ResourceFunction["QuantumDiscreteOperator"][{"XX", Pi/3}, {4}];
operator["Operator"]
Out[119]=

Represent a YY gate for qubit 4 (a y axis Ising coupling gate) with angle π/3:

In[120]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"][{"YY", Pi/3}, {4}];
operator2["Operator"]
Out[120]=

Represent a ZZ gate for qubit 4 (a z axis Ising coupling gate) with angle π/3:

In[121]:=
operator3 = ResourceFunction["QuantumDiscreteOperator"][{"ZZ", Pi/3}, {4}];
operator3["Operator"]
Out[121]=

Represent a Deutsch gate for qubits 1, 2 and 3 with phase π/3:

In[122]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["Deutsch", {1, 2, 3}];
operator["Operator"]
Out[122]=

Represent a single-qubit random unitary operator (selected from a Gaussian unitary ensemble) for qubit 2:

In[123]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {2}];
operator["Operator"]
Out[123]=

Represent a two-qubit random unitary operator (selected from a Gaussian unitary ensemble) for qubits 2 and 3:

In[124]:=
operator2 = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {2, 3}];
operator2["Operator"]
Out[124]=

Represent a single-qudit random unitary operator (selected from a Gaussian unitary ensemble) on 3-dimensional qudits for qudit 2:

In[125]:=
operator3 = ResourceFunction[
   "QuantumDiscreteOperator"][{"RandomUnitary", 3}, {2}];
operator3["Operator"]
Out[125]=

Represent a two-qudit random unitary operator (selected from a Gaussian unitary ensemble) on 3-dimensional qudits for qudits 2 and 3:

In[126]:=
operator4 = ResourceFunction[
   "QuantumDiscreteOperator"][{"RandomUnitary", 3}, {2, 3}];
operator4["Operator"]
Out[126]=

QuantumDiscreteOperator objects can be constructed purely symbolically (without explicit matrix elements):

In[127]:=
operator = ResourceFunction["QuantumDiscreteOperator"][{{a, b}, {c, d}}]
Out[127]=

View the operator association:

In[128]:=
operator["Operator"]
Out[128]=

Standard operations can still be performed on purely symbolic operators/states:

In[129]:=
state = ResourceFunction["QuantumDiscreteState"][{x, y}]
Out[129]=
In[130]:=
state2 = operator[state]
Out[130]=
In[131]:=
state2["Amplitudes"]
Out[131]=
In[132]:=
state2["DensityMatrix"]
Out[132]=

View a list of properties that can be extracted from a QuantumDiscreteOperator object:

In[133]:=
operator = ResourceFunction["QuantumDiscreteOperator"]["RandomUnitary", {2, 3}]
Out[133]=
In[134]:=
operator["Properties"]
Out[134]=

Return the operator association:

In[135]:=
operator["Operator"]
Out[135]=

Return which QuantumBasis the operator is defined with respect to:

In[136]:=
operator["Basis"]
Out[136]=

Return which quantum mechanical picture the operator is defined with respect to:

In[137]:=
operator["Picture"]
Out[137]=

Return the association of names and basis elements:

In[138]:=
operator["BasisElements"]
Out[138]=

Return the matrix representation:

In[139]:=
operator["MatrixRepresentation"]
Out[139]=

Return the ordered matrix representation (when applied to qubits 2 and 3) assuming a state consisting of 3 qubits:

In[140]:=
operator["OrderedMatrixRepresentation"]
Out[140]=

Return the ordered matrix representation (when applied to qubits 2 and 3) assuming a state consisting of 4 qubits:

In[141]:=
operator[{"OrderedMatrixRepresentation", 4}]
Out[141]=

Return the arity (number of input subsystems):

In[142]:=
operator["Arity"]
Out[142]=

Return the number of dimensions:

In[143]:=
operator["Dimensions"]
Out[143]=

Return the order in which the operator is applied to subsystems:

In[144]:=
operator["Order"]
Out[144]=

Determine whether the operator is Hermitian:

In[145]:=
operator["HermitianQ"]
Out[145]=

Determine whether the operator is unitary:

In[146]:=
operator["UnitaryQ"]
Out[146]=

Return the list of eigenvalues:

In[147]:=
operator["Eigenvalues"]
Out[147]=

Return the list of eigenvectors:

In[148]:=
operator["Eigenvectors"]
Out[148]=

Publisher

Jonathan Gorard

Version History

  • 1.1.0 – 02 June 2021

Related Resources

License Information