§
    OŠtj^  ã                   ó¼  — d Z ddlmZ ddlmZ ddlmZmZmZ ddl	m
Z
 ddlmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZmZmZ ddlmZmZmZm Z  ddl!m"Z"m#Z#m$Z$ ddl%m&Z&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z-  G d„ de¦  «        Z. G d„ de¦  «        Z/ G d„ de¦  «        Z0 G d„ de¦  «        Z1 G d„ de¦  «        Z2 G d„ de¦  «        Z3ed„ ¦   «         Z4dS ) z$ Riemann zeta and related function. é    )ÚAdd)Úcacheit)ÚArgumentIndexErrorÚ
expand_mulÚDefinedFunction)Ú	fuzzy_not)ÚpiÚIÚInteger)ÚEq)ÚS)ÚDummy)Úsympify)Ú	bernoulliÚ	factorialÚgenocchiÚharmonic)ÚreÚ
unpolarifyÚAbsÚ
polar_lift)ÚlogÚ	exp_polarÚexp)ÚceilingÚfloor)Úsqrt)Ú	Piecewise)ÚPolyc                   ó2   — e Zd ZdZd„ Zd	d„Zd„ Zd„ Zd„ ZdS )
Úlerchphia^  
    Lerch transcendent (Lerch phi function).

    Explanation
    ===========

    For $\operatorname{Re}(a) > 0$, $|z| < 1$ and $s \in \mathbb{C}$, the
    Lerch transcendent is defined as

    .. math :: \Phi(z, s, a) = \sum_{n=0}^\infty \frac{z^n}{(n + a)^s},

    where the standard branch of the argument is used for $n + a$,
    and by analytic continuation for other values of the parameters.

    A commonly used related function is the Lerch zeta function, defined by

    .. math:: L(q, s, a) = \Phi(e^{2\pi i q}, s, a).

    **Analytic Continuation and Branching Behavior**

    It can be shown that

    .. math:: \Phi(z, s, a) = z\Phi(z, s, a+1) + a^{-s}.

    This provides the analytic continuation to $\operatorname{Re}(a) \le 0$.

    Assume now $\operatorname{Re}(a) > 0$. The integral representation

    .. math:: \Phi_0(z, s, a) = \int_0^\infty \frac{t^{s-1} e^{-at}}{1 - ze^{-t}}
                                \frac{\mathrm{d}t}{\Gamma(s)}

    provides an analytic continuation to $\mathbb{C} - [1, \infty)$.
    Finally, for $x \in (1, \infty)$ we find

    .. math:: \lim_{\epsilon \to 0^+} \Phi_0(x + i\epsilon, s, a)
             -\lim_{\epsilon \to 0^+} \Phi_0(x - i\epsilon, s, a)
             = \frac{2\pi i \log^{s-1}{x}}{x^a \Gamma(s)},

    using the standard branch for both $\log{x}$ and
    $\log{\log{x}}$ (a branch of $\log{\log{x}}$ is needed to
    evaluate $\log{x}^{s-1}$).
    This concludes the analytic continuation. The Lerch transcendent is thus
    branched at $z \in \{0, 1, \infty\}$ and
    $a \in \mathbb{Z}_{\le 0}$. For fixed $z, a$ outside these
    branch points, it is an entire function of $s$.

    Examples
    ========

    The Lerch transcendent is a fairly general function, for this reason it does
    not automatically evaluate to simpler functions. Use ``expand_func()`` to
    achieve this.

    If $z=1$, the Lerch transcendent reduces to the Hurwitz zeta function:

    >>> from sympy import lerchphi, expand_func
    >>> from sympy.abc import z, s, a
    >>> expand_func(lerchphi(1, s, a))
    zeta(s, a)

    More generally, if $z$ is a root of unity, the Lerch transcendent
    reduces to a sum of Hurwitz zeta functions:

    >>> expand_func(lerchphi(-1, s, a))
    zeta(s, a/2)/2**s - zeta(s, a/2 + 1/2)/2**s

    If $a=1$, the Lerch transcendent reduces to the polylogarithm:

    >>> expand_func(lerchphi(z, s, 1))
    polylog(s, z)/z

    More generally, if $a$ is rational, the Lerch transcendent reduces
    to a sum of polylogarithms:

    >>> from sympy import S
    >>> expand_func(lerchphi(z, s, S(1)/2))
    2**(s - 1)*(polylog(s, sqrt(z))/sqrt(z) -
                polylog(s, sqrt(z)*exp_polar(I*pi))/sqrt(z))
    >>> expand_func(lerchphi(z, s, S(3)/2))
    -2**s/z + 2**(s - 1)*(polylog(s, sqrt(z))/sqrt(z) -
                          polylog(s, sqrt(z)*exp_polar(I*pi))/sqrt(z))/z

    The derivatives with respect to $z$ and $a$ can be computed in
    closed form:

    >>> lerchphi(z, s, a).diff(z)
    (-a*lerchphi(z, s, a) + lerchphi(z, s - 1, a))/z
    >>> lerchphi(z, s, a).diff(a)
    -s*lerchphi(z, s + 1, a)

    See Also
    ========

    polylog, zeta

    References
    ==========

    .. [1] Bateman, H.; Erdelyi, A. (1953), Higher Transcendental Functions,
           Vol. I, New York: McGraw-Hill. Section 1.11.
    .. [2] https://dlmf.nist.gov/25.14
    .. [3] https://en.wikipedia.org/wiki/Lerch_transcendent

    c                 óî  ‡‡‡‡‡‡— | j         \  ŠŠŠ‰dk    rt          ‰‰¦  «        S ‰j        rš‰dk    r”t          d¦  «        }t	          |‰z   ‰ z  |¦  «        Šdd|z
  z  }t
          j        }t          ‰                     ¦   «         ¦  «        D ]"}|||z  z  }|| 	                    |¦  «        z  }Œ#| 
                    |‰¦  «        S ‰j        �r�t
          j        }t
          j        }‰dk    rKt          ‰¦  «        Š‰‰k    r‰dz  Š‰‰z  Š‰‰ z  }t          ˆˆˆˆfd„t          ‰¦  «        D ¦   «         Ž }nH‰dk    rBt          ‰ ¦  «        dz   Š‰‰z  Š‰‰z  }t          ˆˆˆˆfd„t          ‰¦  «        D ¦   «         Ž }t          ‰j        ‰j        g¦  «        \  }Št%          dt&          z  t(          z  ‰z  ¦  «        }	‰d‰z  z  }
