| Server IP : 35.80.110.71 / Your IP : 216.73.216.221 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/sympy/physics/__pycache__/ |
Upload File : |
�
M�Zd� � �H � d Z ddlmZ ddlmZ ddlmZ ddlmZm Z m
Z
ddlmZ ddl
mZ ddlmZ dd lmZmZ dd
lmZ ddlmZ ddlmZ dd
lmZmZ ddlmZ ddlm Z ddl!m"Z" ddl#m$Z$ dgZ%d� Z&d� Z'd� Z(d"d�Z)d"d�Z*d"d�Z+d"d�Z,d"d�Z-d"d�Z. G d� de� Z/d� Z0d � Z1d!� Z2y)#a>
Wigner, Clebsch-Gordan, Racah, and Gaunt coefficients
Collection of functions for calculating Wigner 3j, 6j, 9j,
Clebsch-Gordan, Racah as well as Gaunt coefficients exactly, all
evaluating to a rational number times the square root of a rational
number [Rasch03]_.
Please see the description of the individual functions for further
details and examples.
References
==========
.. [Regge58] 'Symmetry Properties of Clebsch-Gordan Coefficients',
T. Regge, Nuovo Cimento, Volume 10, pp. 544 (1958)
.. [Regge59] 'Symmetry Properties of Racah Coefficients',
T. Regge, Nuovo Cimento, Volume 11, pp. 116 (1959)
.. [Edmonds74] A. R. Edmonds. Angular momentum in quantum mechanics.
Investigations in physics, 4.; Investigations in physics, no. 4.
Princeton, N.J., Princeton University Press, 1957.
.. [Rasch03] J. Rasch and A. C. H. Yu, 'Efficient Storage Scheme for
Pre-calculated Wigner 3j, 6j and Gaunt Coefficients', SIAM
J. Sci. Comput. Volume 25, Issue 4, pp. 1416-1428 (2003)
.. [Liberatodebrito82] 'FORTRAN program for the integral of three
spherical harmonics', A. Liberato de Brito,
Comput. Phys. Commun., Volume 25, pp. 81-85 (1982)
.. [Homeier96] 'Some Properties of the Coupling Coefficients of Real
Spherical Harmonics and Their Relation to Gaunt Coefficients',
H. H. H. Homeier and E. O. Steinborn J. Mol. Struct., Volume 368,
pp. 31-37 (1996)
Credits and Copyright
=====================
This code was taken from Sage with the permission of all authors:
https://groups.google.com/forum/#!topic/sage-devel/M4NZdu-7O38
Authors
=======
- Jens Rasch (2009-03-24): initial version for Sage
- Jens Rasch (2009-05-31): updated to sage-4.0
- Oscar Gerardo Lazo Arjona (2017-06-18): added Wigner D matrices
- Phil Adam LeMaitre (2022-09-19): added real Gaunt coefficient
Copyright (C) 2008 Jens Rasch <jyr2000@gmail.com>
� )�Sum)�Add)�Function)�I�Integer�pi)�S)�Dummy)�sympify)�binomial� factorial)�re)�exp)�sqrt)�cos�sin)�Ynm)�zeros)�ImmutableMatrix)�as_int� c �� � | t t � k\ rLt t t � t | dz � � D ]$ }t j t |dz
|z � �& t dt | � dz S )a1
Function calculates a list of precomputed factorials in order to
massively accelerate future calculations of the various
coefficients.
Parameters
==========
nn : integer
Highest factorial to be computed.
Returns
=======
list of integers :
The list of precomputed factorials.
Examples
========
Calculate list of factorials::
sage: from sage.functions.wigner import _calc_factlist
sage: _calc_factlist(10)
[1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]
r N)�len� _Factlist�range�int�append)�nn�iis �6/usr/lib/python3/dist-packages/sympy/physics/wigner.py�_calc_factlistr! M sc � �6
�S��^����I���B��F��4� 5�B����Y�r�A�v�.��3�4� 5��\�c�"�g��k�"�"� c � � t | dz � | dz k7 s(t |dz � |dz k7 st |dz � |dz k7 rt d� �t |dz � |dz k7 s(t |dz � |dz k7 st |dz � |dz k7 rt d� �||z |z dk7 rt j S t dt | |z
|z
� z � }| }| |z |z
}|dk rt j S | |z
|z }|dk rt j S | |z |z } | dk rt j S t |� | kD st |� |kD st |� |kD rt j S t
| |z |z dz | t |� z |t |� z |t |� z � }
t t |
� � t t t | |z |z
� t t | |z
|z � z t t | |z |z � z t t | |z
� z t t | |z � z t t ||z
� z t t ||z � z t t ||z
� z t t ||z � z � t t | |z |z dz � z }t |� }|j s|j r|j � d }t
| | z |z | |z |z
d� }
t ||z | |z
| |z |z
� }d}t t |
� t |� dz � D ]� }t | t t ||z | z
|z
� z t t ||z |z
� z t t | |z
|z
� z t t ||z |z
|z � z t t | |z |z
|z
� z }|t d|z � |z z }�� ||z |z }|S )a�
Calculate the Wigner 3j symbol `\operatorname{Wigner3j}(j_1,j_2,j_3,m_1,m_2,m_3)`.
Parameters
==========
j_1, j_2, j_3, m_1, m_2, m_3 :
Integer or half integer.
Returns
=======
Rational number times the square root of a rational number.
Examples
========
>>> from sympy.physics.wigner import wigner_3j
>>> wigner_3j(2, 6, 4, 0, 0, 0)
sqrt(715)/143
>>> wigner_3j(2, 6, 4, 0, 0, 1)
0
It is an error to have arguments that are not integer or half
integer values::
sage: wigner_3j(2.1, 6, 4, 0, 0, 0)
Traceback (most recent call last):
...
ValueError: j values must be integer or half integer
sage: wigner_3j(2, 6, 4, 1, 0, -1.1)
Traceback (most recent call last):
...
ValueError: m values must be integer or half integer
Notes
=====
The Wigner 3j symbol obeys the following symmetry rules:
- invariant under any permutation of the columns (with the
exception of a sign change where `J:=j_1+j_2+j_3`):
.. math::
\begin{aligned}
\operatorname{Wigner3j}(j_1,j_2,j_3,m_1,m_2,m_3)
&=\operatorname{Wigner3j}(j_3,j_1,j_2,m_3,m_1,m_2) \\
&=\operatorname{Wigner3j}(j_2,j_3,j_1,m_2,m_3,m_1) \\
&=(-1)^J \operatorname{Wigner3j}(j_3,j_2,j_1,m_3,m_2,m_1) \\
&=(-1)^J \operatorname{Wigner3j}(j_1,j_3,j_2,m_1,m_3,m_2) \\
&=(-1)^J \operatorname{Wigner3j}(j_2,j_1,j_3,m_2,m_1,m_3)
\end{aligned}
- invariant under space inflection, i.e.
.. math::
\operatorname{Wigner3j}(j_1,j_2,j_3,m_1,m_2,m_3)
=(-1)^J \operatorname{Wigner3j}(j_1,j_2,j_3,-m_1,-m_2,-m_3)
- symmetric with respect to the 72 additional symmetries based on
the work by [Regge58]_
- zero for `j_1`, `j_2`, `j_3` not fulfilling triangle relation
- zero for `m_1 + m_2 + m_3 \neq 0`
- zero for violating any one of the conditions
`j_1 \ge |m_1|`, `j_2 \ge |m_2|`, `j_3 \ge |m_3|`
Algorithm
=========
This function uses the algorithm of [Edmonds74]_ to calculate the
value of the 3j symbol exactly. Note that the formula contains
alternating sums over large factorials and is therefore unsuitable
for finite precision arithmetic and only useful for a computer
algebra system [Rasch03]_.
Authors
=======
- Jens Rasch (2009-03-24): initial version
� z(j values must be integer or half integerz(m values must be integer or half integerr ���r )r �
ValueErrorr �Zeror �abs�maxr! r r �
is_complex�is_infinite�as_real_imag�minr )�j_1�j_2�j_3�m_1�m_2�m_3�prefid�a1�a2�a3�maxfact�argsqrt�ressqrt�imin�imax�sumresr �den�ress r � wigner_3jr@ n s� � �l �3��7�|�s�Q�w��#�c�A�g�,�#��'�"9���a��L�C�!�G�#��C�D�D�
�3��7�|�s�Q�w��#�c�A�g�,�#��'�"9���a��L�C�!�G�#��C�D�D�
�S�y�3��!���v�v�
�
�b�S��s��S��1�1�
2�F��$�C� �s��S��B� �A�v��v�v�
� �s��S��B� �A�v��v�v�
�
����c� �B� �A�v��v�v�
��C��3��C��H�s�N��C��3���v�v�
��#��)�c�/�A�%�s�S��X�~�s�S��X�~���C��.�"�G��3�w�<� ��i��C�#�I��O� 4�5��s�3��9�s�?�3�4�5��s�C�4�#�:��#3�4�5�6� �s�3��9�~�.�/� �s�3��9�~�.� /�
�s�3��9�~�.�/� �s�3��9�~�.�
/� �s�3��9�~�.�/� �s�3��9�~�.�/� 0� �#�c�C�i�#�o��)�*�+� ,�G� �7�m�G����W�0�0��&�&�(��+����t�c�z�C��#����c�!1�1�5�D��s�S�y�#��)�S�3�Y��_�5�D�
�F��C��I�s�4�y�1�}�-� 4����m��c�"�s�(�S�.�3�.�/�0�1��c�#��)�b�.�)�*�+�
�c�#��(�S�.�)�*�+�
�c�"�s�(�S�.�3�.�/�0� 1�
�c�#��)�c�/�B�.�/�0�1�� �'�2�"�*�-��3�3��4� �F�
�V�
#�C��Jr"