Drawing Quantum Circuit Using Q-Circuit

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
\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

Author

Lei Mao

Posted on

08-16-2020

Updated on

08-16-2020

Licensed under


Comments