Debian Codegraph @

texmf-dist/doc/latex/quantumcubemodel/quantumcubemodel-doc.tex

raw
1 \documentclass{article}
2 \usepackage[a4paper,margin=1in]{geometry}
3 \usepackage{hyperref}
4 \usepackage{quantumcubemodel}
5 \usepackage{quantikz}
6
7 \usepackage{listings}
8 \usepackage[backend=biber, style=authortitle]{biblatex}
9 \addbibresource{quantumcubemodel-bib.bib}
10 \usepackage{parskip}
11 \usepackage{standalone}
12 \standaloneconfig{mode=buildnew}
13
14 \usepackage{adjustbox}
15
16 \title{Quantum Cube Model LaTeX Package (v0.2.1)}
17 \author{Cedric Schacht \\ \texttt{[email protected]}}
18 \date{\today}
19
20 \begin{document}
21 \maketitle
22
23 \section*{Introduction}
24
25 The \textbf{Quantum Cube Model (QCM)} package provides commands that make it easy to create diagrams representing the quantum cube model for up to 3 qubits.
26 The package simplifies drawing complex quantum state diagrams inspired by Prof.~B.~Just's framework.
27
28 The key difference to version v0.1.0 of this package is,
29 the new version exposes the tikz picture canves to the user.
30 This allows for far more refined diagramms, and flexability.
31
32 \section*{Requirements}
33 To use this package include \verb|\usepackage{quantumcubemodel}| in your documents preamble.
34 This package depends on the following LaTeX packages:
35 \begin{verbatim}
36 \RequirePackage{kvoptions}
37 \RequirePackage{braket}
38 \RequirePackage{xcolor}
39 \RequirePackage{tikz}
40 \usetikzlibrary{3d, calc, arrows.meta}
41 \end{verbatim}
42
43 \section*{License}
44 \begin{verbatim}
45 MIT License
46 Copyright (c) 2025 Cedric Schacht
47
48 Permission is hereby granted, free of charge, to any person obtaining a copy
49 of this software and associated documentation files (the "Software"), to deal
50 in the Software without restriction, including without limitation the rights
51 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
52 copies of the Software, and to permit persons to whom the Software is
53 furnished to do so, subject to the following conditions:
54
55 The above copyright notice and this permission notice shall be included in all
56 copies or substantial portions of the Software.
57
58 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
60 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
61 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
62 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
63 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
64 SOFTWARE.
65 \end{verbatim}
66
67 \section*{References}
68 \fullcite{justQuantumComputingCompact2022}
69
70 \section*{Changelog}
71
72
73 \begin{itemize}
74 \item v0.2.1:
75 \begin{itemize}
76 \item Add support for standalone coefficients (amplitudes and phases)
77 \item Add support for Unitary gates with no specific arrow tip style (wireframes)
78 \item Fix PauliZ transformation diagram on three qubit systems
79 \end{itemize}
80 \item v0.2.0:
81 \begin{itemize}
82 \item Provide qcmx environment that exposes tikz canvas.
83 \item Give an option to set the main color.
84 \item Provide commands for easier amplitude configuration.
85 \item Provide options to change qubit axis.
86 \item Enable the use of multiple qcm diagramms in one tikz canvas.
87 \end{itemize}
88 \end{itemize}
89
90 \section*{Package options}
91 To change the appearence of your diagramms you can set the main color as follows:
92 \lstinputlisting{examples/example-change-main-color.tex}
93 \begin{center}
94 \includegraphics{examples/out/example-change-main-color.pdf}
95 \end{center}
96
97 \clearpage
98 \section*{Provided commands}
99 All commands are prefixed with \textbf{qcmx}.
100
101 There are other commands that start with \textbf{QCMXINTERNAL} these are for internal purposes only,
102 the use of those is not recomended.
103
104 \begin{verbatim}
105 \begin{qcmx}
106 % Everything happens in this environment
107 \end{qcmx}
108 \end{verbatim}
109 In this environment you can call one of the following commands to render a qcm diagram
110 for one, two or three qubit diagramms respectively:
111 \begin{itemize}
112 \item \verb|\qcmxRenderQ|
113 \item \verb|\qcmxRenderQQ|
114 \item \verb|\qcmxRenderQQQ|
115 \end{itemize}
116
117 You can draw individual coefficients with:
118 \begin{itemize}
119 \item \verb|\qcmxRenderCoef|
120 \end{itemize}
121
122 Initially all amplitudes are set to 0,
123 you can change them with the commands of the following pattern:
124
125 \verb|\qcmxO{}| or \verb|\qcmxI{}| for one qubit amplitued at $\ket{0}$ (O) or $\ket{1}$ (I).
126
127 \verb|\qcmxOO{}|, \verb|\qcmxOI{}|, \verb|\qcmxIO{}| and \verb|\qcmxII{}| for systems with two qubits.
128
129 \verb|\qcmxOOO{}| up to \verb|\qcmxIII{}| for systems with three qubits...
130
131 \verb|\qcmxCoef{}| for individual coefficients.
132
133 You have to set the amplitudes before calling the corresponding render command.
134 The \verb|\qcmxCoef{}| command has one extra parameter for labeling the coefficient.
135 \begin{lstlisting}
136 \qcmxCoef[180]{0.71}
137 \qcmxRenderCoef{$\ket{\phi}$}
138 \end{lstlisting}
139
140 Each of theses commands gives you an optional parameter to set a phase (in degrees from 0 to 360) for the coefficient,
141 for the state $-\ket{+}$ this results in:
142 \begin{lstlisting}
143 \begin{qcmx}
144 \qcmxO[180]{0.71}
145 \qcmxI[180]{0.71}
146 \qcmxRenderQ
147 \end{qcmx}
148 \end{lstlisting}
149
150 If you want to include more than one qcm diagram in one figure,
151 you can define \lstinline|\def\qcmxOffsetX{5}| to render the next one 5 units to the left.
152 There are Offsets for X, Y and Z where the direction follows the tikz orientations.
153 To reset the amplitudes and phases back to $0$,
154 you can use the corresponding reset command:
155 \begin{itemize}
156 \item \lstinline|\qcmxClearQ|
157 \item \lstinline|\qcmxClearQQ|
158 \item \lstinline|\qcmxClearQQQ|
159 \item \lstinline|\qcmxClearCoef|
160 \end{itemize}
161
162 Use \lstinline|\def\qcmxOrientationQ{y}| to set the orientation of a one qubit system to the y-axis.
163 This needs to be defined befor using the render command.
164 The commands for mutli qubit systems follow the scheme of Q, QQ and QQQ like the render commands.
165 Possible values for orientations are:
166 \begin{itemize}
167 \item in Systems with one qubit: \lstinline|x, y, z| (default: x)
168 \item in Systems with two qubits: \lstinline|xy, xz, yz| (default: xy)
169 \item in Systems with three qubits: \lstinline|xyz| (default: xyz)
170 \end{itemize}
171
172 \pagebreak
173 For the transformations there are specialized render commands for the Pauli-Gates X, Y, Z
174 as well as the Hadamard transformation.
175 In multi qubit systems additionaly there a renderers for CNot and CCNot (Toffolie).
176 These follow a scheme like thie:
177 \lstinline|\qcmxRender[OperationName][QubitCount]{qubits}| where \lstinline|[OperationName]| can be i.e. Hadamard,
178 the \lstinline|[QubitCount]| can be QQ.
179
180 To render the Hadamard transformation on the x qubit in a system with two qubits this results in:
181 \begin{lstlisting}
182 \qcmxRenderHadamardQQ{x}
183 \end{lstlisting}
184 Keep in mind that the \lstinline|\qcmxOrientationQQ| setting will be used to determine that the other qubit is y.
185 \begin{lstlisting}
186 \def\qcmxOrientationQQ{xz}
187 \qcmxRenderHadamardQQ{x}
188 \end{lstlisting}
189 Results in a different diagram.
190
191 The Wireframe variants of these commands can be used to render unitary operations that do not have a specific diagram representation yet.
192
193 The same is true for measurements,
194 the only exceptions are CNot and CCNot, where there is no single qubit (or two qubit for CCNot) version.
195
196 \begin{itemize}
197 \item \lstinline|\qcmxRenderWireframeQ one of [x,y,z]|
198 \item \lstinline|\qcmxRenderWireframeQQ one of [x,y,z]|
199 \item \lstinline|\qcmxRenderWireframeQQQ one of [x,y,z]|
200 \item \lstinline|\qcmxRenderHadamardQ one of [x,y,z]|
201 \item \lstinline|\qcmxRenderHadamardQQ one of [x,y,z]|
202 \item \lstinline|\qcmxRenderHadamardQQQ one of [x,y,z]|
203 \item \lstinline|\qcmxRenderPauliXQ one of [x,y,z]|
204 \item \lstinline|\qcmxRenderPauliXQQ one of [x,y,z]|
205 \item \lstinline|\qcmxRenderPauliXQQQ one of [x,y,z]|
206 \item \lstinline|\qcmxRenderPauliYQ one of [x,y,z]|
207 \item \lstinline|\qcmxRenderPauliYQQ one of [x,y,z]|
208 \item \lstinline|\qcmxRenderPauliYQQQ one of [x,y,z]|
209 \item \lstinline|\qcmxRenderPauliZQ one of [x,y,z]|
210 \item \lstinline|\qcmxRenderPauliZQQ one of [x,y,z]|
211 \item \lstinline|\qcmxRenderPauliZQQQ one of [x,y,z]|
212 \item \lstinline|\qcmxRenderCNotQQ one of [xy,yx,xz,zx,yz,zy]|
213 \item \lstinline|\qcmxRenderCNotQQQ one of [xy,yx,xz,zx,yz,zy]|
214 \item \lstinline|\qcmxRenderCCNotQQQ one of [xyz,yxz,xzy,zxy,yzx,zyx]|
215 \item \lstinline|\qcmxRenderMeasureQ one of [x,y,z]|
216 \item \lstinline|\qcmxRenderMeasureQQ one of [x,y,z,xy,xz,yz]|
217 \item \lstinline|\qcmxRenderMeasureQQQ one of [x,y,z,xy,xz,yz,xyz]|
218 \end{itemize}
219
220 \clearpage
221 \section*{One qubit states}
222 \lstinputlisting{examples/one-qubit-ket-0.tex}
223 \begin{center}
224 \input{examples/one-qubit-ket-0.tex}
225 \end{center}
226
227 \lstinputlisting{examples/one-qubit-ket-1.tex}
228 \begin{center}
229 \input{examples/one-qubit-ket-1.tex}
230 \end{center}
231
232 \lstinputlisting{examples/one-qubit-ket-+.tex}
233 \begin{center}
234 \input{examples/one-qubit-ket-+.tex}
235 \end{center}
236
237 \section*{Amplitudes \& Phases}
238 \lstinputlisting{examples/one-qubit-ket-amplitudes.tex}
239 \begin{center}
240 \input{examples/one-qubit-ket-amplitudes.tex}
241 \end{center}
242
243 \lstinputlisting{examples/one-qubit-ket-phase.tex}
244 \begin{center}
245 \input{examples/one-qubit-ket-phase.tex}
246 \end{center}
247
248 \pagebreak
249 \section*{Two qubit state}
250 \lstinputlisting{examples/two-qubit-state.tex}
251 \begin{center}
252 \input{examples/two-qubit-state.tex}
253 \end{center}
254
255 \pagebreak
256 \section*{Three qubit state}
257 \lstinputlisting{examples/three-qubit-state.tex}
258 \resizebox{\textwidth}{!}{
259 \hspace{-22cm}
260 \input{examples/three-qubit-state.tex}
261 \hspace{2cm}
262 }
263
264 \pagebreak
265 \section*{Orientation and Positioning of qubits}
266 \lstinputlisting{examples/orientation-of-qubits.tex}
267 \resizebox{\textwidth}{!}{
268 \hspace{-22cm}
269 \input{examples/orientation-of-qubits.tex}
270 \hspace{2cm}
271 }
272
273 The same works for:
274 \begin{lstlisting}
275 \def\qcmxOrientationQQ{xy}
276 \end{lstlisting}
277 Possible values are \lstinline|xy, xz, yz| to set the plane accordingly.
278
279 And for future use: \lstinline|\def\qcmxOrientationQQQ{xyz}| is reserved, but there are no other valid values except \lstinline|xyz| for now.
280
281 As you can see, the qcmx environment exposes a 3d Tikz canvas,
282 there for you are free to use commands like \lstinline|\node at|\dots{} to add descriptive markings.
283
284 \pagebreak
285 \section*{Two qubit state from two one qubit state}
286 \lstinputlisting{examples/example-rendering-phi-times-psi-equals-phipsi.tex}
287 \resizebox{\textwidth}{!}{
288 \hspace{-17cm}
289 \input{examples/example-rendering-phi-times-psi-equals-phipsi.tex}
290 \hspace{8cm}
291 }
292
293 \pagebreak
294 \section*{Transformation diagramms}
295 \lstinputlisting{examples/one-qubit-transformations.tex}
296 \resizebox{\textwidth}{!}{
297 \hspace{-20cm}
298 \input{examples/one-qubit-transformations.tex}
299 \hspace{5cm}
300 }
301
302 \pagebreak
303 \lstinputlisting{examples/multi-qubit-transformation-hadamard.tex}
304 \resizebox{\textwidth}{!}{
305 \hspace{-20cm}
306 \input{examples/multi-qubit-transformation-hadamard.tex}
307 \hspace{5cm}
308 }
309
310 As you can see the orientation of the Hadamard Transform is set by two parts,
311 first the value of \lstinline|\qcmxOrientationQQ| is used to determine the plane,
312 then the argument of \lstinline|\qcmxRenderHadamardQQ| is used to select the qubit that is transformed.
313
314 The same is true for the pauli gates (x, y, z) as well as the three dimensional cube,
315 even though \lstinline|\qcmxOrientationQQQ| can only be \lstinline|xyz| for now.
316
317 \pagebreak
318 \section*{Multi qubit transformations}
319 \lstinputlisting{examples/cnot-on-three-qubits.tex}
320 \resizebox{\textwidth}{!}{
321 \hspace{-20cm}
322 \input{examples/cnot-on-three-qubits.tex}
323 \hspace{5cm}
324 }
325
326 Additionaly there is the CCNot (Toffolie) gate,
327 that can be rendered with the \lstinline|\qcmxRenderCCNotQQQ|.
328 Obviously CNot and CCNot are only available in systems with at least two (or three) qubits respectively.
329
330 \pagebreak
331 \section*{Measurement of Qubits}
332 \lstinputlisting{examples/measure-qubit.tex}
333 \resizebox{\textwidth}{!}{
334 \hspace{-20cm}
335 \input{examples/measure-qubit.tex}
336 \hspace{5cm}
337 }
338
339 \pagebreak
340 \lstinputlisting{examples/measure-one-of-two-qubits.tex}
341 \resizebox{\textwidth}{!}{
342 \hspace{-20cm}
343 \input{examples/measure-one-of-two-qubits.tex}
344 \hspace{5cm}
345 }
346
347 For systems with only partial measurements the \lstinline|\qcmxOrientationQQ| and \lstinline|\qcmxOrientationQQQ|
348 values are used to determin the unmeasured qubits.
349
350 Additionaly it is possible to measure more than one qubit at the same time.
351 For \lstinline|\qcmxRenderMeasureQQ| it is possible to choose from \lstinline|x, y, z, xy, xz, yz|.
352 While for \lstinline|\qcmxRenderMeasureQQQ| \lstinline|xyz| is also available.
353
354
355 \pagebreak
356 \section*{Example: Teleportation Algorithm}
357 \begin{center}
358 \begin{quantikz}
359 \lstick{$\ket{\psi}$} & \qw & \qw & \ctrl{1} & \gate{H} & \meter{} & \cw & \cwbend{2} \\
360 \lstick{Bob: $\ket{0}$} & \qw & \targ{} & \targ{} & \qw & \meter{} & \cwbend{1} \\
361 \lstick{Alice: $\ket{0}$} & \gate{H} & \ctrl{-1} & \qw & \qw & \qw & \gate{X} & \gate{Z} & \qw \rstick{$\ket{\psi}$}
362 \end{quantikz}
363
364 \resizebox{0.95\textwidth}{!}{
365 \hspace{-20cm}
366 \input{examples/teleportation.tex}
367 \hspace{5cm}
368 }
369 \end{center}
370
371 \pagebreak
372 \lstinputlisting{examples/teleportation.tex}
373
374 \end{document}