t+          |	¦  «        }g }t          ‰¦  «        D ][}t-          ‰|	|z  |
z  ¦  «        Št/          ‰t,          ¦  «        r ‰j        d
i |¤ŽŠ|                     ‰||z  |
z  |z  z  ¦  «         Œ\||‰‰dz
  z  z  t          |Ž z  z   S t/          ‰t4          ¦  «        r"‰j         d         t&          t(          z  z  j        s‰dt(          t(           fv r¿‰dk    rt          ddg¦  «        \  ŠŠn‰t(          k    rt          ddg¦  «        \  ŠŠn_‰t(           k    rt          ddg¦  «        \  ŠŠn>‰j         d         dt&          z  t(          z  z  }t          |j        |j        g¦  «        \  ŠŠt          ˆˆˆˆfd	„t          ‰¦  «        D ¦   «         Ž S t7          ‰‰‰¦  «        S )Né   r   Útc                 ó4   •— g | ]}‰|‰z
  z   ‰|z   ‰z  z  ‘ŒS © r&   ©Ú.0ÚkÚaÚnÚsÚzs     €€€€úd/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/functions/special/zeta_functions.pyú
<listcomp>z.lerchphi._eval_expand_func.<locals>.<listcomp>    s0   ø€ ÐEÐEÐE°q˜Q  Q¡™Z˜K¨¨Q©°©
Ñ2ÐEÐEÐEó    c                 ó>   •— g | ]}‰‰d z
  |z
  z  ‰|z
  d z
  ‰z  z  ‘ŒS ©r#   r&   r'   s     €€€€r.   r/   z.lerchphi._eval_expand_func.<locals>.<listcomp>¥   s6   ø€ ÐLÐLÐL¸a˜A  A¡¨¡	™N¨A°©E°A©I¸©>Ñ9ÐLÐLÐLr0   é   éÿÿÿÿé   c                 óš   •— g | ]G}t          d t          z  t          z  |z  ‰z  ‰z  ¦  «        ‰‰z  z  t          ‰|‰z   ‰z  ¦  «        z  ‘ŒHS )r3   )r   r	   r
   Úzeta)r(   r)   r*   ÚpÚqr,   s     €€€€r.   r/   z.lerchphi._eval_expand_func.<locals>.<listcomp>¿   se   ø€ ð ,ð ,ð ,Øõ ˜Q�r™T¥!™V A™X a™Z¨™\Ñ*Ô*¨1¨a©4Ñ/µ°Q¸¸Q¹À¹	Ñ0BÔ0BÑBð ,ð ,ð ,r0   r&   )Úargsr7   Ú
is_Integerr   r   r   ÚZeroÚreversedÚ
all_coeffsÚdiffÚsubsÚis_RationalÚOner   r   Úranger8   r9   r   r	   r
   r   ÚpolylogÚ
isinstanceÚ_eval_expand_funcÚappendr   r!   )ÚselfÚhintsr$   ÚstartÚresÚcÚaddÚmulÚmÚzetÚrootÚup_zetÚaddargsr)   Úargr*   r+   r8   r9   r,   r-   s                  @@@@@@r.   rF   zlerchphi._eval_expand_funcƒ   s»  øøøøøø€ Ø”)‰ˆˆ1ˆaØ�Š6ˆ6Ý˜˜1‘:”:ÐØŒ<ð 	"˜A šF˜FÝ�c‘
”
ˆAÝ�a˜!‘e ˜r‘] AÑ&Ô&ˆAØ�q˜1‘u‘IˆEÝ”&ˆCÝ˜aŸlšl™nœnÑ-Ô-ð (ð (�Ø�q˜‘w‘�Ø˜%Ÿ*š* Q™-œ-™��Ø—8’8˜A˜q‘>”>Ð!àŒ=ñ  	6õ ”&ˆCÝ”%ˆCà�1ŠuˆuÝ˜!‘H”H�Ø˜’6�6Ø˜‘F�AØ�Q‘�Ø˜1˜"‘g�ÝÐEÐEÐEÐEÐEÐEÐE½EÀ!¹H¼HÐEÑEÔEÐF��Ø�a’�Ý˜1˜"‘I”I ‘M�Ø�Q‘�Ø˜‘d�ÝÐLÐLÐLÐLÐLÐLÐLÅ5ÈÁ8Ä8ÐLÑLÔLÐM�å�a”c˜1œ3�Z‘=”=‰DˆAˆqÝ˜A�b™D¥™F 1™HÑ%Ô%ˆCØ�q˜‘s‘8ˆDÝ ‘_”_ˆFØˆGÝ˜1‘X”Xð 6ð 6�Ý˜A˜s A™v d™{Ñ+Ô+�Ý˜a¥Ñ)Ô)ð 5Ø+˜Ô+Ð4Ð4¨eÐ4Ð4�AØ—’˜q &¨!¡)¨D¡.°1Ñ!4Ñ4Ñ5Ô5Ð5Ð5Ø˜˜Q  Q¡™Z™­¨W¨Ñ5Ñ5Ð5õ �a�ÑÔð 	- 1¤6¨!¤9­bµ©dÑ#3Ô"@ð 	-ÀAÈ"ÍaÕRSÐQSÈÐDTÐDTà�BŠwˆwÝ˜!˜Q˜‘y”y‘��1�1Ø•a’�Ý˜!˜Q˜‘y”y‘��1�1Ø•q�b’�Ý˜"˜a˜‘z”z‘��1�1à”f˜Q”i ¥2¡¥a¡Ñ(�Ý˜#œ% ¤˜Ñ(Ô(‘��1Ýð ,ð ,ð ,ð ,ð ,ð ,ð ,Ý"'¨¡(¤(ð,ñ ,ô ,ð -ð -õ ˜˜1˜aÑ Ô Ð r0   r#   c                 óÆ   — | j         \  }}}|dk    r| t          ||dz   |¦  «        z  S |dk    r,t          ||dz
  |¦  «        |t          |||¦  «        z  z
  |z  S t          ‚)Né   r#   )r:   r!   r   )rH   Úargindexr-   r,   r*   s        r.   Úfdiffzlerchphi.fdiffÄ   su   € Ø”)‰ˆˆ1ˆaØ�qŠ=ˆ=Ø�2•h˜q ! a¡%¨Ñ+Ô+Ñ+Ð+Ø˜Š]ˆ]Ý˜Q  A¡ qÑ)Ô)¨A­h°q¸!¸QÑ.?Ô.?Ñ,?Ñ?ÀÑBÐBå$Ð$r0   c                 ó\   — |                       ¦   «         }|                     |¦  «        r|S | S ©N)rF   Úhas)rH   ÚtargetrK   s      r.   Ú_eval_rewrite_helperzlerchphi._eval_rewrite_helperÍ   s/   € Ø×$Ò$Ñ&Ô&ˆØ�7Š7�6‰?Œ?ð 	ØˆJàˆKr0   c                 ó6   — |                       t          ¦  «        S rZ   )r]   r7   ©rH   r-   r,   r*   Úkwargss        r.   Ú_eval_rewrite_as_zetazlerchphi._eval_rewrite_as_zetaÔ   s   € Ø×(Ò(­Ñ.Ô.Ð.r0   c                 ó6   — |                       t          ¦  «        S rZ   )r]   rD   r_   s        r.   Ú_eval_rewrite_as_polylogz!lerchphi._eval_rewrite_as_polylog×   s   € Ø×(Ò(­Ñ1Ô1Ð1r0   Nr2   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__rF   rX   r]   ra   rc   r&   r0   r.   r!   r!      sr   € € € € € ðgð gðR?!ð ?!ð ?!ðB%ð %ð %ð %ðð ð ð/ð /ð /ð2ð 2ð 2ð 2ð 2r0   r!   c                   óT   ‡ — e Zd ZdZed„ ¦   «         Zd
