o
    §ƒðj^  ã                   @   sh  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„ deƒZ.G dd„ deƒZ/G dd„ deƒZ0G dd„ deƒZ1G dd„ deƒZ2G dd„ deƒZ3ed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                   @   s:   e Zd ZdZdd„ Zddd„Zdd„ Zd	d
„ Zd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                    sÎ  | j \‰‰‰ ˆdkrtˆˆ ƒS ˆjrIˆdkrItdƒ}t|ˆ  ˆ  |ƒ‰dd|  }tj}tˆ ¡ ƒD ]}||| 7 }|| 	|¡ }q3| 
|ˆ¡S ˆ jr÷tj}tj}ˆ dkr|tˆ ƒ‰ˆˆ krbˆd8 ‰ˆ ˆ8 ‰ ˆˆ  }t‡ ‡‡‡fdd„tˆƒD ƒŽ }n#ˆ dkrŸtˆ  ƒd ‰ˆ ˆ7 ‰ ˆˆ }t‡ ‡‡‡fdd„tˆƒD ƒŽ }tˆ jˆ jgƒ\}‰tdt t ˆ ƒ}	ˆdˆ  }
t|	ƒ}g }tˆƒD ]%}tˆ|	| |
 ƒ‰tˆtƒrÛˆjdi |¤Ž‰| ˆ|| |
 |  ¡ qÃ||ˆˆd   t|Ž   S tˆtƒ�rˆj d tt  j�sˆdtt fv �raˆdk�rtddgƒ\‰‰n2ˆtk�r-tdd	gƒ\‰‰n$ˆt k�r<tdd	gƒ\‰‰nˆj d dt t  }t|j|jgƒ\‰‰t‡ ‡‡‡fd
d„tˆƒD ƒŽ S tˆˆˆ ƒS )Né   r   Útc                    s&   g | ]}ˆ|ˆ   ˆ | ˆ  ‘qS © r"   ©Ú.0Úk©ÚaÚnÚsÚzr"   ú¨/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/sympy/functions/special/zeta_functions.pyÚ
<listcomp>    s   & z.lerchphi._eval_expand_func.<locals>.<listcomp>c                    s,   g | ]}ˆˆd  |  ˆ | d  ˆ  ‘qS ©r    r"   r#   r&   r"   r+   r,   ¥   s   , é   éÿÿÿÿé   c                    sB   g | ]}t d t t | ˆ ˆ ƒˆˆ  tˆ|ˆ  ˆ ƒ ‘qS )r.   )r   r   r	   Úzetar#   )r'   ÚpÚqr)   r"   r+   r,   ¿   s    :ÿr"   )Úargsr1   Ú
is_Integerr   r   r   ÚZeroÚreversedÚ
all_coeffsÚdiffÚsubsÚis_RationalÚOner   r   Úranger2   r3   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'   r(   r2   r3   r)   r*   r+   r@   ƒ   sf   

" 
4

ÿzlerchphi._eval_expand_funcr    c                 C   sZ   | j \}}}|dkr| t||d |ƒ S |dkr+t||d |ƒ|t|||ƒ  | S t‚)Né   r    )r4   r   r   )rB   Úargindexr*   r)   r'   r"   r"   r+   ÚfdiffÄ   s   $zlerchphi.fdiffc                 C   s   |   ¡ }| |¡r|S | S ©N)r@   Úhas)rB   ÚtargetrE   r"   r"   r+   Ú_eval_rewrite_helperÍ   s   
zlerchphi._eval_rewrite_helperc                 K   ó
   |   t¡S rR   )rU   r1   ©rB   r*   r)   r'   Úkwargsr"   r"   r+   Ú_eval_rewrite_as_zetaÔ   ó   
zlerchphi._eval_rewrite_as_zetac                 K   rV   rR   )rU   r>   rW   r"   r"   r+   Ú_eval_rewrite_as_polylog×   rZ   z!lerchphi._eval_rewrite_as_polylogNr-   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r@   rQ   rU   rY   r[   r"   r"   r"   r+   r      s    i
A	r   c                       sP   e Zd ZdZedd„ ƒZddd„Zdd„ Zd	d
„ Zdd„ Z	d‡ fdd„	Z
‡  ZS )r>   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                 C   s   |j r-|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r3tjS | 	tj¡}|r?t|ƒS |du rd|tju rN|d|  S |tju r[|d| d  S |jrd|d|  S | 
tt¡r||sut|ƒtjkdkr~| |t|ƒƒS d S d S )Nr.   Fr    T)Ú	is_numberr   r<   r1   ÚNegativeOneÚdirichlet_etar6   Ú_dilogtableÚis_zeroÚequalsrS   r   r   r   r   )Úclsr)   r*   Ú
dilogtableÚzoner"   r"   r+   Úeval%  s4   





