\documentclass{article} \usepackage[a4paper,margin=1in]{geometry} \usepackage{hyperref} \usepackage{quantumcubemodel} \usepackage{quantikz} \usepackage{listings} \usepackage[backend=biber, style=authortitle]{biblatex} \addbibresource{quantumcubemodel-bib.bib} \usepackage{parskip} \usepackage{standalone} \standaloneconfig{mode=buildnew} \usepackage{adjustbox} \title{Quantum Cube Model LaTeX Package (v0.2.0)} \author{Cedric Schacht \\ \texttt{cedric.schacht@dhbw-stuttgart.de}} \date{\today} \begin{document} \maketitle \section*{Introduction} 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. The package simplifies drawing complex quantum state diagrams inspired by Prof.~B.~Just's framework. The key difference to version v0.1.0 of this package is, the new version exposes the tikz picture canves to the user. This allows for far more refined diagramms, and flexability. \section*{Requirements} To use this package include \verb|\usepackage{quantumcubemodel}| in your documents preamble. This package depends on the following LaTeX packages: \begin{verbatim} \RequirePackage{kvoptions} \RequirePackage{braket} \RequirePackage{xcolor} \RequirePackage{tikz} \usetikzlibrary{3d, calc, arrows.meta} \end{verbatim} \section*{License} \begin{verbatim} MIT License Copyright (c) 2025 Cedric Schacht Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \end{verbatim} \section*{References} \fullcite{justQuantumComputingCompact2022} \section*{Changelog} \begin{itemize} \item Provide qcmx environment that exposes tikz canvas. \item Give an option to set the main color. \item Provide commands for easier amplitude configuration. \item Provide options to change qubit axis. \item Enable the use of multiple qcm diagramms in one tikz canvas. \end{itemize} \section*{Package options} To change the appearence of your diagramms you can set the main color as follows: \lstinputlisting{examples/example-change-main-color.tex} \begin{center} \includegraphics{examples/out/example-change-main-color.pdf} \end{center} \clearpage \section*{Provided commands} All commands are prefixed with \textbf{qcmx}. There are other commands that start with \textbf{QCMXINTERNAL} these are for internal purposes only, the use of those is not recomended. \begin{verbatim} \begin{qcmx} % Everything happens in this environment \end{qcmx} \end{verbatim} In this environment you can call one of the following commands to render a qcm diagram for one, two or three qubit diagramms respectively: \begin{itemize} \item \verb|\qcmxRenderQ| \item \verb|\qcmxRenderQQ| \item \verb|\qcmxRenderQQQ| \end{itemize} Initially all amplitudes are set to 0, you can change them with the commands of the following pattern: \verb|\qcmxO{}| or \verb|\qcmxI{}| for one qubit amplitued at $\ket{0}$ (O) or $\ket{1}$ (I). \verb|\qcmxOO{}|, \verb|\qcmxOI{}|, \verb|\qcmxIO{}| and \verb|\qcmxII{}| for systems with two qubits. \verb|\qcmxOOO{}| up to \verb|\qcmxIII{}| for systems with three qubits.. You have to set the amplitudes befor calling the corresponding render command. Each of theses commands gives you an optional parameter to set a phase (in degrees from 0 to 360) for the coefficient, for the state $-\ket{+}$ this results in: \begin{lstlisting} \begin{qcmx} \qcmxO[180]{0.71} \qcmxI[180]{0.71} \qcmxRenderQ \end{qcmx} \end{lstlisting} If you want to include more than one qcm diagram in one figure, you can define \lstinline|\def\qcmxOffsetX{5}| to render the next one 5 units to the left. There are Offsets for X, Y and Z where the direction follows the tikz orientations. To reset the amplitudes and phases back to $0$, you can use the corresponding reset command: \begin{itemize} \item \lstinline|\qcmxClearQ| \item \lstinline|\qcmxClearQQ| \item \lstinline|\qcmxClearQQQ| \end{itemize} Use \lstinline|\def\qcmxOrientationQ{y}| to set the orientation of a one qubit system to the y-axis. This needs to be defined befor using the render command. The commands for mutli qubit systems follow the scheme of Q, QQ and QQQ like the render commands. Possible values for orientations are: \begin{itemize} \item in Systems with one qubit: \lstinline|x, y, z| (default: x) \item in Systems with two qubits: \lstinline|xy, xz, yz| (default: xy) \item in Systems with three qubits: \lstinline|xyz| (default: xyz) \end{itemize} \pagebreak For the transformations there are specialized render commands for the Pauli-Gates X, Y, Z as welle as the Hadamard transformation. In multi qubit systems additionaly there a renderers for CNot and CCNot (Toffolie). These follow a scheme like thie: \lstinline|\qcmxRender[OperationName][QubitCount]{qubits}| where \lstinline|[OperationName]| can be i.e. Hadamard, the \lstinline|[QubitCount]| can be QQ. To render the hadamard transformation on the x qubit in a system with two qubits this results in: \begin{lstlisting} \qcmxRenderHadamardQQ{x} \end{lstlisting} Keep in mind that the \lstinline|\qcmxOrientationQQ| setting will be used to determine that the other qubit is y. \begin{lstlisting} \def\qcmxOrientationQQ{xz} \qcmxRenderHadamardQQ{x} \end{lstlisting} Results in a different diagram. The same is true for measurements, the only exceptions are CNot and CCNot, where ther is no single qubit (or two qubit for CCNot) version. \begin{itemize} \item \lstinline|\qcmxRenderHadamardQ one of [x,y,z]| \item \lstinline|\qcmxRenderHadamardQQ one of [x,y,z]| \item \lstinline|\qcmxRenderHadamardQQQ one of [x,y,z]| \item \lstinline|\qcmxRenderPauliXQ one of [x,y,z]| \item \lstinline|\qcmxRenderPauliXQQ one of [x,y,z]| \item \lstinline|\qcmxRenderPauliXQQQ one of [x,y,z]| \item \lstinline|\qcmxRenderPauliYQ one of [x,y,z]| \item \lstinline|\qcmxRenderPauliYQQ one of [x,y,z]| \item \lstinline|\qcmxRenderPauliYQQQ one of [x,y,z]| \item \lstinline|\qcmxRenderPauliZQ one of [x,y,z]| \item \lstinline|\qcmxRenderPauliZQQ one of [x,y,z]| \item \lstinline|\qcmxRenderPauliZQQQ one of [x,y,z]| \item \lstinline|\qcmxRenderCNotQQ one of [xy,yx,xz,zx,yz,zy]| \item \lstinline|\qcmxRenderCNotQQQ one of [xy,yx,xz,zx,yz,zy]| \item \lstinline|\qcmxRenderCCNotQQQ one of [xyz,yxz,xzy,zxy,yzx,zyx]| \item \lstinline|\qcmxRenderMeasureQ one of [x,y,z]| \item \lstinline|\qcmxRenderMeasureQQ one of [x,y,z,xy,xz,yz]| \item \lstinline|\qcmxRenderMeasureQQQ one of [x,y,z,xy,xz,yz,xyz]| \end{itemize} \clearpage \section*{One qubit states} \lstinputlisting{examples/one-qubit-ket-0.tex} \begin{center} \input{examples/one-qubit-ket-0.tex} \end{center} \lstinputlisting{examples/one-qubit-ket-1.tex} \begin{center} \input{examples/one-qubit-ket-1.tex} \end{center} \lstinputlisting{examples/one-qubit-ket-+.tex} \begin{center} \input{examples/one-qubit-ket-+.tex} \end{center} \section*{Amplitudes \& Phases} \lstinputlisting{examples/one-qubit-ket-amplitudes.tex} \begin{center} \input{examples/one-qubit-ket-amplitudes.tex} \end{center} \lstinputlisting{examples/one-qubit-ket-phase.tex} \begin{center} \input{examples/one-qubit-ket-phase.tex} \end{center} \pagebreak \section*{Two qubit state} \lstinputlisting{examples/two-qubit-state.tex} \begin{center} \input{examples/two-qubit-state.tex} \end{center} \pagebreak \section*{Three qubit state} \lstinputlisting{examples/three-qubit-state.tex} \resizebox{\textwidth}{!}{ \hspace{-22cm} \input{examples/three-qubit-state.tex} \hspace{2cm} } \pagebreak \section*{Orientation and Positioning of qubits} \lstinputlisting{examples/orientation-of-qubits.tex} \resizebox{\textwidth}{!}{ \hspace{-22cm} \input{examples/orientation-of-qubits.tex} \hspace{2cm} } The same works for: \begin{lstlisting} \def\qcmxOrientationQQ{xy} \end{lstlisting} Possible values are \lstinline|xy, xz, yz| to set the plane accordingly. And for future use: \lstinline|\def\qcmxOrientationQQQ{xyz}| is reserved, but there are no other valid values except \lstinline|xyz| for now. As you can see, the qcmx environment exposes a 3d Tikz canvas, there for you are free to use commands like \lstinline|\node at|\dots{} to add descriptive markings. \pagebreak \section*{Two qubit state from two one qubit state} \lstinputlisting{examples/example-rendering-phi-times-psi-equals-phipsi.tex} \resizebox{\textwidth}{!}{ \hspace{-17cm} \input{examples/example-rendering-phi-times-psi-equals-phipsi.tex} \hspace{8cm} } \pagebreak \section*{Transformation diagramms} \lstinputlisting{examples/one-qubit-transformations.tex} \resizebox{\textwidth}{!}{ \hspace{-20cm} \input{examples/one-qubit-transformations.tex} \hspace{5cm} } \pagebreak \lstinputlisting{examples/multi-qubit-transformation-hadamard.tex} \resizebox{\textwidth}{!}{ \hspace{-20cm} \input{examples/multi-qubit-transformation-hadamard.tex} \hspace{5cm} } As you can see the orientation of the Hadamard Transform is set by two parts, first the value of \lstinline|\qcmxOrientationQQ| is used to determine the plane, then the argument of \lstinline|\qcmxRenderHadamardQQ| is used to select the qubit that is transformed. The same is true for the pauli gates (x, y, z) as well as the three dimensional cube, even though \lstinline|\qcmxOrientationQQQ| can only be \lstinline|xyz| for now. \pagebreak \section*{Multi qubit transformations} \lstinputlisting{examples/cnot-on-three-qubits.tex} \resizebox{\textwidth}{!}{ \hspace{-20cm} \input{examples/cnot-on-three-qubits.tex} \hspace{5cm} } Additionaly there is the CCNot (Toffolie) gate, that can be rendered with the \lstinline|\qcmxRenderCCNotQQQ|. Obviously CNot and CCNot are only available in systems with at least two (or three) qubits respectively. \pagebreak \section*{Measurement of Qubits} \lstinputlisting{examples/measure-qubit.tex} \resizebox{\textwidth}{!}{ \hspace{-20cm} \input{examples/measure-qubit.tex} \hspace{5cm} } \pagebreak \lstinputlisting{examples/measure-one-of-two-qubits.tex} \resizebox{\textwidth}{!}{ \hspace{-20cm} \input{examples/measure-one-of-two-qubits.tex} \hspace{5cm} } For systems with only partial measurements the \lstinline|\qcmxOrientationQQ| and \lstinline|\qcmxOrientationQQQ| values are used to determin the unmeasured qubits. Additionaly it is possible to measure more than one qubit at the same time. For \lstinline|\qcmxRenderMeasureQQ| it is possible to choose from \lstinline|x, y, z, xy, xz, yz|. While for \lstinline|\qcmxRenderMeasureQQQ| \lstinline|xyz| is also available. \pagebreak \section*{Example: Teleportation Algorithm} \begin{center} \begin{quantikz} \lstick{$\ket{\psi}$} & \qw & \qw & \ctrl{1} & \gate{H} & \meter{} & \cw & \cwbend{2} \\ \lstick{Bob: $\ket{0}$} & \qw & \targ{} & \targ{} & \qw & \meter{} & \cwbend{1} \\ \lstick{Alice: $\ket{0}$} & \gate{H} & \ctrl{-1} & \qw & \qw & \qw & \gate{X} & \gate{Z} & \qw \rstick{$\ket{\psi}$} \end{quantikz} \resizebox{0.95\textwidth}{!}{ \hspace{-20cm} \input{examples/teleportation.tex} \hspace{5cm} } \end{center} \pagebreak \lstinputlisting{examples/teleportation.tex} \end{document}