5

There are several questions here already asking about packages and tools for use in generating quantum mechanics and quantum computation diagrams suitable for incorporation into TeX documents, but all of these are rather old, and generally point to even older tools and packages.

What are the most current and easiest to use tools for generating

  • quantum circuit diagrams, and
  • Bloch Sheres and other quantum representations?

In addition to the narrow focus of existing questions (TeX packages or TikZ, etc.) I'd be interested more generally in anything that can generate output (e.g., PDF) suitable for incorporation into a TeX publication.

  • Hi. I know this question is old, but please consider to accept my answer. – 3244611user Nov 2 '18 at 19:54
7

Though this question is very old, I will answer it since it is one of the first results if you search for 'bloch sphere latex'.

There is the package 'blochsphere', which you can install with sudo tlmgr install blochsphere. The repository (and documentation) can be found on Github.

Here is an example:

enter image description here

and the code would be

\documentclass{standalone}

\usepackage{blochsphere}

\begin{document}

\begin{blochsphere}[radius=1.5 cm,tilt=15,rotation=-20]
    \drawBallGrid[style={opacity=0.1}]{30}{30}

    \drawGreatCircle[style={dashed}]{-60}{0}{0}
    \drawGreatCircle[style={dashed}]{60}{0}{0}

    \drawRotationLeft[scale=1.3,style={red}]{-60}{0}{0}{15}
    \drawRotationRight[scale=1.3,style={red}]{60}{0}{0}{15}

    \node at (-0.8,1.9) {\textcolor{red}{\tiny $J_{12}(t)$}};
    \node at (1.1,1.8) {\textcolor{red}{\tiny $J_{23}(t)$}};

    \labelLatLon{up}{90}{0};
    \labelLatLon{down}{-90}{90};
    \node[above] at (up) {{\tiny $\left|1\right>$ }};
    \node[below] at (down) {{\tiny $\left|0\right>$}};

    \labelLatLon[labelmark=false]{d}{15}{90};
    \node at (d) {\color{gray}\fontsize{0.15cm}{1em}\selectfont $60^\circ$};

    \labelLatLon[labelmark=false]{d2}{5}{78};
    \node at (d2) {\color{gray}\fontsize{0.15cm}{1em}\selectfont $60^\circ$};
\end{blochsphere}
\end{document}

Major Addition: How I easily draw quantum circuits in Tex

I could not find a good package (technically, you could use qasm2circ, but I did not like it too much and there is qcircuit, which I have not tested yet), but I figured it is pretty easy to just do it in plain Tex with the help of 'pics'.

Example:

A simple and somewhat nonsensical example circuit

% !TeX encoding = UTF-8
% !TeX spellcheck = de_DE

\documentclass[11pt,border=2mm]{standalone}

\usepackage{tikz}
\usepackage{nicefrac}
\usetikzlibrary{positioning}

\begin{document}
    \begin{tikzpicture}[
    scale=1,
    pics/measure/.style 2 args={code={\draw[fill=white] (0,-#2/2) rectangle (#1,#2/2);\draw (1,-0.25) arc (0:180:0.4);\draw[->] (0.5,-0.25) -- (1,0.25);}},
    pics/dot/.style={code={\fill[black] (0,0) circle (0.1);}},
    pics/odot/.style={code={\fill[draw=black, fill=white] (0,0) circle (0.1); \draw (-0.1,0) -- (+0.1,0) (0,-0.1) -- (0,+0.1);}},
    pics/qubit/.style 2 args={code={\draw[black, thick, fill=#1] (-0.3,0) node[anchor=center] {#2} circle (0.3);}},
    ]
    %change these values:
    \pgfmathsetmacro{\linedist}{-0.7}
    \pgfmathsetmacro{\ep}{5}
    \pgfmathsetmacro{\ms}{0.5cm}



    \draw[] (0,0) pic[anchor=east] {qubit={blue!50}{X}}
    -- ++(0.5, 0) node[anchor=center, fill=white, draw=black, minimum size=\ms]{H}
    -- (4, 0) node[anchor=center, fill=white, draw=black, minimum size=\ms]{H}
    -- (\ep-0.6, 0) pic[anchor=center,scale=0.51] {measure={1.2}{1}};

    \draw[] (0,\linedist) pic[anchor=east] {qubit={red!80!black!70}{A}}
    -- ++(0.5, 0) node[anchor=center, fill=white, draw=black, minimum size=\ms]{H}
    -- (4, 1*\linedist) node[anchor=center, fill=white, draw=black, minimum size=\ms]{H}
    -- (\ep,\linedist) {};

    \draw[] (0,2*\linedist) pic[anchor=east] {qubit={red!80!black!70}{B}}
    -- ++(0.5, 0) node[anchor=center, fill=white, draw=black, minimum size=\ms]{H}
    -- ++(2.5, 0) node[anchor=center, fill=white, draw=black, minimum size=\ms]{$R_\mathrm{\varphi}^{\nicefrac{\pi}{2}}$}
    -- (4, 2*\linedist) node[anchor=center, fill=white, draw=black, minimum size=\ms]{H}
    -- (\ep,2*\linedist) {};

    \draw (1.5,0) pic[] {dot} -- ++ (0,2*\linedist){} pic[] {dot};
    \draw (2.0,0) pic[] {dot} -- ++ (0,1*\linedist){} pic[] {odot};
    \end{tikzpicture}
\end{document}
| improve this answer | |
1

For quantum circuit diagrams see this post: What's a good package for typesetting quantum circuits?

For Bloch spheres Tikz should be a good option. If you have to repeat the same sketch several times, defining a Tikz macro might be a good option.

| improve this answer | |
  • Is there really nothing more recent? – orome Mar 10 '16 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.