"ÿzpolylog.evalr    c                 C   s(   | j \}}|dkrt|d |ƒ| S t‚)Nr.   r    )r4   r>   r   )rB   rP   r)   r*   r"   r"   r+   rQ   L  s   
zpolylog.fdiffc                 K   s   |t ||dƒ S ©Nr    ©r   )rB   r)   r*   rX   r"   r"   r+   Ú_eval_rewrite_as_lerchphiR  s   z!polylog._eval_rewrite_as_lerchphic                 K   sz   | j \}}|dkrtd| ƒ S |jr8|dkr8tdƒ}|d|  }t| ƒD ]	}|| |¡ }q&t|ƒ ||¡S t||ƒS )Nr    r   Úu)	r4   r   r5   r   r=   r9   r   r:   r>   )rB   rC   r)   r*   rm   rD   Ú_r"   r"   r+   r@   U  s   

zpolylog._eval_expand_funcc                 C   s   | j d }|jr
dS d S )Nr    T)r4   rd   )rB   r*   r"   r"   r+   Ú_eval_is_zeroa  s   
ÿzpolylog._eval_is_zeror   c              	      s  ddl m} | j\}}| |d¡}|tju r%|j|dt|ƒjr!dndd�}|j	r€z	| 
|¡\}	}
W n ttfy>   |  Y S w |
jr€t||
 ƒ}||| |ƒ}| ||||¡ ¡ }|tju r`|S |}|g}td|ƒD ]}||9 }| |||  ¡ qjt|Ž | S tt| ƒ ||||¡S )Nr   )ÚOrderú-ú+)Údirr.   )Úsympy.series.orderrp   r4   r:   r   ÚNaNÚlimitr   Úis_negativerd   ÚleadtermÚ
ValueErrorÚNotImplementedErrorÚis_positiver   Ú_eval_nseriesÚremoveOr6   r=   rA   r   Úsuperr>   )rB   Úxr(   ÚlogxÚcdirrp   Únur*   Úz0rn   r   ÚnewnÚoÚrÚtermr)   r%   ©Ú	__class__r"   r+   r|   f  s0   

ÿ
zpolylog._eval_nseriesr-   )r   )r\   r]   r^   r_   Úclassmethodri   rQ   rl   r@   ro   r|   Ú__classcell__r"   r"   rˆ   r+   r>   ß   s    E

&r>   c                       sf   e Zd ZdZeddd„ƒZddd„Zddd	„Zdd
d„Zdd„ Z	dd„ Z
ddd„Z‡ fdd„Z‡  ZS )r1   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                 C   s*  |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}|d u r8t j}|rH|jrHtd| |ƒ|d  S |t ju ri|re|j	rgdt
 t |  t|ƒ dt|ƒ  S d S d S |r||jr||jr|| |ƒt|d |ƒ S |jr�|jr‘|jdu sŒ|jdu r“t jS d S d S d S )Nr    r.   F)r   r<   ru   ÚComplexInfinityÚInfinityr6   r5   Úis_nonpositiver   Úis_evenr   r	   r   r{   r   Ú
is_integer)rf   r)   r'   Úsintr"   r"   r+   ri   ö  s4   






&ÿþz	zeta.evalr    c                 K   sV   |dkr |j r |jr |jr dt t |  t|ƒ dt|ƒ  S td| |ƒ|d  S )Nr    r.   )r�   Úis_nonnegativer�   r   r	   r   r   ©rB   r)   r'   rX   r"   r"   r+   Ú_eval_rewrite_as_bernoulli  s   &zzeta._eval_rewrite_as_bernoullic                 K   s.   |dkr| S | j d }t|ƒddd|    S )Nr    r   r.   )r4   rb   r“   r"   r"   r+   Ú_eval_rewrite_as_dirichlet_eta  s   
z#zeta._eval_rewrite_as_dirichlet_etac                 K   s   t d||ƒS rj   rk   r“   r"   r"   r+   rl     s   zzeta._eval_rewrite_as_lerchphic                 C   s   t | jd d jƒS )Nr   r    )r   r4   rd   )rB   r"   r"   r+   Ú_eval_is_finite  s   zzeta._eval_is_finitec                 K   sn   | j d }t| j ƒdkr| j d ntj}|jr5|jr%t|ƒt|d |ƒ S |jr5|jdu s2|jdu r5tj	S | S )Nr   r    F)
r4   Úlenr   r<   r�   r{   r1   r   rŽ   ru   )rB   rC   r)   r'   r"   r"   r+   r@   "  s   

zzeta._eval_expand_funcc                 C   sH   t | jƒdkr| j\}}n| jd \}}|dkr"| t|d |ƒ S t‚)Nr.   r-   r    )r—   r4   r1   r   )rB   rP   r)   r'   r"   r"   r+   rQ   -  s   z
zeta.fdiffc                    s|   t | jƒdkr| j\}}n	| jtjf \}}z	| |¡\}}W n ty*   |  Y S w |jr3|js3t‚tt	| ƒj
|||d�S )Nr.   )r€   r�   )r—   r4   r   r<   rx   rz   rw   r{   r~   r1   Ú_eval_as_leading_term)rB   r   r€   r�   r)   r'   rF   Úerˆ   r"   r+   r˜   7  s   ÿzzeta._eval_as_leading_termrR   r-   )r\   r]   r^   r_   rŠ   ri   r”   r•   rl   r–   r@   rQ   r˜   r‹   r"   r"   rˆ   r+   r1   ‹  s    j




r1   c                   @   s>   e Zd ZdZeddd„ƒZddd„Zejfdd	„Z	d
d„ Z
dS )rb   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                 C   sÔ   |t ju r	| |ƒS |d u r*|dkrtdƒS t|ƒ}| t¡s(ddd|   | S d S |dkrDddlm} tdƒ||ƒ ||d d ƒ S t||ƒ}t||d d ƒ}| t¡sf| t¡sh|dd|  |  S d S d S )Nr    r.   r   ©Údigamma)r   r<   r   r1   rS   Ú'sympy.functions.special.gamma_functionsr›   )rf   r)   r'   r*   r›   Úz1Úz2r"   r"   r+   ri   w  s"   

 
ÿzdirichlet_eta.evalr    c                 K   sœ   ddl m} |dkr"ttdƒt|dƒfddd|   t|ƒ dfƒS ttdƒ||ƒ ||d d ƒ t|dƒft||ƒdd|  t||d d ƒ  dfƒS )Nr   rš   r    r.   T)rœ   r›   r   r   r   r1   ©rB   r)   r'   rX   r›   r"   r"   r+   rY   Š  s   0**ÿz#dirichlet_eta._eval_rewrite_as_zetac                 K   sV   ddl m} ttdƒ||ƒ ||d d ƒ t|dƒftd| |ƒd|d   dfƒS )Nr   rš   r.   r    T)rœ   r›   r   r   r   r   rŸ   r"   r"   r+   Ú_eval_rewrite_as_genocchi‘  s   *ÿz'dirichlet_eta._eval_rewrite_as_genocchic                 C   s(   t dd„ | jD ƒƒr|  t¡ |¡S d S )Nc                 s   s   � | ]}|j V  qd S rR   )r`   )r$   Úir"   r"   r+   Ú	<genexpr>—  s   € z,dirichlet_eta._eval_evalf.<locals>.<genexpr>)Úallr4   Úrewriter1   Ú_eval_evalf)rB   Úprecr"   r"   r+   r¥   –  s   ÿzdirichlet_eta._eval_evalfrR   r-   )r\   r]   r^   r_   rŠ   ri   rY   r   r<   r    r¥   r"   r"   r"   r+   rb   H  s    .
rb   c                   @   s$   e Zd ZdZedd„ ƒZd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                 C   sd   ddl m} t|ƒ}|tjtjfv rtjS t|tƒs0||d  ||d ƒ | dt|d    S d S ©Nr   )Úgammar    r.   )	rœ   r©   r1   r   r6   r<   ÚHalfr?   r   )rf   r)   r©   r*   r"   r"   r+   ri   ³  s   
,ÿzriemann_xi.evalc                 K   s<   ddl m} ||d  ||d ƒ t|ƒ dt|d    S r¨   )rœ   r©   r1   r   )rB   r)   rX   r©   r"   r"   r+   rY   ½  s   0z riemann_xi._eval_rewrite_as_zetaN)r\   r]   r^   r_   rŠ   ri   rY   r"   r"   r"   r+   r§   ›  s
    
	r§   c                   @   s   e Zd ZdZed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                 C   s®   |d urt |ƒ}|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s1tjS |tju r=|dv r=tjS |j	rCtjS |j
