4

For example the following circuit is for $e^{-i(Z\otimes Z\otimes Z)\Delta t} $

enter image description here

I know this can even be done without the ancilla qubit, having the CNOTs control the last qubit and applying an RZ on the last qubit. Also, if instead of only Zs, our Pauli matrix is any combination of $I$,$X$,$Y$ and $Z$, we can still have it in this sort of format by swapping the $X-Z$ or $Y-Z$ bases before and after the circuit shown above.

So if I have an operator like $e^{-i 0.022616399973028944 YYXX}$, in Qiskit, how I can make this into a circuit of this kind of form? I am looking for a function that does this for a general operator of this form. Is there such a function in Qiskit?

glS
  • 24,708
  • 5
  • 34
  • 108
shashvat
  • 805
  • 4
  • 13

2 Answers2

3

How about:

enter image description here

Note that $X = HZH$ and $Y= R_Z(-\pi/2) H Z H R_Z(\pi/2)$.

In term of is there a way to do this automatically in qiskit, I don't think there is a way to do this for general case in qiskit... but I might be wrong. My best bet is you will have to write your own function to do this automatically. It shouldn't be too much of a task.


If you want to do it without the ancilla qubit case like you mentioned in your question, then you can use WeightedPauliOperator from qiskit.

For example:

pauli_dict = {'paulis': [{"coeff": {"imag": 0, "real": 0.04523/2 }, "label": "XXYY"}]}
operator = WeightedPauliOperator.from_dict(pauli_dict)
circuit = operator.evolve(evo_time= 1, num_time_slices=1).decompose()
circuit.draw( 'mpl',style={'name': 'bw'}, plot_barriers= False, initial_state = True, scale = 1)

will generate the circuit:

enter image description here

KAJ226
  • 13,822
  • 2
  • 10
  • 30
  • Hi, thank you for sharing the circuit, this is exactly what I want to produce. I am looking for how I can do this using code in Qiskit – shashvat Feb 19 '21 at 05:25
  • 1
    Do you want to do it in general case or just specifically? If it is general, then you want to write a function to do such thing automatically. – KAJ226 Feb 19 '21 at 05:29
  • Yes general case. Is there any helper function already in Qiskit? (Otherwise, I've just written up my own implementation already) – shashvat Feb 19 '21 at 05:29
  • I see. I don't think there is a function within qiskit to do this. If you don't want to use ancilla case then there is a way through operator.evolve() but I guess you have to write your own function... sorry to misunderstood your point earlier. – KAJ226 Feb 19 '21 at 05:33
3

You can try,

from qiskit.quantum_info import Operator
from qiskit.extensions import HamiltonianGate

create tensor of single-qubit operators. Recognized labels are

I, X, Y, Z, H, S, T, 0, 1, +, -, r, l

op = Operator.from_label('ZZZ')

create gate which evolves according to exp(-iop0.02)

gate = HamiltonianGate(op, 0.02) circuit = QuantumCircuit(3)

apply gate to qubits [0, 1, 2] in circuit

circuit.append(gate, [0, 1, 2])

viwosh
  • 51
  • 2