This question is on quantum computing where I have to: Write a function createQubit. It takes two inputs: alpha and beta. These are floating point values. It should return a list [x,y] where: x = alpha / N y = beta / N and: N = sqrt(alpha2 + beta2 ) This makes sure that the list [x,y] is a proper qubit (in that it is normalized: x2 + y2 = 1). (Check this yourself on paper and make sure x2 + y2 = 1)
Here is the code
import math
import random
def createQubit(alpha, beta):
N = math.sqrt(alpha**2 + beta**2)
x, y = alpha/N, beta/N
return [x,y]
print(createQubit(10,30))
I have provided the screenshot of the output and verify the answer on the paper
If u have any doubt, please comment below. Please like the answer. Tq
Get Answers For Free
Most questions answered within 1 hours.