� I�g���p�ddlmZmZedd���Zed���Zed���Zed���ZdS)�)�defun� defun_wrappedNc �p����� ����������j�n�������dkrtd�������n�������dkr�jd��zzzS��jk}��k}|rJt ���dkr'|r�dks�dkr �j�zStd����dkr �j�z S|�dd�jz��� |r|r�� �fd �}��|��S��� ��fd �}�� |��S) a Evaluates the q-Pochhammer symbol (or q-rising factorial) .. math :: (a; q)_n = \prod_{k=0}^{n-1} (1-a q^k) where `n = \infty` is permitted if `|q| < 1`. Called with two arguments, ``qp(a,q)`` computes `(a;q)_{\infty}`; with a single argument, ``qp(q)`` computes `(q;q)_{\infty}`. The special case .. math :: \phi(q) = (q; q)_{\infty} = \prod_{k=1}^{\infty} (1-q^k) = \sum_{k=-\infty}^{\infty} (-1)^k q^{(3k^2-k)/2} is also known as the Euler function, or (up to a factor `q^{-1/24}`) the Dedekind eta function. **Examples** If `n` is a positive integer, the function amounts to a finite product:: >>> from mpmath import * >>> mp.dps = 25; mp.pretty = True >>> qp(2,3,5) -725305.0 >>> fprod(1-2*3**k for k in range(5)) -725305.0 >>> qp(2,3,0) 1.0 Complex arguments are allowed:: >>> qp(2-1j, 0.75j) (0.4628842231660149089976379 + 4.481821753552703090628793j) The regular Pochhammer symbol `(a)_n` is obtained in the following limit as `q \to 1`:: >>> a, n = 4, 7 >>> limit(lambda q: qp(q**a,q,n) / (1-q)**n, 1) 604800.0 >>> rf(a,n) 604800.0 The Taylor series of the reciprocal Euler function gives the partition function `P(n)`, i.e. the number of ways of writing `n` as a sum of positive integers:: >>> taylor(lambda q: 1/qp(q), 0, 10) [1.0, 1.0, 2.0, 3.0, 5.0, 7.0, 11.0, 15.0, 22.0, 30.0, 42.0] Special values include:: >>> qp(0) 1.0 >>> findroot(diffun(qp), -0.4) # location of maximum -0.4112484791779547734440257 >>> qp(_) 1.228348867038575112586878 The q-Pochhammer symbol is related to the Jacobi theta functions. For example, the following identity holds:: >>> q = mpf(0.5) # arbitrary >>> qp(q) 0.2887880950866024212788997 >>> root(3,-2)*root(q,-24)*jtheta(2,pi/6,root(q,6)) 0.2887880950866024212788997 N�zn cannot be negativer�����z#q-function only defined for |q| < 1�maxterms�2c3��K�d}|V�d}�}�dz} d|z|zV�d|z|zV�|�d|zdzzz}|�d|zdzzz}|dz }|�kr�j��C)Nr�r�)� NoConvergence)�t�k�x1�x2�ctxr�qs ����k/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/mpmath/functions/qfunctions.py�termszqp.<locals>.termsfs�������A��G�G�G��A��B��A��B� ,��A�g��l�"�"�"��A�g��l�"�"�"��a�!�A�#�a�%�j� ���a�!�A�#�a�%�j� ���Q����x�<�<��+�+� ,�c3�p�K�d}�j} d�|zz V�|�z}|dz }|�krdS|�kr�j��*)Nrr)�oner )r�r�arr�nrs �����r�factorszqp.<locals>.factorsvs`����� �� �G�� (��a��c�'�M�M�M� ��F�A� ��F�A��A�v�v����8�|�|��'�'� (r) �convert�inf� ValueErrorr�abs�zero�get�prec�sum_accurately�mul_accurately) rrrr�kwargs�infinite�samerrrs ```` @r�qpr)s��������T � � �A���A��y� �G��� �K�K��N�N���1�u�u��/�0�0�0��y� ��� �K�K��N�N���A�v�v��w��A�a�C�� � ��S�W� �H� ��F�D��� �q�6�6�Q�;�;�� $��b���A��F�F��x�!�|�#��B�C�C� C� �!�V�V��7�Q�;� ��z�z�*�b���k�2�2�H��)�D�)� ,� ,� ,� ,� ,� ,� ,��!�!�%�(�(�(� (� (� (� (� (� (� (� (� (� � � �g� &� &�&rc ���t|��dkr+|�|d|z ��||dz |dz zdzzzS|j||dfi|��|j||z|dfi|��z d|z d|z zzS)a� Evaluates the q-gamma function .. math :: \Gamma_q(z) = \frac{(q; q)_{\infty}}{(q^z; q)_{\infty}} (1-q)^{1-z}. **Examples** Evaluation for real and complex arguments:: >>> from mpmath import * >>> mp.dps = 25; mp.pretty = True >>> qgamma(4,0.75) 4.046875 >>> qgamma(6,6) 121226245.0 >>> qgamma(3+4j, 0.5j) (0.1663082382255199834630088 + 0.01952474576025952984418217j) The q-gamma function satisfies a functional equation similar to that of the ordinary gamma function:: >>> q = mpf(0.25) >>> z = mpf(2.5) >>> qgamma(z+1,q) 1.428277424823760954685912 >>> (1-q**z)/(1-q)*qgamma(z,q) 1.428277424823760954685912 rr g�?N)r �qgammar))r�zrr&s rr+r+�s���D �1�v�v��z�z��z�z�!�A�a�C� � ��a��c�A�a�C�[��_�!5�5�5� �3�6�!�Q�� '� '�� '� '����q�!�t�Q��'�'��'�'� (�+,�Q�3�!�A�#�,� 7�7rc ���|�|��rT|�|��dkr;t|�|����}|j|||fi|��d|z |zz S|j|dz|fi|��S)a� Evaluates the q-factorial, .. math :: [n]_q! = (1+q)(1+q+q^2)\cdots(1+q+\cdots+q^{n-1}) or more generally .. math :: [z]_q! = \frac{(q;q)_z}{(1-q)^z}. **Examples** >>> from mpmath import * >>> mp.dps = 25; mp.pretty = True >>> qfac(0,0) 1.0 >>> qfac(4,3) 2080.0 >>> qfac(5,6) 121226245.0 >>> qfac(1+1j, 2+1j) (0.4370556551322672478613695 + 0.2609739839216039203708921j) rr)�isint�_re�intr)r+)rr,rr&rs r�qfacr1�s���: �y�y��|�|�4����� � �Q��� ����� � �O�O���s�v�a��A�(�(��(�(�A�a�C�!�8�3�3� �3�:�a��c�1� '� '�� '� '�'rc �d������ � ��fd��D����fd��D���������������t���}t���}d|z|z � |�dd�jz��� ���� � ��fd�}��|��S)a Evaluates the basic hypergeometric series or hypergeometric q-series .. math :: \,_r\phi_s \left[\begin{matrix} a_1 & a_2 & \ldots & a_r \\ b_1 & b_2 & \ldots & b_s \end{matrix} ; q,z \right] = \sum_{n=0}^\infty \frac{(a_1;q)_n, \ldots, (a_r;q)_n} {(b_1;q)_n, \ldots, (b_s;q)_n} \left((-1)^n q^{n\choose 2}\right)^{1+s-r} \frac{z^n}{(q;q)_n} where `(a;q)_n` denotes the q-Pochhammer symbol (see :func:`~mpmath.qp`). **Examples** Evaluation works for real and complex arguments:: >>> from mpmath import * >>> mp.dps = 25; mp.pretty = True >>> qhyper([0.5], [2.25], 0.25, 4) -0.1975849091263356009534385 >>> qhyper([0.5], [2.25], 0.25-0.25j, 4) (2.806330244925716649839237 + 3.568997623337943121769938j) >>> qhyper([1+j], [2,3+0.5j], 0.25, 3+4j) (9.112885171773400017270226 - 1.272756997166375050700388j) Comparing with a summation of the defining series, using :func:`~mpmath.nsum`:: >>> b, q, z = 3, 0.25, 0.5 >>> qhyper([], [b], q, z) 0.6221136748254495583228324 >>> nsum(lambda n: z**n / qp(q,q,n)/qp(b,q,n) * q**(n*(n-1)), [0,inf]) 0.6221136748254495583228324 c�:��g|]}��|����S��r)�.0rrs �r� <listcomp>zqhyper.<locals>.<listcomp>��#��� '� '� '�a�3�;�;�q�>�>� '� '� 'rc�:��g|]}��|����Sr4r5)r6�brs �rr7zqhyper.<locals>.<listcomp>�r8rrrr c3���K�� j}|V�d}d}d} �D]}d||zz }||z}��D]}d||zz }|st�||z}�|� z}|d� z|� zzz}|� z}|d|z z}|dz }||zV�|� kr� j��g)Nrrr)rrr )r�qkr�xr�pr:�a_s�b_sr�drrr,s �������rrzqhyper.<locals>.termss������ �G������ �� �� �� (�� � ����"��H���Q����� � ����"��H���%�$�$��Q���� ��F�A� �"�q��2��7�"� "�A� �!�G�B� �!�b�&�M�A� ��F�A��a�%�K�K�K��8�|�|��'�'�! (r)r�lenr"r#r$) rr?r@rr,r&r�srrArs ````` @@r�qhyperrD�s����������Z (� '� '� '�3� '� '� '�C� '� '� '� '�3� '� '� '�C� � � �A���A� � � �A���A� �C���A� �C���A� �!��A��A��z�z�*�b���k�2�2�H�(�(�(�(�(�(�(�(�(�(�(�. � � �e� $� $�$r)NN)� functionsrrr)r+r1rDr4rr�<module>rFs���+�+�+�+�+�+�+�+��}'�}'�}'���}'�~�$7�$7���$7�L�(�(���(�B�K%�K%���K%�K%�K%r
Memory