Wolfram/QuantumFramework

Perform analytic and numeric quantum computations

Contributed By: Wolfram Research, Quantum Computation Framework team

The Wolfram Quantum Framework brings a broad, coherent design for quantum computation, together with a host of leading-edge capabilities, and full integration into Mathematica and Wolfram Language. Starting from discrete quantum mechanics, the Framework provides a high-level symbolic representation of quantum bases, states, and operators. The Framework can perform measurements and is equipped with various well-known states and operators, such as Bell states and Pauli operators. Using such simulation capabilities as a foundation, one can use the Framework to model and simulate quantum circuits and algorithms.

All functions and objects in the Wolfram Quantum Framework work seamlessly with the 5,000+ built-in made available through Wolfram Language. The immediate availability of such functions allows one to study a full range of questions around quantum computation, and can serve as a helpful resource for teaching.

Installation Instructions

To install this paclet in your Wolfram Language environment, evaluate this code:
PacletInstall[ResourceObject["Wolfram/QuantumFramework"]]

Details

This paclet works with version 13.0 and higher of the Wolfram Language.

Paclet Guide

Examples

Quantum Basis and Quantum State (19) 

In order to use QuantumBasis, one gives dimension information as arguments, which will be interpreted as the computational basis. Alternatively, an association can be given with the basis name as the key and the corresponding basis elements as the values.


Define a 2D quantum basis (computational):

In[1]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumBasis", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumBasis\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumBasis"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumBasis"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][2]
Out[1]=

Given a basis of dimension n, the basis elements will be indexed by the key with :

In[2]:=
Normal /@ %["ElementAssociation"]
Out[2]=

Use QuantumBasis[n,m] to define a basis for qudits of dimension (for which the overall dimension will be ). For example, define a 2–2–2 dimensional quantum basis (with three qubits):

In[3]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumBasis", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumBasis\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumBasis"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumBasis"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][2, 3]
Out[3]=
In[4]:=
%["Dimensions"]
Out[4]=

Use QuantumBasis[{n1,n2,,nm}] to define an -dimensional Hilbert space of qudits as a list. For example, define a 3×5 dimensional quantum basis (with two qudits):

In[5]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumBasis", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumBasis\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumBasis"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumBasis"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{3, 5}]
Out[5]=

A basis can also be defined as an association with the basis element names as keys and the corresponding vectors as values:

In[6]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumBasis", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumBasis\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumBasis"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumBasis"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][<|a -> {1, I}, b -> {2, -I}|>]
Out[6]=
In[7]:=
Normal /@ %["ElementAssociation"]
Out[7]=

There are many 'named' bases built into the quantum framework, including "Computational", "PauliX", "PauliY", "PauliZ", "Fourier", "Identity", "Schwinger", "Pauli", "Dirac" and "Wigner" bases:

In[8]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/8968f248-16fe-4c29-ac11-0664b1ea336c"]
Out[8]=

After a basis object has been defined, it is straightforward to construct quantum states and operators. A quantum state is represented by a QuantumState object and a quantum operator is represented by QuantumOperator.

A pure quantum state is represented as a vector for which the elements are amplitudes. The corresponding basis should be given in this format: QuantumState[arg1,arg2], where arg1 specifies amplitudes or the density matrix, and arg2 specifies the basis. With no basis specified, the default basis will be the computational basis, the dimension of which depends on the amplitude vector given in arg1.

Note that we use the big endian convention, such that qubits are labelled left-to-right, starting with one. For example, the decimal representation of (which means 3) is . Additionally, for the eigenvalues of Pauli-Z, we have:

In[9]:=
Eigensystem[PauliMatrix[3]]
Out[9]=

We shall denote the eigenstate {1,0} by (which corresponds to +1 eigenvalue), and {0,1} by (corresponding to the eigenvalue -1)


Define a pure 2-dimensional quantum state (qubit) in the Pauli-X basis:

In[10]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/8ddaa622-5344-4395-ae4a-83d30d0fde69"]
Out[10]=
In[11]:=
%["Formula"]
Out[11]=

If the basis is not specified, the default is the computational basis of dimensions ( qubits):

In[12]:=
state = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{3, 2 I, 1, -5}]
Out[12]=
In[13]:=
state["Amplitudes"]
Out[13]=

If the vector has more than 2 elements, it is interpreted as an -qubit state, unless the dimension is specified. If fewer than amplitudes are specified, right-padding is applied to reach the 'ceiling':

In[14]:=
state = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{2, 0, I}]
Out[14]=
In[15]:=
state["Amplitudes"]
Out[15]=

Here is the same amplitude vector, but this time with the dimension specified:

In[16]:=
state = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{2, 0, I}, 3];
state["Amplitudes"]
Out[17]=

Binary strings can be also used as inputs:

In[18]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["001"]
Out[18]=

Many 'named' states are available through the framework:

In[19]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/9c88b304-37c7-4901-ab95-00ee9bf628ea"]
Out[19]=

Using associations, one can create a superposition of states, where the keys are lists of corresponding indexes and the values are amplitudes.

Create a superposition of 3 qubits (i.e., QuantumBasis[2,3]) as :

In[20]:=
\[Psi] = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][<|{0, 0, 0} -> 1/
    Sqrt[2], {1, 1, 1} -> 1/Sqrt[2]|>, 2, 3]
Out[20]=
In[21]:=
\[Psi]["Formula"]
Out[21]=
In[22]:=
\[Psi]["Dimensions"]
Out[22]=

A superposition can also be created by simply adding two quantum state objects. For example, the previous state can also be constructed as follows:

In[23]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/29710e1f-ac08-4c7e-a394-673faf714e42"]
Out[24]=

With a built-in basis specified, amplitudes correspond to the basis elements. For example, use the Bell basis:

In[25]:=
Normal /@ InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumBasis", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumBasis\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumBasis"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumBasis"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["Bell"][
  "ElementAssociation"]
Out[25]=
In[26]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/07b944ff-02ff-4e77-8550-b88c87f9514f"]
Out[26]=
In[27]:=
\[Psi]["Amplitudes"]
Out[27]=

