
    g ^                        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
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          Z. G d de          Z/ G d de          Z0 G d de          Z1ed             Z2dS )z$ Riemann zeta and related function.     )Add)cacheit)ArgumentIndexError
expand_mulFunction)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    rt          d          }t	          |z    z  |          dd|z
  z  }t
          j        }t                                                    D ]"}|||z  z  }||	                    |          z  }#|
                    |          S j        rt
          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     b/var/www/html/ai-engine/env/lib/python3.11/site-packages/sympy/functions/special/zeta_functions.py
<listcomp>z.lerchphi._eval_expand_func.<locals>.<listcomp>   s0    EEEqQQZK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LaAA	NAEAI>9LLLr/         c                     g | ]G}t          d t          z  t          z  |z  z  z            z  z  t          |z   z            z  HS )r2   )r   r   r	   zeta)r'   r(   r)   pqr+   s     r-   r.   z.lerchphi._eval_expand_func.<locals>.<listcomp>   se     , , , QrT!VAXaZ\**1a4/QQ	0B0BB , , ,r/   r%   )argsr6   
is_Integerr   r   r   Zeroreversed
all_coeffsdiffsubsis_RationalOner   r   ranger7   r8   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*   r7   r8   r+   r,   s                  @@@@@@r-   rE   zlerchphi._eval_expand_func   s   )1a661::< 	"AFFc

Aa!er]A&&Aq1uIE&Callnn-- ( (qw%**Q--88Aq>>!=  	6 &C%C1uu!HH66FAQ1"gEEEEEEEE!HHEEEFa1"IIMQdLLLLLLL588LLLMac13Z==DAqAbDF1H%%Cqs8D__FG1XX 6 6AsAvd{++a)) 5++44e44Aq&!)D.1!445555QQZW555 a 	-16!9bd#3"@ 	-A"aRSQSDTDTBww!Qyy11a!Qyy11qb"azz11fQi2a(#%((1 , , , , , , ,"'((, , , - - 1a   r/   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"   )r9   r    r   )rG   argindexr,   r+   r)   s        r-   fdiffzlerchphi.fdiff   su    )1aq==2hq!a%++++]]QAq))Ahq!Q.?.?,??BB$$r/   c                 \    |                                  }|                    |          r|S | S N)rE   has)rG   targetrJ   s      r-   _eval_rewrite_helperzlerchphi._eval_rewrite_helper   s/    $$&&776?? 	JKr/   c                 6    |                      t                    S rY   )r\   r6   rG   r,   r+   r)   kwargss        r-   _eval_rewrite_as_zetazlerchphi._eval_rewrite_as_zeta   s    ((...r/   c                 6    |                      t                    S rY   )r\   rC   r^   s        r-   _eval_rewrite_as_polylogz!lerchphi._eval_rewrite_as_polylog   s    ((111r/   Nr1   )	__name__
__module____qualname____doc__rE   rW   r\   r`   rb   r%   r/   r-   r    r       sr        g gR?! ?! ?!B% % % %  / / /2 2 2 2 2r/   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 )rC   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 )Nr2   Fr"   T)	is_numberr   rA   r6   NegativeOnedirichlet_etar;   _dilogtableis_zeroequalsrZ   r   r   r   r   )clsr+   r,   
dilogtablezones        r-   evalzpolylog.eval$  sf   ; 
	)AEzzAwwam##%a((((afva(]]

??%a=(9 	6M xx 	!77NU]]
 AF{{!a%y am##!a%!|#y !!a%y  55J'' 	)T 	)c!ffo$5N5N3q*Q--(((	) 	)5N5Nr/   r"   c                 \    | j         \  }}|dk    rt          |dz
  |          |z  S t          )Nr2   r"   )r9   rC   r   )rG   rV   r+   r,   s       r-   rW   zpolylog.fdiffK  s5    y1q==1q5!$$Q&&  r/   c                 *    |t          ||d          z  S Nr"   r    )rG   r+   r,   r_   s       r-   _eval_rewrite_as_lerchphiz!polylog._eval_rewrite_as_lerchphiQ  s    !Q""""r/   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)	r9   r   r:   r   rB   r>   r   r?   rC   )rG   rH   r+   r,   ry   rI   _s          r-   rE   zpolylog._eval_expand_funcT  s    y166AJJ;< 	0AFFc

Aq1uIEA2YY ( (%**Q--e$$))!Q///q!}}r/   c                 2    | j         d         }|j        rdS d S )Nr"   Tr9   rm   )rG   r,   s     r-   _eval_is_zerozpolylog._eval_is_zero`  s&    IaL9 	4	 	r/   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        rt          ||
z            } |||z  |          }|                    ||||                                          }|t          j        u r|S |}|g}t%          d|          D ]"}||z  }|                    |||z  z             #t)          | |z   S t+          t,          |                               ||||          S )Nr   )Order-+)dirr2   )sympy.series.orderr   r9   r?   r   NaNlimitr   is_negativerm   leadterm
ValueErrorNotImplementedErroris_positiver   _eval_nseriesremoveOr;   rB   rF   r   superrC   )rG   xr*   logxcdirr   nur,   z0rz   r   newnortermr+   r(   	__class__s                    r-   r   zpolylog._eval_nseriese  s   ,,,,,,	AVVAq\\;;A"T((*>#G33CHHB: 	#A33 34     #qu~~E!Q$NNOOAq$55==??;;HFq$ ) )AAIDHHT!R%Z((((Aw{"Wd##11!QdCCCs   ,B BBr1   )r   )rc   rd   re   rf   classmethodrr   rW   rw   rE   r}   r   __classcell__r   s   @r-   rC   rC      s        C CJ $) $) [$)L! ! ! !# # #
 
 
  
D D D D D D D D D Dr/   rC   c                   h     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d fd	Z xZS )r6   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"   r2   F)r   rA   r   ComplexInfinityInfinityr;   r:   is_nonpositiver   is_evenr   r	   r   r   r   
is_integer)ro   r+   r)   sints       r-   rr   z	zeta.eval  s   ::3q66M!%ZZ1::5L!%ZZ$$!*__5L!*__6M|9A 		A$ 		QqS!$$!,,!%ZZ F	 F2a!|ill2a	!nEEF F F F 	al 	q} 	3q66HQqS!,,,,\ 	a. 	&&!*:e*C*C5L	 	 	 	*C*Cr/   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"   r2   )r   is_nonnegativer   r   r	   r   r   rG   r+   r)   r_   s       r-   _eval_rewrite_as_bernoullizzeta._eval_rewrite_as_bernoulli  si    66al6q'76AI6rT!VaK<)A,,.!IaLL.AA1a  AaC((r/   c                 b    |dk    r| S | j         d         }t          |          ddd|z
  z  z
  z  S )Nr"   r   r2   )r9   rk   r   s       r-   _eval_rewrite_as_dirichlet_etaz#zeta._eval_rewrite_as_dirichlet_eta  s:    66KIaLQQQZ00r/   c                 $    t          d||          S ru   rv   r   s       r-   rw   zzeta._eval_rewrite_as_lerchphi  s    1a   r/   c                 :    | j         d         dz
  j        }|| S d S )Nr   r"   r|   )rG   
