Gallery of Quantum Gates by José Luis Gómez-Muñoz http://homepage.cem.itesm.mx/lgomez/quantum/ jose.luis.gomez@itesm.mx Introduction This is a tutorial on the use of Quantum`Computing` Mathematica add-on to use quantum gates in quantum circuits and algorithms Load the Package First load the Quantum`Computing` package. Write: Needs["Quantum`Computing`"] then press at the same time the keys -Û to evaluate. Mathematica will load the package. Needs@"Quantum`Computing`"D In order to use the keyboard to enter quantum objects write: SetComputingAliases[ ]; then press at the same time the keys -Û to evaluate. The semicolon prevents Mathematica from printing the help message. Remember that SetComputingAliases[ ] must be evaluated again in each new notebook: SetComputingAliases@D; qˆ Gate The qˆ gate is the first Pauli gate on qubit q. In order enter the template for this gate, press the keys: [ESC]xg[ESC] then press [TAB] to select the place-holder (empty square) and write the qubit number or label: ˆ ˆ Use QuantumPlot to plot the gate in a quantum circuit:
v7gallery.nb QuantumPlotA ˆE This is a more interesting circuit (Teleportation) that includes this gate: QuantumPlotB 8ˆ<A ˆE 8ˆ<A ˆE QubitMeasurementB ˆ 8ˆ<A ˆE, :ˆ, ˆ>F, QuantumGateShifting FalseF This is the Dirac representation of this gate QuantumEvaluateA ˆE ˆ] Y0 ˆ 0 ˆ] Y ˆ This is the action of this gate on a qubit on state 0\ QuantumEvaluateA ˆ 0 ˆ]E ˆ] This is the action of this gate on a qubit on state \ QuantumEvaluateA ˆ ˆ]E 0 ˆ] The @qˆd gate negates qubit q, therefore a controlled @qˆd gate is the same as a controlled not gate (notice the use of two equal symbols == in order to indicate comparison instead of assignment):
v7gallery.nb QuantumEvaluateB 8ˆ<A ˆEF QuantumEvaluateB 8ˆ<A ˆEF True This is the matrix representation of this gate: QuantumMatrixFormA ˆE K 0 0 O This is the representation of this gate in terms of Pauli operators PauliExpandA ˆE σ,ˆ Products of Pauli gates are not simplified ˆ ˆ ˆ ˆ On the other hand, products of Pauli operators are simplified σ,ˆ σ,ˆ σ,ˆ qˆ Gate The qˆ gate is the second Pauli gate on qubit q. In order enter the template for this gate, press the keys: [ESC]yg[ESC] then press [TAB] to select the place-holder (empty square) and write the qubit number or label: ˆ ˆ Use QuantumPlot to plot the gate in a quantum circuit:
4 v7gallery.nb QuantumPlotA ˆE Notice the arragenment of gates in this quantum circuit: the gates are in different columns in the resulting plot: QuantumPlotA ˆ ˆ ˆ ˆ ˆE Even with the option QuantumGateShifting Ø False the gates are not in the same column QuantumPlotA ˆ ˆ ˆ ˆ ˆ, QuantumGateShifting FalseE There is a notation that allows to have all the gates in the same column. Press the keys [ESC]yggg[ESC] for the template:
v7gallery.nb 5 QuantumPlotB ˆ :ˆ,ˆ,ˆ> ˆF Both notations evaluate to the same Dirac expression: QuantumEvaluateA ˆ ˆ ˆE QuantumEvaluateB :ˆ,ˆ,ˆ>F True This is the Dirac representation of this gate QuantumEvaluateA ˆE ˆ] Y0 ˆ 0 ˆ] Y ˆ This is the matrix representation of this gate: QuantumMatrixFormA ˆE K 0 0 O This is the representation of this gate in terms of Pauli operators PauliExpandA ˆE σ,ˆ Products of Pauli gates are not simplified ˆ ˆ ˆ ˆ On the other hand, products of Pauli operators are simplified
6 v7gallery.nb σ,ˆ σ,ˆ σ,ˆ qˆ Gate The qˆ gate is the third Pauli gate on qubit q. In order enter the template for this gate, press the keys: [ESC]zg[ESC] then press [TAB] to select the place-holder (empty square) and write the qubit number or label: ˆ ˆ Use QuantumPlot to plot the gate in a quantum circuit: QuantumPlotA ˆE This is a more interesting circuit (Teleportation) that includes this gate: QuantumPlotDB 8ˆ<A ˆE 8ˆ<A ˆE QubitMeasurementB ˆ 8ˆ<A ˆE, :ˆ, ˆ>F, QuantumGateShifting FalseF This is the Dirac representation of this gate
v7gallery.nb 7 QuantumEvaluateA ˆE 0 ˆ] Y0 ˆ ˆ] Y ˆ Controlled-@qˆD gates are the same if the control qubit and the controlled qubit are exchanged (notice the use of two equal symbols == in order to indicate comparison instead of assignment): QuantumEvaluateB 8ˆ<A ˆEF == QuantumEvaluateB 8ˆ<A ˆEF True Controlled-@qˆD gates are the same if the control qubit and the controlled qubit are exchanged (notice the use of two equal symbols == in order to indicate comparison instead of assignment): QuantumEvaluateB F == QuantumEvaluateB F True This is the matrix representation of this gate: QuantumMatrixFormA ˆE K 0 0 O This is the representation of this gate in terms of Pauli operators
8 v7gallery.nb PauliExpandA ˆE σ,ˆ This is the representation of a controlled-@qˆd gate in terms of Pauli operators PauliExpandB 8ˆ<A ˆEF σ,ˆ σ,ˆ σ,ˆ σ,ˆ σ,ˆ σ,ˆ σ,ˆ σ,ˆ Notice that the representation is the same if the qubits are exchanged. This is a property of controlled-@qˆd gates: PauliExpandB 8ˆ<A ˆEF σ,ˆ σ,ˆ σ,ˆ σ,ˆ σ,ˆ σ,ˆ σ,ˆ σ,ˆ Identity Gate qˆ The qˆ gate is the identity gate on qubit q. In order enter the template for this gate, press the keys: [ESC]ig[ESC] then press [TAB] to select the place-holder (empty square) and write the qubit number or label: ˆ ˆ The identity gate leaves the qubit without nay change QuantumTableFormA ˆE Input Output 0 0 ˆ] 0 ˆ] ˆ] ˆ] This is an application of the identity gate: we get the representation of the @ˆD, taking into account that qubit ˆ also exists:
v7gallery.nb 9 QuantumMatrixFormA ˆ ˆE 0 0 0 0 0 0 0 0 0 0 0 0 The option QubitList can be used (instead of @ˆD) in order to specify that that qubit ˆ also exists: QuantumMatrixFormB ˆ, QubitList :ˆ, ˆ>F 0 0 0 0 0 0 0 0 0 0 0 0 If neither @ˆD nor QubitList->{ˆ,ˆ} are used, the QuantumMatrixForm assumes that ˆ is the only qubit: QuantumMatrixFormA ˆE K 0 0 O This is an application of the identity gate: we get the representation of the @ˆD, taking into account that qubits ˆ and ˆ also exists: QuantumMatrixFormA ˆ ˆ ˆE 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 This is the representation of this gate in terms of Pauli operators PauliExpandA ˆE σ,ˆ Pauli gates are not simplified ˆ ˆ ˆ ˆ
0 v7gallery.nb On the other hand, Pauli operators are simplified σ 0,ˆ σ,ˆ σ,ˆ Hadamard qˆ Gate The qˆ gate is the Hadamard gate on qubit q. In order enter the template for this gate, press the keys: [ESC]hg[ESC] then press [TAB] to select the place-holder (empty square) and write the qubit number or label: ˆ ˆ The matrix representation of the Hadamard gate: QuantumMatrixFormA ˆE The bra-ket representation of the Hadamard gate: QuantumEvaluateA ˆE 0 ˆ] Y0 ˆ ˆ] Y0 ˆ 0 ˆ] Y ˆ ˆ] Y ˆ This is the "truth table" for the Hadamard gate: QuantumTableFormA ˆE Input 0 0 ˆ] ˆ] Output 0 ˆ] ˆ] 0 ˆ] ˆ] A Hadamard gate is usually combined with a controlled-not gate in order to generate Bell states:
v7gallery.nb QuantumTableFormB 8ˆ<A ˆE ˆF Input 0 0 ˆ, 0 ˆ] 0 ˆ, ˆ] ˆ, 0 ˆ] ˆ, ˆ] Output 0 ˆ,0 ˆ] 0 ˆ, ˆ] 0 ˆ,0 ˆ] 0 ˆ, ˆ] ˆ, ˆ] ˆ,0 ˆ] ˆ, ˆ] ˆ,0 ˆ] The states generated by 8ˆ<A@ˆDE @ˆD are the Bell states: GridAQuantumEvaluateA99,ˆ,ˆ]=, 9,ˆ,ˆ]=, 9,ˆ,ˆ]=, 9,ˆ,ˆ]==E, Dividers AllE 0 ˆ,0 ˆ] 0 ˆ, ˆ] 0 ˆ,0 ˆ] 0 ˆ, ˆ] ˆ, ˆ] ˆ,0 ˆ] ˆ, ˆ] ˆ,0 ˆ] This is a "tensor power" of Hadamard gates: I ˆM ˆ ˆ ˆ Notice that the Hadamard gates are not in a column:
v7gallery.nb QuantumPlotBI ˆM 8ˆ<A ˆEF Notice that the Hadamard gates are not in a column: QuantumPlotBI ˆM 8ˆ<A ˆE, QuantumGateShifting FalseF There is a notation that allows to have all the gates in the same column. Press the keys [ESC]hggg[ESC] for the template:
v7gallery.nb QuantumPlotB :ˆ,ˆ,ˆ> 8ˆ<A ˆEF Both notations evaluate to the same Dirac expression: QuantumEvaluateBI ˆM F QuantumEvaluateB :ˆ,ˆ,ˆ>F True This is a more interesting circuit (Teleportation) that includes this gate: QuantumPlotB 8ˆ<A ˆE 8ˆ<A ˆE QubitMeasurementB ˆ 8ˆ<A ˆE, :ˆ, ˆ>F, QuantumGateShifting FalseF This is the Hadamard gate in terms of Pauli operators: PauliExpandA ˆE σ,ˆ σ,ˆ
4 v7gallery.nb Parametric Phase Gate qˆ@αd The αˆ gate is the parametric phase gate on qubit q. In order enter the template for this gate, press the keys: [ESC]pg[ESC] then press [TAB] to select the first place-holder (empty square) and write the qubit number or label. Press [TAB] again to select the remaining place-holder and write the parameter, for example t: ˆ@tD ˆ@tD Matrix representation: QuantumMatrixFormA ˆ@tDE 0 0 t Dirac representation: QuantumEvaluateA ˆ@tDE 0 ˆ] Y0 ˆ t ˆ] Y ˆ A specific value for the parameter: QuantumEvaluateA ˆ@πê4DE HL 0 ˆ] Y0 ˆ ˆ] Y ˆ The T-p/8 gate is a particular case of the parametric phase gate: SimplifyA ˆ@πê4D ˆE True The S-phase gate is another particular case of the parametric phase gate: SimplifyA ˆ@πêD ˆE True The Z-Pauli gate is another particular case of the parametric phase gate:
v7gallery.nb 5 SimplifyA ˆ@πD ˆE True This simple quantum circuit can be used to generate an arbitrary superposition in a single qubit: QuantumPlotA ˆ@βπêD ˆ ˆ@αD ˆ 0 ˆ]E p 0\ @ad Bb F Replace QuantumPlot with QuantumEvaluate in order to "simulate" the circuit operation: QuantumEvaluateA ˆ@βπêD ˆ ˆ@αD ˆ 0 ˆ]E α 0 ˆ] I π βm α I π βm ˆ] Press [ESC]pgg[ESC] to get the template that represents two phase gates with the same parameter: QuantumEvaluateB :ˆ,ˆ>@πêDF 0 ˆ, 0 ˆ] Y0 ˆ, 0 ˆ 0 ˆ, ˆ] Y0 ˆ, ˆ 0 ˆ, ˆ] Y0 ˆ, ˆ ˆ, 0 ˆ] Y ˆ, 0 ˆ ˆ, 0 ˆ] Y ˆ, 0 ˆ ˆ, ˆ] Y ˆ, ˆ ˆ, ˆ] Y ˆ, ˆ The two gates below, wich have the same parameter, represent the same as above: QuantumEvaluateA ˆ@πêD ˆ@πêDE 0 ˆ, 0 ˆ] Y0 ˆ, 0 ˆ 0 ˆ, ˆ] Y0 ˆ, ˆ 0 ˆ, ˆ] Y0 ˆ, ˆ ˆ, 0 ˆ] Y ˆ, 0 ˆ ˆ, 0 ˆ] Y ˆ, 0 ˆ ˆ, ˆ] Y ˆ, ˆ ˆ, ˆ] Y ˆ, ˆ The main use of the [ESC]pgg[ESC] template is to create circuit plots where both pahse gates are placed in the same column:
6 v7gallery.nb :QuantumPlotB :ˆ,ˆ>@πêD ˆF, QuantumPlotA ˆ@πêD ˆ@πêD ˆE> p B F :, p B F p B F > p B F The "quantum register" (press [ESC]qr[ESC]) notation has the same effect, with some advantages in the flexibility to name the qubits that make the register: 9QuantumPlotA egister@50,60,0,wd @πêd ˆ w50 E, QuantumPlotA ˆ@πêD ˆ@πêD ˆE= w50 p B F :, w60 p B F p B F > p B F
v7gallery.nb 7 qˆ Gate The qˆ gate is the S phase gate on qubit q. In order enter the template for this gate, press the keys: [ESC]sg[ESC] then press [TAB] to select the place-holder (empty square) and write the qubit number or label: ˆ ˆ Truth-table: QuantumTableFormA ˆE Input Output 0 0 ˆ] 0 ˆ] ˆ] ˆ] Matrix representation QuantumMatrixFormA ˆE K 0 0 O Bra-ket representation: QuantumEvaluateA ˆE 0 ˆ] Y0 ˆ ˆ] Y ˆ Gate in a circuit: QuantumPlotA ˆE This "Quantum Fourier Transform" for three qubits includes (a controlled) gate:
8 v7gallery.nb QuantumPlotB ˆ,ˆ ˆ 8ˆ<A ˆE ˆ 8ˆ<A ˆE 8ˆ<A ˆE ˆF The ˆ gate transformed to Pauli operators. PauliExpandA ˆE σ,ˆ σ,ˆ qˆ Gate The qˆ gate is the p/8 gate on qubit q. In order enter the template for this gate, press the keys: [ESC]tg[ESC] then press [TAB] to select the place-holder (empty square) and write the qubit number or label: ˆ ˆ Truth-table: QuantumTableFormA ˆE Input 0 0 ˆ] 0 ˆ] Output ˆ] HL ˆ] The fourth-power of the p/8 gate is the qˆ gate: 9QuantumTableFormA ˆ4E, QuantumTableFormA ˆE= Input Output : 0 0 ˆ] 0 ˆ], ˆ] ˆ] Input Output 0 0 ˆ] 0 ˆ] ˆ] ˆ] > The fourth-power of the p/8 gate is the qˆ gate:
v7gallery.nb 9 PauliExpandA ˆ4E σ,ˆ Matrix representation: QuantumMatrixFormA ˆE 0 0 Numerical matrix representation: NAQuantumMatrixFormA ˆEE. 0. K 0. 0.707070.70707 O Bra-ket representation: QuantumEvaluateA ˆE HL 0 ˆ] Y0 ˆ ˆ] Y ˆ This "Quantum Fourier Transform" for three qubits includes this gate. The evaluation of this command can take several seconds before showing the result: QuantumTableFormB ˆ,ˆ ˆ 8ˆ<A ˆE ˆ 8ˆ<A ˆE 8ˆ<A ˆE ˆF Input 0 0 ˆ, 0 ˆ, 0 ˆ] 0 ˆ, 0 ˆ, ˆ] 0 ˆ, ˆ, 0 ˆ] 0 ˆ, ˆ, ˆ] 4 ˆ, 0 ˆ, 0 ˆ] 5 ˆ, 0 ˆ, ˆ] 6 ˆ, ˆ, 0 ˆ] 7 ˆ, ˆ, ˆ] Output 0 ˆ,0 ˆ,0 ˆ] 0 ˆ,0 ˆ,0 ˆ] 0 ˆ,0 ˆ,0 ˆ] 0 ˆ,0 ˆ,0 ˆ] 0 ˆ,0 ˆ,0 ˆ] 0 ˆ,0 ˆ,0 ˆ] 0 ˆ,0 ˆ,0 ˆ] 0 ˆ,0 ˆ,0 ˆ] 0 ˆ,0 ˆ, ˆ] 0 ˆ, ˆ,0 ˆ] 0 ˆ, ˆ, ˆ] ˆ,0 ˆ,0 ˆ] ˆ,0 ˆ, ˆ] ˆ, ˆ,0 ˆ] I 0 ˆ, ˆ,0 ˆ] M 0 4 4 ˆ, 0 ˆ, ˆ] I ˆ,0 ˆ,0 M 0 4 4 ˆ, ˆ, ˆ] 0 ˆ,0 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b TraditionalFormAQuantumEvaluateA ˆ,ˆEE 00\X00 0\X0 0\X0 \X This "Quantum Fourier Transform" for three qubits includes the gate: QuantumPlotDB ˆ,ˆ ˆ 8ˆ<A ˆE ˆ 8ˆ<A ˆE 8ˆ<A ˆE ˆF Next circuit is equivalent to a Swap gate: QuantumPlotB 8ˆ<A ˆE 8ˆ<A ˆE 8ˆ<A ˆEF Next circuit is equivalent to a Swap gate:
v7gallery.nb QuantumEvaluateB F == QuantumEvaluateB F True 8q ˆ <B ˆ q FGate The 8qˆ <B qˆf gate is the control-not gate on qubits q, q. In order enter the template for this gate, press the keys: [ESC]cnot[ESC] then press [TAB] to select the place-holders (empty square) and write the qubit numbers or labels: 8ˆ<A ˆE 8ˆ<A ˆE The matrix representation QuantumMatrixFormB 8ˆ<A ˆEF 0 0 0 0 0 0 0 0 0 0 0 0 The tensor representation
v7gallery.nb QuantumTensorFormB 8ˆ<A ˆEF K 0 0 O K 0 0 0 0 O K 0 0 0 0 O K 0 0 O The truth table QuantumTableFormB 8ˆ<A ˆEF Input Output 0 0 ˆ, 0 ˆ] 0 ˆ, 0 ˆ] 0 ˆ, ˆ] 0 ˆ, ˆ] ˆ, 0 ˆ] ˆ, ˆ] ˆ, ˆ] ˆ, 0 ˆ] Next circuit is equivalent to a Swap gate: QuantumPlotB 8ˆ<A ˆE 8ˆ<A ˆE 8ˆ<A ˆEF Next circuit is equivalent to a Swap gate: QuantumTableFormB 8ˆ<A ˆE 8ˆ<A ˆE 8ˆ<A ˆEF Input Output 0 0 ˆ, 0 ˆ] 0 ˆ, 0 ˆ] 0 ˆ, ˆ] ˆ, 0 ˆ] ˆ, 0 ˆ] 0 ˆ, ˆ] ˆ, ˆ] ˆ, ˆ] ˆ ˆ ˆ q,q,q Gate The qˆ,qˆ,qˆ gate is the Toffoli gate (control-control-not) on qubits q, q, q. In order enter the template for this gate, press the keys: [ESC]toff[ESC] then press [TAB] to select the place-holders (empty square) and write the qubit numbers or labels:
4 v7gallery.nb ˆ,ˆ,ˆ :ˆ,ˆ> AˆE A Toffoli gate is actually a control-contol-not: QuantumPlotA ˆ,ˆ,ˆE Truth table: QuantumTableFormA ˆ,ˆ,ˆE Input Output 0 0 ˆ, 0 ˆ, 0 ˆ] 0 ˆ, 0 ˆ, 0 ˆ] 0 ˆ, 0 ˆ, ˆ] 0 ˆ, 0 ˆ, ˆ] 0 ˆ, ˆ, 0 ˆ] 0 ˆ, ˆ, 0 ˆ] 0 ˆ, ˆ, ˆ] 0 ˆ, ˆ, ˆ] 4 ˆ, 0 ˆ, 0 ˆ] ˆ, 0 ˆ, 0 ˆ] 5 ˆ, 0 ˆ, ˆ] ˆ, 0 ˆ, ˆ] 6 ˆ, ˆ, 0 ˆ] ˆ, ˆ, ˆ] 7 ˆ, ˆ, ˆ] ˆ, ˆ, 0 ˆ] This is the Toffoli gate in terms of Pauli operators:
v7gallery.nb 5 PauliExpandA ˆ,ˆ,ˆE 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ ˆ ˆ ˆ q,q,q Gate The qˆ,qˆ,qˆ gate is the Fredkin gate (control-swap) on qubits q, q, q. In order enter the template for this gate, press the keys: [ESC]fred[ESC] then press [TAB] to select the place-holders (empty square) and write the qubit numbers or labels: ˆ,ˆ,ˆ 8ˆ<A ˆ,ˆE A Fredkin gate is actually a control-swap: QuantumPlotA ˆ,ˆ,ˆE Truth table:
6 v7gallery.nb QuantumTableFormA ˆ,ˆ,ˆE Input Output 0 0 ˆ, 0 ˆ, 0 ˆ] 0 ˆ, 0 ˆ, 0 ˆ] 0 ˆ, 0 ˆ, ˆ] 0 ˆ, 0 ˆ, ˆ] 0 ˆ, ˆ, 0 ˆ] 0 ˆ, ˆ, 0 ˆ] 0 ˆ, ˆ, ˆ] 0 ˆ, ˆ, ˆ] 4 ˆ, 0 ˆ, 0 ˆ] ˆ, 0 ˆ, 0 ˆ] 5 ˆ, 0 ˆ, ˆ] ˆ, ˆ, 0 ˆ] 6 ˆ, ˆ, 0 ˆ] ˆ, 0 ˆ, ˆ] 7 ˆ, ˆ, ˆ] ˆ, ˆ, ˆ] This is the Toffoli gate in terms of Pauli operators: PauliExpandA ˆ,ˆ,ˆE 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ 4 σ,ˆ σ,ˆ σ,ˆ TraditionalForm gives a format closer to the format used in papers and textbooks: TraditionalFormAPauliExpandA ˆ,ˆ,ˆEE - 4 s s s 4 s s s - 4 s s s 4 s s s 4 s s s 4 s s s - 4 s s s 4 s s s Controlled Gates Truth table for an arbitrary controlled-gate. Press [ESC]cgate[ESC] for the controlled-gate template 8ˆ<@D and [ESC]qg[ESC] for the quantum gate template ˆ: SetQuantumGate@mygate, D; QuantumTableFormB 8ˆ<Amygate ˆEF Input Output 0 0 ˆ, 0 ˆ] 0 ˆ, 0 ˆ] 0 ˆ, ˆ] 0 ˆ, ˆ] ˆ, 0 ˆ] ˆ] mygate ˆ 0 ˆ] ˆ, ˆ] ˆ] mygate ˆ ˆ] Matrix representation for an arbitrary controlled-gate. Press [ESC]cgate[ESC] for the controlled-gate template:
v7gallery.nb 7 SetQuantumGate@mygate, D; QuantumMatrixFormB 8ˆ<Amygate ˆEF 0 0 0 0 0 0 0 0 Y0 ˆ mygate ˆ 0 ˆ] Y0 ˆ mygate ˆ ˆ] 0 0 Y ˆ mygate ˆ 0 ˆ] Y ˆ mygate ˆ ˆ] Bra-ket representation for an arbitrary controlled-gate. Press [ESC]cgate[ESC] for the controlled-gate template: SetQuantumGate@mygate, D; QuantumEvaluateB 8ˆ<Amygate ˆEF 0 ˆ, 0 ˆ] Y0 ˆ, 0 ˆ 0 ˆ, ˆ] Y0 ˆ, ˆ ˆ] mygate ˆ Y ˆ Quantum Fourier Transform Press [ESC]qft[ESC] for the template of the one-qubit Quantum Fourier Transform ˆ ˆ Its truth table: QuantumTableFormA ˆE Input Output 0 0 ˆ] 0.70707 0 ˆ]0.70707 ˆ] ˆ] 0.70707 0 ˆ] 0.70707 ˆ] Press [ESC]qqft[ESC] for the template of the two-qubits Quantum Fourier Transform. Scroll to the right in order to see the full answer: QuantumTableFormA ˆ,ˆE Input Output 0 0 ˆ, 0 ˆ] 0.5 0 ˆ, 0 ˆ]0.5 0 ˆ, ˆ]0.5 ˆ, 0 ˆ]0.5 ˆ, ˆ] 0 ˆ, ˆ] 0.5 0 ˆ, 0 ˆ]0.5 0 ˆ, ˆ] 0.5 ˆ, 0 ˆ] 0.5 ˆ, ˆ] ˆ, 0 ˆ] 0.5 0 ˆ, 0 ˆ] 0.5 0 ˆ, ˆ]0.5 ˆ, 0 ˆ] 0.5 ˆ, ˆ] ˆ, ˆ] 0.5 0 ˆ, 0 ˆ] 0.5 0 ˆ, ˆ] 0.5 ˆ, 0 ˆ]0.5 ˆ, ˆ]
8 v7gallery.nb The Hermitian Conjugate of any gate is its inverse, because by definition all gates are unitary (they preserve the norm of the state kets). Therefore, the Hermitian of the Quantum Fourier Transform is the inverserse transform, as you can see by comparing the result of the calculation below with the last row of the table above. Press [ESC]her[ESC] for the Hermitian Conjugate template HL, and press [ESC]qqft[ESC] for the template of the two-qubits Quantum Fourier Transform ˆ,ˆ: QuantumEvaluateBI ˆ,ˆM 0 ˆ, 0 ˆ] 0 ˆ, ˆ] ˆ, 0 ˆ] ˆ, ˆ] F H0.0. L 0 ˆ, 0 ˆ]0. 0 ˆ, ˆ]H0.0. L ˆ, 0 ˆ]. ˆ, ˆ] Chop replaces approximate real numbers in expr that are close to zero by the exact integer 0: ChopBQuantumEvaluateBI ˆ,ˆM 0 ˆ, 0 ˆ] 0 ˆ, ˆ] ˆ, 0 ˆ] ˆ, ˆ] FF. ˆ, ˆ] Press [ESC]qqqft[ESC] for the template of the three-qubits Quantum Fourier Transform. Scroll to the right in order to see the full answer: QuantumTableFormA ˆ,ˆ,ˆE Input Output 0 0 ˆ, 0 ˆ, 0 ˆ] 0.555 0 ˆ, 0 ˆ, 0 ˆ]0.555 0 ˆ, 0 ˆ, ˆ]0.555 0 ˆ, ˆ, 0 ˆ] 0 ˆ, 0 ˆ, ˆ] 0.555 0 ˆ, 0 ˆ, 0 ˆ]H0.50.5 L 0 ˆ, 0 ˆ, ˆ]0.555 0 ˆ, 0 ˆ, ˆ, 0 ˆ] 0.555 0 ˆ, 0 ˆ, 0 ˆ]0.555 0 ˆ, 0 ˆ, ˆ] 0.555 0 ˆ, ˆ, 0 ˆ] 0 ˆ, ˆ, ˆ] 0.555 0 ˆ, 0 ˆ, 0 ˆ] H0.5 0.5 L 0 ˆ, 0 ˆ, ˆ] 0.555 0 ˆ, 4 ˆ, 0 ˆ, 0 ˆ] 0.555 0 ˆ, 0 ˆ, 0 ˆ] 0.555 0 ˆ, 0 ˆ, ˆ]0.555 0 ˆ, ˆ, 0 ˆ] 5 ˆ, 0 ˆ, ˆ] 0.555 0 ˆ, 0 ˆ, 0 ˆ] H0.50.5 L 0 ˆ, 0 ˆ, ˆ]0.555 0 ˆ, 6 ˆ, ˆ, 0 ˆ] 0.555 0 ˆ, 0 ˆ, 0 ˆ] 0.555 0 ˆ, 0 ˆ, ˆ] 0.555 0 ˆ, ˆ, 0 ˆ] 7 ˆ, ˆ, ˆ] 0.555 0 ˆ, 0 ˆ, 0 ˆ]H0.5 0.5 L 0 ˆ, 0 ˆ, ˆ] 0.555 0 ˆ, Press [ESC]qqqqft[ESC] for the template of the four-qubits Quantum Fourier Transform. Scroll to the right in order to see the full answer:
v7gallery.nb 9 QuantumTableFormA ˆ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 H0.0956709 0.09 000\ 0.5 0000\ H0.76777 0.76777 ÂL 000\ 0.5 Â 000\- H0.76777-0.76777 ÂL 00\- 0.5 00\ 0.5 0000\ H0.0956709 0.097 ÂL 000\- H0.76777-0.76777 ÂL 000\- H0.097 0.095670 4 000\ 0.5 0000\0.5Â 000\-0.5 000\-0.5Â 00\0.5 000\0.5Â 00\-0.5 00 5 00\ 0.5 0000\- H0.0956709-0.097 ÂL 000\- H0.76777 0.76777 ÂL 000\ H0.097-0.095670 6 00\ 0.5 0000\- H0.76777-0.76777 ÂL 000\- 0.5 Â 000\ H0.76777 0.76777 ÂL 00\- 0.5 7 0\ 0.5 0000\- H0.097-0.0956709 ÂL 000\ H0.76777-0.76777 ÂL 000\- H0.0956709-0.09 8 000\ 0.5 0000\- 0.5 000\ 0.5 000\- 0.5 00\ 0.5 000\- 0.5 00\ 0.5 00\- 9 00\ 0.5 0000\- H0.097 0.0956709 ÂL 000\ H0.76777 0.76777 ÂL 000\- H0.0956709 0.09 0 00\ 0.5 0000\- H0.76777 0.76777 ÂL 000\ 0.5 Â 000\ H0.76777-0.76777 ÂL 00\- 0.5 0\ 0.5 0000\- H0.0956709 0.097 ÂL 000\- H0.76777-0.76777 ÂL 000\ H0.097 0.095670 00\ 0.5 0000\-0.5Â 000\-0.5 000\0.5Â 00\0.5 000\-0.5Â 00\-0.5 00 0\ 0.5 0000\ H0.0956709-0.097 ÂL 000\- H0.76777 0.76777 ÂL 000\- H0.097-0.095670 4 0\ 0.5 0000\ H0.76777-0.76777 ÂL 000\- 0.5 Â 000\- H0.76777 0.76777 ÂL 00\- 0.5 5 \ 0.5 0000\ H0.097-0.0956709 ÂL 000\ H0.76777-0.76777 ÂL 000\ H0.0956709-0.09
0 v7gallery.nb by José Luis Gómez-Muñoz http://homepage.cem.itesm.mx/lgomez/quantum/ jose.luis.gomez@itesm.mx