Skip to content

Visualisation of Pauli Polynomials #10

@daehiff

Description

@daehiff

Currently ( as with PR: #5 ), we can only visualize Pauli gadgets and Pauli Polynomials in the terminal as follows:

pp = PauliPolynomial(num_qubits=4)
pp >>= PPhase(0.5) @ [X, Y, Z, I]
print(pp)

An interesting extension would be:

  1. Provide a mechanism to display Pauli Polynomials in Jupyter notebooks
  2. Provide a possibility to export Pauli Polynomials as .tex Files

Display Pauli Polynomials in Jupyter notebooks

An extension towards Jupiter notebooks, already present with Phase gadgets plus Latex support, would be interesting.

For the Jupyter notebooks, one can orient himself at: https://github.com/sg495/pauliopt/blob/main/pauliopt/phase/phase_circuits.py#L937). Here the phase circuit is cast to an SVG. This can be shown in Pybooks using the display function.

Latex Support

For Latex support a template can be found in the following:

\documentclass[preview]{standalone}

\usepackage{tikz}
\usetikzlibrary{zx-calculus}
\usetikzlibrary{quantikz}
\usepackage{graphicx}

\tikzset{
diagonal fill/.style 2 args={fill=#2, path picture={
\fill[#1, sharp corners] (path picture bounding box.south west) -|
                         (path picture bounding box.north east) -- cycle;}},
reversed diagonal fill/.style 2 args={fill=#2, path picture={
\fill[#1, sharp corners] (path picture bounding box.north west) |- 
                         (path picture bounding box.south east) -- cycle;}}
}

\tikzset{
pauliY/.style={
anchor=center,
minimum height=0.5em,
minimum width=0.5em,
draw,
line width=\zxDefaultLineWidth,
diagonal fill={colorZxX}{colorZxZ}
}
}

\tikzset{
pauliX/.style={
anchor=center,
minimum height=0.5em,
minimum width=0.5em,
draw,
line width=\zxDefaultLineWidth,
fill=colorZxX
}
}

\tikzset{
pauliZ/.style={
anchor=center,
minimum height=0.5em,
minimum width=0.5em,
draw,
line width=\zxDefaultLineWidth,
fill=colorZxZ
}
}

\tikzset{
pauliPhase/.style={
anchor=center,
minimum height=1em,
minimum width=1em,
draw,
line width=\zxDefaultLineWidth,
fill=white
}
}

\begin{document}

\begin{ZX}
	\zxNone{}       &                				& |[pauliPhase]| {\alpha}\\
	\\
	\zxNone{} \rar  & |[pauliX]|  \ar[ruu, bend right] \rar 	& \zxNone{}\\
	\zxNone{} \rar  & |[pauliY]| \ar[ruuu, bend right] \rar 	& \zxNone{}\\
	\zxNone{} \rar 	& |[pauliZ]| \ar[ruuuu, bend right] \rar	& \zxNone{}\\
	\zxNone{} \rar 	& \zxNone{} \rar				& \zxNone{}\\
\end{ZX}

\end{document}

This .tex code will render a Pauli gadget like this:

Screenshot 2023-05-12 at 21 21 37

Note that this Latex Script is mainly based on the ZX-Calculus library (https://ctan.org/pkg/zx-calculus?lang=en)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions