Home Reference Source
import TimeEvolution from 'projectq/src/ops/timeevolution.js'
public class | source

TimeEvolution

Extends:

BasicGate → TimeEvolution

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
public

time: *

Method Summary

Public Methods
public

equal()

public

getInverse(): *

public

Return self merged with another TimeEvolution gate if possible.

public

or(qubits: Array<Qubit> | Qureg | Qubit)

Operator| overload which enables the following syntax:

public

Inherited Summary

From class BasicGate
public static

makeTupleOfQureg(qubits: Qubit | Qubit[] | Qureg | Qureg[]): Qureg[]

Convert quantum input of "gate | quantum input" to internal formatting.

public
public
public

equal(other: BasicGate | Object): boolean

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

Public Constructors

public constructor(time: number, hamiltonian: QubitOperator) source

Override:

BasicGate#constructor

Params:

NameTypeAttributeDescription
time number

time to evolve under (can be negative).

hamiltonian QubitOperator

hamiltonian to evolve under.

Throw:

Error

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 Members

public hamiltonian: * source

public time: * source

Public Methods

public equal() source

Override:

BasicGate#equal

public getInverse(): * source

Override:

BasicGate#getInverse

Return:

*

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#getMerged

Params:

NameTypeAttributeDescription
other TimeEvolution

TimeEvolution gate

Return:

TimeEvolution

New TimeEvolution gate equivalent to the two merged gates.

Throw:

NotMergeable

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#or

Params:

NameTypeAttributeDescription
qubits Array<Qubit> | Qureg | Qubit

one Qubit object, one list of Qubit objects, one Qureg object, or a tuple of the former three cases.

Example:


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.

public toString(): string source

Override:

BasicGate#toString

Return:

string