arg_is_ones     r-   _eval_is_finitezzeta._eval_is_finite  s+    ilQ&/
!!>! "!r/   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)
r9   lenr   rA   r   r   r6   r   r   r   )rG   rH   r+   r)   s       r-   rE   zzeta._eval_expand_func#  s    IaL	NNQ..DIaLLAE< 	} 2Aww!A#q!1!111 Q\U%:%:$--ur/   c                     t          | j                  dk    r| j        \  }}n| j        dz   \  }}|dk    r| t          |dz   |          z  S t          )Nr2   r1   r"   )r   r9   r6   r   )rG   rV   r+   r)   s       r-   rW   z
zeta.fdiff.  sZ    ty>>Q9DAqq9t#DAqq==2d1q5!nn$$$$r/   r   c                 P   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 )Nr2   )r   r9   r   rA   r   r   r   r   r   r6   _eval_as_leading_term)	rG   r   r   r   r+   r)   rK   er   s	           r-   r   zzeta._eval_as_leading_term8  s    ty>>Q9DAqq9x'DAq	::a==DAqq" 	 	 	KKK	 = 	& 	&%%T4  66q$EEEs   A A&%A&rY   r1   )Nr   )rc   rd   re   rf   r   rr   r   r   rw   r   rE   rW   r   r   r   s   @r-   r6   r6     s        h hT    [4) ) ) )
1 1 1 1! ! ! !" " "
	 	 	% % % %F F F F F F F F F Fr/   r6   c                   L    e Zd ZdZedd            Zd	dZej        fdZ	d Z