A state can also be defined by inputting a density matrix:

In[28]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][
 1/2 (IdentityMatrix[2] + PauliMatrix[2])]
Out[28]=

For pure states, one can get the corresponding normalized state vector:

In[29]:=
%["Formula"]
Out[29]=

Define a generic Bloch vector:

In[30]:=
mat[r_] /; VectorQ[r] := 1/2 (IdentityMatrix[2] + r . Table[PauliMatrix[i], {i, 3}])
In[31]:=
r = {.1, .1, 0};
state = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][mat[r]]
Out[27]=

Test to see if it is a mixed state:

In[32]:=
state["MixedStateQ"]
Out[32]=

Calculate its Von Neumann entropy:

In[33]:=
state["VonNeumannEntropy"]
Out[33]=

Compute its purity:

In[34]:=
state["Purity"]
Out[34]=

Note that one can directly use a Bloch vector as an input:

In[35]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{"BlochVector", r}]
Out[35]=
In[36]:=
% == state
Out[36]=

Test to see if a matrix is positive semidefinite:

In[37]:=
mat[{1, 2, 0}] // PositiveSemidefiniteMatrixQ
Out[37]=

A matrix that is not positive semidefinite cannot be a density matrix in standard quantum mechanics (with some exceptional cases, such as ZX formalism). Here is the result when we attempt to define a state using such a matrix:

In[38]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][mat[{1, 2, 0}]]
Out[38]=

When a matrix is given as input, but no basis is given, the default basis will be computational:

In[39]:=
m = RandomComplex[{-1 - I, 1 + I}, {8, 8}];
\[Rho] = ConjugateTranspose[m] . m;
state = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][\[Rho]]
Out[27]=
In[40]:=
state["Dimensions"]
Out[40]=

Using , define a quantum state in a 2–4 dimensional basis (and note the number of qudits):

In[41]:=
state = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][\[Rho], {2, 4}]
Out[41]=
In[42]:=
state["Dimensions"]
Out[42]=

Define a quantum state in 8D Hilbert space (with one 8-dimensional qudit only):

In[43]:=
state = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][\[Rho], 8]
Out[43]=
In[44]:=
state["Dimensions"]
Out[44]=

One can also define a state in a given basis, and then transform it into a new basis. For example, transform , the computational basis, into the Pauli-X basis {,}:

In[45]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/f0400e78-f30b-44f5-bb4b-7f388ed4e9d6"]
Out[38]=

Return the amplitudes:

In[46]:=
\[Psi]1["Formula"]
Out[46]=
In[47]:=
\[Psi]2["Formula"]
Out[47]=

Note that the states are the same, but defined in different bases:

In[48]:=
\[Psi]1 == \[Psi]2
Out[48]=

One can use QuantumTensorProduct to construct different states or operators. Create a tensor product of a + state with three qubits :

In[49]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/a52b68b0-9245-449e-b878-6ec4dc086421"]
Out[38]=

Another way of defining is to first define a basis and then assign amplitudes:

In[50]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/d0011cc4-a14c-4d95-b920-7dfa0b7bcbd9"]
In[51]:=
\[Psi]2 = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{0, 0, 0, 0, 0, 0, 0, 1}, plusbasis];
\[Psi]2["Formula"]
Out[48]=
In[52]:=
\[Psi]2 == \[Psi]1
Out[52]=

Quantum Operators (10) 

Quantum operators can be defined by a matrix or by specifying eigenvalues with respect to a QuantumBasis. Additionally, there are many built-in named operators that can be used.


Define a Pauli-X operator:

In[53]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["PauliX"]
Out[53]=

Apply a Pauli-X operator to a symbolic state :

In[54]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/c8d7edaf-b630-436d-aae1-2e9321ffb7ac"]
Out[54]=

Test to see if the application of the Pauli-X operator yields the correct state:

In[55]:=
% == InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{\[Beta], \[Alpha]}]
Out[55]=

Apply the Hadamard operator :

In[56]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/c5b33079-5145-4b13-9c53-6bd36fa66a30"]
Out[56]=

Test to see if the application of the Hadamard operator yields the correct state:

In[57]:=
% == InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["Plus"]
Out[57]=

One can also compose operators. Here's a composition of two Hadamard operators and one Pauli-Z operator:

In[58]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/92146f43-9c3a-4be8-b6ed-b66f460156c8"]
Out[58]=

Check the relation :

In[59]:=
% == InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["PauliX"]
Out[59]=

Multi-qubit operators can take specific orders.

For instance, first define the state +:

In[60]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/77d84bc7-0cb6-488a-a7b5-48fafe97f0b1"]
Out[59]=

Then, apply a Pauli-X operator on the second qubit only (by defining an order for the operator):

In[61]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["PauliX", {2}][state]
Out[61]=

Test the result:

In[62]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/d7e4d628-34f1-4336-9f53-47245d545668"]
Out[62]=

For multi-qudit cases, one can define an order or construct the operator using QuantumTensorProduct. For example:

In[63]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/4a265d26-d609-46c3-88c0-525469bf64f4"]
Out[63]=

Generalize Pauli matrices to higher dimensions:

In[64]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{"PauliX", 3}]
Out[64]=

Convert to matrix form:

In[65]:=
%["Matrix"] // MatrixForm
Out[65]=

Generalize the Hadamard operator to more qubits:

In[66]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{"Hadamard", 3}]
Out[66]=

Test that the Hadamard operator can be constructed as a tensor product :

In[67]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/9ee4cae7-5464-4d2d-a287-a8c7a8aa4288"]
Out[67]=

One can define a "ControlledU" operator with specific target and control qudits:

In[68]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/54de1b6e-8c6d-4750-8f00-13aef657e06c"]

Return the control and target qudits:

In[69]:=
AssociationMap[ct, {"ControlOrder", "TargetOrder"}]
Out[69]=

Get the action of the operator (T-controlled (1, 2)) on :

In[70]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/686d80a2-694f-4c99-abce-bf350e7325ac"]
Out[70]=
In[71]:=
%["Formula"]
Out[71]=

