TimeEvolution
Extends:
Gate for time evolution under a Hamiltonian (QubitOperator object).
This gate is the unitary time evolution propagator: exp(-i H t), where H is the Hamiltonian of the system and t is the time. Note that -i factor is stored implicitely.
Example:
wavefunction = eng.allocateQureg(5)
hamiltonian = 0.5 * QubitOperator("X0 Z1 Y5")
# Apply exp(-i * H * t) to the wavefunction:
TimeEvolution(time=2.0, hamiltonian=hamiltonian) | wavefunction
Attributes:
time(float, int): time t
hamiltonian(QubitOperator): hamiltonaian H
Constructor Summary
Public Constructor | ||
public |
constructor(time: number, hamiltonian: QubitOperator) |
Member Summary
Public Members | ||
public |
hamiltonian: * |
|
public |
time: * |
Method Summary
Public Methods | ||
public |
equal() |
|
public |
getInverse(): * |
|
public |
getMerged(other: TimeEvolution): TimeEvolution Return self merged with another TimeEvolution gate if possible. |
|
public |
Operator| overload which enables the following syntax: |
|
public |
|
Inherited Summary
From class BasicGate | ||
public static |
Convert quantum input of "gate | quantum input" to internal formatting. |
|
public |
|
|
public |
|
|
public |
|
|
public |
generateCommand(qubits: *): Command Helper function to generate a command consisting of the gate and the qubits being acted upon. |
|
public |
|
|
public |
|
|
public |
|
|
public |
or(qubits: *) Operator| overload which enables the syntax Gate | qubits. |
|
public |
toString() |
Public Constructors
public constructor(time: number, hamiltonian: QubitOperator) source
Override:
BasicGate#constructorParams:
Name | Type | Attribute | Description |
time | number | time to evolve under (can be negative). |
|
hamiltonian | QubitOperator | hamiltonian to evolve under. |
Throw:
If time is not a numeric type and hamiltonian is not a QubitOperator. |
|
NotHermitianOperatorError |
If the input hamiltonian is not hermitian (only real coefficients). |
Public Methods
public getMerged(other: TimeEvolution): TimeEvolution source
Return self merged with another TimeEvolution gate if possible.
Two TimeEvolution gates are merged if: 1) both have the same terms 2) the proportionality factor for each of the terms must have relative error <= 1e-9 compared to the proportionality factors of the other terms.
Note: While one could merge gates for which both hamiltonians commute, we are not doing this as in general the resulting gate would have to be decomposed again.
Note: We are not comparing if terms are proportional to each other with an absolute tolerance. It is up to the user to remove terms close to zero because we cannot choose a suitable absolute error which works for everyone. Use, e.g., a decomposition rule for that.
Override:
BasicGate#getMergedParams:
Name | Type | Attribute | Description |
other | TimeEvolution | TimeEvolution gate |
Throw:
If the other gate is not a TimeEvolution gate or hamiltonians are not suitable for merging. |
public or(qubits: Array<Qubit> | Qureg | Qubit) source
Operator| overload which enables the following syntax:
Override:
BasicGate#orExample:
TimeEvolution(...) | qureg
TimeEvolution(...) | (qureg,)
TimeEvolution(...) | qubit
TimeEvolution(...) | (qubit,)
Unlike other gates, this gate is only allowed to be applied to one
quantum register or one qubit.
wavefunction = eng.allocateQureg(5)
hamiltonian = QubitOperator("X1 Y3", 0.5)
TimeEvolution(time=2.0, hamiltonian=hamiltonian) | wavefunction
While in the above example the TimeEvolution gate is applied to 5
qubits, the hamiltonian of this TimeEvolution gate acts only
non-trivially on the two qubits wavefunction[1] and wavefunction[3].
Therefore, the operator| will rescale the indices in the hamiltonian
and sends the equivalent of the following new gate to the MainEngine:
h = QubitOperator("X0 Y1", 0.5)
TimeEvolution(2.0, h) | [wavefunction[1], wavefunction[3]]
which is only a two qubit gate.