
    \hw                    2   S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJrJr  S SKJr  S SKJr  S SKJrJrJr  S SKJ r   S SK!J"r"J#r#J$r$J%r%J&r&J'r'  S SK(J)r)  S SK*J+r+  S SK,J-r-J.r.  S SK/J0r0J1r1  S SK2J3r3  SSK4J5r5  S SK6J7r7  S SK8J9r9J:r:  S SK;J<r<  S SK=J>r>  S SK?J@r@  S SKAJBrB  S SKCJDrD  S SKEJFrF  S S KGJHrH   " S! S"\5      rIS#S$S#S#S#S%.S& jrJS' rK\BR                  " \I5      S( 5       rMSS)KNJOrO  SS*KPJQrQJRrRJSrS  SS+KTJUrU  g#),    )annotations)AddWithLimits)Add)Basic)Tuple)Expr)factor_terms)diff)
fuzzy_bool)Mul)oopi)Ne)S)DummySymbolWild)sympify)	Piecewisesqrtpiecewise_foldtancotatan)log)floor)Abssign)MinMax)	Heaviside   )ratint)
MatrixBase)PolyPolynomialError)FormalPowerSeries)limit)Order)shape)sympy_deprecation_warning)is_sequence)
filldedentc                     ^  \ rS rSr% SrSrS\S'   SS jrS r\	U 4S j5       r
S	 rS
 rS rS r  SS jrSS jrSS jrS rS rSS jrS rSrU =r$ )Integral#   z Represents unevaluated integral. ztuple[Expr, Tuple]argsc                    [        US5      (       a  UR                  " U0 UD6$ [        U[        5      (       a  [	        SSSS9  [
        R                  " X/UQ70 UD6nU$ )a  Create an unevaluated integral.

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

Arguments are an integrand followed by one or more limits.

If no limits are given and there is only one free symbol in the
expression, that symbol will be used, otherwise an error will be
raised.

>>> from sympy import Integral
>>> from sympy.abc import x, y
>>> Integral(x)
Integral(x, x)
>>> Integral(y)
Integral(y, y)

When limits are provided, they are interpreted as follows (using
``x`` as though it were the variable of integration):

    (x,) or x - indefinite integral
    (x, a) - "evaluate at" integral is an abstract antiderivative
    (x, a, b) - definite integral

The ``as_dummy`` method can be used to see which symbols cannot be
targeted by subs: those with a prepended underscore cannot be
changed with ``subs``. (Also, the integration variables themselves --
the first element of a limit -- can never be changed by subs.)

>>> i = Integral(x, x)
>>> at = Integral(x, (x, x))
>>> i.as_dummy()
Integral(x, x)
>>> at.as_dummy()
Integral(_0, (_0, x))

_eval_Integralz
                integrate(Poly) and Integral(Poly) are deprecated. Instead,
                use the Poly.integrate() method, or convert the Poly to an
                Expr first with the Poly.as_expr() method.
                z1.6zdeprecated-integrate-poly)deprecated_since_versionactive_deprecations_target)hasattrr4   