Note that "CT" is also a 'named' controlled operator in our framework:

In[72]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["CT"] == ct
Out[72]=

One can create a new operator by performing some mathematical operations (e.g., exponential, fraction power, etc.) on a quantum operator:

In[73]:=
Exp[-I \[Phi]/2 InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["X"]]
Out[73]=

Show that the result is the same as a rotation operator around x:

In[74]:=
% == InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{"XRotation", \[Phi]}]
Out[74]=

Get the fractional power of the NOT operator:

In[75]:=
Sqrt[InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["NOT"]]
Out[75]=
In[76]:=
%["Matrix"]
Out[76]=

Time Evolution Operators (4) 

Time evolution can be implemented by adding a parametric specification to any operator. Then, using the EvolutionOperator property of a quantum operator, one can generate the corresponding time evolution operator.

Unitary operator and analytic solution of time-dependent Schrödinger equation (2) 

Setting a Pauli-X operator as the Hamiltonian and evolving , we get:

In[77]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/7b5d7ed1-c5f8-4c6d-a62f-6d2288151841"]
Out[74]=

Return the amplitudes at time :

In[78]:=
\[Psi]f["StateVector"] // Normal
Out[78]=

Evolution in a time-dependent field: nuclear magnetic resonance (NMR): (2) 

Set up the Hamiltonian (as a time-dependent operator) in a magnetic field :

In[79]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/07b4b333-5780-420a-8274-4913eb546cd7"]
In[80]:=
u = hamiltonian["EvolutionOperator"];
\[Psi]f = u@InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{Cos[\[Alpha]/2], Sin[\[Alpha]/2]}]
Out[78]=

Get the state vector for the pure state:

In[81]:=
\[Psi]f["StateVector"] // Normal // FullSimplify
Out[81]=

Quantum Measurement (12) 

In the Wolfram Quantum Framework, one can study projective measurements or, generally, any positive operator-valued measurement (POVM), using QuantumMeasurementOperator.

PVMs (projective measurements) (5) 

A measurement can be defined by specifying the corresponding measurement basis.


Measure a 3D system in its state basis:

In[82]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/61cb5417-b98b-49e6-a02f-8640b161f1a9"]
Out[43]=
In[83]:=
m["ProbabilityPlot"]
Out[83]=

Test to confirm that the measured states are the same as the basis states:

In[84]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/22d08941-5372-4b9b-a5cb-6695648a5e94"]
Out[84]=

Measure a 2-qubit system in the computational basis:

In[85]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/2ab99936-cb6d-4656-8da6-92eda4364f5e"]
Out[86]=
In[87]:=
m["ProbabilityPlot"]
Out[87]=

Note the labels represents the corresponding eigenvalues, from 0 to n-1. One can get the corresponding computational basis representation as follows:

In[88]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumMeasurement", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumMeasurement\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurement"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurement"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][m, "Label" -> Automatic]["ProbabilityPlot"]
Out[88]=

For composite systems, one can measure one or more qudits. This can be done by specifying an order for QuantumMeasurementOperator.

2D×3D composite system:

In[89]:=
\[Psi]0 = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][
   "RandomPure", {2, 3}];

Measure only the first qudit:

In[90]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumMeasurementOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumMeasurementOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][\[Psi]0[
    "Dimensions"], {1}][\[Psi]0]["ProbabilityPlot"]
Out[90]=

Measure only the 2nd qudit:

In[91]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumMeasurementOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumMeasurementOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][\[Psi]0[
    "Dimensions"], {2}][\[Psi]0]["ProbabilityPlot"]
Out[91]=

Measure both qudits:

In[92]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumMeasurementOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumMeasurementOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][\[Psi]0["Dimensions"], {1, 2}][\[Psi]0]["ProbabilityPlot"]
Out[92]=

One can use the following format for 'named' bases and their corresponding eigenvalues: QuantumMeasurementOperator[nameeigenvalues].

For example, define a measurement operator with a 'named‘ QuantumBasis (as an eigenbasis) and a list of eigenvalues:

In[93]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumMeasurementOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumMeasurementOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["Bell" -> {1, 2, 3, 4}]
Out[93]=

POVMs (7) 

One can also give a list of POVM elements by which to define the measurement operator:

In[94]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/6d8671a3-539f-4d09-b8dd-feb006125cb3"]

Check that all POVM elements are explicitly positive semidefinite:

