qrisp.operators.fermionic.FermionicOperator.trotterization#
- FermionicOperator.trotterization(t=1, steps=1, iter=1)[source]#
Returns a function for performing Hamiltonian simulation, i.e., approximately implementing the unitary operator \(e^{itH}\) via Trotterization. Note that this method will always simulate the hermitized operator, i.e.
\[H = (O + O^\dagger)/2\]- Returns:
- Ufunction
A Python function that implements the first order Suzuki-Trotter formula. Given a Hamiltonian \(H=H_1+\dotsb +H_m\) the unitary evolution \(e^{itH}\) is approximated by
\[e^{itH}\approx U_1(t,N)=\left(e^{iH_1t/N}\dotsb e^{iH_mt/N}\right)^N\]This function recieves the following arguments:
- qargQuantumVariable or QuantumArray
The quantum argument.
- tfloat, optional
The evolution time \(t\). The default is 1.
- stepsint, optional
The number of Trotter steps \(N\). The default is 1.
- iterint, optional
The number of iterations the unitary \(U_1(t,N)\) is applied. The default is 1.
Examples
We simulate a simple FermionicOperator.
>>> from sympy import Symbol >>> from qrisp.operators import a,c >>> from qrisp import QuantumVariable >>> O = a(0)*a(1) + a(2) >>> U = O.trotterization() >>> qv = QuantumVariable(3) >>> t = Symbol("t") >>> U(qv, t = t) >>> print(qv.qs) QuantumCircuit: --------------- ┌───┐ ┌───┐ ┌────────────┐ ┌───┐┌───┐ qv.0: ────■─┤ X ├────┤ X ├───────■──┤ Rz(-0.5*t) ├──■──┤ X ├┤ X ├─■──── │ └─┬─┘ ├───┤ ┌─┴─┐├────────────┤┌─┴─┐├───┤└─┬─┘ │ qv.1: ─■──┼───■──────┤ H ├─────┤ X ├┤ Rz(-0.5*t) ├┤ X ├┤ H ├──■───┼──■─ │ │ ┌───┐┌───┴───┴────┐├───┤└────────────┘└───┘└───┘ │ │ qv.2: ─■──■─┤ H ├┤ Rz(-1.0*t) ├┤ H ├──────────────────────────────■──■─ └───┘└────────────┘└───┘ Live QuantumVariables: ---------------------- QuantumVariable qv
Execute a simulation:
>>> print(qv.get_measurement(subs_dic = {t : 0.5})) {'000': 0.9242, '001': 0.06026, '110': 0.01459, '111': 0.00095}