# How to prepare an initial state for variational quantum algorithms?

I would like to prepare an initial state for variational quantum algorithms.

The initial state should include the following states: $$|000\rangle, |010\rangle, |100\rangle$$, and $$|001\rangle$$.

How can I prepare this initial state?

FYI, I referred to this paper. In this paper, the circuit creates $$|100\rangle$$, $$|101\rangle$$, and $$|001\rangle$$.

In addition, the Hamiltonian I want to solve is $$H = - \frac{1}{2} \varepsilon \sum_{i=1}^{N} Z_i + \frac{1}{4} V \sum_{i,j=1}^N(X_iXj - Y_iY_j) \;,$$ where $$\varepsilon$$ and $$V$$ is the coefficients and $$N$$ is the number of quits.

To prepare this state specifically, start with $$|000\rangle$$ and apply H to the 0th and 1st qubits, yielding

$$\frac{1}{4} (|000\rangle + |010\rangle + |100\rangle + |110\rangle)$$

Then, we can apply the Toffoli gate to the 0th and 1st qubit with the 2nd qubit as the target, yielding:

$$\frac{1}{4} (|000\rangle + |010\rangle + |100\rangle + |111\rangle)$$

Now, apply a CNOT with 2nd qubit as control and 0th and 1st qubits as targets, yielding:

$$\frac{1}{4} (|000\rangle + |010\rangle + |100\rangle + |001\rangle)$$

As desired.

More talk on state prep

Because your Hamiltonian is relatively simple, both Trotterization and Variational Quantum Eigensolvers (VQEs) could work. I'll refer to the VQE, because it talks more about quantum state prep, specifically:

If a quantum state is characterized by an exponentially large number of parameters, it cannot be prepared with a polynomial number of operations. The set of efficiently preparable states are therefore characterized by polynomially many parameters, and we choose a particular set of ansatz states of this type.

Basically, especially for quantum chem algorithms with complex ansatzes, we need efficient state preparation algorithms that are parametrized with a polynomial number of parameters. This is still an active area of research and especially important for Trotterization/VQEs/Qubitization, etc.

• To calculate with VQE, we have to prepare the initial state as the following style: $$a|000> + b|010> + c|100> + d|100>$$ with $$a^2 + b^2 + c^2 + d^2 = 1$$. Am I right ?
– Ashy
Commented Oct 13, 2019 at 6:47
• @Ashy all quantum states need to be in the form $\sum_{i} a_i |i \rangle$ where $\sum_{i} |a_i|^2 = 1$ and $a_i \in \mathbb{C}$ Commented Oct 13, 2019 at 15:23
• To calculate the minimum value with VQE, I think we should prepare the initial state with some parameters.
– Ashy
Commented Oct 15, 2019 at 7:22
• @Ashy, do you have a specific question? If so, I'd recommend creating a new question Commented Oct 15, 2019 at 17:37
• you have to change the initial state |x(theta)> with respect to theta to find the minimu value of <x(theta) | H | x(theta) > for variational calculations. However, the state you mentioned is not changeable. Anyway, I make a new question. Thank you very much.
– Ashy
Commented Oct 16, 2019 at 9:27

State preparation in general is a common task for beginning quantum algorithms. Most generically, you can prepare your state with Classiq like this. Classiq Function Library in Github

from classiq import *

@qfunc
def main(x: Output[QArray[QBit]]):
probabilities = [0.25, 0.25, 0.25, 0.0, 0.25, 0.0, 0.0, 0.0] #prepare the state 0.25(|000> + |001> + |010> + |001>)[![enter image description here][2]][2]
prepare_state(probabilities=probabilities, bound=0.0, out=x)

qmod = create_model(main)
write_qmod(qmod, "prepare_state")
qprog = synthesize(qmod)

job = execute(qprog)
result = job.result()[0].value
print(result.parsed_counts)

job.open_in_ide()