In[95]:=
PositiveSemidefiniteMatrixQ[#["Matrix"]] & /@ povm
Out[95]=

Check the completeness relations:

In[96]:=
Total[povm] == InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["Identity"]
Out[96]=

Measure POVMs on a quantum state:

In[97]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/0727f841-ac2d-422d-9dae-8d4b2029b473"]

Get the post-measurement states:

In[98]:=
qm["StatesAssociation"]
Out[98]=

Get the corresponding probabilities:

In[99]:=
qm["Probabilities"]
Out[99]=

Show post-measurement states are the same as states we defined POVMs initially:

In[100]:=
Thread[qm["States"] == states]
Out[100]=

Quantum Circuits (8) 

Trace out the second subsystem in a 2-qubit state:

In[101]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/f790b5c9-28b5-41f6-a649-f83c32938108"]
Out[101]=

A partial trace can also be applied to QuantumBasis:

In[102]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/46b4d92e-9bf7-4c6a-85f9-d1b526aa2840"]
Out[102]=

There are several metrics by which one can measure entanglement between two qudits, such as concurrence, entanglement entropy, negativity, etc. The calculation of entanglement measure is represented by the QuantumEntanglementMonotone function.

Plotting various entanglement measure for the state :

In[103]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/6db68161-2cfe-4509-8fe4-5fd0cf9b32f2"]
Out[103]=

To know whether a state is entangled or separable without computing its measure, use QuantumEntangledQ.

Check whether subsystems 1 and 3 are entangled in the "W" state:

In[104]:=
state = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["W"];
state["Formula"]
Out[102]=
In[105]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumEntangledQ", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumEntangledQ\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumEntangledQ"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumEntangledQ"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][state, {{1}, {3}}]
Out[105]=

In quantum information, there exist notions of distance between quantum states, such as fidelity, trace distance, Bures angle, etc. One can use QuantumDistance to compute the distance between two quantum states with various metrics.

Measure the trace distance between a pure state and a mixed state:

In[106]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/4a886dba-97b6-4a83-9e3a-90cc9bec4168"]
In[107]:=
AssociationMap[InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumDistance", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumDistance\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumDistance"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumDistance"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][\[Psi]1, \[Psi]2, #] &, {"Fidelity", "Trace", "BuresAngle", "HilbertSchmidt"}]
Out[107]=

One may create a list of QuantumOperator and/or QuantumMeasurementOperator objects to build a quantum circuit, which can be represented as a QuantumCircuitOperator object.

Construct a quantum circuit that includes a controlled Hadamard gate:

In[108]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/215070ef-d829-495d-9c9e-2314cddcc224"]
Out[102]=

The wire labels can be customized:

In[109]:=
qc["Diagram", "WireLabels" -> {{Placed["\!\(\*SubscriptBox[\(a\), \(i\)]\)", Left],
     Placed["\!\(\*SubscriptBox[\(a\), \(f\)]\)", Right]}, {Placed[
     "\!\(\*SubscriptBox[\(b\), \(i\)]\)", Left], Placed["\!\(\*SubscriptBox[\(b\), \(f\)]\)", Right]}}, "MeasurementWireLabel" -> "M"]
Out[109]=

Construct a Toffoli gate as a circuit:

In[110]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/2b185e83-212e-4903-9f67-c916d9a10287"]
Out[110]=

Show that the circuit is the same as the Toffoli gate:

In[111]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["Toffoli"] == qc["CircuitOperator"]
Out[111]=

One can define more than one control and target qubit:

In[112]:=
controls = {1, 3};
targets = {2};

Define the unitary operator and controlled-u operator:

In[113]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/ecf4825f-6908-41c8-91bb-252e694141b7"]
Out[95]=

Return the control qubits:

In[114]:=
cu["ControlOrder"]
Out[114]=

Return the target qubits:

In[115]:=
cu["TargetOrder"]
Out[115]=

Define the control-0 qubits:

In[116]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/2e47a6d2-30a8-42d0-a4d6-62d8344c0e57"]
Out[44]=

Define a combination of control-0 and control-1 qubits:

In[117]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/c9e39ce5-e36d-45a5-895e-aac3bf4caa19"]
Out[100]=

Measurement operators can also be added to a quantum circuit. For a single-qubit unitary operator with eigenvalues ±1, a measurement of can be implemented in the following circuit. (Note that here, Pauli-Y is considered a operator):

In[118]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/16835f9d-4a18-4c97-8a1f-ae7febea1386"]
Out[111]=

Applying the circuit operators to a quantum state results in a quantum measurement:

In[119]:=
m = qc[InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{"Register", 2}]]
Out[119]=

Calculate the state of the second qubit after the measurement by tracing over the first qubit:

In[120]:=
statesQ2 = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumPartialTrace", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumPartialTrace\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumPartialTrace"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumPartialTrace"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][#, {1}] & /@ m["States"]
Out[120]=
In[121]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/883435e0-1fb9-408b-899b-aced67a74924"]
Out[121]=

The post-measurement states of the second qubit should be the same as the Pauli-Y eigenstates.

Quantum Protocols & Algorithms (59) 

Superdense coding (5) 

Alice wants to send Bob two classical bits: 00, 01, 10, or 11. She can do so by using a single qubit if her qubit and Bob's are initially prepared as Bell states:

In[122]:=
\[Phi] = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["PhiPlus"];
\[Phi]["Formula"]
Out[123]=

Depending on Alice's intended message, she will perform the following operations on her qubit:

1. To send 00, she does nothing.

2. To send 01, she applies the X-gate.

3. To send 10, she applies the Z-gate.

4. To send 11, she applies the X-gate and then the Z-gate.

Such operations can be represented as circuits, each with a final state resulting from application of its respective gate(s) to the initial Bell state:

In[124]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/cfaa9d7f-de04-4b71-a71c-8a41c20d12ad"]
Out[124]=

Next, Alice sends her qubit to Bob through a quantum channel. If Bob performs a Bell measurement on his qubits, he receives Alice’s message.

Alice's 'messaging' with Bob can be fully implemented in a quantum circuit using two ancillary qubits. In the circuit, the 1st qubit is Alice's, the 2nd one is Bob's, and the 3rd and the 4th are the ancillary qubits. (Note that Alice sends her qubit to Bob and Bob performs a measurement on qubits 1 and 2):

In[125]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/1a27d6e2-0848-45e8-97c3-337bbf50a8f7"]
Out[114]=

Define an initial state as , where is the code that Alice wants to send Bob, which is encoded in two ancillary qubits (qubits 3 and 4).

Run the state through the circuit and return the outcome probabilities:

In[126]:=
superdense[InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][
      "00" <> #1 <> #2]]["ProbabilityPlot"] & @@@ Tuples[{"0", "1"}, 2] // Row
Out[126]=

For each case, Bob finds Alice's code with probability 1.

Quantum teleportation (4) 

Quantum teleportation is the reverse of superdense coding. Here, one wants to teleport a generic unknown quantum bit. Suppose that Alice wants to send a qubit (qubit 1) to Bob. To implement a quantum circuit for teleporting a qubit, Alice and Bob share an entangled state (qubits 2 and 3). Qubits 1 and 2 represent Alice's system, while qubit 3 is Bob's. The goal is to transfer the state of Alice’s first qubit to Bob’s qubit.

Set up a circuit:

In[127]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/ad30bb74-694b-4127-85d8-d68ca1a543a8"]
In[128]:=
qc["Diagram"]
Out[128]=

The state to be teleported is =α+β, where α and β are unknown amplitudes. The input state of the circuit is as follows:

In[129]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/3df29a36-99ac-462c-a91d-7638d88ef952"]

Given the result of Alice’s measurement on the first and second qubits, get the post-measurement states:

In[130]:=
postMeasurementStates = qc[\[Psi]0]["States"];
#["Formula"] & /@ postMeasurementStates
Out[114]=

Regardless of measurement results, the state of the third qubit is the same state as the original first qubit =α+β (with only a normalization difference). Trace out the first and second qubits and compare the reduced state of qubit 3 only:

In[131]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/fdf2f6bc-b3f0-4e68-8a6c-43c52a8135fb"]
Out[131]=

Deutsch–Jozsa algorithm (3) 

Alice wants to determine if a Boolean function , used by Bob, is constant for all values of or balanced (where is an -digit binary number between 0 and -1). Consider a balanced implementation of for n=2 as follows: , , , meaning .

Given n=4, show that XOR is balanced:

In[132]:=
states = Tuples[{0, 1}, 2^4];
BitXor @@@ states // Counts
Out[128]=

Consider the case where Alice stores her query in a 2-qubit system, denoted by qubit 1 and qubit 2. Bob will store the answer in the 3rd qubit (the answer qubit). After Bob performs the oracle, Alice measures her qubits. If she gets anything other than , then the oracle is a balanced function.

Implement the algorithm:

In[133]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/05a633f5-b64b-42ff-bb03-f1e2dbcfb405"]
In[134]:=
qc["Diagram"]
Out[134]=

Get the action of the quantum circuit as a measurement of the initial state:

In[135]:=
qc[InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]]["001"]]["ProbabilityPlot"]
Out[135]=