d„Zd„ Zd„ Zd„ Z	dˆ fd	„	Z
ˆ xZS )rD   a  
    Polylogarithm function.

    Explanation
    ===========

    For $|z| < 1$ and $s \in \mathbb{C}$, the polylogarithm is
    defined by

    .. math:: \operatorname{Li}_s(z) = \sum_{n=1}^\infty \frac{z^n}{n^s},

    where the standard branch of the argument is used for $n$. It admits
    an analytic continuation which is branched at $z=1$ (notably not on the
    sheet of initial definition), $z=0$ and $z=\infty$.

    The name polylogarithm comes from the fact that for $s=1$, the
    polylogarithm is related to the ordinary logarithm (see examples), and that

    .. math:: \operatorname{Li}_{s+1}(z) =
                    \int_0^z \frac{\operatorname{Li}_s(t)}{t} \mathrm{d}t.

    The polylogarithm is a special case of the Lerch transcendent:

    .. math:: \operatorname{Li}_{s}(z) = z \Phi(z, s, 1).

    Examples
    ========

    For $z \in \{0, 1, -1\}$, the polylogarithm is automatically expressed
    using other functions:

    >>> from sympy import polylog
    >>> from sympy.abc import s
    >>> polylog(s, 0)
    0
    >>> polylog(s, 1)
    zeta(s)
    >>> polylog(s, -1)
    -dirichlet_eta(s)

    If $s$ is a negative integer, $0$ or $1$, the polylogarithm can be
    expressed using elementary functions. This can be done using
    ``expand_func()``:

    >>> from sympy import expand_func
    >>> from sympy.abc import z
    >>> expand_func(polylog(1, z))
    -log(1 - z)
    >>> expand_func(polylog(0, z))
    z/(1 - z)

    The derivative with respect to $z$ can be computed in closed form:

    >>> polylog(s, z).diff(z)
    polylog(s - 1, z)/z

    The polylogarithm can be expressed in terms of the lerch transcendent:

    >>> from sympy import lerchphi
    >>> polylog(s, z).rewrite(lerchphi)
    z*lerchphi(z, s, 1)

    See Also
    ========

    zeta, lerchphi

    c                 óÄ  — |j         ru|t          j        u rt          |¦  «        S |t          j        u rt          |¦  «         S |t          j        u rt          j        S |dk    rt          ¦   «         }||v r||         S |j        rt          j        S | 	                    t          j        ¦  «        }|rt          |¦  «        S |du r>|t          j        u r|d|z
  z  S |t          j        u r|d|z
  dz  z  S |j        r|d|z
  z  S | 
                    t          t          ¦  «        r<|s!t          |¦  «        t          j        k    dk    r | |t          |¦  «        ¦  «        S d S d S )Nr3   Fr#   T)Ú	is_numberr   rB   r7   ÚNegativeOneÚdirichlet_etar<   Ú_dilogtableÚis_zeroÚequalsr[   r   r   r   r   )Úclsr,   r-   Ú
dilogtableÚzones        r.   Úevalzpolylog.eval%  sf  € àŒ;ð 
	)Ø•A”EˆzˆzÝ˜A‘w”w�Ø•a”mÐ#Ð#Ý% aÑ(Ô(Ð(Ð(Ø•a”f��Ý”v�Ø�a’�Ý(™]œ]�
