Main Content

qftGate

Quantum Fourier transform gate

Since R2023a

Installation Required: This functionality requires MATLAB Support Package for Quantum Computing.

Description

cg = qftGate(targetQubits) applies the quantum Fourier transform (QFT) to the target qubits and returns a quantum.gate.CompositeGate object with a Name property of "qft".

example

Examples

collapse all

Create a quantum Fourier transform gate that acts on three qubits.

cg = qftGate(1:3)
cg = 

  CompositeGate with properties:

             Name: "qft"
    ControlQubits: [1×0 double]
     TargetQubits: [3×1 double]
            Gates: [7×1 quantum.gate.SimpleGate]

Get the matrix representation of the gate.

M = getMatrix(cg)
M =

  Columns 1 through 5

   0.3536 + 0.0000i   0.3536 + 0.0000i   0.3536 + 0.0000i   0.3536 + 0.0000i   0.3536 + 0.0000i
   0.3536 + 0.0000i   0.2500 + 0.2500i   0.0000 + 0.3536i  -0.2500 + 0.2500i  -0.3536 + 0.0000i
   0.3536 + 0.0000i   0.0000 + 0.3536i  -0.3536 + 0.0000i  -0.0000 - 0.3536i   0.3536 + 0.0000i
   0.3536 + 0.0000i  -0.2500 + 0.2500i  -0.0000 - 0.3536i   0.2500 + 0.2500i  -0.3536 + 0.0000i
   0.3536 + 0.0000i  -0.3536 + 0.0000i   0.3536 + 0.0000i  -0.3536 + 0.0000i   0.3536 + 0.0000i
   0.3536 + 0.0000i  -0.2500 - 0.2500i   0.0000 + 0.3536i   0.2500 - 0.2500i  -0.3536 + 0.0000i
   0.3536 + 0.0000i  -0.0000 - 0.3536i  -0.3536 + 0.0000i   0.0000 + 0.3536i   0.3536 + 0.0000i
   0.3536 + 0.0000i   0.2500 - 0.2500i  -0.0000 - 0.3536i  -0.2500 - 0.2500i  -0.3536 + 0.0000i

  Columns 6 through 8

   0.3536 + 0.0000i   0.3536 + 0.0000i   0.3536 + 0.0000i
  -0.2500 - 0.2500i  -0.0000 - 0.3536i   0.2500 - 0.2500i
   0.0000 + 0.3536i  -0.3536 + 0.0000i  -0.0000 - 0.3536i
   0.2500 - 0.2500i   0.0000 + 0.3536i  -0.2500 - 0.2500i
  -0.3536 + 0.0000i   0.3536 + 0.0000i  -0.3536 + 0.0000i
   0.2500 + 0.2500i  -0.0000 - 0.3536i  -0.2500 + 0.2500i
  -0.0000 - 0.3536i  -0.3536 + 0.0000i   0.0000 + 0.3536i
  -0.2500 + 0.2500i   0.0000 + 0.3536i   0.2500 + 0.2500i

Plot the returned QFT gate to show its internal gates.

plot(cg)

Create a quantum circuit that consists of two QFT gates. The first gate acts on qubits with indices 2 to 4. The second gate acts on qubits with indices 1, 3, and 5.

gates = [qftGate(2:4); qftGate([1 3 5])];
c = quantumCircuit(gates)
c = 

  quantumCircuit with properties:

    NumQubits: 5
        Gates: [2×1 quantum.gate.CompositeGate]
         Name: ""

Plot the quantum circuit.

plot(c)

Quantum circuit with two QFT gates

The plotted circuit consists of five qubits with indices 1 to 5. The plot shows that qubits 2 to 4 of the outer circuit are mapped to qubits 1 to 3 of the inner circuit of internal gates that construct the first QFT gate. For the second QFT gate, qubit 1 of the outer circuit is mapped to qubit 1 of the inner circuit, qubit 3 of the outer circuit is mapped to qubit 2 of the inner circuit, and qubit 5 of the outer circuit is mapped to qubit 3 of the inner circuit.

Click either QFT gate in the plot. A new figure showing the internal gates of the composite gate appears.

Internal gates of the QFT composite gate

Input Arguments

collapse all

Target qubits to apply QFT, specified as a positive integer vector of qubit indices.

More About

collapse all

Quantum Fourier Transform

The quantum Fourier transform (QFT) acts on a quantum state |x=m=0N1xm|m and maps it to a quantum state |y=k=0N1yk|k according to the formula:

yk=1Nm=0N1xmωNmkk=0,1,,N1,

where ωN=exp(2πiN) and ωNk is an Nth root of unity.

Here, N=2n is the number of basis states for the n qubits that are quantum Fourier transformed. The state |m (or |k) represents the binary notation |m1m2mn of the possible basis states, where the value of m is m=2n1m1+2n2m2++21mn1+20mn. By this definition, the effect of the QFT on the state vector matches the inverse discrete Fourier transform, but with a difference in the scaling factor because QFT uses 1/N instead of 1/N.

In matrix representation, the QFT can also be expressed as

QFT=1N[111111ωω2ω3ωN11ω2ω4ω6ω2(N1)1ω3ω6ω9ω3(N1)1ωN1ω2(N1)ω3(N1)ω(N1)(N1)].

References

[1] Nielsen, Michael A., and Isaac L. Chuang. Quantum Computation and Quantum Information. 10th anniversary ed, Cambridge; New York: Cambridge University Press, 2010.

Version History

Introduced in R2023a