The measurement indicates that the oracle is a balanced function.

Bernstein–Vazirani algorithm (7) 

For an oracle given a state , there is a transformation (-1)s.x with s being a secret string:

In[136]:=
oracle[secret_List] := Module[{list, fs, qubits},
  qubits = Length[secret];
  list = Tuples[{0, 1}, qubits];
  fs = Mod[secret . #, 2] & /@ list;
  InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][
   SparseArray[{Table[{i, i}, {i, 2^qubits}] -> (-1)^fs}], "Label" -> "BV-oracle"]]

As an example, take the secret string as the fourth state of a 3-qubit system ():

In[137]:=
oracle[{0, 1, 1}]
Out[137]=

Define the circuit as a list of operators: Hadamard Oracle Hadamard:

In[138]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/6fd6f070-cce7-4301-985c-646521a4de27"]

Shown below is a specific example for two qubits (i.e., ) and a secret string 11 (i.e., the fourth state ):

In[139]:=
BernsteinVazirani[{1, 1}]["Diagram"]
In[140]:=
\!\(\*
GraphicsBox[{{InsetBox[
StyleBox["\<\"c\"\>",
StripOnInput->False,
FontFamily->"Times",
FontSize->24], {-1, 0}], 
{Thickness[
      0.25 Dynamic[
        0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
          Magnification])]], LineBox[{{0, -0.125}, {36, -0.125}}], LineBox[{{0, 0.125}, {36, 0.125}}]}}, {
     BSplineCurveBox[{{0, -5}, {36, -5}},
SplineDegree->3], BSplineCurveBox[{{0, -10}, {36, -10}},
SplineDegree->3], InsetBox[
StyleBox["1",
StripOnInput->False,
FontFamily->"Times",
FontSize->24], {-1, -5}], InsetBox[
StyleBox["2",
StripOnInput->False,
FontFamily->"Times",
FontSize->24], {-1, -10}]}, {
{GrayLevel[1], EdgeForm[Thickness[
      0.25 Dynamic[
        0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
          Magnification])]]], RectangleBox[NCache[{2, Rational[-23, 2]}, {2, -11.5}], NCache[{6, Rational[-7, 2]}, {6, -3.5}]]}, InsetBox[
RotationBox[
StyleBox[
TemplateBox[{"\"H\"", 
RowBox[{"\[CircleTimes]", "2"}]},
"Superscript"],
StripOnInput->False,
FontFamily->"Times",
FontSize->24],
BoxRotation->-1.5707963267948966`], NCache[{4, Rational[-15, 2]}, {4, -7.5}]]}, {
{GrayLevel[1], EdgeForm[Thickness[
      0.25 Dynamic[
        0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
          Magnification])]]], RectangleBox[NCache[{8, Rational[-23, 2]}, {8, -11.5}], NCache[{12, Rational[-7, 2]}, {12, -3.5}]]}, InsetBox[
RotationBox[
StyleBox["\<\"BV-oracle\"\>",
StripOnInput->False,
FontFamily->"Times",
FontSize->24],
BoxRotation->-1.5707963267948966`], NCache[{10, Rational[-15, 2]}, {10, -7.5}]]}, {
{GrayLevel[1], EdgeForm[Thickness[
      0.25 Dynamic[
        0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
          Magnification])]]], RectangleBox[NCache[{14, Rational[-23, 2]}, {14, -11.5}], NCache[{18, Rational[-7, 2]}, {18, -3.5}]]}, InsetBox[
RotationBox[
StyleBox[
TemplateBox[{"\"H\"", 
RowBox[{"\[CircleTimes]", "2"}]},
"Superscript"],
StripOnInput->False,
FontFamily->"Times",
FontSize->24],
BoxRotation->-1.5707963267948966`], NCache[{16, Rational[-15, 2]}, {16, -7.5}]]}, {
{Thickness[
      0.25 Dynamic[
        0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
          Magnification])]], CircleBox[{22, -5}, 1.7, NCache[{0, Pi}, {0, 3.141592653589793}]]}, 
{Thickness[
      0.25 Dynamic[
        0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
          Magnification])]], Arrowheads[
      0.002 Dynamic[
        0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
          Magnification])]], ArrowBox[{{22, -5}, {23, -3.6}}]}, {
      InsetBox[
StyleBox["\<\"M\"\>",
StripOnInput->False,
FontFamily->"Times",
FontSize->12], {22, -5.9}], 
{EdgeForm[Thickness[
       0.25 Dynamic[
         0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
           Magnification])]]], FaceForm[None], RectangleBox[
        NCache[{20, Rational[-20, 3]}, {20, -6.666666666666667}], {24, -3}]}}}, 
{Thickness[
     0.25 Dynamic[
       0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
         Magnification])]], LineBox[{{22.125, -2.95}, {22.125, -1}}], LineBox[{{21.875, -2.95}, {21.875, -1}}], PolygonBox[{{21.25, -1.4}, {
       22.75, -1.4}, {22, -0.1499999999999999}}]}, {
{Thickness[
      0.25 Dynamic[
        0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
          Magnification])]], CircleBox[{28, -10}, 1.7, NCache[{0, Pi}, {0, 3.141592653589793}]]}, 
{Thickness[
      0.25 Dynamic[
        0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
          Magnification])]], Arrowheads[
      0.002 Dynamic[
        0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
          Magnification])]], ArrowBox[{{28, -10}, {29, -8.6}}]}, {
      InsetBox[
StyleBox["\<\"M\"\>",
StripOnInput->False,
FontFamily->"Times",
FontSize->12], {28, -10.9}], 
{EdgeForm[Thickness[
       0.25 Dynamic[
         0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
           Magnification])]]], FaceForm[None], RectangleBox[
        NCache[{26, Rational[-35, 3]}, {26, -11.666666666666666`}], {30, -8}]}}}, 
{Thickness[
     0.25 Dynamic[
       0.26 (CurrentValue["FontCapHeight"]/AbsoluteCurrentValue[
         Magnification])]], LineBox[{{28.125, -7.95}, {28.125, -1}}], LineBox[{{27.875, -7.95}, {27.875, -1}}], PolygonBox[{{27.25, -1.4}, {
       28.75, -1.4}, {28, -0.1499999999999999}}]}},