rM|dv rMtjS |jdkrUtjS d S )Nr   rj   F)r   r   ru   r5   rŽ   rŒ   Ú	is_Numberr6   Ú
EulerGammaÚis_extended_negativerd   r�   )rf   r(   r'   r"   r"   r+   ri   ç  s,   


ÿzstieltjes.evalrR   )r\   r]   r^   r_   rŠ   ri   r"   r"   r"   r+   r«   Â  s    $r«   c                   C   sâ  t jtd d tdƒd d  tdƒtd d tt tdƒ  tdƒd  d td  d ttdƒd d ƒd d  tdƒd  d td  d ttdƒd d ƒd  dtdƒ d td d ttdƒd d ƒd  tdƒd d td d ttdƒd d ƒd  ttt j td d	  t t t j td d	  dt td d
 tt j  tt d tdƒ  dt td d
 tt j  tt d tdƒ  dt d tdƒd  d tt tdƒ d  dtd  d  tt j  iS )Nr.   é   r0   é   r    é   é
   rO   é0   é   é   é`   )r   rª   r   r   r
   r	   r   ÚCatalanr"   r"   r"   r+   rc     s    8400..Hõrc   N)5r_   Ú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   r>   r1   rb   r§   r«   rc   r"   r"   r"   r+   Ú<module>   s8     G - >S'B