�
I�g� � �p � d dl mZmZ edd�� � Zed� � � Zed� � � Zed� � � ZdS )� )�defun�
defun_wrappedNc �p � ���� � � � �� � ���� j �n� � �� � ��dk rt d� � �����n� � �� � ��dk r� j d��z z z S �� j k }��k }|rJt �� � dk r'|r�dk s�dk r
� j �z S t d� � ��dk r
� j �z
S |� dd� j z � � � |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�2 c 3 � �K � d} | V � d}�}�dz } d|z |z V � d|z |z V � |�d|z dz z z }|�d|z dz z z }|dz
}|�k r�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>.termsf s� �� � � ��A��G�G�G��A��B��A��B�
,��A�g��l�"�"�"��A�g��l�"�"�"��a�!�A�#�a�%�j� ���a�!�A�#�a�%�j� ���Q����x�<�<��+�+�
,� c 3 �p �K � d} �j } d�|z z
V � |�z }| dz
} | �k rd S | �k r�j ��*)Nr r )�oner
)r �r�ar r �nr s �����r �factorszqp.<locals>.factorsv s` �� � � �
���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)
r r r r �kwargs�infinite�samer r r s
```` @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�&�&�&r c �� � t |� � dk r+| � |d|z � � ||dz
|dz
z dz z z S | j ||dfi |�� | j ||z |dfi |��z d|z
d|z
z z S )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
r r g �?N)r �qgammar) )r �zr r&