Pauli: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Added multi-qubit functionality |
||
| Line 9: | Line 9: | ||
:<math>X = \begin{bmatrix}0 & 1\\ 1 & 0\end{bmatrix}, \ \ Y = \begin{bmatrix}0 & -i\\ i & 0\end{bmatrix}, \ \ Z = \begin{bmatrix}1 & 0\\ 0 & -1\end{bmatrix}, \ \ I = \begin{bmatrix}1 & 0\\ 0 & 1\end{bmatrix}.</math> | :<math>X = \begin{bmatrix}0 & 1\\ 1 & 0\end{bmatrix}, \ \ Y = \begin{bmatrix}0 & -i\\ i & 0\end{bmatrix}, \ \ Z = \begin{bmatrix}1 & 0\\ 0 & -1\end{bmatrix}, \ \ I = \begin{bmatrix}1 & 0\\ 0 & 1\end{bmatrix}.</math> | ||
This function can also produce multi-qubit Pauli operators. | |||
==Syntax== | ==Syntax== | ||
| Line 15: | Line 17: | ||
==Argument descriptions== | ==Argument descriptions== | ||
* <tt>IND</tt>: An index indicating which Pauli operator you would like to be generated. Values of <tt>1</tt>, <tt>2</tt>, <tt>3</tt>, and <tt>0</tt> correspond to the Pauli X, Y, Z, and identity operators, respectively. Values of <tt>' | * <tt>IND</tt>: An index indicating which Pauli operator you would like to be generated. Values of <tt>1</tt>, <tt>2</tt>, <tt>3</tt>, and <tt>0</tt> correspond to the Pauli X, Y, Z, and identity operators, respectively. Values of <tt>'I'</tt>, <tt>'X'</tt>, <tt>'Y'</tt>, and <tt>'Z'</tt> are also accepted, and indicate the Pauli identity, X, Y, and Z operators, respectively. If <tt>IND</tt> is a vector then this function returns a multi-qubit Pauli operator whose action on the <tt>K</tt>-th qubit is the same as <tt>Pauli(K)</tt>. | ||
* <tt>SP</tt> (optional, default | * <tt>SP</tt> (optional, default 1): A flag (either 1 or 0) indicating that the Pauli operator produced should or should not be sparse. | ||
==Examples== | ==Examples== | ||
===Single-qubit examples=== | |||
<syntaxhighlight> | <syntaxhighlight> | ||
>> Pauli(' | >> full(Pauli('X')) | ||
ans = | ans = | ||
| Line 27: | Line 30: | ||
1 0 | 1 0 | ||
>> Pauli(1) | >> full(Pauli(1)) | ||
ans = | ans = | ||
| Line 34: | Line 37: | ||
1 0 | 1 0 | ||
>> Pauli(0) | >> full(Pauli(0)) | ||
ans = | ans = | ||
| Line 41: | Line 44: | ||
0 1 | 0 1 | ||
>> Pauli(' | >> full(Pauli('Y')) | ||
ans = | ans = | ||
| Line 48: | Line 51: | ||
0.0000 + 1.0000i 0.0000 + 0.0000i | 0.0000 + 1.0000i 0.0000 + 0.0000i | ||
>> Pauli(' | >> Pauli('Z',1) % sparse Pauli Z operator | ||
ans = | ans = | ||
| Line 54: | Line 57: | ||
(1,1) 1 | (1,1) 1 | ||
(2,2) -1 | (2,2) -1 | ||
</syntaxhighlight> | |||
===Multi-qubit examples=== | |||
<syntaxhighlight> | |||
>> full(Pauli('XZI')) % the three-qubit Pauli operator X \otimes Z \otimes I | |||
ans = | |||
0 0 0 0 1 0 0 0 | |||
0 0 0 0 0 1 0 0 | |||
0 0 0 0 0 0 -1 0 | |||
0 0 0 0 0 0 0 -1 | |||
1 0 0 0 0 0 0 0 | |||
0 1 0 0 0 0 0 0 | |||
0 0 -1 0 0 0 0 0 | |||
0 0 0 -1 0 0 0 0 | |||
>> Pauli([0,1,2]) % the three-qubit Pauli operator I \otimes X \otimes Y | |||
ans = | |||
(4,1) 0 + 1.0000i | |||
(3,2) 0 - 1.0000i | |||
(2,3) 0 + 1.0000i | |||
(1,4) 0 - 1.0000i | |||
(8,5) 0 + 1.0000i | |||
(7,6) 0 - 1.0000i | |||
(6,7) 0 + 1.0000i | |||
(5,8) 0 - 1.0000i | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 21:52, 27 November 2014
| Pauli | |
| Produces a Pauli operator | |
| Other toolboxes required | none |
|---|---|
| Related functions | GellMann GenGellMann GenPauli |
| Function category | Special states, vectors, and operators |
Pauli is a function that produces the 2-by-2 Pauli X, Y, Z, or identity operator, as defined here:
- <math>X = \begin{bmatrix}0 & 1\\ 1 & 0\end{bmatrix}, \ \ Y = \begin{bmatrix}0 & -i\\ i & 0\end{bmatrix}, \ \ Z = \begin{bmatrix}1 & 0\\ 0 & -1\end{bmatrix}, \ \ I = \begin{bmatrix}1 & 0\\ 0 & 1\end{bmatrix}.</math>
This function can also produce multi-qubit Pauli operators.
Syntax
- P = Pauli(IND)
- P = Pauli(IND,SP)
Argument descriptions
- IND: An index indicating which Pauli operator you would like to be generated. Values of 1, 2, 3, and 0 correspond to the Pauli X, Y, Z, and identity operators, respectively. Values of 'I', 'X', 'Y', and 'Z' are also accepted, and indicate the Pauli identity, X, Y, and Z operators, respectively. If IND is a vector then this function returns a multi-qubit Pauli operator whose action on the K-th qubit is the same as Pauli(K).
- SP (optional, default 1): A flag (either 1 or 0) indicating that the Pauli operator produced should or should not be sparse.
Examples
Single-qubit examples
>> full(Pauli('X'))
ans =
0 1
1 0
>> full(Pauli(1))
ans =
0 1
1 0
>> full(Pauli(0))
ans =
1 0
0 1
>> full(Pauli('Y'))
ans =
0.0000 + 0.0000i 0.0000 - 1.0000i
0.0000 + 1.0000i 0.0000 + 0.0000i
>> Pauli('Z',1) % sparse Pauli Z operator
ans =
(1,1) 1
(2,2) -1Multi-qubit examples
>> full(Pauli('XZI')) % the three-qubit Pauli operator X \otimes Z \otimes I
ans =
0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 -1 0
0 0 0 0 0 0 0 -1
1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
0 0 -1 0 0 0 0 0
0 0 0 -1 0 0 0 0
>> Pauli([0,1,2]) % the three-qubit Pauli operator I \otimes X \otimes Y
ans =
(4,1) 0 + 1.0000i
(3,2) 0 - 1.0000i
(2,3) 0 + 1.0000i
(1,4) 0 - 1.0000i
(8,5) 0 + 1.0000i
(7,6) 0 - 1.0000i
(6,7) 0 + 1.0000i
(5,8) 0 - 1.0000iSource code
Click here to view this function's source code on github.
External links
- Pauli matrices at Wikipedia