# Quantum Fourier transform, three qubits

> Hadamards, controlled phase rotations, and the final swap of the first and last qubits. A quantikz example with its LaTeX source.

A quantikz example in the TeXeR TikZ library: https://texer.org/library/quantikz/qft-three

Package: [quantikz](https://texer.org/library/quantikz.md), on CTAN at https://ctan.org/pkg/quantikz.

Tags: QFT, fourier transform, three qubit

## Source

```latex
\usepackage{quantikz}

\begin{quantikz}
  \lstick{$|x_1\rangle$} & \gate{H} & \gate{R_2} & \gate{R_3} & \qw & \qw & \qw & \swap{2} & \qw \\
  \lstick{$|x_2\rangle$} & \qw & \ctrl{-1} & \qw & \gate{H} & \gate{R_2} & \qw & \qw & \qw \\
  \lstick{$|x_3\rangle$} & \qw & \qw & \ctrl{-2} & \qw & \ctrl{-1} & \gate{H} & \targX{} & \qw
\end{quantikz}
```

## As a complete document

The same example in a document that compiles on its own with pdfLaTeX:

```latex
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{quantikz}

\begin{document}

\begin{quantikz}
  \lstick{$|x_1\rangle$} & \gate{H} & \gate{R_2} & \gate{R_3} & \qw & \qw & \qw & \swap{2} & \qw \\
  \lstick{$|x_2\rangle$} & \qw & \ctrl{-1} & \qw & \gate{H} & \gate{R_2} & \qw & \qw & \qw \\
  \lstick{$|x_3\rangle$} & \qw & \qw & \ctrl{-2} & \qw & \ctrl{-1} & \gate{H} & \targX{} & \qw
\end{quantikz}
\end{document}
```