ImageSize->{512, Automatic}]\)

The secret string is , and it is measured as the final state:

In[141]:=
final = BernsteinVazirani[{1, 1}][InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{"BasisState", {0, 0}}]]["ProbabilityPlot"]
Out[141]=

Let's go through another example with 3 qubits and a secret string :

In[142]:=
BernsteinVazirani[{1, 0, 0}]["Diagram"]
Out[142]=

The section string is the fifth state (), and it is measured as the final state:

In[143]:=
final = BernsteinVazirani[{1, 0, 0}][InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{"BasisState", {0, 0, 0}}]]["ProbabilityPlot"]
Out[143]=

Grover's search algorithm (8) 

Grover's algorithm is a search algorithm for one marked entry that is an n-bit binary number.

In order to implement the algorithm first define the oracle gate as a unitary operator:

In[144]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/ad58184f-6585-4019-9c13-f309d93b7cf5"]

As an example, define the oracle for marking the state :

In[145]:=
OracleGate[{1, 0, 1}]
Out[145]=

Check that the only element of the operator matrix, –1, is the same as the decimal number of the corresponding binary number:

In[146]:=
n = FromDigits[{1, 0, 1}, 2] + 1;
Position[Normal[
   OracleGate[{1, 0, 1}]["MatrixRepresentation"]], -1] == {{n, n}}
Out[139]=

Implement a 3-qubit Grover algorithm by first defining a Grover circuit using a marker state:

In[147]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/dbabc22e-ec93-4585-ac77-af9117e28e42"]
In[148]:=
GroverCircuit[{1, 0, 1}]["Diagram"]
Out[148]=

Define the initial state:

In[149]:=
\[Psi]0 = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{"BasisState", {0, 0, 0}}];

Return the final state (output of the Grover circuit on the initial state):

In[150]:=
\[Psi]f = GroverCircuit[{1, 0, 1}][\[Psi]0];
\[Psi]f["ProbabilityPlot"]
Out[117]=

The probability is highest for the fifth state, .

Search for another entry; for example, :

In[151]:=
GroverCircuit[{0, 0, 1}][\[Psi]0]["ProbabilityPlot"]
Out[151]=

Search for another entry; for example, :

In[152]:=
GroverCircuit[{0, 1, 1}][\[Psi]0]["ProbabilityPlot"]
Out[152]=

Quantum phase estimation (7) 

The Quantum phase estimation (QPE) algorithm solves the problem of finding in the eigenvalue equation = where is a unitary operator. The inputs of the algorithm are qubits at the initial state . The output is .

Here, use QPE to estimate the value of . This is possible if we choose , which is QantumOperator[{"P",1}], since , and so QPE will return . Thus, by measuring the final state, you can estimate the value of .

Provided below is a step-by-step example of the algorithm for :

First, construct the QPE circuit:

In[153]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/990597fa-06a6-4667-b7bf-655998cc27f3"]
In[154]:=
qc["Diagram"]
Out[154]=

Initialize the input state:

In[155]:=
initState = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{"Register", 4}];

Feed the input state to the circuit and extract π from the measurement statistic:

In[156]:=
result = qc[InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{"Register", 4}]];
In[157]:=
result["ProbabilityPlot"]
Out[157]=

The distribution peaks at the state 001, which is equivalent to integer 1. So, by this approximation, , or :

In[158]:=
FromDigits[{0, 0, 1}, 2]
Out[158]=
In[159]:=
2^(3 - 1)/%
Out[159]=

One can build a PiEstimationCircuit for any . Here, n=5:

In[160]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/ddda6303-568d-4a18-b59f-15a1dea7dcad"]
In[161]:=
piEstimateQC[5]["Diagram"]
Out[161]=

Approximate π with six qubits ():

