QuantumComputing
ConvertDirac
convert quantum state between Dirac notation and an Array
Calling Sequence Parameters Description
Examples
Calling Sequence
ConvertDirac(state)
Parameters
state
-
polynom or Array; quantum state in Dirac notation (polynom) or as a multidimensional Array (Array)
Description
The ConvertDirac command converts a quantum state between Dirac notation and an Array. If the state is given in Dirac notation, it is converted to an Array; if the state is given as an Array, it is converted to Dirac notation.
In Dirac notation the number of qubits is represented by the number of indices on the wave function symbol; in Array notation the number of qubits is represented by the number of dimensions of the Array.
The two states of each qubit are denoted as 0 and 1 in Dirac notation; they are represented by the range 1..2 of each dimension in Array notation.
First we load the QuantumChemistry package
with⁡QuantumChemistry:
Next we load the QuantumComputing subpackage
withQuantumComputing;
ConvertDirac,Gate,InitialState,MeasureState,PrepareState,QubitPopulations,QubitPopulationsPlot
We can initialize a state of 4 qubits on our simulated quantum computer with the InitialState command
state0 ≔ InitialState4;
state0≔Ψ0,0,0,0
The initial wave function has each of its 4 qubits in the lower state of the qubit, denoted by 0. To illustrate preparing a state on the quantum computer, let's use a product of gates (unitary transformations), known as a circuit, to prepare a Schrodinger cat state in which the state of all qubits down becomes entangled with the state of all qubits up. In QCT the circuit is readily assemble as a Maple list of equations. The left side of an equation indicates the qubit or qubits on which the gate acts and the right side provides the gate itself.
circuit ≔ 1= GateH,seqi,i+1=GateCNOT, i=1..3;
circuit≔1=222222−22,1,2=1000000100100100,2,3=1000000100100100,3,4=1000000100100100
To prepare the new state, we act on the initial state state0 with our circuit
state2 ≔ PrepareStatecircuit,state0;
state2≔2⁢Ψ0,0,0,02+2⁢Ψ1,1,1,12
The new state entangles a state of 4 "down" qubits with a state of 4 "up" qubits. Like Schrodinger's cat, our state is half up and half down. We can convert the Dirac notation of state2 into an Array using ConvertDirac.
state3 ≔ ConvertDiracstate2;
Likewise, we can convert the Array notation of state3 into Dirac notation using a second call to ConvertDirac.
state4 ≔ ConvertDiracstate3;
state4≔2⁢Ψ0,0,0,02+2⁢Ψ1,1,1,12
See Also
QuantumChemistry QuantumComputing
Download Help Document