Quantum.SIG examples

Quantum Fourier Transform (QFT)

Implement quantum phase estimation with the discrete Fourier transform for quantum computing applications.

⚙� Run Demo

How It Works

The Quantum Fourier Transform is the quantum implementation of the discrete Fourier transform. It serves as a crucial component in many quantum algorithms such as Shor's algorithm for integer factorization.

import { QuantumCircuit, QFT } from '@quantum-sig/core';

// Initialize a 4-qubit quantum circuit for QFT demonstration
async function runQFT() {
  const circuit = QuantumCircuit.builder()
    .addQubits(4)
    .applyHadamardToAll()
    .applyH(0)
    .applyCPHASE(0, 1, -Math.PI)
    .applyH(1)
    .applyCPHASE(0, 1, Math.PI)
    .applyCPHASE(1, 1, -Math.PI)
    .applyH(2)
    .applyCPHASE(0, 2, Math.PI/2)
    .applyCPHASE(1, 2, -Math.PI/2)
    .applyCPHASE(2, 2, Math.PI)
    .measureAll();

  const result = await QFT.execute(circuit);
  document.getElementById('qft-result').innerText = 
    `Transformed State: ${result.stateVector.map(s => s.toFixed(4)).join(', ')}`;
  updateQubits(result.probabilities);
}

runQFT();

This implementation demonstrates the recursive QFT algorithm with conditional phase shifts.

Transformation Results

Waiting for execution...

State Probability Distribution

Probability distribution of final qubit states after QFT

QFT Circuit Architecture

Q3 Q2 Q1

Quantum circuit illustrating the layered entanglement and phase rotation operations in QFT