page_type | languages | products | urlFragment | description | jupyter | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
|
|
gaussian-initial-state |
This sample demonstrates using Quantum Development Kit to prepare the Gaussian initial state. |
|
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.
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)
.
-
- Calculate
alpha
fromsigma
andmu
. - Apply the rotation operation
Ry(alpha, _)
to the 0th qubit.
- Calculate
- Compute
(sigma1, mu1)
, wheresigma1 = sigma0 / 2.0
andmu1 = mu0 / 2.0
if the previously rotated qubit is in the |0⟩ state, andmu1 = (mu0 - 1) / 2.0
if it is in the |1⟩ state. - 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#.
- The Microsoft Quantum Development Kit.
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
- PrepareGaussian.qs: Q# code defining how to prepare Gaussian state.
- Program.qs: Q# entry point to interact with and print out results of the Q# operations for this sample.
- gaussian-initial-state.csproj: Main Q# project for the example.