Jump to content

File:Qcircuit ToffolifromCNOT.svg

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file (SVG file, nominally 1,959 × 584 pixels, file size: 20 KB)

Summary

Description
English: Quantum circuit diagram constructing a Toffoli gate from single-qubit operations and six controlled NOT (CNOT) gates. This is the minimum number of CNOTs required to build a Toffoli.[1]
Date
Source

Own work

Created in LaTeX using Q-circuit
Author Geek3
SVG development
InfoField
 
The SVG code is valid.
 
This vector image was created with LaTeX, using Q-circuit
gate matrix:
Source code
InfoField

LaTeX code

LaTeX Qcircuit source code
\documentclass[border=10pt]{standalone}
\input{Qcircuit} % available on https://github.com/CQuIC/qcircuit
\usepackage{graphicx}
\begin{document}
\newcommand{\multistate}[2]{*+{\hphantom{#2}} \POS[0,0].[#1,0] !C
  *{#2} \POS[0,0].[#1,0] \drop\frm{}}
\newcommand{\ghoststate}[1]{*+{\hphantom{#1}} }
\newcommand{\ccteqg}{\ghoststate{=}}
\newcommand{\ccteq}[1]{\multistate{#1}{=}}
\scalebox{5}{%
\Qcircuit @C=0.8em {
& \control \qw & \qw & \ccteq{2} & & \qw & \qw & \qw & \control \qw & \qw &
\qw & \qw & \control \qw & \qw & \control \qw & \gate{T} & \control \qw & \qw \\
& \control \qw \qwx & \qw & \ccteqg & & \qw & \control \qw & \qw & \qw \qwx &
\qw & \control \qw & \qw & \qw \qwx & \gate{T} & \targ \qwx & \gate{T^\dagger}
& \targ \qwx  & \qw \\
& \targ \qw \qwx & \qw & \ccteqg & & \gate{H} & \targ \qwx & \gate{T^\dagger}
& \targ \qwx & \gate{T} & \targ \qwx & \gate{T^\dagger} & \targ \qwx & \gate{T}
& \qw & \gate{H} & \qw & \qw }}
\end{document}

Bash code

postprocessing with pdf2svg, Inkscape and Scour
x=Qcircuit_ToffolifromCNOT;
pdflatex $x.tex;
pdf2svg $x.pdf $x_.svg;
inkscape --without-gui --verb=EditSelectAll --verb=SelectionUnGroup --verb=FileVacuum --verb=FileSave --verb=FileClose $x_.svg;
scour -i $x_.svg -o $x.svg --renderer-workaround --remove-metadata --enable-id-stripping --create-groups --enable-viewboxing

Mathematica code

The following Mathematica code shows the equality:
PauliMatrix = {{{0, 1}, {1, 0}}, {{0, -I}, {I, 0}}, {{1, 0}, {0, -1}}}[[#1]] &;
R[x_, y_, z_] := MatrixExp[-I/2 Sum[{x, y, z}[[i]]*PauliMatrix[i], {i, 3}]];
A_B_ := KroneckerProduct[A, B];
A_B_C_ := KroneckerProduct[A, B, C];
Gn[G_, i_, n_] := Fold[#1#2 &, {{1}}, ReplacePart[Table[I2, {n}], i -> G]];
I2 = IdentityMatrix[2];
X = R[Pi, 0, 0] I;
Z = R[0, 0, Pi] I;
H = {{1, 1}, {1, -1}}/Sqrt[2];
T = Exp[I Pi/8] R[0, 0, Pi/4];
Tdag = ConjugateTranspose[T];
Swap = {{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}};
CNOT = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}, {0, 0, 1, 0}};
CNOT12 = (CNOTI2);
CNOT23 = (I2CNOT);
CNOT13 = (SwapI2).CNOT23.(SwapI2);

Toffoli = 
 CNOT12.(TTdagH).CNOT12.(I2TT).CNOT13.Gn[Tdag, 3, 3].CNOT23.Gn[
    T, 3, 3].CNOT13.Gn[Tdag, 3, 3].CNOT23.Gn[H, 3, 3] // MatrixForm

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
  1. On the CNOT-cost of TOFFOLI gates

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

20,448 byte

image/svg+xml

8b4b2a4e6ab4a1f94e63efdf3e5e8a8971c6ce77

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current22:13, 9 January 2019Thumbnail for version as of 22:13, 9 January 20191,959 × 584 (20 KB)Geek3User created page with UploadWizard

The following page uses this file:

Global file usage

The following other wikis use this file:

Metadata