Ø˜
�?�?Ø% aœ=Ð(àŒ9ð 	Ý”6ˆMð �xŠx�œ‰Œˆàð 	!Ý˜‘7”7ˆNØ�Uˆ]ˆ]ð
 •A”Fˆ{ˆ{Ø˜!˜a™%‘yÐ Ø•a”mÐ#Ð#Ø˜!˜a™% !™‘|Ð#ØŒyð !Ø˜!˜a™%‘yÐ ð �5Š5•�JÑ'Ô'ð 	)¨Tð 	)µc¸!±f´fÅÄ²oÈ$Ò5NÐ5NØ�3�q�* Q™-œ-Ñ(Ô(Ð(ð	)ð 	)Ð5NÐ5Nr0   r#   c                 ó\   — | j         \  }}|dk    rt          |dz
  |¦  «        |z  S t          ‚)Nr3   r#   )r:   rD   r   )rH   rW   r,   r-   s       r.   rX   zpolylog.fdiffL  s5   € ØŒy‰ˆˆ1Ø�qŠ=ˆ=Ý˜1˜q™5 !Ñ$Ô$ QÑ&Ð&Ý Ð r0   c                 ó*   — |t          ||d¦  «        z  S ©Nr#   ©r!   )rH   r,   r-   r`   s       r.   Ú_eval_rewrite_as_lerchphiz!polylog._eval_rewrite_as_lerchphiR  s   € Ø•˜!˜Q Ñ"Ô"Ñ"Ð"r0   c                 óL  — | j         \  }}|dk    rt          d|z
  ¦  «         S |j        rk|dk    ret          d¦  «        }|d|z
  z  }t	          | ¦  «        D ]}||                     |¦  «        z  }Œt          |¦  «                             ||¦  «        S t          ||¦  «        S )Nr#   r   Úu)	r:   r   r;   r   rC   r?   r   r@   rD   )rH   rI   r,   r-   rz   rJ   Ú_s          r.   rF   zpolylog._eval_expand_funcU  sª   € ØŒy‰ˆˆ1Ø�Š6ˆ6Ý˜˜A™‘J”J�;ÐØŒ<ð 	0˜A šF˜FÝ�c‘
”
ˆAØ�q˜1‘u‘IˆEÝ˜A˜2‘Y”Yð (ð (�Ø˜%Ÿ*š* Q™-œ-™��Ý˜eÑ$Ô$×)Ò)¨!¨QÑ/Ô/Ð/Ý�q˜!‰}Œ}Ðr0   c                 ó2   — | j         d         }|j        rdS d S )Nr#   T)r:   rn   )rH   r-   s     r.   Ú_eval_is_zerozpolylog._eval_is_zeroa  s&   € ØŒI�aŒLˆØŒ9ð 	Ø�4ð	ð 	r0   r   c                 óÞ  •— ddl m} | j        \  }}|                     |d¦  «        }|t          j        u r.|                     |dt          |¦  «        j        rdnd¬¦  «        }|j	        rÙ	 | 
                    |¦  «        \  }	}
n# t          t          f$ r | cY S w xY w|
j        rŸt          ||
z  ¦  «        } |||z  |¦  «        }|                     ||||¦  «                             ¦   «         }|t          j        u r|S |}|g}t%          d|¦  «        D ]"}||z  }|                     |||z  z  ¦  «         Œ#t)          |Ž |z   S t+          t,          | ¦  «                             ||||¦  «        S )Nr   )ÚOrderú-ú+)Údirr3   )Úsympy.series.orderr   r:   r@   r   ÚNaNÚlimitr   Úis_negativern   ÚleadtermÚ
ValueErrorÚNotImplementedErrorÚis_positiver   Ú_eval_nseriesÚremoveOr<   rC   rG   r   ÚsuperrD   )rH   Úxr+   ÚlogxÚcdirr   Únur-   Úz0r{   r   ÚnewnÚoÚrÚtermr,   r)   Ú	__class__s                    €r.   r‹   zpolylog._eval_nseriesf  s�  ø€ Ø,Ð,Ð,Ð,Ð,Ð,Ø”	‰ˆˆAà�VŠV�A�q‰\Œ\ˆØ•”ˆ;ˆ;Ø—’˜˜A­"¨T©(¬(Ô*>Ð#G 3 3ÀC�ÑHÔHˆBàŒ:ð 	#ðØŸš A™œ‘��3�3øÝÕ 3Ð4ð ð ð Ø���ðøøøð Œð #Ý˜q ™u‘~”~�Ø�E˜!˜Q™$ ‘N”N�Ø—O’O A q¨$°Ñ5Ô5×=Ò=Ñ?Ô?�Ø�œ�;�;Ø�Hà�Ø�F�Ý˜q $™œð )ð )�AØ˜A‘I�DØ—H’H˜T ! R¡%™ZÑ(Ô(Ð(Ð(Ý˜A�w ‘{Ð"å•W˜dÑ#Ô#×1Ò1°!°Q¸¸dÑCÔCÐCs   Á,B ÂBÂBr2   )r   )rd   re   rf   rg   Úclassmethodrs   rX   rx   rF   r}   r‹   Ú__classcell__©r—   s   @r.   rD   rD   ß   s±   ø€ € € € € ðCð CðJ ð$)ð $)ñ „[ð$)ðL!ð !ð !ð !ð#ð #ð #ð
ð 
ð 
ðð ð ð
Dð Dð Dð Dð Dð Dð Dð Dð Dð Dr0   rD   c                   óf   ‡ — e Zd ZdZedd„¦   «         Zdd„Zdd„Zdd„Zd„ Z	d	„ Z
dd
„Zˆ fd„Zˆ xZS )r7   aØ
  
    Hurwitz zeta function (or Riemann zeta function).

    Explanation
    ===========

    For $\operatorname{Re}(a) > 0$ and $\operatorname{Re}(s) > 1$, this
    function is defined as

    .. math:: \zeta(s, a) = \sum_{n=0}^\infty \frac{1}{(n + a)^s},

    where the standard choice of argument for $n + a$ is used. For fixed
    $a$ not a nonpositive integer the Hurwitz zeta function admits a
    meromorphic continuation to all of $\mathbb{C}$; it is an unbranched
    function with a simple pole at $s = 1$.

    The Hurwitz zeta function is a special case of the Lerch transcendent:

    .. math:: \zeta(s, a) = \Phi(1, s, a).

    This formula defines an analytic continuation for all possible values of
    $s$ and $a$ (also $\operatorname{Re}(a) < 0$), see the documentation of
    :class:`lerchphi` for a description of the branching behavior.

    If no value is passed for $a$ a default value of $a = 1$ is assumed,
    yielding the Riemann zeta function.

    Examples
    ========

    For $a = 1$ the Hurwitz zeta function reduces to the famous Riemann
    zeta function:

    .. math:: \zeta(s, 1) = \zeta(s) = \sum_{n=1}^\infty \frac{1}{n^s}.

    >>> from sympy import zeta
    >>> from sympy.abc import s
    >>> zeta(s, 1)
    zeta(s)
    >>> zeta(s)
    zeta(s)

    The Riemann zeta function can also be expressed using the Dirichlet eta
    function:

    >>> from sympy import dirichlet_eta
    >>> zeta(s).rewrite(dirichlet_eta)
    dirichlet_eta(s)/(1 - 2**(1 - s))

    The Riemann zeta function at nonnegative even and negative integer
    values is related to the Bernoulli numbers and polynomials:

    >>> zeta(2)
    pi**2/6
    >>> zeta(4)
    pi**4/90
    >>> zeta(0)
    -1/2
    >>> zeta(-1)
    -1/12
    >>> zeta(-4)
    0

    The specific formulae are:

    .. math:: \zeta(2n) = -\frac{(2\pi i)^{2n} B_{2n}}{2(2n)!}
    .. math:: \zeta(-n,a) = -\frac{B_{n+1}(a)}{n+1}

    No closed-form expressions are known at positive odd integers, but
    numerical evaluation is possible:

    >>> zeta(3).n()
    1.20205690315959

    The derivative of $\zeta(s, a)$ with respect to $a$ can be computed:

    >>> from sympy.abc import a
    >>> zeta(s, a).diff(a)
    -s*zeta(s + 1, a)

    However the derivative with respect to $s$ has no useful closed form
    expression:

    >>> zeta(s, a).diff(s)
    Derivative(zeta(s, a), s)

    The Hurwitz zeta function can be expressed in terms of the Lerch
    transcendent, :class:`~.lerchphi`:

    >>> from sympy import lerchphi
    >>> zeta(s, a).rewrite(lerchphi)
    lerchphi(1, s, a)

    See Also
    ========

    dirichlet_eta, lerchphi, polylog

    References
    ==========

    .. [1] https://dlmf.nist.gov/25.11
    .. [2] https://en.wikipedia.org/wiki/Hurwitz_zeta_function

    Nc                 óø  — |t           j        u r | |¦  «        S |t           j        u s|t           j        u rt           j        S |t           j        u rt           j        S |t           j        u rt           j        S |t           j        u rt           j        S |j        }|€t           j        }|r |j        rt          d|z
  |¦  «        |dz
  z  S |t           j        u rF|r@|j	        r;dt          z  t          z  |z   t          |¦  «        z  dt          |¦  «        z  z  S d S d S |r-|j        r&|j        r | |¦  «        t          |dz
  |¦  «        z
  S |j        r%|j        r |j        du s	|j        du rt           j        S d S d S d S )Nr#   r3   F)r   rB   r„   ÚComplexInfinityÚInfinityr<   r;   Úis_nonpositiver   Úis_evenr	   r
   r   rŠ   r   Ú
