Doubt in Exercise I.1.1

Hi. I am just getting started with quantum computing and got myself stuck in the first problem :sweat_smile:.

I have attached the code I wrote below. I’m trying to find the unit vector by dividing the elements of the state_vector by the modulus of the vector.(I don’t know if this is the right way to solve this.) I submitted this code and got correct as feedback, but when I ran it on my machine with the alpha and beta given in the example section I got the output
[ 1.02412383+0.00945397j -0.04304483+0.22492908j]
but as per the example I should get
[ 0.87287156+0.43643578j, -0.13093073+0.17457431j]

Can anyone tell me why I’m getting this result?

Hi Abhinav,
Remember, alpha and beta, in general are complex, so when you have np.sqrt(alpha**2 +beta**2) this is also a complex number instead of a real number. You should take absolute value before exponentiate.