# Qiskit **Param - Power of Parameter [closed]

Trying to create gate, that its angle is parametrized, where my parameter is k, and I want to assign to theta = 1/2**k - 2 in the power of k. Looks like:

k = Parameter('k')
# Build a sub-circuit
q = QuantumRegister(2)
CROT_circ = QuantumCircuit(q, name='CROT')
theta = 2*pi/(2**k)
CROT_circ.cp(theta, 0, 1)


And I get this error:

TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'Parameter'

Suggestions? Thanks!

• I’m voting to close this question because it is not about quantum computing. The question is about operator overloading in python and belongs on StackOverflow. Dec 21 '21 at 18:07
• Actually it is about qiskit specifically, because this is a problem of the Parameter object, which is part of qiskit Dec 22 '21 at 9:58
• @RonCohen just to clarify regarding the on-topicness: this question is indeed clearly about qiskit, but it is specifically about purely programming aspects of it, as also evident from the answer, which is just about how to write a mathematical expression with numpy. Questions about qiskit are on-topic here, but only as long as they require some knowledge of quantum computation/mechanics to be answered. Purely programming questions can already be asked e.g. on stackoverflow.
– glS
Dec 27 '21 at 7:58

Using the fact that $$2^{-k}=e^{\ln(0.5)k}$$,
theta = 2*pi/(2**k)

theta = 2 * pi * numpy.exp(numpy.log(0.5) * k)