is_integer)rp   r,   r*   Úsints       r.   rs   z	zeta.evalö  sž  € à•”ˆ:ˆ:Ø�3�q‘6”6ˆMØ•!”%ˆZˆZ˜1¥¤˜:˜:Ý”5ˆLØ•!”%ˆZˆZÝÔ$Ð$Ø•!”*ˆ_ˆ_Ý”5ˆLØ•!”*ˆ_ˆ_Ý”6ˆMàŒ|ˆØˆ9Ý”ˆAØð 		�AÔ$ð 		Ý˜Q˜q™S !Ñ$Ô$¨¨!©Ñ,Ð,Ø•!”%ˆZˆZØð F˜œ	ð FØ�2™�a™ !™�|¥i°¡l¤lÑ2°a½	À!¹¼±nÑEÐEðFð Fð Fð Fàð 	�a”lð 	 q¤}ð 	Ø�3�q‘6”6�H Q q¡S¨!Ñ,Ô,Ñ,Ð,ØŒ\ð 	˜aÔ.ð 	Ø” Ð&Ð&¨!Ô*:¸eÐ*CÐ*CÝ”5ˆLð	ð 	ð 	ð 	Ø*CÐ*Cr0   r#   c                 óÜ   — |dk    rN|j         rG|j        r@|j        r9dt          z  t          z  |z   t          |¦  «        z  dt          |¦  «        z  z  S t          d|z
  |¦  «        |dz
  z  S )Nr#   r3   )r¡   Úis_nonnegativer    r	   r
   r   r   ©rH   r,   r*   r`   s       r.   Ú_eval_rewrite_as_bernoullizzeta._eval_rewrite_as_bernoulli  si   € Ø�Š6ˆ6�a”lˆ6 qÔ'7ˆ6¸A¼Iˆ6Ø•r‘T�!‘V˜a‘K�<¥)¨A¡,¤,Ñ.°!µI¸a±L´L±.ÑAÐAÝ˜˜1™˜aÑ Ô  A a¡CÑ(Ð(r0   c                 ób   — |dk    r| S | j         d         }t          |¦  «        ddd|z
  z  z
  z  S )Nr#   r   r3   )r:   rl   r¥   s       r.   Ú_eval_rewrite_as_dirichlet_etaz#zeta._eval_rewrite_as_dirichlet_eta  s:   € Ø�Š6ˆ6ØˆKØŒI�aŒLˆÝ˜QÑÔ  Q¨¨Q©¡Z¡Ñ0Ð0r0   c                 ó$   — t          d||¦  «        S rv   rw   r¥   s       r.   rx   zzeta._eval_rewrite_as_lerchphi  s   € Ý˜˜1˜aÑ Ô Ð r0   c                 óF   — t          | j        d         dz
  j        ¦  «        S )Nr   r#   )r   r:   rn   )rH   s    r.   Ú_eval_is_finitezzeta._eval_is_finite  s   € Ý˜$œ) Aœ,¨Ñ*Ô3Ñ4Ô4Ð4r0   c                 ó.  — | j         d         }t          | j         ¦  «        dk    r| j         d         nt          j        }|j        rO|j        r#t          |¦  «        t          |dz
  |¦  «        z
  S |j        r|j        du s	|j        du rt          j	        S | S )Nr   r#   F)
r:   Úlenr   rB   r¡   rŠ   r7   r   rŸ   r„   )rH   rI   r,   r*   s       r.   rF   zzeta._eval_expand_func"  s”   € ØŒI�aŒLˆÝ ¤	™NœN¨QÒ.Ð.ˆDŒI�aŒLˆLµA´EˆØŒ<ð 	ØŒ}ð 2Ý˜A‘w”w¥¨!¨A©#¨qÑ!1Ô!1Ñ1Ð1ØÔð  Q¤\°UÐ%:Ð%:ØÔ$¨Ð-Ð-Ý”u�Øˆr0   c                 óª   — t          | j        ¦  «        dk    r| j        \  }}n| j        dz   \  }}|dk    r| t          |dz   |¦  «        z  S t          ‚)Nr3   r2   r#   )r­   r:   r7   r   )rH   rW   r,   r*   s       r.   rX   z
zeta.fdiff-  sZ   € ÝˆtŒy‰>Œ>˜QÒÐØ”9‰DˆAˆqˆqà”9˜tÑ#‰DˆAˆqØ�qŠ=ˆ=Ø�2•d˜1˜q™5 !‘n”nÑ$Ð$å$Ð$r0   c                 óR  •— t          | j        ¦  «        dk    r| j        \  }}n| j        t          j        fz   \  }}	 |                     |¦  «        \  }}n# t
          $ r | cY S w xY w|j        r|j        st
          ‚t          t          | ¦  «         
                    |||¬¦  «        S )Nr3   )r�   r�   )r­   r:   r   rB   r‡   r‰   r†   rŠ   r�   r7   Ú_eval_as_leading_term)	rH   rŽ   r�   r�   r,   r*   rL   Úer—   s	           €r.   r°   zzeta._eval_as_leading_term7  sµ   ø€ ÝˆtŒy‰>Œ>˜QÒÐØ”9‰DˆAˆqˆqà”9¥¤˜xÑ'‰DˆAˆqð	Ø—:’:˜a‘=”=‰DˆAˆqˆqøÝ"ð 	ð 	ð 	ØˆKˆKˆKð	øøøð Œ=ð 	& ¤ð 	&Ý%Ð%å•T˜4Ñ Ô ×6Ò6°q¸tÈ$Ð6ÑOÔOÐOs   ¾A ÁA&Á%A&rZ   r2   )rd   re   rf   rg   r˜   rs   r¦   r¨   rx   r«   rF   rX   r°   r™   rš   s   @r.   r7   r7   ‹  sÜ   ø€ € € € € ðhð hðT ðð ð ñ „[ðð4)ð )ð )ð )ð
1ð 1ð 1ð 1ð!ð !ð !ð !ð5ð 5ð 5ð	ð 	ð 	ð%ð %ð %ð %ðPð Pð Pð Pð Pð Pð Pð Pð Pr0   r7   c                   óL   — e Zd ZdZedd„¦   «         Zd	d„Zej        fd„Z	d„ Z
dS )
rl   aµ  
    Dirichlet eta function.

    Explanation
    ===========

    For $\operatorname{Re}(s) > 0$ and $0 < x \le 1$, this function is defined as

    .. math:: \eta(s, a) = \sum_{n=0}^\infty \frac{(-1)^n}{(n+a)^s}.

    It admits a unique analytic continuation to all of $\mathbb{C}$ for any
    fixed $a$ not a nonpositive integer. It is an entire, unbranched function.

    It can be expressed using the Hurwitz zeta function as

    .. math:: \eta(s, a) = \zeta(s,a) - 2^{1-s} \zeta\left(s, \frac{a+1}{2}\right)

    and using the generalized Genocchi function as

    .. math:: \eta(s, a) = \frac{G(1-s, a)}{2(s-1)}.

    In both cases the limiting value of $\log2 - \psi(a) + \psi\left(\frac{a+1}{2}\right)$
    is used when $s = 1$.

    Examples
    ========

    >>> from sympy import dirichlet_eta, zeta
    >>> from sympy.abc import s
    >>> dirichlet_eta(s).rewrite(zeta)
    Piecewise((log(2), Eq(s, 1)), ((1 - 2**(1 - s))*zeta(s), True))

    See Also
    ========

    zeta

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Dirichlet_eta_function
    .. [2] Peter Luschny, "An introduction to the Bernoulli function",
           https://arxiv.org/abs/2009.06743

    Nc                 ó  — |t           j        u r | |¦  «        S |€N|dk    rt          d¦  «        S t          |¦  «        }|                     t          ¦  «        sddd|z
  z  z
  |z  S d S |dk    r3ddlm} t          d¦  «         ||¦  «        z
   ||dz   dz  ¦  «        z   S t          ||¦  «        }t          ||dz   dz  ¦  «        }|                     t          ¦  «        s(|                     t          ¦  «        s|dd|z
  z  |z  z
  S d S d S )Nr#   r3   r   ©Údigamma)r   rB   r   r7   r[   Ú'sympy.functions.special.gamma_functionsrµ   )rp   r,   r*   r-   rµ   Úz1Úz2s          r.   rs   zdirichlet_eta.evalw  s)  € à•”ˆ:ˆ:Ø�3�q‘6”6ˆMØˆ9Ø�AŠvˆvÝ˜1‘v”v�Ý�Q‘”ˆAØ—5’5�‘;”;ð *Ø˜A  !¡™H™¨Ñ)Ð)ØˆFØ�!ŠVˆVØGÐGÐGÐGÐGÐGÝ�q‘6”6˜G˜G A™JœJÑ&¨¨°!°A±#°q±Ñ)9Ô)9Ñ9Ð9Ý�!�Q‰ZŒZˆÝ�!�a˜‘c˜1‘WÑÔˆØ�vŠv•d‰|Œ|ð 	& B§F¢F­4¡L¤Lð 	&Ø˜˜A˜a™C™ 2™Ñ%Ð%ð	&ð 	&ð 	&ð 	&r0   r#   c           
      ó   — ddl m} |dk    rHt          t          d¦  «        t	          |d¦  «        fddd|z
  z  z
  t          |¦  «        z  df¦  «        S t          t          d¦  «         ||¦  «        z
   ||dz   dz  ¦  «        z   t	          |d¦  «        ft          ||¦  «        dd|z
  z  t          ||dz   dz  ¦  «        z  z
  df¦  «        S )Nr   r´   r#   r3   T)r¶   rµ   r   r   r   r7   ©rH   r,   r*   r`   rµ   s        r.   ra   z#dirichlet_eta._eval_rewrite_as_zetaŠ  sÞ   € ØCÐCÐCÐCÐCÐCØ�Š6ˆ6Ý�c !™fœf¥b¨¨A¡h¤hÐ/°1°q¸1¸Q¹3±x±<Å4ÈÁ7Ä7Ñ2JÈDÐ1QÑRÔRÐRÝ�#˜a™&œ& 7 7¨1¡:¤:Ñ-°°¸¸1¹¸a¹Ñ0@Ô0@Ñ@Å"ÀQÈÁ(Ä(ÐKÝ�a˜‘”˜a ! A¡#™h­¨a°!°A±#°q±Ñ)9Ô)9Ñ9Ñ9¸4Ð@ñBô Bð 	Br0   c                 óÜ   — ddl m} t          t          d¦  «         ||¦  «        z
   ||dz   dz  ¦  «        z   t	          |d¦  «        ft          d|z
  |¦  «        d|dz
  z  z  df¦  «        S )Nr   r´   r3   r#   T)r¶   rµ   r   r   r   r   rº   s        r.   Ú_eval_rewrite_as_genocchiz'dirichlet_eta._eval_rewrite_as_genocchi‘  s‚   € ØCÐCÐCÐCÐCÐCÝ�#˜a™&œ& 7 7¨1¡:¤:Ñ-°°¸¸1¹¸a¹Ñ0@Ô0@Ñ@Å"ÀQÈÁ(Ä(ÐKÝ˜!˜A™#˜qÑ!Ô! Q¨!¨A©#¡YÑ/°Ð6ñ8ô 8ð 	8r0   c                 óœ   — t          d„ | j        D ¦   «         ¦  «        r-|                      t          ¦  «                             |¦  «        S d S )Nc              3   ó$   K  — | ]}|j         V — Œd S rZ   )rj   )r(   Úis     r.   ú	<genexpr>z,dirichlet_eta._eval_evalf.<locals>.<genexpr>—  s$   è è € Ð.Ð.˜qˆqŒ{Ð.Ð.Ð.Ð.Ð.Ð.r0   )Úallr:   Úrewriter7   Ú_eval_evalf)rH   Úprecs     r.   rÃ   zdirichlet_eta._eval_evalf–  sM   € ÝÐ.Ð. D¤IÐ.Ñ.Ô.Ñ.Ô.ð 	8Ø—<’<¥Ñ%Ô%×1Ò1°$Ñ7Ô7Ð7ð	8ð 	8r0   rZ   r2   )rd   re   rf   rg   r˜   rs   ra   r   rB   r¼   rÃ   r&   r0   r.   rl   rl   H  s�   € € € € € ð,ð ,ð\ ð&ð &ð &ñ „[ð&ð$Bð Bð Bð Bð ./¬Uð 8ð 8ð 8ð 8ð
