1
$\begingroup$

I am using Qiskit to simulate a probabilistic problem. However, part of it I have to use a Ripple Carry Adder to calculate the result and reset the input part for future use. But I cannot use the function "reset()", I need to switch the input state back to zero by using like Rx,Ry gates. But the state vector shown after the Adder is so weird especially qubit 4 and 5 why the arrow point to the inside of the Bloch-sphere instead of outside? What it means ? Please help me, thanks.

Here is the code I am using:"

import numpy as np
from qiskit import *
from qiskit_finance.circuit.library import *
from qiskit.circuit.library import HRSCumulativeMultiplier,CDKMRippleCarryAdder
myAdder = CDKMRippleCarryAdder(2, 'full')
P= NormalDistribution(3, mu=0, sigma=5)


qr=QuantumRegister(6)
cr=ClassicalRegister(1)
q=QuantumCircuit(qr,cr)
q.append(P_two,qr[1:3])
q.append(myAdder,qr[:])
q.draw('mpl')

circuit draw weird statevector

$\endgroup$

1 Answer 1

2
$\begingroup$

But the state vector shown after the Adder is so weird especially qubit 4 and 5 why the arrow point to the inside of the Bloch-sphere instead of outside

This is because the state is entangled. Qiskit textbook explains this here.

I need to switch the input state back to zero by using like Rx,Ry gates.

If you want to undo the effect of some gate (this is called uncomputation), you can apply its inverse which can simply be constructed by using inverse() method . For example, to undo the effect of the adder in your circuit, you can use the following:

q.append(myAdder.inverse(),qr[:])

See here for more details about uncomputation.

$\endgroup$
4
  • $\begingroup$ Thank you so much for the entangled state mentioned. For the inverse() function, I only want to uncomputation the input and leave the output for future use. Is it possible to like only inverse some part of it ? $\endgroup$
    – Parker
    Apr 6, 2022 at 23:56
  • $\begingroup$ CDKMRippleCarryAdder writes the result in place of 2nd operand and carry-out. That means some input qubits are used to store output. So, you may need to use the "compute-copy-uncompute" tirck by copying the result to some ancillary qubits using CNOTs then uncompute. $\endgroup$ Apr 7, 2022 at 10:16
  • $\begingroup$ Thank you for your answer. I will have a try. $\endgroup$
    – Parker
    Apr 7, 2022 at 21:12
  • $\begingroup$ Hi, I have read those material but I am wondering if I use "HRSCumulativeMultiplier" instead of the RippleCarryAdder which all inputs qubits are kept. Is there any way to make the input entangled state back to zero by not using any ancillary qubits? When I am using the Multiplier, the input qubit should keep the same however those input qubits become entangled although the probability remains the same. So I cannot directly just use ".inverse()". I have no idea how to make this input back to zero state. $\endgroup$
    – Parker
    Apr 13, 2022 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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