# Weird statevector shown after Ripple Carry Adder

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 *
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.draw('mpl')


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.

• 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 ? Apr 6, 2022 at 23:56
• 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. Apr 7, 2022 at 10:16
• Thank you for your answer. I will have a try. Apr 7, 2022 at 21:12
• 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. Apr 13, 2022 at 20:09