8ð 8ð 8ð 8ð 8r0   rl   c                   ó.   — e Zd ZdZed„ ¦   «         Zd„ ZdS )Ú
riemann_xiaç  
    Riemann Xi function.

    Examples
    ========

    The Riemann Xi function is closely related to the Riemann zeta function.
    The zeros of Riemann Xi function are precisely the non-trivial zeros
    of the zeta function.

    >>> from sympy import riemann_xi, zeta
    >>> from sympy.abc import s
    >>> riemann_xi(s).rewrite(zeta)
    s*(s - 1)*gamma(s/2)*zeta(s)/(2*pi**(s/2))

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Riemann_Xi_function

    c                 óü   — ddl m} t          |¦  «        }|t          j        t          j        fv rt          j        S t          |t          ¦  «        s+||dz
  z   ||dz  ¦  «        z  |z  dt          |dz  z  z  z  S d S ©Nr   )Úgammar#   r3   )	r¶   rÉ   r7   r   r<   rB   ÚHalfrE   r	   )rp   r,   rÉ   r-   s       r.   rs   zriemann_xi.eval³  sŠ   € àAÐAÐAÐAÐAÐAÝ�‰GŒGˆØ•”�œ�ÐÐÝ”6ˆMå˜!�TÑ"Ô"ð 	8Ø�a˜!‘e‘9˜U˜U 1 Q¡3™ZœZÑ'¨Ñ)¨1­R°!°A±#©Y©;Ñ7Ð7ð	8ð 	8r0   c                 ó~   — ddl m} ||dz
  z   ||dz  ¦  «        z  t          |¦  «        z  dt          |dz  z  z  z  S rÈ   )r¶   rÉ   r7   r	   )rH   r,   r`   rÉ   s       r.   ra   z riemann_xi._eval_rewrite_as_zeta½  sO   € ØAÐAÐAÐAÐAÐAØ�!�a‘%‰y˜˜˜q ™s™œÑ#¥D¨¡G¤GÑ+¨Q­r°A°a±C©y©[Ñ9Ð9r0   N)rd   re   rf   rg   r˜   rs   ra   r&   r0   r.   rÆ   rÆ   ›  sH   € € € € € ðð ð. ð8ð 8ñ „[ð8ð:ð :ð :ð :ð :r0   rÆ   c                   ó*   — e Zd ZdZedd„¦   «         ZdS )Ú	stieltjesa€  
    Represents Stieltjes constants, $\gamma_{k}$ that occur in
    Laurent Series expansion of the Riemann zeta function.

    Examples
    ========

    >>> from sympy import stieltjes
    >>> from sympy.abc import n, m
    >>> stieltjes(n)
    stieltjes(n)

    The zero'th stieltjes constant:

    >>> stieltjes(0)
    EulerGamma
    >>> stieltjes(0, 1)
    EulerGamma

    For generalized stieltjes constants:

    >>> stieltjes(n, m)
    stieltjes(n, m)

    Constants are only defined for integers >= 0:

    >>> stieltjes(-1)
    zoo

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Stieltjes_constants

    Nc                 óÚ  — |�Ct          |¦  «        }|t          j        u rt          j        S |j        r|j        rt          j        S |j        r]|t          j        u rt          j        S |dk     rt          j        S |j        st          j        S |t          j        u r|dv rt          j        S |j	        rt          j        S |j
        r|dv rt          j        S |j        dk    rt          j        S d S )Nr   rv   F)r   r   r„   r;   rŸ   r�   Ú	is_Numberr<   Ú
EulerGammaÚis_extended_negativern   r¡   )rp   r+   r*   s      r.   rs   zstieltjes.evalç  sé   € àˆ=Ý˜‘
”
ˆAØ•A”EˆzˆzÝ”u�ØŒ|ð ) Ô 0ð )ÝÔ(Ð(àŒ;ð 	$Ø•A”EˆzˆzÝ”u�Ø�Q’�ÝÔ(Ð(Ø”\ð $ÝÔ(Ð(Ø•a”f��  i  Ý”|Ð#àÔ!ð 	%ÝÔ$Ð$àŒ9ð 	 ˜˜i˜˜Ý”<ÐàŒ<˜5Ò Ð ÝÔ$Ð$ð !Ð r0   rZ   )rd   re   rf   rg   r˜   rs   r&   r0   r.   rÍ   rÍ   Â  s?   € € € € € ð"ð "ðH ð%ð %ð %ñ „[ð%ð %ð %r0   rÍ   c                  óº  — t           j        t          dz  dz  t          d¦  «        dz  dz  z
  t	          d¦  «        t          dz  dz  t
          t          z  t          d¦  «        z  z
  t          d¦  «        dz
   dz  t          dz   dz  t          t          d¦  «        dz
  dz  ¦  «        dz  dz  z   t          d¦  «        dz    dz  t          dz   dz  t          t          d¦  «        dz   dz  ¦  «        dz  z
  dt          d¦  «        z
  dz  t          dz  dz  t          t          d¦  «        dz
  dz  ¦  «        dz  z
  t          d¦  «        dz
  dz  t          dz  dz  t          t          d¦  «        dz
  dz  ¦  «        dz  z
  t
          t
          t           j        z  t          dz  d	z  z
  t
           t
           t           j        z  t          dz  d	z  z
  dt
          z
  t          dz  d
z  t
          t           j        z  z
  t          t
          z  dz  t          d¦  «        z  z
  dt
          z   t          dz  d
z  t
          t           j        z  z   t          t
          z  dz  t          d¦  «        z  z   dt
          z
  dz  t          d¦  «        dz   dz  t          t
          z  t          d¦  «        z  dz  z   dt          dz  z  dz  z   t
          t           j        z  z
  iS )Nr3   é   r5   é   r#   é   é
   rV   é0   é   é   é`   )r   rÊ   r	   r   r   r
   r   ÚCatalanr&   r0   r.   rm   rm     s;  € õ 	