isinstancer%   r+   r   __new__)clsfunctionsymbolsassumptionsobjs        Q/var/www/auris/envauris/lib/python3.13/site-packages/sympy/integrals/integrals.pyr9   Integral.__new__*   sm    T 8-..**GC{CCh%%%
 */+FH ##CKGK{K
    c           	         U R                   4[        U R                   Vs/ s H  n[        U5      PM     sn5      -   $ s  snf N)r;   tuplelimits)selfxabs     r?   __getnewargs__Integral.__getnewargs__d   s3    %t{{(K{s{(K"LLL(Ks   >
c                   > [         TU ]  $ )a  
This method returns the symbols that will exist when the
integral is evaluated. This is useful if one is trying to
determine whether an integral depends on a certain
symbol or not.

Examples
========

>>> from sympy import Integral
>>> from sympy.abc import x, y
>>> Integral(x, (x, y, 1)).free_symbols
{y}

See Also
========

sympy.concrete.expr_with_limits.ExprWithLimits.function
sympy.concrete.expr_with_limits.ExprWithLimits.limits
sympy.concrete.expr_with_limits.ExprWithLimits.variables
)superfree_symbols)rF   	__class__s    r?   rL   Integral.free_symbolsg   s    . w##rA   c                   U R                   R                  (       a  gSnU R                   HK  n[        U5      S:X  d  M  US   US   :H  =(       d    US   US   -
  R                  nU(       a    gUb  MI  SnMM     U R                   R                  nU R                   H  n[        U5      S:X  a  UR                  US   5        M(  [        U5      S:X  a1  US   U;  a(  US   R                  (       a    gUS   R                  c  SnUR                  US   5        USS   H  nUR                  UR                  5        M      M     U R                   R                  SL a  USL a  gg g )NTF   r"      r   )r;   is_zerorE   lenrL   adddiscardupdate)rF   got_nonelzfreerG   is          r?   _eval_is_zeroIntegral._eval_is_zero   s7    ==  A1v{qTQqT\;qtad{&;&;Y#H  }}));;C3x1}Q 3x1}Qt!3q6>>V^^+#H LLQ WANN+   ==  E)h%.? /@)rA   c                	  ^^^ [        S5      mUR                  R                  U R                  5      n[	        U5      S:  a  [        SU R                  -  5      eU(       a  UR                  5       OTnX@R                  ;  a  U $ [        U5      n[        U[        5      (       ac  UR                  n[	        U5      S:X  a  [        [        S5      5      e[	        U5      S:  a  [        [        S5      5      eUR                  5       nOSUu  p&XbR                  ;  a  [        [        S5      5      e[        U[        5      (       d  [        [        SU-  5      5      eUR                  (       a#  UR                  (       a  U R                  X05      $ UR                  (       d  UR                  (       d  [        S	5      eXd:X  a4  U R                  XR                  UT5      T45      R                  TU05      $ X`R                   ;   a  [        [        S
5      5      eSSKJn  UR                  (       dQ  UR                  UT5      /mU" X!-
  USS9nU(       d  [        S5      eU V	s/ s H  oR                  UT5      PM     n
n	OUR                  UT5      /n
SSKJn  U" X!-
  5      u  pUR                  UR+                  5        VVs/ s H  u  pX4PM
     snn5      nU" UU5       Vs/ s H  nUR                  U5      PM     nnU(       d  [        S5      eU V	s/ s H  oR                  UT5      PM     sn	mU
 V	s1 s H@  n	U R,                  R                  XI5      U	R/                  T5      -  R                  TU5      iMB     nn	[	        U5      S:  a  [        [        S5      5      eUR                  5       nU4S jmUU4S jn/ nU R                    H  nUS   nUU:X  a  [	        U5      S:X  aM  USS u  nnU" UU5      U" UU5      nn[1        UU-
  S:  5      (       a  UUnnU* nUR3                  UUU45        Mj  [	        U5      S:X  a!  U" US   S5      nUR3                  UU45        M  UR3                  U5        M  UR3                  U5        M     U R4                  " U/UQ76 $ s  sn	f s  snnf s  snf s  sn	f s  sn	f )ag  
Performs a change of variables from `x` to `u` using the relationship
given by `x` and `u` which will define the transformations `f` and `F`
(which are inverses of each other) as follows:

1) If `x` is a Symbol (which is a variable of integration) then `u`
   will be interpreted as some function, f(u), with inverse F(u).
   This, in effect, just makes the substitution of x with f(x).

2) If `u` is a Symbol then `x` will be interpreted as some function,
   F(x), with inverse f(u). This is commonly referred to as
   u-substitution.

Once f and F have been identified, the transformation is made as
follows:

.. math:: \int_a^b x \mathrm{d}x \rightarrow \int_{F(a)}^{F(b)} f(x)
          \frac{\mathrm{d}}{\mathrm{d}x}

where `F(x)` is the inverse of `f(x)` and the limits and integrand have
been corrected so as to retain the same value after integration.

Notes
=====

The mappings, F(x) or f(u), must lead to a unique integral. Linear
or rational linear expression, ``2*x``, ``1/x`` and ``sqrt(x)``, will
always work; quadratic expressions like ``x**2 - 1`` are acceptable
as long as the resulting integrand does not depend on the sign of
the solutions (see examples).

The integral will be returned unchanged if ``x`` is not a variable of
integration.

``x`` must be (or contain) only one of of the integration variables. If
``u`` has more than one free symbol then it should be sent as a tuple
(``u``, ``uvar``) where ``uvar`` identifies which variable is replacing
the integration variable.
XXX can it contain another integration variable?

Examples
========

>>> from sympy.abc import a, x, u
>>> from sympy import Integral, cos, sqrt

>>> i = Integral(x*cos(x**2 - 1), (x, 0, 1))

transform can change the variable of integration

>>> i.transform(x, u)
Integral(u*cos(u**2 - 1), (u, 0, 1))

transform can perform u-substitution as long as a unique
integrand is obtained:

>>> ui = i.transform(x**2 - 1, u)
>>> ui
Integral(cos(u)/2, (u, -1, 0))

This attempt fails because x = +/-sqrt(u + 1) and the
sign does not cancel out of the integrand:

>>> Integral(cos(x**2 - 1), (x, 0, 1)).transform(x**2 - 1, u)
Traceback (most recent call last):
...
ValueError:
The mapping between F(x) and f(u) did not give a unique integrand.

transform can do a substitution. Here, the previous
result is transformed back into the original expression
using "u-substitution":

>>> ui.transform(sqrt(u + 1), x) == i
True

We can accomplish the same with a regular substitution:

>>> ui.transform(u, x**2 - 1) == i
True

If the `x` does not contain a symbol of integration then
the integral will be returned unchanged. Integral `i` does
not have an integration variable `a` so no change is made:

>>> i.transform(a, x) == i
True

When `u` has more than one free symbol the symbol that is
replacing `x` must be identified by passing `u` as a tuple:

>>> Integral(x, (x, 0, 1)).transform(x, (u + a, u))
Integral(a + u, (u, -a, 1 - a))
>>> Integral(x, (x, 0, 1)).transform(x, (u + a, a))
Integral(a + u, (a, -u, 1 - u))

See Also
========

sympy.concrete.expr_with_limits.ExprWithLimits.variables : Lists the integration variables
as_dummy : Replace integration variables with dummy ones
dr"   z F(x) can only contain one of: %sr   z*
                f(u) cannot be a constantz
                When f(u) has more than one free symbol, the one replacing x
                must be identified: pass f(u) as (f(u), u)z
                Expecting a tuple (expr, symbol) where symbol identified
                a free symbol in expr, but symbol is not in expr's free
                symbols.za
                Expecting a tuple (expr, symbol) but didn't get
                a symbol; got %szeither x or u must be a symbolz{
            u must contain the same variable as in x
            or a variable that is not already an integration variable)solveF)checkz%no solution for solve(F(x) - f(u), x))posifyz%no solution for solve(F(x) - f(u), u)z[
            The mapping between F(x) and f(u) did not give
            a unique integrand.c                   > U R                  TU5      nU[        R                  L d   UR                  SL a*  UR                  (       a  [	        [        U5      U -  TU5      $ U$ )Y
replace d with a, using subs if possible, otherwise limit
where sign of b is considered
F)subsr   NaN	is_finiter(   r   )Fabwokr_   s       r?   _calc_limit_1)Integral.transform.<locals>._calc_limit_1T  sL    
 &&A,Caee|s}}5!++T!WQY1--JrA   c           
        > [        T Vs1 s H  nT" X U5      iM     sn5      n[        U5      S:  a  [        [        S5      5      eUS   $ s  snf )rd   r"   z_
                The mapping between F(x) and f(u) did not
                give a unique limit.r   )listrS   
ValueErrorr-   )ri   rj   Fiavalsrh   rl   s       r?   _calc_limit'Integral.transform.<locals>._calc_limit^  sY    
 A>Ab-q1A>?E5zA~  -( ") * * 8O ?s   ArP   NrQ   )r   rL   intersection	variablesrS   rp   popr   r8   r   r-   r   	is_Symbolxreplace	transformre   rE   sympy.solvers.solversr`   sympy.simplify.simplifyrb   itemsr;   r
   r   appendfunc)rF   xuxfreexvarufreeuvarr`   solnfifrb   pdiffrepskvpuvarsnewfuncsnewfuncrs   	newlimitsrG   symri   rj   rh   rl   r_   s                             @@@r?   rz   Integral.transform   sR   N #J++DNN;u:>2T^^CE E#uyy{~~%KAJaNNE5zQ  -- ". / /5zA~  -> "? @ @ 99;DGA>>)  - "   dF++  -$&*-+ ", - - ;;1;;==!(({{1;;=>><>>!ffT1oq%9:CCQINN;;Z )I J K K 	0{{a!AE2D !HII,01Dbq!DA1Aa!A6 -KEII$**,?,$!v,?@E*/u*=>*=QAFF4L*=D> !HII,01Dbq!D1A 34523B ]]''1"''!*<$q$-(23 	 5x=1Z )# $ % % ,,.	
	 	;;Ca&Cd{s8q=qr7DAq&q!,k!Q.?qA!!a%!),, !1#*($$dAq\2X]#CFA.A$$dAY/$$T*  %! $ yy-9--y 2
 @> 25s   "R&R+
%R1R6:AR;c                  ^ ^^0^1^2^3^4 TR                  SS5      (       d  T $ TR                  SS5      nTR                  SS5      m2TR                  SS5      m0TR                  SS5      nTR                  S	S5      nTR                  S
S5      n[        [        [        SUT2X445      5      5      S:  a  [	        S5      eU(       a  S=m2=p4O(T2(       a  S=n=p4OU(       a  S=n=m2nOU(       a  S=n=m2nT2X5UT0S.nT0S;  a  [	        ST0-  5      eU(       a,  [        S T R                   5       5      (       a  [	        S5      eT R                  (       a  [        R                  $ SSK
Jn  [        T R                  U5      (       a  [        U 4S jT R                   5       5      (       a  [	        S5      e[        S T R                  R                  S   SS  5       5      (       a  T $ T nT R                  n	U	R                  " UR                  " U	R                  /UR                  Q76 R!                  5       /U	R                  Q76 R!                  5       $ T R                  n
U
R#                  S S 5      n
U(       a  U
R                   " S.0 TD6n
U
R                  (       a  [        R                  $ [        U
[$        5      (       a  U
R'                  UU 4S j5      $ [        U
[(        5      (       af  [        T R                  5      S:  a  [*        eT R                  S   n[        U5      S:  a  U
R,                  " U40 UD6$ U
R,                  " US   40 UD6$ 0 nT R                   H  n[        U5      S:w  a  M  Uu  m4pX4n[/        S U 5       5      (       a  T4R0                  (       d
  [3        SS9nOf[/        S U 5       5      (       a  T4R4                  (       d
  [3        SS9nO4[/        S  U 5       5      (       a  T4R6                  (       d
  [3        SS!9nOSnU(       d  M  UUT4'   M     U(       a  UR9                  5        VVs0 s H	  u  nnUU_M     nnnT R;                  U5      R                   " S.0 TD6n[        U[<        5      (       a-  [=        U Vs/ s H  nUR;                  U5      PM     sn5      nU$ UR;                  U5      nU$ / n[?        5       nT R                   GH  n[        U5      S:X  a  [?        USS 5      m3OY[        U5      S":X  a  US   R@                  m3O:[        U5      S:X  a+  US   R@                  RC                  US"   R@                  5      m3US   U;   d  [        U34S# jU 5       5      (       a_  URE                  U5        URG                  T35        T R                  " U
/U/-   6 n
U
RI                  5       n[        U[J        5      (       d  Un
M  U
RM                  [N        [P        5      (       a  [        U5      S:  a  [/        S$ U 5       5      (       d)  [        U5      S:X  ab  [/        S% USS  5       5      (       aH  [3        S&SS!9nU
R;                  US   U05      RS                  [T        5      R;                  UUS   05      n
O4U
RM                  [V        [X        5      (       a  U
RS                  [T        5      n
U
RM                  [T        5      (       a   [        U
[T        5      (       d  [[        U
5      n
[        U
[T        5      (       a>  [        U5      S:X  a  U
R\                  " US   40 UD6nGOT R\                  " XS   40 UD6nOU0U2U 4S' jnT2nT2SLa  [        U5      S:X  a  US   R^                  (       a}  US"   R^                  (       ai  U
R`                  (       dX  US   RM                  [b        [b        * 5      (       d#  US"   RM                  [b        [b        * 5      (       a  U" X5      nUb  Un
GM!  SnUSL a  T2SL a  SnO.T R\                  " XS   40 UD6nUc  T2SL a  U" X5      nUb  Un
GM^  TR                  S(S5      nU(       Ga  [        U[J        5      (       Gd  UGb  URe                  [f        5       GHq  nURh                  S   n U Re                  [j        5       H  n![3        S)5      n"U Rm                  U!U"5      n#U#Ro                  U"5      n$U"U$R@                  ;  d  MC  U!Rh                  S   nURm                  U[q        U[Q        U$5      [r        -  [u        U[r        S"-  -
  [r        -  5      -  5      5      nM     U Re                  [v        5       H  n%[3        S)5      n"U Rm                  U%U"5      n&U&Ro                  U"5      n$U"U$R@                  ;  d  MC  U%Rh                  S   nURm                  U[q        U[Q        U$5      [r        -  [u        U[r        -  5      -  5      5      nM     GMt     Uc]  URE                  U5        T R                  " U
/U/-   6 RI                  5       n
U
RI                  5       n[        U[J        5      (       d  Un
GM}  [        U5      S:X  a  Un
GM  [        U5      S:X  a  Uu  m4pO[        U5      S":X  a  Uu  m4nSnO[*        eU(       aN  [        U[x        5      (       a  UR                   " S.0 TD6n[        U[x        5      (       a  UR                   " S.0 TD6nUR`                  (       aW  [        URz                  5      n'U'R}                  T45        UR                  5       nUR                  T4X5      n
[        U
/U'Q76 n
GM  S* m1U14S+ jn(/ / / n+n*n)[p        R                  " U5       H  n,[        U1U44S, j[        R                  " U,5       5       5      (       a  U)RE                  U,5        ME  [        S- [        R                  " U,5       5       5      (       a  U+RE                  [[        U,5      5        M  U*RE                  U,5        M     [q        U) V,s/ s H  n,U(" U,T4X5      PM     sn,6 n- [q        U*6 R                  T4X5      n.[[        [q        U+6 5      R                  T4X5      n/U-U.-   U/-   n
GM     U
$ s  snnf s  snf s  sn,f ! [*         aU    URE                  U5        T R                  " U
/U/-   6 n
U
RI                  5       n[        U[J        5      (       d  Un
 GM   GM  f = f)/a  
Perform the integration using any hints given.

Examples
========

>>> from sympy import Piecewise, S
>>> from sympy.abc import x, t
>>> p = x**2 + Piecewise((0, x/t < 0), (1, True))
>>> p.integrate((t, S(4)/5, 1), (x, -1, 1))
1/3

See Also
========

sympy.integrals.trigonometry.trigintegrate
sympy.integrals.heurisch.heurisch
sympy.integrals.rationaltools.ratint
as_sum : Approximate the integral using a sum
	integralsTdeepmeijergNconds	piecewiserischheurischmanualr"   z;At most one of manual, meijerg, risch, heurisch can be TrueFr   r   r   r   r   )separater   nonez=conds must be one of "separate", "piecewise", "none", got: %sc              3  >   #    U  H  n[        U5      S :  v   M     g7f)r"   N)rS   ).0rG   s     r?   	<genexpr> Integral.doit.<locals>.<genexpr>  s     =#SAs   z4risch=True is only allowed for indefinite integrals.r   Sumc              3  Z   >#    U  H   oTR                   R                  S    ;   v   M"     g7fr   N)r;   rE   )r   r   rF   s     r?   r   r     s#     HA,,Q//s   (+z3Limit of the sum cannot be an integration variable.c              3  8   #    U  H  oR                   v   M     g 7frC   )is_infinite)r   rX   s     r?   r   r     s     F*EQ==*E   c                Z    [        U [        5      =(       a    U R                  S   S-  S:g  $ )Nr"   rQ   )r8   r!   r2   r   s    r?   <lambda>Integral.doit.<locals>.<lambda>  s$    jI.C166!9Q;!3CCrA   c                2    [        U R                  S   5      $ Nr   )r!   r2   r   s    r?   r   r     s    iq	*rA   c                ^   > TR                   " U /TR                  Q76 R                  " S0 TD6$ )Nr1   )r   rE   doit)r   hintsrF   s    r?   r   r     s%    $))A4499BEBrA   rP   c              3  8   #    U  H  oR                   v   M     g 7frC   )is_nonnegativer   r[   s     r?   r   r     s     /Q##Qr   )positivec              3  8   #    U  H  oR                   v   M     g 7frC   )is_nonpositiver   s     r?   r   r     s     1q!%%qr   )negativec              3  8   #    U  H  oR                   v   M     g 7frC   )is_realr   s     r?   r   r     s     *1YYr   )realrQ   c              3  2   >#    U  H  oS    T;   v   M     g7fr   r1   )r   r   ulis     r?   r   r     s     #GAaDCKs   c              3  8   #    U  H  oR                   v   M     g 7frC   )is_extended_realr   r   s     r?   r   r     s     %F#Q&8&8#r   c              3  j   #    U  H)  nUR                   =(       a    UR                  (       + v   M+     g 7frC   )r   r   r   s     r?   r   r     s,      ' ()'9'9'O!-->O'Os   13xrc                b  > S n[        U5      S:X  a  TSLaz  Uu  p4n [        XXE5      nUbe  Uu  pxT
S:X  a!  TR	                  XXE45      n	[        Xx4U	S4SS9$ T
S:X  a2  [        TR                  5      S:w  a  [        [        S	5      5      eXx4nU$ UnU$ ! [         a    [        S5        S n Nf = f)
NrP   F+NotImplementedError from meijerint_definiter   T)evaluater   r"   z
                                        conds=separate not supported in
                                        multiple integrals)	rS   meijerint_definiteNotImplementedError_debugr   r   rE   rp   r-   )r;   rG   retr   ri   rj   resr   condr   r   r   rF   s             r?   try_meijerg"Integral.doit.<locals>.try_meijerg8  s    C3x1})="%a'"4X!"GC
 ?&)GA$3$(IIhA	$B
 (1!QI-2(4 !4!&*!4#&t{{#3q#8*4Z A> 6? +@ %@ '(g J '(J-  3 '" $: ;"&C's   B B.-B.finalx1c                p   ^ [        U [        5      =(       a    [        U4S jU R                   5       5      $ )Nc              3  .   >#    U  H
  oT4:H  v   M     g 7frC   r1   )r   r[   r   s     r?   r   6Integral.doit.<locals>.is_indef_int.<locals>.<genexpr>  s     'D8aaT	8s   )r8   r/   anyrE   )gr   s    `r?   is_indef_int#Integral.doit.<locals>.is_indef_int  s+    $.q($; %E$''D188'D$DFrA   c                   > / n[         R                  " U 5       HD  nT" XQ5      (       a#  UR                  UR                  XU5      5        M3  UR                  U5        MF     [        U6 $ rC   )r   	make_argsr~   _eval_interval)r   r   ri   rj   r2   r   r   s         r?   eval_factored$Integral.doit.<locals>.eval_factored  sX     $&D%(]]1%5#/#5#5$(KK0@0@q0I$J$(KKN	 &6
 $':-rA   c              3  6   >#    U  H  nT" UT5      v   M     g 7frC   r1   )r   r   r   r   s     r?   r   r     s"      #>,<q $01#5#5,<s   c              3  B   #    U  H  n[        U[        5      v   M     g 7frC   )r8   r   )r   r   s     r?   r   r     s"      %@.> &09%=%=.>s   r1   )DgetrS   ro   filterrp   r   rE   rR   r   Zerosympy.concrete.summationsr   r8   r;   rv   r   r   replacer$   	applyfuncr'   r   	integrateallr   r   r   r   r}   ry   rD   setrL   unionr~   rV   factorr/   hasr   r   rewriter   r   r    r   _eval_integralr   is_Polyr   atomsr   r2   r   re   r
   r   r   r   r   r   gensremoveas_exprr   r%   r   r   )5rF   r   r   r   r   r   eval_kwargsr   _i_sumr;   rG   r   ri   rj   rX   r_   r   r   undodidr[   undone_limitsuljfactored_functionr   	antiderivr   meijerg1r   r   	atan_termatan_argtan_partr   tan_exp1coeffcot_partcot_exp1r   r   r   others
piecewisesr   unevalevalued
evalued_pwr   r   r   r   r   s5   ``                                              @@@@@r?   r   Integral.doit  sX   * yyd++Kyy&))It,		';/		'4(99Z.8T*tF4&'5!CDEFJZ[[)..G.eh(--F-UX*//F/Wx',,F,Wu")EYa 99 /167 8 8 S====STT <<66M 	2dmmS))HHHH !VWWF$--*>*>q*A!"*EFFFB==D99RWWT]]?RYY?DDFUUZZ\\ == ##C*, }}-u-H66M h
++%%BD D h 1224;;!#))++a.C3x!|))#===))#a&@K@@ ;;C3x1} GAqA/Q///8H8H4(1q111!:J:J4(****199t$qQ+ , %)ZZ\2\TQAqD\D2--%**3U3C#u%%s;s!QZZ-s;< J ll4(J e;;C 3x1}#bq'lSQ!f))SQ!f))//A0C0CD
 1v}#G#G G G$$S)

399zSE'9;$,OO$5!!"3X>>0H||C&&SA#%F#%F"F"FSQ3 '!"g' $ $ t$/B ( 1 13q62, ? +HHb#a&\,B c3''#++I6Y''x33-h7H(I..s8q= ( 7 7A !'%!'I !% 3 3 a&!9,7!9I< #5(CA#a&*A*Ac!fF]F] ( 0 0QB,,A

2s0C0C%h4C#& $H u$D $I $ 3 3 a&!9,7!9I (W_)(8?'*H$IIgt,E jH==%!*!6I(~~a0H$,NN3$7"4[#+==2#> (b 1U%7%77 (a 0A(1y#i $UBua1fb[/A ACC )DI %8 %-NN3$7"4[#+==2#> (b 1U%7%77 (a 0A(1y#i $UBuaV} <C> )?I %8 "7,  $$S)99zSE'9;BBD$,OO$5!!"3X>>0Hs8q=(H3x1}"%1aSQ"1 11%a// !A%a// !A ((#INN3A$-$5$5$7	#,#;#;Aq#D#'#84#8F
. 9;B:6	!$y!9A" #>,/MM!,<#>  >  > ) 0 0 3!$ %@.1mmA.>%@ "@ "@ * 1 1.2C D &a 0 ": "%09';091 (5Q1'@09'; "<=&)6l&A&A!Q&JG)7Z8H)I)X)XYZ\])aJ'-'7*'DHU f  3 <\';  3 = *005'+yyH:3E'GH080A-#-.?#J#J+< $K=s&   >rr.r
ArAs>=s>c                n  ^ ^^ T R                   [        T R                  5      p2UR                  S5      n[	        U5      S:X  a  Uu  mpVO[	        U5      S:X  a  Uu  mnSnOS=pVUS   mU(       a  T R
                  " U/[        U5      Q76 nU UU4S jn[        R                  nUb
  X" X&5      -  nUb
  X" X%5      -  n[	        U5      S:X  a  TT:X  a  Un	X-  nU$ [        S5      n
UR                  TU
5      R                  T5      R                  U
T5      n	U	(       a  UT R                  U	TXV45      -  nU$ )	a  Evaluate the derivative of the current Integral object by
differentiating under the integral sign [1], using the Fundamental
Theorem of Calculus [2] when possible.

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

Whenever an Integral is encountered that is equivalent to zero or
has an integrand that is independent of the variable of integration
those integrals are performed. All others are returned as Integral
instances which can be resolved with doit() (provided they are integrable).

References
==========

.. [1] https://en.wikipedia.org/wiki/Differentiation_under_the_integral_sign
.. [2] https://en.wikipedia.org/wiki/Fundamental_theorem_of_calculus

Examples
========

>>> from sympy import Integral
>>> from sympy.abc import x, y
>>> i = Integral(x + y, y, (y, 1, x))
>>> i.diff(x)
Integral(x + y, (y, x)) + Integral(1, y, (y, 1, x))
>>> i.doit().diff(x) == i.diff(x).doit()
True
>>> i.diff(y)
0

The previous must be true since there is no y in the evaluated integral:

>>> i.free_symbols
{x}
>>> i.doit()
2*x**3/3 - x/2 - 1/6

rP   rQ   Nr   c                R  > [        UT5      nU(       d  [        R                  $ [        U [        5      (       aU  U R
                   Vs/ s H!  n[        U5      S:X  a  US   T:X  a  TT4OUPM#     nnTR                  " U R                  /UQ76 n U R                  TU5      U-  $ s  snf Nr"   r   )
r
   r   r   r8   r/   rE   rS   r   r;   re   )r   abdab_dsymrX   rE   rF   r   r   s        r?   _do&Integral._eval_derivative.<locals>._do  s    B}Hvv!X&&#$88-#+a &)Vq[QqTQY1a&QF#+  -IIajj26266!R=))-s   (B$r"   r   )r;   ro   rE   rw   rS   r   rD   r   r   r   re   r
   )rF   r   r   rE   r(   ri   rj   r  rvargr   r   s   ``         @r?   _eval_derivativeIntegral._eval_derivative  s-   Z MM4#46 

2u:?GAq!Z1_DAqALAaA		!,eFm,A	* VV=#a)OB=#a)OBu:?saxCIB 		 c
A&&A,##C(--a3CdiiaY//	rA   c	                   SSK Jn	Jn
  SSKJn  U(       a   U	" XUS9$ U(       a"   U" X5      nUb  UR                  [        :w  a  U$ X4UXgS.n[        U[        5      (       a&  U(       d  U(       d  U(       d  UR                  U5      $ [        U[        5      (       a  UR                  " U40 UD6$ UR                  U5      (       d  X-  $ UR!                  U5      nUb3  U(       d,  U(       d%  U(       d  UR                  5       R#                  5       $ USLa@   U	" XSUS	9u  pU(       a,  US:X  a  U
" X5      R%                  SS
9$ XR%                  SS
9-   $ U$ SSKJn  / n[*        R,                  " U5      nU GH  nUR/                  U5      u  nnU[0        R2                  L a  U(       d  UR5                  UU-  5        MH  UR7                  5       nUb~  U R8                  " UR;                  5       U40 UD6nUbW  U R8                  " UR<                  U40 UD6nUb6  UR                  " U/UR>                  Q76 nUR5                  UUU-   -  5        M    gUR@                  (       Ga>  URB                  R                  U5      (       Gd  U(       Gd  [E        SU/S9n[E        SU/S9nURF                  RI                  UU-  U-   5      nUb  URB                  S:X  a  [K        URF                  5      nOUS:w  a-  URF                  URB                  S-   -  URB                  S-   -  nOe[K        URF                  5      nURF                  URB                  S-   -  URB                  S-   -  n[        U[M        URB                  S5      4US45      nUR5                  UU-  UU   -  5        GM)  URO                  U5      (       a6  U(       d/  U(       d(  U(       d!  UR5                  U[Q        UU5      -  5        GMu  U(       d  U(       d  U(       d  [S        UX'S9nUb  UR5                  UU-  5        GM  [U        UU5      nUb  UR5                  UU-  5        GM  SSK+J,n  U" UU5      nUb  UR5                  UU-  5        GM  USLa=   U	" UUSUS	9u  nnU(       a  UUR%                  SS
9-   nUR5                  UU-  5        GM?  USLa!  SSK-J.nJ/n    US:X  a	  U " UU/ S9nOU" UU/ S9nOOSnUSLa*  Uc'   [a        UU5      nUb  UR5                  UU-  5        GM  Uc  USLa   U" UU5      nUb  [        U[        5      (       d  UR                  [        5      (       ay  U(       dr  Un!SU!S'   SU!S'   UR                  " URd                   V"s/ s H1  n"U"R                  [        5      (       a  U"R$                  " S0 U!D6OU"PM3     sn"6 Rg                  SSSSS9nUR                  [        5      (       d  UR5                  UU-  5        GM  U(       dK  [i        U5      S:X  a<  U" U5      Rg                  SSS9nURj                  (       a  U R8                  " X40 UD6s  $ Ub  UR5                  UU-  5        GM    g   [+        U6 $ ! [
         a     gf = f! [        [        4 a     GNOf = f! [
         a     GNQf = f! [
         a    Sn GNf = f! [         a    Sn GNf = f! [
         a    [c        S5         GNf = fs  sn"f ! [        [        4 a     GN
f = f)a  
Calculate the anti-derivative to the function f(x).

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

The following algorithms are applied (roughly in this order):

1. Simple heuristics (based on pattern matching and integral table):

   - most frequently used functions (e.g. polynomials, products of
     trig functions)

2. Integration of rational functions:

   - A complete algorithm for integrating rational functions is
     implemented (the Lazard-Rioboo-Trager algorithm).  The algorithm
     also uses the partial fraction decomposition algorithm
     implemented in apart() as a preprocessor to make this process
     faster.  Note that the integral of a rational function is always
     elementary, but in general, it may include a RootSum.

3. Full Risch algorithm:

   - The Risch algorithm is a complete decision
     procedure for integrating elementary functions, which means that
     given any elementary function, it will either compute an
     elementary antiderivative, or else prove that none exists.
     Currently, part of transcendental case is implemented, meaning
     elementary integrals containing exponentials, logarithms, and
     (soon!) trigonometric functions can be computed.  The algebraic
     case, e.g., functions containing roots, is much more difficult
     and is not implemented yet.

   - If the routine fails (because the integrand is not elementary, or
     because a case is not implemented yet), it continues on to the
     next algorithms below.  If the routine proves that the integrals
     is nonelementary, it still moves on to the algorithms below,
     because we might be able to find a closed-form solution in terms
     of special functions.  If risch=True, however, it will stop here.

4. The Meijer G-Function algorithm:

   - This algorithm works by first rewriting the integrand in terms of
     very general Meijer G-Function (meijerg in SymPy), integrating
     it, and then rewriting the result back, if possible.  This
     algorithm is particularly powerful for definite integrals (which
     is actually part of a different method of Integral), since it can
     compute closed-form solutions of definite integrals even when no
     closed-form indefinite integral exists.  But it also is capable
     of computing many indefinite integrals as well.

   - Another advantage of this method is that it can use some results
     about the Meijer G-Function to give a result in terms of a
     Piecewise expression, which allows to express conditionally
     convergent integrals.

   - Setting meijerg=True will cause integrate() to use only this
     method.

5. The "manual integration" algorithm:

   - This algorithm tries to mimic how a person would find an
     antiderivative by hand, for example by looking for a
     substitution or applying integration by parts. This algorithm
     does not handle as many integrands but can return results in a
     more familiar form.

   - Sometimes this algorithm can evaluate parts of an integral; in
     this case integrate() will try to evaluate the rest of the
     integrand using the other methods here.

   - Setting manual=True will cause integrate() to use only this
     method.

6. The Heuristic Risch algorithm:

   - This is a heuristic version of the Risch algorithm, meaning that
     it is not deterministic.  This is tried as a last resort because
     it can be very slow.  It is still used because not enough of the
     full Risch algorithm is implemented, so that there are still some
     integrals that can only be computed using this method.  The goal
     is to implement enough of the Risch and Meijer G-function methods
     so that this can be deleted.

     Setting heurisch=True will cause integrate() to use only this
     method. Set heurisch=False to not use it.

r   )risch_integrateNonElementaryIntegral)manualintegrate)r   Nr   FT)separate_integralr   )r   )sincos_to_sumri   )excluderj   r  r   r"   )singularityintegrate)r   heurisch_wrapper)r   r   r   r   )multinomialr   	power_exp
power_base)mulr   r1   )6sympy.integrals.rischr  r  sympy.integrals.manualintegrater  r   r   r/   rp   r&   r8   r%   r   r   piecewise_integrater   as_polyr   r   sympy.simplify.fur  r   r   as_independentr   Oner~   getOr   removeOexprrv   is_Powexpr   basematchr   r   is_rational_functionr#   trigintegratedeltaintegratesingularityfunctionsr  sympy.integrals.heurischr   r  meijerint_indefiniter   r2   expandrS   is_Add)#rF   r   r   r   r   r   r   r   r   r  r  r  resultr   polyr[   r  partsr2   r   r  
order_termhh_order_exprh_order_termri   rj   Mh1h2r  	heurisch_r  new_eval_kwargsr  s#                                      r?   r   Integral._eval_integral7  s   x 	QC&q599 (.%&++*A!M #*V 2 a'U ;;q>! a##((:k:: uuQxx3J yy|Vw%>>#++--"+AD!	
  {4Q:??e?LL%U(;;;!M 	4}}QA''*HE1 AEEz'U1W% J%''		QF+F=#'#6#6z#Y[#YL#/'1((A+5+?+?(AUA,<%=> 
  xxx		!Wqc*qc*FFLL1q)=uu{K+-FFQUUQY/15519= [VVaeeai0AEEAI>%r2aeeR=&9B:FLLQqT!12
 %%a((&GuUVAq\12g!!Q4=LL+ #1a(=LL+F(A.=LL+ %
!.q!.2% A1
  !AFFF$7 7AU1W-  5(L	! K/ 0AR @A )!Qb 9A ) e#	J,Q2A =LL+yV50,Q2F)*VX2N2N!::h// /:O8=OH57<OG4%+[[ ,2;;3 ,7C !$ 1 1 !$ ;? ;7:!;+63 &  &v%*/0516  &  8	 #  &zz(33!LL8$  Ta!!$++5+A88  ..qC{CC}UQY'O R E{g '  0 F ' ` / ! !$ + ! !	! + JHIJ&3 #O4 s   Y3  Z 
Z 9Z+Z>Z>'[A([2>8[-
6A[23
Z ?Z ZZ
Z('Z(+Z;:Z;>[[[*)[*-[22\\c              #     #    U R                  5       nUnUR                   H  nXSS  ;   d  M  US   n  O   UR                  R                  XR5       H  n[	        U/UR                  Q76 v   M     g 7fr  )as_dummyrE   r;   lseriesr   )rF   r   logxcdirr,  symbrX   terms           r?   _eval_lseriesIntegral._eval_lseries  si     }}AabEzt  MM))$5DD/4;;// 6s   (A2AA2c                6   UnU R                    H  nXSS  ;   d  M  US   n  O   U R                  R                  XRUS9R                  [        5      u  pxU V	s/ s H  oR                  XQ5      PM     nn	[        U/U R                   Q76 [        U6 U-  -   $ s  sn	f )Nr"   r   )r   nrI  )rE   r;   nseriesas_coeff_addr)   re   r   r   )
rF   r   rP  rI  rJ  rK  rX   termsorderos
             r?   _eval_nseriesIntegral._eval_nseries  s    AabEzt  }},,d - $$0L$7 	*/0%Q%0--UA== 1s   Bc                    U R                   S   R                  U5      nU H  nUS:w  d  M    O   [        W/U R                   SS  Q76 $ )Nr   r"   )r2   rH  r   )rF   r   rI  rJ  
series_genleading_terms         r?   _eval_as_leading_termIntegral._eval_as_leading_term  sK    YYq\))!,
&Lq  ' 6		!"66rA   c           
         [        U 5      n[        U[        5      (       a6  SSKJn  UR
                  " UR                   Vs/ s H  oC" U40 UD6PM     sn6 $ UR                  " S0 UD6$ s  snf )Nr   )simplifyr1   )r	   r8   r/   r|   r^  r   r2   )rF   kwargsr,  r^  r[   s        r?   _eval_simplifyIntegral._eval_simplify  s`    D!dH%%899diiHix4V4iHII}}&v&& Is   A)c           
        SSK Jn  U R                  n[        U5      S:  a  [	        S5      eUS   n[        U5      S:w  d$  US   R
                  SL d  US   R
                  SL a  [        S5      eUc  [        S	S
S
S9nO[        U5      nUR                  SL d  UR                  SL d  UR
                  SL a  [        SU-  5      eUu  pxn	X-
  U-  n
[        SS
S
S9nU R                  nUS:X  a'  X" UR                  XxUS-
  U
-  -   5      USU45      -  nOUS:X  a#  X" UR                  XxX-  -   5      USU45      -  nOUS:X  a)  X" UR                  XxX-  -   U
S-  -
  5      USU45      -  nOaUS:X  aM  XR                  Xx5      UR                  Xy5      -   S-  U" UR                  XxX-  -   5      USUS-
  45      -   -  nO[        SU-  5      eU(       a  UR                  5       $ U$ )a  
Approximates a definite integral by a sum.

Parameters
==========

n :
    The number of subintervals to use, optional.
method :
    One of: 'left', 'right', 'midpoint', 'trapezoid'.
evaluate : bool
    If False, returns an unevaluated Sum expression. The default
    is True, evaluate the sum.

Notes
=====

These methods of approximate integration are described in [1].

Examples
========

>>> from sympy import Integral, sin, sqrt
>>> from sympy.abc import x, n
>>> e = Integral(sin(x), (x, 3, 7))
>>> e
Integral(sin(x), (x, 3, 7))

For demonstration purposes, this interval will only be split into 2
regions, bounded by [3, 5] and [5, 7].

The left-hand rule uses function evaluations at the left of each
interval:

>>> e.as_sum(2, 'left')
2*sin(5) + 2*sin(3)

The midpoint rule uses evaluations at the center of each interval:

>>> e.as_sum(2, 'midpoint')
2*sin(4) + 2*sin(6)

The right-hand rule uses function evaluations at the right of each
interval:

>>> e.as_sum(2, 'right')
2*sin(5) + 2*sin(7)

The trapezoid rule uses function evaluations on both sides of the
intervals. This is equivalent to taking the average of the left and
right hand rule results:

>>> s = e.as_sum(2, 'trapezoid')
>>> s
2*sin(5) + sin(3) + sin(7)
>>> (e.as_sum(2, 'left') + e.as_sum(2, 'right'))/2 == s
True

Here, the discontinuity at x = 0 can be avoided by using the
midpoint or right-hand method:

>>> e = Integral(1/sqrt(x), (x, 0, 1))
>>> e.as_sum(5).n(4)
1.730
>>> e.as_sum(10).n(4)
1.809
>>> e.doit().n(4)  # the actual value is 2
2.000

The left- or trapezoid method will encounter the discontinuity and
return infinity:

>>> e.as_sum(5, 'left')
zoo

The number of intervals can be symbolic. If omitted, a dummy symbol
will be used for it.

>>> e = Integral(x**2, (x, 0, 2))
>>> e.as_sum(n, 'right').expand()
8/3 + 4/n + 4/(3*n**2)

This shows that the midpoint rule is more accurate, as its error
term decays as the square of n:

>>> e.as_sum(method='midpoint').expand()
8/3 - 2/(3*_n**2)

A symbolic sum is returned with evaluate=False:

>>> e.as_sum(n, 'midpoint', evaluate=False)
2*Sum((2*_k/n - 1/n)**2, (_k, 1, n))/n

See Also
========

Integral.doit : Perform the integration using any hints

References
==========

.. [1] https://en.wikipedia.org/wiki/Riemann_sum#Riemann_summation_methods
r   r   r"   z2Multidimensional midpoint rule not implemented yetrP   FrQ   z5Expecting a definite integral over a finite interval.rP  T)integerr   z$n must be a positive integer, got %sr   leftrightmidpoint	trapezoidzUnknown method %s)r   r   rE   rS   r   rg   rp   r   r   is_positive
is_integerr;   re   r   )rF   rP  methodr   r   rE   r(   r   ri   rj   dxr   r   r9  s                 r?   as_sumIntegral.as_sum  s   R 	2v;?%DF F 1IEE
a58#5#5#>a""e+  "7 8 89c4$7A
AMMU"alle&;KK5 CaGHHaeQY#td3MMVAFF11Q3(l3aAY??FwAFF1!$h/!Q;;Fz!AFF1!$hAo6Aq	BBF{"&&,5q8AFF1!$h'!QA78 9F 069:: (v{{}4f4rA   c           
        [        U R                  5      S:w  d%  [        [        U R                  S   5      5      S:w  a  [        S5      eU R                  S   u  p#nUR                  (       a  UR                  (       a  X4::  d  [        S5      eX4:X  a  [
        R                  $ SSKJn  [        S5      nU R                  nU" Xr5       Vs/ s H)  oR                  (       d  M  X8s=::  a  U::  d  M#  O  M'  UPM+     n	nU	 H  n
XU4;   d  M  [        SU
-  5      e   [        Xr40 UD6nUR                  [        5      (       a  U $ U[        * L a-  U[        L a$  [        XR!                  X"* 5      -
  U[        5      nO[        XUS	5      [        XUS
5      -
  nU	 H;  nU[        UR!                  X(U-
  5      UR!                  X(U-   5      -
  USS
5      -  nM=     U$ s  snf )a  
Compute the Cauchy Principal Value of the definite integral of a real function in the given interval
on the real axis.

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

In mathematics, the Cauchy principal value, is a method for assigning values to certain improper
integrals which would otherwise be undefined.

Examples
========

>>> from sympy import Integral, oo
>>> from sympy.abc import x
>>> Integral(x+1, (x, -oo, oo)).principal_value()
oo
>>> f = 1 / (x**3)
>>> Integral(f, (x, -oo, oo)).principal_value()
0
>>> Integral(f, (x, -10, 10)).principal_value()
0
>>> Integral(f, (x, -10, oo)).principal_value() + Integral(f, (x, -oo, 10)).principal_value()
0

References
==========

.. [1] https://en.wikipedia.org/wiki/Cauchy_principal_value
.. [2] https://mathworld.wolfram.com/CauchyPrincipalValue.html
r"   r   rP   zkYou need to insert a variable, lower_limit, and upper_limit correctly to calculate cauchy's principal valuezThe lower_limit must be smaller than or equal to the upper_limit to calculate cauchy's principal value. Also, a and b need to be comparable.)singularitiesrzRThe principal value is not defined in the given interval due to singularity at %d.-+)rS   rE   ro   rp   is_comparabler   r   sympy.calculus.singularitiesro  r   r;   r   r   r/   r   r(   re   )rF   r_  r   ri   rj   ro  rp  r   r   singularities_listr[   rh   Is                r?   principal_valueIntegral.principal_value>  s   @ t{{q CT[[^(<$=$B 8 9 9++a.aAOO ^ _ _666M>#JMM)6q)<`)<AaTUT_^_T_aT_a)<`#AF{ hlmnp p $ a%f%55??K8Ra&&B-'B/AaAs#eA!S&99A#Aq5)QVVA1u-==1cJJA $ as   
G"
G0G4G)returnr/   )NNNNr   Nr   )Nrf  T)__name__
__module____qualname____firstlineno____doc__	__slots____annotations__r9   rH   propertyrL   r\   rz   r   r  r   rM  rV  r[  r`  rl  rw  __static_attributes____classcell__)rM   s   @r?   r/   r/   #   s    *I
8tM $ $0!FZ.xYv
[z EI>BUn
0	>7'K5Z< <rA   r/   Nr   )r   r   r   r   r   c                &   SU UUUUS.n[        U0 UD6n[        U[         5      (       a  UR                  " S0 UD6$ UR                   V	s/ s H,  n	[        U	[         5      (       a  U	R                  " S0 UD6OU	PM.     n
n	UR                  " U
6 $ s  sn	f )a  integrate(f, var, ...)

.. deprecated:: 1.6

   Using ``integrate()`` with :class:`~.Poly` is deprecated. Use
   :meth:`.Poly.integrate` instead. See :ref:`deprecated-integrate-poly`.

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

Compute definite or indefinite integral of one or more variables
using Risch-Norman algorithm and table lookup. This procedure is
able to handle elementary algebraic and transcendental functions
and also a huge class of special functions, including Airy,
Bessel, Whittaker and Lambert.

var can be:

- a symbol                   -- indefinite integration
- a tuple (symbol, a)        -- indefinite integration with result
                                given with ``a`` replacing ``symbol``
- a tuple (symbol, a, b)     -- definite integration

Several variables can be specified, in which case the result is
multiple integration. (If var is omitted and the integrand is
univariate, the indefinite integral in that variable will be performed.)

Indefinite integrals are returned without terms that are independent
of the integration variables. (see examples)

Definite improper integrals often entail delicate convergence
conditions. Pass conds='piecewise', 'separate' or 'none' to have
these returned, respectively, as a Piecewise function, as a separate
result (i.e. result will be a tuple), or not at all (default is
'piecewise').

**Strategy**

SymPy uses various approaches to definite integration. One method is to
find an antiderivative for the integrand, and then use the fundamental
theorem of calculus. Various functions are implemented to integrate
polynomial, rational and trigonometric functions, and integrands
containing DiracDelta terms.

SymPy also implements the part of the Risch algorithm, which is a decision
procedure for integrating elementary functions, i.e., the algorithm can
either find an elementary antiderivative, or prove that one does not
exist.  There is also a (very successful, albeit somewhat slow) general
implementation of the heuristic Risch algorithm.  This algorithm will
eventually be phased out as more of the full Risch algorithm is
implemented. See the docstring of Integral._eval_integral() for more
details on computing the antiderivative using algebraic methods.

The option risch=True can be used to use only the (full) Risch algorithm.
This is useful if you want to know if an elementary function has an
elementary antiderivative.  If the indefinite Integral returned by this
function is an instance of NonElementaryIntegral, that means that the
Risch algorithm has proven that integral to be non-elementary.  Note that
by default, additional methods (such as the Meijer G method outlined
below) are tried on these integrals, as they may be expressible in terms
of special functions, so if you only care about elementary answers, use
risch=True.  Also note that an unevaluated Integral returned by this
function is not necessarily a NonElementaryIntegral, even with risch=True,
as it may just be an indication that the particular part of the Risch
algorithm needed to integrate that function is not yet implemented.

Another family of strategies comes from re-writing the integrand in
terms of so-called Meijer G-functions. Indefinite integrals of a
single G-function can always be computed, and the definite integral
of a product of two G-functions can be computed from zero to
infinity. Various strategies are implemented to rewrite integrands
as G-functions, and use this information to compute integrals (see
the ``meijerint`` module).

The option manual=True can be used to use only an algorithm that tries
to mimic integration by hand. This algorithm does not handle as many
integrands as the other algorithms implemented but may return results in
a more familiar form. The ``manualintegrate`` module has functions that
return the steps used (see the module docstring for more information).

In general, the algebraic methods work best for computing
antiderivatives of (possibly complicated) combinations of elementary
functions. The G-function methods work best for computing definite
integrals from zero to infinity of moderately complicated
combinations of special functions, or indefinite integrals of very
simple combinations of special functions.

The strategy employed by the integration code is as follows:

- If computing a definite integral, and both limits are real,
  and at least one limit is +- oo, try the G-function method of
  definite integration first.

- Try to find an antiderivative, using all available methods, ordered
  by performance (that is try fastest method first, slowest last; in
  particular polynomial integration is tried first, Meijer
  G-functions second to last, and heuristic Risch last).

- If still not successful, try G-functions irrespective of the
  limits.

The option meijerg=True, False, None can be used to, respectively:
always use G-function methods and no others, never use G-function
methods, or use all available methods (in order as described above).
It defaults to None.

Examples
========

>>> from sympy import integrate, log, exp, oo
>>> from sympy.abc import a, x, y

>>> integrate(x*y, x)
x**2*y/2

>>> integrate(log(x), x)
x*log(x) - x

>>> integrate(log(x), (x, 1, a))
a*log(a) - a + 1

>>> integrate(x)
x**2/2

Terms that are independent of x are dropped by indefinite integration:

>>> from sympy import sqrt
>>> integrate(sqrt(1 + x), (x, 0, x))
2*(x + 1)**(3/2)/3 - 2/3
>>> integrate(sqrt(1 + x), x)
2*(x + 1)**(3/2)/3

>>> integrate(x*y)
Traceback (most recent call last):
...
ValueError: specify integration variables to integrate x*y

Note that ``integrate(x)`` syntax is meant only for convenience
in interactive sessions and should be avoided in library code.

>>> integrate(x**a*exp(-x), (x, 0, oo)) # same as conds='piecewise'
Piecewise((gamma(a + 1), re(a) > -1),
    (Integral(x**a*exp(-x), (x, 0, oo)), True))

>>> integrate(x**a*exp(-x), (x, 0, oo), conds='none')
gamma(a + 1)

>>> integrate(x**a*exp(-x), (x, 0, oo), conds='separate')
(gamma(a + 1), re(a) > -1)

See Also
========

Integral, Integral.doit

F)r   r   r   r   r   r   r1   )r/   r8   r   r2   r   )r   r   r   r   r   r2   r_  
doit_flagsintegralri   new_argss              r?   r   r   ~  s    | 
J ((H(H%%}}*z** ]]$" -7q(,C,CAFF(Z(J" 	 $}}h''$s   
3Bc                P   SSK Jn  [        U 5      nU(       d  [        S5      e[	        X5      (       d  [        S5      e[        U5      (       d  [        S5      e[        UR                  5      [        U5      :w  a  [        S5      eUR                  U;   a  [        S5      eUnSn[        U5       HA  u  pxUR                  U   n	[        XR                  5      n
XjU
-  -   nUR                  X5      nMC     U[        U5      -  n[        XQR                  5      R                  SS	9nU$ )
aQ  line_integrate(field, Curve, variables)

Compute the line integral.

Examples
========

>>> from sympy import Curve, line_integrate, E, ln
>>> from sympy.abc import x, y, t
>>> C = Curve([E**t + 1, E**t - 1], (t, 0, ln(2)))
>>> line_integrate(x + y, C, [x, y])
3*sqrt(2)

See Also
========

sympy.integrals.integrals.integrate, Integral
r   )Curvez6Expecting function specifying field as first argument.z*Expecting Curve entity as second argument.z)Expecting ordered iterable for variables.z3Field variable size does not match curve dimension.z.Curve parameter clashes with field parameters.F)r   )sympy.geometryr  r   rp   r8   r,   rS   	functions	parameter	enumerater
   re   r   r/   rE   r   )fieldcurvevarsr  rh   Ftdldtr[   var_f_dnr  s               r?   line_integrater  -  s   & %ADF 	Fe##EFFtDEE
5??s4y(NOO$IJJ 
BDD/__Q2'Sy!WWS " 
d4jBLL)..E.:HOrA   c                ,    [        U R                  5      $ rC   )r*   r;   )r,  s    r?   _r  a  s    rA   )r3  )r   r6  r   )r2  )V
__future__r   sympy.concrete.expr_with_limitsr   sympy.core.addr   sympy.core.basicr   sympy.core.containersr   sympy.core.exprr   sympy.core.exprtoolsr	   sympy.core.functionr
   sympy.core.logicr   sympy.core.mulr   sympy.core.numbersr   r   sympy.core.relationalr   sympy.core.singletonr   sympy.core.symbolr   r   r   sympy.core.sympifyr   sympy.functionsr   r   r   r   r   r   &sympy.functions.elementary.exponentialr   #sympy.functions.elementary.integersr   $sympy.functions.elementary.complexesr   r   (sympy.functions.elementary.miscellaneousr   r    -sympy.functions.special.singularity_functionsr!   rationaltoolsr#   sympy.matricesr$   sympy.polysr%   r&   sympy.series.formalr'   sympy.series.limitsr(   sympy.series.orderr)   sympy.tensor.functionsr*   sympy.utilities.exceptionsr+   sympy.utilities.iterablesr,   sympy.utilities.miscr-   r/   r   r  registerr  deltafunctionsr3  	meijerintr   r6  r   trigonometryr2  r1   rA   r?   <module>r     s    " 9  " '   - $ '  % $ " 3 3 & K K 6 5 : = C ! % - 1 % $ ( @ 1 +W} Wv* "D4X\ m(^/h     + G G 'rA   