dS )
rk   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"   r2   r   digamma)r   rA   r   r6   rZ   'sympy.functions.special.gamma_functionsr   )ro   r+   r)   r,   r   z1z2s          r-   rr   zdirichlet_eta.evalx  s)   ::3q66M9Avv1vvQA55;; *A!H))F!VVGGGGGGq66GGAJJ&!A#q)9)999!QZZ!ac1Wvvd|| 	&BFF4LL 	&AaC2%%	& 	& 	& 	&r/   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"   r2   T)r   r   r   r   r   r6   rG   r+   r)   r_   r   s        r-   r`   z#dirichlet_eta._eval_rewrite_as_zeta  s    CCCCCC66c!ffbAhh/1q1Q3x<4772JD1QRRR#a&&771::-1a0@0@@"Q((Kaa!A#ha!A#q)9)9994@B B 	Br/   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   r2   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&&771::-1a0@0@@"Q((K!A#q!!Q!A#Y/68 8 	8r/   c                     t          d | j        D                       r-|                     t                                        |          S d S )Nc              3   $   K   | ]}|j         V  d S rY   )ri   )r'   is     r-   	<genexpr>z,dirichlet_eta._eval_evalf.<locals>.<genexpr>  s$      ..qq{......r/   )allr9   rewriter6   _eval_evalf)rG   precs     r-   r   zdirichlet_eta._eval_evalf  sM    ..DI..... 	8<<%%11$777	8 	8r/   rY   r1   )rc   rd   re   rf   r   rr   r`   r   rA   r   r   r%   r/   r-   rk   rk   I  s        , ,\ & & & [&$B B B B ./U 8 8 8 8
8 8 8 8 8r/   rk   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"   r2   )	r   r   r6   r   r;   rA   HalfrD   r   )ro   r+   r   r,   s       r-   rr   zriemann_xi.eval  s    AAAAAAGG6M!T"" 	8a!e9UU1Q3ZZ')1R!A#Y;77	8 	8r/   c                 ~    ddl m} ||dz
  z   ||dz            z  t          |          z  dt          |dz  z  z  z  S r   )r   r   r6   r   )rG   r+   r_   r   s       r-   r`   z riemann_xi._eval_rewrite_as_zeta  sO    AAAAAA!a%yqs#DGG+QrAaCy[99r/   N)rc   rd   re   rf   r   rr   r`   r%   r/   r-   r   r     sH         . 8 8 [8: : : : :r/   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   ru   F)r   r   r   r:   r   r   	is_Numberr;   
EulerGammais_extended_negativerm   r   )ro   r*   r)   s      r-   rr   zstieltjes.eval  s    =

AAEzzu| ) 0 )((; 	$AEzzuQ((\ $((afi|#! 	%$$9 	 i<<5  $$ ! r/   rY   )rc   rd   re   rf   r   rr   r%   r/   r-   r   r     s?        " "H % % % [% % %r/   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 )Nr2      r4      r"      
   rU   0         `   )r   r   r   r   r
   r	   r   Catalanr%   r/   r-   rl   rl     s;    	
Ab3q6619Q;&

RU1WqtCFF{*
q''A+qBE6"9sDGGAIq='9'91'<Q'>>
q''A+qBE6"9sDGGAIq='9'91'<<	
T!WWa"a%(S$q''!)Q%7%7%::	a1a"a%(S$q''!)Q%7%7%::	AaiK"a%("	
aR	\BE"H$	AAb1QY;&AaA6	AAb1QY;&AaA6	
Q	SVVQYJqL2a4A;q=01RU72:=!)K r/   N)3rf   sympy.core.addr   sympy.core.cacher   sympy.core.functionr   r   r   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    rC   r6   rk   r   r   rl   r%   r/   r-   <module>r      s   * *       $ $ $ $ $ $ H H H H H H H H H H - - - - - - - - - - $ $ $ $ $ $ " " " " " " # # # # # # & & & & & & 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 2x 2 2 2LeD eD eD eD eDh eD eD eDX|F |F |F |F |F8 |F |F |F~P8 P8 P8 P8 P8H P8 P8 P8f$: $: $: $: $: $: $: $:N?% ?% ?% ?% ?% ?% ?% ?%D 	  	  r/   