In[162]:=
result1 = piEstimateQC[
    5][InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumState", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumState\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumState"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumState"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][{"Register", 6}]];
In[163]:=
TakeLargest[result1["Probabilities"], 1]
Out[163]=
In[164]:=
FromDigits[{0, 0, 1, 0, 1}, 2]
Out[164]=
In[165]:=
2^(5 - 1)/% // N
Out[165]=

Shor's algorithm

Shor's algorithm is an algorithm that can factorize a large number using a quantum computation. Given an integer , Shor's algorithm can return its factors and such that . This task is difficult for a classical computer if is large. The algorithm involves three main steps: classical pre-processing, quantum order-finding, and classical post-processing.

1. Classical preprocessing

- If is even, return 2 and /2.

- If is odd, pick a random number .

- Compute the greatest common divisor (GCD) of a and N. If GCD(, )!=1, return a and /a.

- If GCD(, )= 1, proceed to the order-finding algorithm.

2. Quantum order-finding

- Initialize a 2n qubit register (for ) in the state .

- Apply Hadamard gates to the first qubits.

- Apply modular exponentiation gate , where the subscript indicates the number of qubits.

- Apply the inverse quantum Fourier transform to the first qubits.

- Measure the first qubits in the computational basis.

3. Classical post-processing

- Let s be the integer representation of the measurement outcome. Compute the order r of axmod N by finding the solutions to j(/r) = s, where j is an integer.

- If is odd or choose a different a and repeat the process.

- Otherwise, at least one of or is a nontrivial factor of .

The quantum circuit used for quantum order-finding can be schematically illustrated as the following (n =3). (Note that U4 is the modular exponent gate):

In[166]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/59d32344-54d6-4117-b394-34aee915bf68"]
Out[166]=

Currently, the specific gate implementation of the modular exponentiation for arbitrary and a is unknown. However, there are some specific cases that have been studied. In the following, consider the implementation of quantum order-finding for (, a) = (15, 7) that has been demonstrated in experiments. Although one needs 8 qubits to factor 15 in general, by choosing a specific a, it is possible to use only 7 qubits (3 register, 4 ancilla).

Prepare the quantum order-finding circuit for (, a) = (15, 7):

In[167]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/33a574eb-1a5a-4819-873b-77defcceef91"]
In[168]:=
ShorCircuit1["Diagram"]
Out[168]=

Initialize the state:

In[169]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/6db3453a-0a9a-4cd3-a758-23a0e45edc68"]

Apply the Shor circuit to the initial state:

In[170]:=
result = ShorCircuit1[initState]
Out[170]=
In[171]:=
result["ProbabilityPlot"]
Out[171]=

In decimal notation, the possible states are: , , , and . If one obtains , one must repeat the protocol. Otherwise:

Outcome: |2〉 j(8/r) = 2 (j, r) = (1, 4)

p=GCD[(74/2+1) ,15] = 5 and q= GCD[(74/2-1),15] = 3

Outcome: |4〉 j(8/r) = 4 (j, r) = (1, 2)

p= GCD[(72/2+1),15] = 1 and q= GCD[(72/2-1),15] = 3

Outcome: |6〉 j(8/r) = 6 (j, r) = (3, 4)

p=GCD[(74/2+1) ,15] = 5 and q= GCD[(74/2-1),15] = 3

Thus, with 0.75 probability, one can find at least one nontrivial factor of 15.

Quantum Key Distribution: BB84 scheme (11) 

As an example of a quantum key distribution (QKD), consider the BB84 protocol. Alice generates random bits and for each, randomly chooses either a Z-basis or X-basis of measurement. Consider a sequence of 9 bits:

In[172]:=
aliceBits = RandomChoice[{0, 1}, 9]
Out[172]=
In[173]:=
aliceBases = RandomChoice[{"Z", "X"}, 9]
Out[173]=

Depending on her choice of bit and base, she follows the following protocol for sending a qubit to Bob:

In[174]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/b81cdc40-bbf2-4b9f-867a-44885235b064"]
Out[165]=

With Alice’s bits and bases having been generated randomly, she will send Bob these qubits:

In[175]:=
aliceQubits = aliceProtocol /@ Thread[List[aliceBits, aliceBases]];
#["Formula"] & /@ aliceQubits
Out[176]=

Bob randomly generates a sequence of either Z-bases or X-bases of measurement:

In[177]:=
bobBases = RandomChoice[{"Z", "X"}, 9]
Out[177]=

Thus, Bob applies the following measurement operators on the qubits he recieved from Alice:

In[178]:=
InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumMeasurementOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumMeasurementOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]] /@ bobBases
Out[178]=

Post-measurement, it is the case that, whenever Bob’s measurement basis is not the same as Alice’s, he gets two random results:

