NOTE: This notebook conains some old fragments referring to GWFrames.Wigner3jSingleton
, which was a complicated singleton that allowed me to just evaluate all the Wigner 3-j symbols once, store them, and retrieve them (memoization). As implemented, this was actually a bit slower than direct evaluation. Even worse, it seemed to be wrong for many combinations. Therefore, I have removed the singleton object.
In [1]:
import sys
from sympy import N
from sympy.physics.wigner import wigner_3j
from SphericalFunctions import Wigner3j
In [2]:
%timeit Wigner3j(14,5,10,-11,3,8)
In [3]:
Wigner3j(3,4,1,-3,-4,0)
Out[3]:
In [4]:
from math import isnan
ellMax=16
for j_1 in range(ellMax+1):
for m_1 in range(-j_1,j_1+1):
for j_2 in range(ellMax+1):
for m_2 in range(-j_2,j_2+1):
m_3 = -m_1-m_2
for j_3 in range(abs(j_1-j_2),min((j_1+j_2),ellMax)+1):
if(abs(m_3)>j_3):
continue
a=Wigner3j(j_1,j_2,j_3,m_1,m_2,m_3)
if(isnan(a)):
print(j_1,j_2,j_3,m_1,m_2,m_3)
In [ ]:
In [ ]:
In [7]:
%%time
ellMax=16
for j_1 in range(ellMax+1):
for m_1 in range(-j_1,j_1+1):
for j_2 in range(ellMax+1):
for m_2 in range(-j_2,j_2+1):
m_3 = -m_1-m_2
for j_3 in range(max(abs(m_3),abs(j_1-j_2)),min((j_1+j_2),ellMax)+1):
a=Wigner3j(j_1,j_2,j_3,m_1,m_2,m_3)
In [ ]:
In [ ]:
In [ ]:
%%time
ellMax=12
i=0
i_bad=0
for j_1 in range(ellMax+1):
for m_1 in range(-j_1,j_1+1):
for j_2 in range(ellMax+1):
for m_2 in range(-j_2,j_2+1):
m_3 = -m_1-m_2
for j_3 in range(max(abs(m_3),abs(j_1-j_2)),min((j_1+j_2),ellMax)+1):
i = i+1
a,b = N(wigner_3j(j_1,j_2,j_3,m_1,m_2,m_3)),Wigner_3j(j_1,j_2,j_3,m_1,m_2,m_3)
if(abs(a-b)>1e-12*abs(a+b) and abs(a+b)>1e-12):
print(j_1,j_2,j_3,m_1,m_2,m_3,a,b)
sys.stdout.flush()
i_bad=i_bad+1
print(i,i_bad)
In [8]:
2.34/1419857
Out[8]:
In [ ]:
In [10]:
from sympy import summation, simplify, expand, horner, symbols, N
In [2]:
L,X,T,B,S,l,x,t,b,s,Lmax = symbols('L,X,T,B,S,l,x,t,b,s,Lmax', integer=True)
In [9]:
horner(simplify((L*(24+L*(50+L*(35+L*(10+L))))/120).subs({L:L+1}).expand())*120)
Out[9]:
In [11]:
N((L*(24+L*(50+L*(35+L*(10+L))))/120).subs({L:16}))
Out[11]:
In [12]:
N((L*(274+L*(225+L*(85+L*(15+L))))/120+1).subs(L,16))
Out[12]:
In [13]:
N((L*(274+L*(225+L*(85+L*(15+L))))/120+1).subs(L,32))
Out[13]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: