PYTHON 7
###### Alfabeta.py Guest on 20th November 2020 05:56:05 PM
1. import cmath, math, numpy
2. def c1(N,I,M,b,gammaI, alfa):
3.         return 2*alfa * (I*(I+1) - M*(M+1))**0.5
4.
5. def c2(N,I,M,b,gammaI, alfa):
6.         a = b * (1-N * gammaI) + 2* M + 1  # - 0.5 * N * gammaI * b -(b -1)*M - (0.5 * N * gammaI * b -(b +1)*(M+1))
7.
8.         c = alfa * (I*(I+1) - M*(M+1))**0.5
9.
10.         return a + ( a**2 + 4*c**2 )**0.5
11.
12. def phi(N,I,M,b,gammaI, alfa):
13.         return cmath.phase( 2*M+1 - b *(N * gammaI -1) + 2* alfa * 1j * ( I*(I+1) - M*(M+1) )**0.5 )
14.
15. N=4
16. I=2
17. alfa = 0.45
18. for gammaI in numpy.linspace(0,3,4):
19.         for b in xrange(0,2):
20.                 for M in xrange(-I,I-1):
21.                         norm = (c1(N,I,M,b,gammaI, alfa)**2 + c2(N,I,M,b,gammaI, alfa)**2)**0.5
22.                         if (not round(c1(N,I,M,b,gammaI, alfa)/norm, 12) == round(math.sin(phi(N,I,M,b,gammaI, alfa)/2.), 12) or not round(c2(N,I,M,b,gammaI, alfa)/norm, 12) ==  round(math.cos(phi(N,I,M,b,gammaI, alfa)/2.), 12)):
23.                                 print 'gamma/N = %g, b= %g, M = %g '%(float(gammaI), float(b), float(M))
24.                                 print 'alfa = %f or %f,         beta = %f or %f'%(c1(N,I,M,b,gammaI, alfa)/norm,  math.sin(phi(N,I,M,b,gammaI, alfa)/2.), c2(N,I,M,b,gammaI, alfa)/norm,  math.cos(phi(N,I,M,b,gammaI, alfa)/2.) )

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Recent Pastes

Raw Paste

or to edit or fork this paste. It's free.