Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualisation of Pauli Polynomials #10

Open
daehiff opened this issue May 12, 2023 · 0 comments
Open

Visualisation of Pauli Polynomials #10

daehiff opened this issue May 12, 2023 · 0 comments

Comments

@daehiff
Copy link
Collaborator

daehiff commented May 12, 2023

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)

@daehiff daehiff mentioned this issue May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant