�
I�g�� � � � d Z ddlmZmZ ed� � � Zd� Zed9d�� � Zed9d�� � Zed9d�� � Zed9d �� � Z ed9d
�� � Z
i ddgd
gdgdgddf�ddgd
gd
gdgddf�ddgdgdgdgddf�dd
gdgdgdgddf�dd
gdgdgd
gddf�ddgdgdgdgddf�ddgdgdgd
gddf�d ddgd
dgdgdgddf�d!dgd
gd
gdgddf�d"dgdgd
gdgd#d$f�d%d
gdgdgd
gddf�d&d
dgddgdgdgdd$f�d'd�d(d�d)d�d*d�Zed9d+�� � Zed:d,�� � Z
d-� Zd;d/�Zd0� Zed1� � � Zed;d2�� � Zed<d3�� � Zed4� � � Zed5� � � Zed6� � � Zed7� � � Zed8� � � ZdS )=aN
Elliptic functions historically comprise the elliptic integrals
and their inverses, and originate from the problem of computing the
arc length of an ellipse. From a more modern point of view,
an elliptic function is defined as a doubly periodic function, i.e.
a function which satisfies
.. math ::
f(z + 2 \omega_1) = f(z + 2 \omega_2) = f(z)
for some half-periods `\omega_1, \omega_2` with
`\mathrm{Im}[\omega_1 / \omega_2] > 0`. The canonical elliptic
functions are the Jacobi elliptic functions. More broadly, this section
includes quasi-doubly periodic functions (such as the Jacobi theta
functions) and other functions useful in the study of elliptic functions.
Many different conventions for the arguments of
elliptic functions are in use. It is even standard to use
different parameterizations for different functions in the same
text or software (and mpmath is no exception).
The usual parameters are the elliptic nome `q`, which usually
must satisfy `|q| < 1`; the elliptic parameter `m` (an arbitrary
complex number); the elliptic modulus `k` (an arbitrary complex
number); and the half-period ratio `\tau`, which usually must
satisfy `\mathrm{Im}[\tau] > 0`.
These quantities can be expressed in terms of each other
using the following relations:
.. math ::
m = k^2
.. math ::
\tau = i \frac{K(1-m)}{K(m)}
.. math ::
q = e^{i \pi \tau}
.. math ::
k = \frac{\vartheta_2^2(q)}{\vartheta_3^2(q)}
In addition, an alternative definition is used for the nome in
number theory, which we here denote by q-bar:
.. math ::
\bar{q} = q^2 = e^{2 i \pi \tau}
For convenience, mpmath provides functions to convert
between the various parameters (:func:`~mpmath.qfrom`, :func:`~mpmath.mfrom`,
:func:`~mpmath.kfrom`, :func:`~mpmath.taufrom`, :func:`~mpmath.qbarfrom`).
**References**
1. [AbramowitzStegun]_
2. [WhittakerWatson]_
� )�defun�
defun_wrappedc � � | � |� � dk rt d� � �| � |dz � � }|| � |dz � � z S )aC
Returns the Dedekind eta function of tau in the upper half-plane.
>>> from mpmath import *
>>> mp.dps = 25; mp.pretty = True
>>> eta(1j); gamma(0.25) / (2*pi**0.75)
(0.7682254223260566590025942 + 0.0j)
0.7682254223260566590025942
>>> tau = sqrt(2) + sqrt(5)*1j
>>> eta(-1/tau); sqrt(-1j*tau) * eta(tau)
(0.9022859908439376463573294 + 0.07985093673948098408048575j)
(0.9022859908439376463573295 + 0.07985093673948098408048575j)
>>> eta(tau+1); exp(pi*1j/12) * eta(tau)
(0.4493066139717553786223114 + 0.3290014793877986663915939j)
(0.4493066139717553786223114 + 0.3290014793877986663915939j)
>>> f = lambda z: diff(eta, z) / eta(z)
>>> chop(36*diff(f,tau)**2 - 24*diff(f,tau,2)*f(tau) + diff(f,tau,3))
0.0
g z+eta is only defined in the upper half-plane� � )�im�
ValueError�expjpi�qp)�ctx�tau�qs �i/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/mpmath/functions/elliptic.py�etar C sV � �, �v�v�c�{�{�c����F�G�G�G��
�
�3�r�6���A��s�v�v�a��e�}�}��� c � � | � |� � }|s|S || j k r|S | � |� � r|S | � |� � r8|| j k r t |� � d� � S | � d� � S | � | j |z
� � }| � |� � }| � | j |z |z � � }| �
|� � s?| � |� � dk r&| � |� � r|j
S |j
dz S |dk r| � d|j � � }|S )N�����r y � � )�convert�one�isnan�isinf�ninf�type�mpc�ellipk�exp�pi�_im�_re�
_is_real_type�real�imag)r �m�a�b�vs r �nomer) ^ s9 � ����A���A�� ����C�G�|�|���
�y�y��|�|� ���
�y�y��|�|� ����=�=��4��7�7�2�;�;���7�7�2�;�;���
�
�3�7�1�9���A��
�
�1�
�
�A�������� �!����A��7�7�1�:�:� �#�'�'�!�*�*�q�.�.����Q��� ��6�M��6�B�;��
�a����G�G�A�q�v�����Hr Nc � � |�| � |� � S |�t | |� � S |�&t | | � |� � dz � � S |�| � |� � S |�| � |� � S dS )a�
Returns the elliptic nome `q`, given any of `q, m, k, \tau, \bar{q}`::
>>> from mpmath import *
>>> mp.dps = 25; mp.pretty = True
>>> qfrom(q=0.25)
0.25
>>> qfrom(m=mfrom(q=0.25))
0.25
>>> qfrom(k=kfrom(q=0.25))
0.25
>>> qfrom(tau=taufrom(q=0.25))
(0.25 + 0.0j)
>>> qfrom(qbar=qbarfrom(q=0.25))
0.25
Nr )r r) r
�sqrt�r r r% �kr
�qbars r �qfromr/ w s� � �&