Lei Mao bio photo

Lei Mao

Machine Learning, Artificial Intelligence, Computer Science.

Twitter Facebook LinkedIn GitHub   G. Scholar E-Mail RSS

Introduction

Q-circuit is a macro package for drawing quantum circuit diagrams in $\rm\LaTeX$. In this blog post, I would present a simple example of quantum circuit drawn using Q-circuit.

Example

In this particular example, there is a quantum oracle $U_f$ in the circuit. We wrote the following $\rm\LaTeX$ code for drawing the quantum circuits. It should be noted that mathptmx makes the math symbol font Times and it looks much better.

\documentclass{article}
\usepackage[braket, qm]{qcircuit}
\usepackage{mathptmx}
\usepackage{amsmath}

\begin{document}
\[ 
\Qcircuit @C=2.75em @R=3em {
& \ustick{\ket{\mathbf{0}}} \qw & /^{n} \qw & \gate{H^{\otimes n}} & /^{n} \qw & \multigate{1}{\hspace{2em} U_f \hspace{2em}} & /^{n} \qw & \meter\\
& \ustick{\ket{0}} \qw & \dstick{\Uparrow} \qw & \qw & \dstick{\Uparrow} \qw & \ghost{\hspace{2em} U_f \hspace{2em}} & \dstick{\Uparrow} \qw & \qw \\
& & \ustick{\ket{\varphi_0}} & & \ustick{\ket{\varphi_1}} & & \ustick{\ket{\varphi_2}} & \\
} 
\]
\end{document}

The quantum circuit diagram created is as follows.

Quantum Circuit Drawn Using Q-Circuit

Resources

More examples and resources could be found in the Q-circuit tutorial in the references.

References