In[179]:=
MapThread[#1[#2] &, {InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumMeasurementOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumMeasurementOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]] /@ bobBases, aliceQubits}]
Out[179]=

Return one possible realization of Bob' s series of measurements (noting that some results will be consistent and other random, depending on Alice' s qubit and Bob's measurement):

In[180]:=
bobRealization = #["SimulatedMeasurement"] & /@ MapThread[#1[#2] &, {InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumMeasurementOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumMeasurementOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]] /@ bobBases, aliceQubits}]
Out[180]=

Bob assigns the bit 0 whenever he gets or , and the bit 1 for or :

In[181]:=
bobBits = bobRealization /. {Wolfram`QuantumFramework`QuditName[
Subscript["\[Psi]", 
Subscript["z", "+"]], "Dual" -> False] | Wolfram`QuantumFramework`QuditName[
Subscript["\[Psi]", 
Subscript["x", "+"]], "Dual" -> False] :> 0, Wolfram`QuantumFramework`QuditName[
Subscript["\[Psi]", 
Subscript["z", "-"]], "Dual" -> False] | Wolfram`QuantumFramework`QuditName[
Subscript["\[Psi]", 
Subscript["x", "-"]], "Dual" -> False] :> 1}
Out[181]=

Finally, Alice and Bob publicly share with each other the measurement basis that they used (in other words, they conduct a classical communication). If the basis is same, they each keep the bit; if not, they each disregard the corresponding bit. (Note that each does so separately, and each one obtains a secret key, which will be the same as the other's):

In[182]:=
aliceSecretKey = Select[Transpose[{aliceBits, aliceBases, bobBases}], #[[2]] == #[[3]] &][[All, 1]]
Out[182]=
In[183]:=
bobSecretKey = Select[Transpose[{bobBits, aliceBases, bobBases}], #[[2]] == #[[3]] &][[All, 1]]
Out[183]=
In[184]:=
bobSecretKey == aliceSecretKey
Out[184]=

Alice and Bob now share a secret key. Note that the key length is less than the number of qubits Alice sent to Bob (because Bob picks the measurement basis randomly, and he might not get the same outcome as Alice). Alice can keep sending Bob qubits until they reach a desired length. This can be implemented as follows:

In[185]:=
add[{x_, y_}] := Module[{aliceBit, aliceBase, aliceQubit, bobBase, bobBit},
  aliceBit = RandomChoice[{0, 1}];
  aliceBase = RandomChoice[{"Z", "X"}];
  aliceQubit = aliceProtocol[{aliceBit, aliceBase}];
  bobBase = RandomChoice[{"Z", "X"}];
  bobBit = InterpretationBox[FrameBox[TagBox[TooltipBox[PaneBox[GridBox[List[List[GraphicsBox[List[Thickness[0.006082377284997087`], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[2.78206`, 85.44900000000004`], List[79.17353999999999`, 41.67850000000004`], List[79.17353999999999`, 1.6779000000000508`], List[2.78206`, 45.44840000000002`]], List[List[127.7826`, 115.44898000000003`], List[127.7826`, 26.449000000000012`], List[161.7832`, 47.44780000000006`], List[161.7832`, 135.44923000000003`]], List[List[5.78267`, 141.44910000000004`], List[40.783`, 121.44819000000003`], List[117.7831`, 165.44919000000004`], List[81.37629999999999`, 187.24592000000004`]]]]], List[FaceForm[RGBColor[0.9843139999999999`, 0.662745`, 0.25098000000000004`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[79.20467000000001`, 90.91309000000003`], List[79.20546`, 48.911800000000056`], List[43.782610000000005`, 69.44830000000003`], List[43.782610000000005`, 111.44764000000002`]], List[List[82.77993`, 137.44809000000004`], List[48.77938`, 117.44782000000004`], List[82.77993`, 97.44923000000004`], List[117.7808`, 117.44782000000004`]], List[List[86.41823000000001`, 90.97696000000002`], List[86.45015000000001`, 48.71930000000003`], List[121.7829`, 70.44880000000003`], List[121.7829`, 112.44819000000003`]]]]], List[FaceForm[RGBColor[0.46274499999999996`, 0.066667`, 0.07451`, 1.`]]], Rule[StripOnInput, False]], StyleBox[List[FilledCurveBox[List[List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]], List[List[0, 2, 0], List[0, 1, 0], List[0, 1, 0]]], List[List[List[158.7825`, 141.44910000000004`], List[123.7817`, 121.44886000000004`], List[89.78278999999999`, 141.44910000000004`], List[123.7817`, 161.44770000000003`]], List[List[2.7817600000000002`, 92.44794000000003`], List[37.782610000000005`, 72.44770000000003`], List[37.782610000000005`, 114.44870000000003`], List[2.7817600000000002`, 134.44898000000003`]], List[List[86.45015000000001`, 1.7736000000000445`], List[121.78269999999999`, 23.44920000000002`], List[121.78269999999999`, 63.33730000000003`], List[86.45015000000001`, 41.66350000000003`]]]]], List[FaceForm[RGBColor[1.`, 0.41568600000000006`, 0.054902000000000006`, 1.`]]], Rule[StripOnInput, False]]], List[Rule[BaselinePosition, Scaled[0.15`]], Rule[ImageSize, 10], Rule[ImageSize, List[30, Automatic]]]], StyleBox[RowBox[List["QuantumMeasurementOperator", " "]], Rule[ShowAutoStyles, False], Rule[ShowStringCharacters, False], Rule[FontSize, Times[0.9`, Inherited]], Rule[FontColor, GrayLevel[0.1`]]]]], Rule[GridBoxSpacings, List[Rule["Columns", List[List[0.25`]]]]]], Rule[Alignment, List[Left, Baseline]], Rule[BaselinePosition, Baseline], Rule[FrameMargins, List[List[3, 0], List[0, 0]]], Rule[BaseStyle, List[Rule[LineSpacing, List[0, 0]], Rule[LineBreakWithin, False]]]], RowBox[List["PacletSymbol", "[", RowBox[List["\"Wolfram/QuantumFramework\"", ",", "\"QuantumMeasurementOperator\""]], "]"]], Rule[TooltipStyle, List[Rule[ShowAutoStyles, True], Rule[ShowStringCharacters, True]]]], Function[Annotation[Slot[1], Style[Defer[PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"]], Rule[ShowStringCharacters, True]], "Tooltip"]]], Rule[Background, RGBColor[0.968`, 0.976`, 0.984`]], Rule[BaselinePosition, Baseline], Rule[DefaultBaseStyle, List[]], Rule[FrameMargins, List[List[0, 0], List[1, 1]]], Rule[FrameStyle, RGBColor[0.831`, 0.847`, 0.85`]], Rule[RoundingRadius, 4]], PacletSymbol["Wolfram/QuantumFramework", "QuantumMeasurementOperator"], Rule[Selectable, False], Rule[SelectWithContents, True], Rule[BoxID, "PacletSymbolBox"]][bobBase][
      aliceQubit][
     "SimulatedMeasurement"] /. {Wolfram`QuantumFramework`QuditName[
Subscript["\[Psi]", 
Subscript["z", "+"]], "Dual" -> False] | Wolfram`QuantumFramework`QuditName[
Subscript["\[Psi]", 
Subscript["x", "+"]], "Dual" -> False] :> 0, Wolfram`QuantumFramework`QuditName[
Subscript["\[Psi]", 
Subscript["z", "-"]], "Dual" -> False] | Wolfram`QuantumFramework`QuditName[
Subscript["\[Psi]", 
Subscript["x", "-"]], "Dual" -> False] :> 1};
  If[aliceBase == bobBase, {Append[x, aliceBit], Append[y, bobBit]}, {x, y}]]

For example, the key length is set to 5 bits below:

In[186]:=
NestWhile[add, {{}, {}}, Length[#[[1]]] < 5 &]
Out[186]=

Compatibility

Wolfram Language Version 13.0

License Information

MIT License

Resource History

Paclet Source