ket.qulib.prepare¶
Quantum state preparation.
Utilities for preparing quantum states.
Functions ket.qulib.prepare
¶
|
Prepare a Bell state = \(\frac{1}{\sqrt{2}}(\ket{0}+\ket{1})\) state. |
|
Prepare a GHZ = \(\frac{1}{\sqrt{2}}(\ket{0\dots0}+\ket{1\dots1})\) state. |
|
Prepare a quantum state in the +1 or -1 eigenstate of a Pauli operator. |
|
Prepare a quantum state from a list of amplitudes probabilities. |
|
Prepare a W = \(\frac{1}{\sqrt{n}}\sum_{k=0}^{n}\ket{2^k}\) state. |
- bell(qubit_a: Quant, qubit_b: Quant) Quant ¶
Prepare a Bell state = \(\frac{1}{\sqrt{2}}(\ket{0}+\ket{1})\) state.
- ghz(qubits: Quant) Quant ¶
Prepare a GHZ = \(\frac{1}{\sqrt{2}}(\ket{0\dots0}+\ket{1\dots1})\) state.
- pauli_state(pauli: Literal['X', 'Y', 'Z'], eigenvalue: Literal[1, -1], qubits: Quant | None = None) Quant | Callable[[Quant], Quant] ¶
Prepare a quantum state in the +1 or -1 eigenstate of a Pauli operator.
This function prepares a quantum state in the +1 or -1 eigenstate of a specified Pauli operator. The resulting quantum state can be obtained by either directly calling the function with qubits, or by returning a closure that can be applied to qubits later.
- Parameters:
pauli – Pauli operator to prepare the eigenstate for.
eigenvalue – Eigenvalue of the Pauli operator (+1 or -1).
qubits – Qubits to prepare the eigenstate on. If None, returns a closure.
- Returns:
If qubits is provided, returns the resulting quantum state. If qubits is None, returns a closure that can be applied to qubits later.
- state(amp: list[complex], qubits: Quant)¶
Prepare a quantum state from a list of amplitudes probabilities.
If the qubits are in the state \(\ket{0\dots0}\), the resulting state will be \(\sum_{i=0}^{n} a_i \ket{i}\), where \(a_i\) are the amplitudes corresponding to the computational basis states.
The amplitude probabilities are normalized automatically, so the sum of the squares of the absolute values of the amplitudes will be equal to 1.
Warning
The execution time of this function is exponential in the number of qubits.
- Parameters:
amp – List of complex numbers representing the amplitudes of the quantum state.
qubits – Qubits to prepare the quantum state on.