Skip to content

Latest commit

 

History

History
 
 

gaussian-initial-state

page_type languages products urlFragment description jupyter
sample
qsharp
qdk
gaussian-initial-state
This sample demonstrates using Quantum Development Kit to prepare the Gaussian initial state.
jupytext kernelspec
cell_markers text_representation
region,endregion
extension format_name format_version jupytext_version
.md
markdown
1.2
1.5.2
display_name language name
.NET (PowerShell)
PowerShell
.net-powershell

Gaussian Initial State Sample

This sample demonstrates the use of the Quantum Development Kit for preparing the Gaussian initial state.

The goal of the algorithm is to prepare a quantum state that encodes the Gaussian wavefunction using probability amplitudes. The Gaussian state can be defined via a recursive definition, as described in arXiv:0801.0342.

Image of Gaussian state definition

We implemented this algorithm in two ways in Q#. The first is as a for loop, following the approach outlined in Guen Prawiroatmodjo's blog post. The second is by recursion.

In particular, the recursive approach calls the following subroutine, using the input data (sigma0, mu0) = (sigma, mu).

    1. Calculate alpha from sigma and mu.
    2. Apply the rotation operation Ry(alpha, _) to the 0th qubit.
  1. Compute (sigma1, mu1), where sigma1 = sigma0 / 2.0 and mu1 = mu0 / 2.0 if the previously rotated qubit is in the |0⟩ state, and mu1 = (mu0 - 1) / 2.0 if it is in the |1⟩ state.
  2. On the remaining N - 1 qubits, prepare the state |ψ(sigma1, mu1, N - 1)⟩.

Note that after the last qubit, we proceed only through step 1 (b), as after this qubit is rotated we do not need another pair of parameters.

Both approaches use the ApplyControlledOnBitString operation in Q#.

Prerequisites

Running the Sample

To run the sample, use the dotnet run command from your terminal, passing which of the algorithms and how many qubits you'd like to use:

dotnet run -- --recursive true --n-qubits 7

To plot the state prepared by this Q# program, you can use Q# + Python interoperability:

python host.py

Manifest