2
$\begingroup$

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?

$\endgroup$
1
2
$\begingroup$

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

$\endgroup$
4
  • $\begingroup$ 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 $\endgroup$ – user3717194 Feb 19 at 5:25
  • 1
    $\begingroup$ 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. $\endgroup$ – KAJ226 Feb 19 at 5:29
  • $\begingroup$ Yes general case. Is there any helper function already in Qiskit? (Otherwise, I've just written up my own implementation already) $\endgroup$ – user3717194 Feb 19 at 5:29
  • $\begingroup$ 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. $\endgroup$ – KAJ226 Feb 19 at 5:33
0
$\begingroup$

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(-i*op*0.02)
gate = HamiltonianGate(op, 0.02)
circuit = QuantumCircuit(3)

# apply gate to qubits [0, 1, 2] in circuit
circuit.append(gate, [0, 1, 2])
$\endgroup$
1
  • 1
    $\begingroup$ Hi and welcome to Quantum Computing SE. Please add some details how the code works (e.g. add comment to each line what it does). $\endgroup$ – Martin Vesely Feb 20 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.