Œ•�A‘�b‘�3˜q™6œ6 1™9 Q™;Ñ&Ý�‰
Œ
•R˜‘U˜1‘W�q¥™t¥C¨¡F¤F™{Ñ*Ý
ˆq‰'Œ'�A‰+ˆ�qÑ�B ™E˜6 "™9¥s­D°©G¬G°A©I°q©=Ñ'9Ô'9¸1Ñ'<¸QÑ'>Ñ>Ý
ˆq‰'Œ'�A‰+ˆ�qÑ�B ™E˜6 "™9¥s­D°©G¬G°A©I°q©=Ñ'9Ô'9¸1Ñ'<Ñ<Ø	
�T�!‰WŒW‰�a‰�"˜a™% ™(¥S­$¨q©'¬'°!©)°Q©Ñ%7Ô%7¸Ñ%:Ñ:Ý	ˆa‰Œ�1‰�a‰�"˜a™% ™(¥S­$¨q©'¬'°!©)°Q©Ñ%7Ô%7¸Ñ%:Ñ:Ý	�A�aŒi‰K�"˜a™% ™(Ñ"Ý	
ˆ�aˆR•”	‰\�B ™E "™HÑ$Ø	�A‰•�A‘�b‘�1�QœY™;Ñ&­­A©¨a©µ°A±´©Ñ6Ø	�A‰•�A‘�b‘�1�QœY™;Ñ&­­A©¨a©µ°A±´©Ñ6Ø	
�Q‰�‰	•S˜‘V”V˜Q‘Y�J˜q‘L¥2¥a¡4­¨A©¬¡;¨q¡=Ñ0°1µR¸±U±7¸2±:Ñ=ÅÅ!Ä)ÁÑKðð r0   N)5rg   Úsympy.core.addr   Úsympy.core.cacher   Úsympy.core.functionr   r   r   Úsympy.core.logicr   Úsympy.core.numbersr	   r
   r   Úsympy.core.relationalr   Úsympy.core.singletonr   Úsympy.core.symbolr   Úsympy.core.sympifyr   Ú%sympy.functions.combinatorial.numbersr   r   r   r   Ú$sympy.functions.elementary.complexesr   r   r   r   Ú&sympy.functions.elementary.exponentialr   r   r   Ú#sympy.functions.elementary.integersr   r   Ú(sympy.functions.elementary.miscellaneousr   Ú$sympy.functions.elementary.piecewiser   Úsympy.polys.polytoolsr   r!   rD   r7   rl   rÆ   rÍ   rm   r&   r0   r.   ú<module>rì      sÐ  ðØ *Ð *à Ð Ð Ð Ð Ð Ø $Ð $Ð $Ð $Ð $Ð $Ø OÐ OÐ OÐ OÐ OÐ OÐ OÐ OÐ OÐ OØ &Ð &Ð &Ð &Ð &Ð &Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø $Ð $Ð $Ð $Ð $Ð $Ø "Ð "Ð "Ð "Ð "Ð "Ø #Ð #Ð #Ð #Ð #Ð #Ø &Ð &Ð &Ð &Ð &Ð &Ø ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZØ PÐ PÐ PÐ PÐ PÐ PÐ PÐ PÐ PÐ PÐ PÐ PØ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FÐ FØ >Ð >Ð >Ð >Ð >Ð >Ð >Ð >Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø :Ð :Ð :Ð :Ð :Ð :Ø &Ð &Ð &Ð &Ð &Ð &ð2ð 2ð 2ð 2ð 2ˆñ 2ô 2ð 2ðLeDð eDð eDð eDð eDˆoñ eDô eDð eDðXzPð zPð zPð zPð zPˆ?ñ zPô zPð zPðzP8ð P8ð P8ð P8ð P8�Oñ P8ô P8ð P8ðf$:ð $:ð $:ð $:ð $:�ñ $:ô $:ð $:ðN?%ð ?%ð ?%ð ?%ð ?%�ñ ?%ô ?%ð ?%ðD 	ðð ñ 	„ðð ð r0   