
    wgd                     0   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 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 d d
lmZm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$m%Z%m&Z&m'Z' d dl(m)Z) d dl*m+Z+ d dl,m-Z-m.Z. d dl/m0Z0m1Z1 d dl2m3Z3 ddl4m5Z5 d dl6m7Z7 d dl8m9Z9m:Z: d dl;m<Z< d dl=m>Z> d dl?m@Z@ d dlAmBZB d dlCmDZD d dlEmFZF d dlGmHZH  G d  d!e      ZId"d#d"d"d"d$d%ZJd& ZK eBj                  eI      d'        ZMdd(lNmOZO dd)lPmQZQmRZRmSZS dd*lTmUZU y")+    )Tuple)AddWithLimits)Add)Basic)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                        e Zd ZU dZdZeeef   ed<   d Z	d Z
e fd       Zd Zd Zd	 Zd
 Z	 	 ddZddZddZddZd ZddZd Z xZS )Integralz Represents unevaluated integral. argsc                     t        |d      r |j                  |i |S t        |t              rt	        ddd       t        j                  | |g|i |}|S )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)hasattrr2   
isinstancer$   r*   r   __new__)clsfunctionsymbolsassumptionsobjs        ^/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/sympy/integrals/integrals.pyr7   zIntegral.__new__*   sk    T 8-.*8**GC{CCh%%
 */+FH ##CKGK{K
    c           	          | j                   ft        | j                  D cg c]  }t        |       c}      z   S c c}w N)r9   tuplelimits)selfxabs     r=   __getnewargs__zIntegral.__getnewargs__d   s/    %t{{(Ks(K"LLL(Ks   ;
c                     t         |   S )ao  
        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)rC   	__class__s    r=   rH   zIntegral.free_symbolsg   s    . w##r>   c                 |   | j                   j                  ryd}| j                  D ]<  }t        |      dk(  s|d   |d   k(  xs |d   |d   z
  j                  }|r y|;d}> | j                   j                  }| j                  D ]  }t        |      dk(  r|j                  |d          &t        |      dk(  r)|d   |vr"|d   j                  r y|d   j                  d}|j                  |d          |dd  D ]  }|j                  |j                           | j                   j                  du r|du ryy y )NTF   r!      r   )r9   is_zerorB   lenrH   adddiscardupdate)rC   got_nonelzfreerD   is          r=   _eval_is_zerozIntegral._eval_is_zero   sF    ==   	$A1v{qTQqT\;qtad{&;&;Y#H	$ }}));; 	,C3x1}Q 3x1}Qt!3q6>>V^^+#H LLQ W ,ANN+,	, ==  E)h%.? /@)r>   c                    t        d      |j                  j                  | j                        }t	        |      dkD  rt        d| j                  z        |r|j                         n}|| j                  vr| S t        |      }t        |t              ra|j                  }t	        |      dk(  rt        t        d            t	        |      dkD  rt        t        d            |j                         }nN|\  }}||j                  vrt        t        d            t        |t              st        t        d|z              |j                  r|j                  r| j                  ||i      S |j                  s|j                  st        d	      ||k(  r5| j                  ||j                  |      f      j                  |i      S || j                   v rt        t        d
            ddlm} |j                  sN|j                  |      g |||z
  |d      }|st        d      |D 	cg c]  }	|	j                  |       }
}	n|j                  |      g}
ddlm}  |||z
        \  }}|j                  |j+                         D cg c]	  \  }}||f c}}      } |||      D cg c]  }|j                  |       }}|st        d      |D 	cg c]  }	|	j                  |       c}	|
D 	ch c]@  }	| j,                  j                  ||	      |	j/                        z  j                  |      B }}	t	        |      dkD  rt        t        d            |j                         }fdfd}g }| j                   D ]  }|d   }||k(  rt	        |      dk(  rG|dd \  }} |||       |||      }}t1        ||z
  dkD        r||}}| }|j3                  |||f       bt	        |      dk(  r  ||d   d      }|j3                  ||f       |j3                  |       |j3                  |         | j4                  |g| S c c}	w c c}}w c c}w c c}	w c c}	w )a  
        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                     | j                  |      }|t        j                  u s|j                  du r%|j                  rt	        t        |      | z  |      S |S )}
            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wokrY   s       r=   _calc_limit_1z)Integral.transform.<locals>._calc_limit_1T  sL    
 &&A,Caee|s}}5!++T!WQY1--Jr>   c           
          t        D ch c]  } || |       c}      }t        |      dkD  rt        t        d            |d   S c c}w )r^   r!   z_
                The mapping between F(x) and f(u) did not
                give a unique limit.r   )listrN   
ValueErrorr,   )rc   rd   Fiavalsrb   rf   s       r=   _calc_limitz'Integral.transform.<locals>._calc_limit^  sW    
 A>b-Aq1>?E5zA~  -( ") * * 8O ?s   A
rK   NrL   )r   rH   intersection	variablesrN   ri   popr   r6   r   r,   r   	is_Symbolxreplace	transformr_   rB   sympy.solvers.solversrZ   sympy.simplify.simplifyr\   itemsr9   r	   r
   appendfunc)rC   xuxfreexvarufreeuvarrZ   solnfifr\   pdiffrepskvpuvarsnewfuncsnewfuncrl   	newlimitsrD   symrc   rd   rb   rf   rY   s                             @@@r=   rr   zIntegral.transform   s]   N #J++DNN;u:>2T^^CE E#uyy{t~~%KAJaNNE5zQ  -- ". / /5zA~  -> "? @ @ 99;DGAt1>>)  - "   dF+  -$&*-+ ", - - ;;1;;==!Q(({{1;;=>>4<>>!affT1oq%9:CCQINN4;;Z )I J K K 	0{{a!AQE2D !HII,01bq!1A1a!A6 Q-KE4II$**,?$!Q1v?@E*/u*=>QAFF4L>D> !HII,01bq!1A 345,. ]]''b1"''!*<$q$-( 5 5x=1Z )# $ % % ,,.	
	 	;; 	&Ca&Cd{s8q=qr7DAq&q!,k!Q.?qA!!a%!), !1#*($$dAq\2X]#CFA.A$$dAY/$$T*  %!	&$ tyy-9--y 2
 @> 25s   6QQ"
8Q(#Q-AQ2c                    01234 j                  dd      s S j                  dd      }j                  dd      2j                  dd      0j                  dd      }j                  d	d      }j                  d
d      }t        t        t        d|2||f                  dkD  rt	        d      |rdx2x}}n2rdx}x}}n|rdx}x2}n|rdx}x2}2|||0d}0dvrt	        d0z        |r't        d  j                  D              rt	        d       j                  rt        j                  S ddl
m} t         j                  |      rt         fd j                  D              rt	        d      t        d  j                  j                  d   dd D              r S  } j                  }	 |	j                   |j                  |	j                  g|j                   j!                         g|	j                   j!                         S  j                  }
|
j#                  d d       }
|r |
j                   d.i }
|
j                  rt        j                  S t        |
t$              r|
j'                   fd      S t        |
t(              rdt         j                        dkD  rt*         j                  d   }t        |      dkD  r |
j,                  |fi |S  |
j,                  |d   fi |S i } j                  D ]  }t        |      dk7  r|\  4}}||f}t/        d |D              r4j0                  st3        d      }nXt/        d |D              r4j4                  st3        d      }n-t/        d  |D              r4j6                  st3        d!      }nd}|s||4<    |r|j9                         D ci c]  \  }}||
 }}}  j;                  |      j                   d.i }t        |t<              r*t=        |D cg c]  }|j;                  |       c}      }|S |j;                  |      }|S g }t?               } j                  D ]  }t        |      dk(  rt?        |dd       3nWt        |      d"k(  r|d   j@                  3n9t        |      dk(  r+|d   j@                  jC                  |d"   j@                        3|d   |v st        3fd#|D              rY|jE                  |       |jG                  3         j                  |
g|gz    }
|
jI                         }t        |tJ              s|}
|
jM                  tN        tP              rt        |      dk  rt/        d$ |D              s#t        |      dk(  r`t/        d% |dd D              rKt3        d&d!      }|
j;                  |d   |i      jS                  tT              j;                  ||d   i      }
n/|
jM                  tV        tX              r|
jS                  tT              }
|
jM                  tT              rt        |
tT              st[        |
      }
t        |
tT              r=t        |      dk(  r |
j\                  |d   fi |}n  j\                  |
|d   fi |}nɈ02 fd'}2}2durt        |      dk(  rw|d   j^                  rh|d"   j^                  rY|
j`                  sM|d   jM                  tb        tb               s|d"   jM                  tb        tb               r ||
|      }||}
d}|du r2du rd}n,  j\                  |
|d   fi |}|2du r ||
|      }||}
	j                  d(d      }|rt        |tJ              s||je                  tf              D ]f  }|jh                  d   } | je                  tj              D ]  }!t3        d)      }"| jm                  |!|"      }#|#jo                  |"      }$|"|$j@                  vs@|!jh                  d   }|jm                  |tq        |tQ        |$      tr        z  tu        |tr        d"z  z
  tr        z        z              } | je                  tv              D ]  }%t3        d)      }"| jm                  |%|"      }&|&jo                  |"      }$|"|$j@                  vs@|%jh                  d   }|jm                  |tq        |tQ        |$      tr        z  tu        |tr        z        z              } i |W|jE                  |         j                  |
g|gz    jI                         }
|
jI                         }t        |tJ              s|}

t        |      dk(  r|}
t        |      dk(  r|\  4}}nt        |      d"k(  r|\  4}d}nt*        |rDt        |tx              r |j                   d.i }t        |tx              r |j                   d.i }|j`                  rWt        |jz                        }'|'j}                  4       |j                         }|j                  4||      }
t        |
g|' }
d* 11fd+}(g g g }+}*})tq        j                  |      D ]  },t        14fd,t        j                  |,      D              r|)jE                  |,       =t        d- t        j                  |,      D              r|+jE                  t[        |,             }|*jE                  |,        tq        |)D ,cg c]  }, |(|,4||       c}, }-	 tq        |* j                  4||      }.t[        tq        |+       j                  4||      }/|-|.z   |/z   }
 |
S c c}}w c c}w c c},w # t*        $ rK |jE                  |         j                  |
g|gz    }
|
jI                         }t        |tJ              s|}
Y tw xY w)/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   8   K   | ]  }t        |      d kD    yw)r!   N)rN   ).0rD   s     r=   	<genexpr>z Integral.doit.<locals>.<genexpr>  s     =#SA=s   z4risch=True is only allowed for indefinite integrals.r   Sumc              3   T   K   | ]  }|j                   j                  d    v  ! ywr   N)r9   rB   )r   r   rC   s     r=   r   z Integral.doit.<locals>.<genexpr>  s%     HA1,,Q//Hs   %(z3Limit of the sum cannot be an integration variable.c              3   4   K   | ]  }|j                     y wr@   )is_infinite)r   rS   s     r=   r   z Integral.doit.<locals>.<genexpr>  s     FQ1==F   c                 P    t        | t              xr | j                  d   dz  dk7  S )Nr!   rL   )r6   r    r0   rx   s    r=   <lambda>zIntegral.doit.<locals>.<lambda>  s#    jI.C166!9Q;!3C r>   c                 2    t        | j                  d         S Nr   )r    r0   r   s    r=   r   zIntegral.doit.<locals>.<lambda>  s    iq	* r>   c                 ^      j                   | gj                   j                  di S )Nr/   )rw   rB   doit)r   hintsrC   s    r=   r   zIntegral.doit.<locals>.<lambda>  s,    9)$))A4499BEB r>   rK   c              3   4   K   | ]  }|j                     y wr@   )is_nonnegativer   rV   s     r=   r   z Integral.doit.<locals>.<genexpr>  s     /1##/r   )positivec              3   4   K   | ]  }|j                     y wr@   )is_nonpositiver   s     r=   r   z Integral.doit.<locals>.<genexpr>  s     1!Q%%1r   )negativec              3   4   K   | ]  }|j                     y wr@   )is_realr   s     r=   r   z Integral.doit.<locals>.<genexpr>  s     *1QYY*r   )realrL   c              3   ,   K   | ]  }|d    v   ywr   r/   )r   r   ulis     r=   r   z Integral.doit.<locals>.<genexpr>  s     #GAAaDCK#Gs   c              3   4   K   | ]  }|j                     y wr@   )is_extended_realr   rx   s     r=   r   z Integral.doit.<locals>.<genexpr>  s     %FQa&8&8%Fr   c              3   R   K   | ]  }|j                   xr |j                    ! y wr@   )r   r   r   s     r=   r   z Integral.doit.<locals>.<genexpr>  s-      ' ()'9'9'O!-->O'O 's   %'xrc                 j   d }t        |      dk(  rdur|\  }}}	 t        | |||      }|j|\  }}
dk(  r'j	                  | |||f      }	t        ||f|	dfd      S 
dk(  r2t        j                        dk7  rt        t        d	            ||f}|S |}|S # t        $ r t        d       d }Y w xY w)
NrK   F+NotImplementedError from meijerint_definiter   T)evaluater   r!   z
                                        conds=separate not supported in
                                        multiple integrals)	rN   meijerint_definiteNotImplementedError_debugrw   r   rB   ri   r,   )r9   rD   retrx   rc   rd   resr   condry   r   r   rC   s             r=   try_meijergz"Integral.doit.<locals>.try_meijerg8  s    C3x1})="%1a'"4Xq!Q"GC
 ?&)GAt$3$(IIhAq	$B
 (1!TQI-2(4 !4!&*!4#&t{{#3q#8*4Z A> 6? +@ %@ '(g J '(J-  3 '" $: ;"&C's   B B21B2finalx1c                 d    t        | t              xr t        fd| j                  D              S )Nc              3   *   K   | ]
  }|fk(    y wr@   r/   )r   rV   rx   s     r=   r   z6Integral.doit.<locals>.is_indef_int.<locals>.<genexpr>  s     'DaaT	'Ds   )r6   r.   anyrB   )grx   s    `r=   is_indef_intz#Integral.doit.<locals>.is_indef_int  s+    $.q($; %E$''D188'D$DFr>   c                     g }t        j                  |       D ]?  } ||      r#|j                  |j                  |||             /|j                  |       A t        | S r@   )r   	make_argsrv   _eval_interval)r   rx   rc   rd   r0   r   r   s         r=   eval_factoredz$Integral.doit.<locals>.eval_factored  s^     $&D%(]]1%5 3#/1#5$(KK0@0@Aq0I$J$(KKN	3
 $':-r>   c              3   0   K   | ]  } |        y wr@   r/   )r   r   r   rx   s     r=   r   z Integral.doit.<locals>.<genexpr>  s       #>'( $01#5 #>s   c              3   <   K   | ]  }t        |t                y wr@   )r6   r   )r   r   s     r=   r   z Integral.doit.<locals>.<genexpr>  s!      %@)* &09%= %@s   r/   )DgetrN   rh   filterri   r   rB   rM   r   Zerosympy.concrete.summationsr   r6   r9   rn   rw   r   replacer#   	applyfuncr&   r   	integrateallr   r   r   r   ru   rq   rA   setrH   unionrv   rQ   factorr.   hasr   r   rewriter   r   r   r   _eval_integralr   is_Polyr   atomsr   r0   r   r_   r	   r   r   r   r   r   gensremoveas_exprr   r$   r   r   )5rC   r   r   r   r   r   eval_kwargsr   _i_sumr9   rD   r   rc   rd   rS   rY   r   r   undodidrV   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   rx   s5   ``                                              @@@@@r=   r   zIntegral.doit  s@   * yyd+Kyy&))It,		';/		'4(99Z.8T*tF4&'5(!CDEFJZ[[)..G.eh(--F-UX*//F/Wx',,F,Wu")EVYa 99 /167 8 8 S===STT <<66M 	2dmmS)HHH !VWWF$--*>*>q*A!"*EFFB==D499WRWWT]]?RYY?DDFUUZZ\\ == ##C*, $x}}-u-H66M h
+%%BD D h 124;;!#))++a.C3x!|)x))#===)x))#a&@K@@ ;; 	C3x1} GAq!AA/Q//8H8H4(1q11!:J:J4(***199t$Q+	, %)ZZ\2TQAqD2D2*$--%**3U3C#u%s;!QZZ-;< J ll4(J e;; R	=C 3x1}#bq'lSQ!f))SQ!f))//A0C0CD
 1v}#G#G G$$S)

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

2s0C%h4C#& $H u$D $I 3 3 3 #a&!9,7!9I (W_)(C8?'*H$IIgt,E jH=%!*!6 ?I(~~a0H$,NN3$7 D"4[#+==2#> (b 1U%7%77 (a 0A(1y#i $UBua1fb[/A ACC )DID %-NN3$7 ?"4[#+==2#> (b 1U%7%77 (a 0A(1y#i $UBuaV} <C> )?I??,  $$S)$499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!9 1A" #>,/MM!,<#>  > ) 0 0 3!$ %@.1mmA.>%@ "@ * 1 1.2C D &a 01 "%09';+, (5Q1a'@ '; "<=&)6l&A&A!Q&JG)7Z8H)I)X)XYZ\]_`)aJ'-'7*'DHUR	=f  3 <\';  3 = *005'0tyyH:3E'GH080A-#-.?#J+<=s&   m5m;n 
-AnAooc                 ^     j                   t         j                        }}|j                  d      }t	        |      dk(  r|\  }}nt	        |      dk(  r|\  }d}n	dx}}|d   |r  j
                  |gt        |       } fd}t        j                  }|| |||      z  }|| |||      z  }t	        |      dk(  rk(  r	|}	||	z  }|S t        d      }
|j                  |
      j                        j                  |
      }	|	r| j                  |	||f      z  }|S )	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

        rK   rL   Nr   c                 4   t        |      }|st        j                  S t        | t              rP| j
                  D cg c]  }t        |      dk(  r|d   k(  rfn|  }} j                  | j                  g| } | j                  |      |z  S c c}w Nr!   r   )
r	   r   r   r6   r.   rB   rN   rw   r9   r_   )r   abdab_dsymrS   rB   rC   r   rx   s        r=   _doz&Integral._eval_derivative.<locals>._do  s    B}Hvv!X&#$88- &)Vq[QqTQY1a&QF - -DIIajj26266!R=))-s   #Br!   ry   )r9   rh   rB   ro   rN   rw   rA   r   r   r   r_   r	   )rC   r   r   rB   r'   rc   rd   r   rvargry   rx   s   ``         @r=   _eval_derivativez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AY//	r>   c	                    ddl m}	m}
 ddlm} |r	  |	|||      S |r!	  |||      }||j                  t        k7  r|S |||||d}t        |t              r|s|s|s|j                  |      S t        |t              r |j                  |fi |S |j                  |      s||z  S |j!                  |      }|$|s"|s |s|j                         j#                         S |durG	  |	||d|	      \  }}|r3|dk(  r |
||      j%                  d
      S ||j%                  d
      z   S |S ddlm} g }t+        j,                  |      }|D ]  }|j/                  |      \  }}|t0        j2                  u r|s|j5                  ||z         A|j7                         }|{ | j8                  |j;                         |fi |}|U | j8                  |j<                  |fi |}|5 |j                  |g|j>                   }|j5                  |||z   z          y|j@                  r6|jB                  j                  |      s|stE        d|g      }tE        d|g      }|jF                  jI                  ||z  |z         }||jB                  dk(  rtK        |jF                        }n|dk7  r-|jF                  |jB                  dz   z  |jB                  dz   z  }netK        |jF                        }|jF                  |jB                  dz   z  |jB                  dz   z  }t        |tM        |jB                  d      f|df      }|j5                  ||z  ||   z         |jO                  |      r&|s$|s"|s |j5                  |tQ        ||      z         H|s|s|stS        |||      }||j5                  ||z         ttU        ||      }||j5                  ||z         ddl+m,}  |||      }||j5                  ||z         |dur=	  |	||d|	      \  }}|r||j%                  d
      z   }|j5                  ||z          |dur(ddl-m.}m/}  	 |dk(  r | ||g       }n |||g       }nd}|dur'|%	 ta        ||      }||j5                  ||z         W||dur	  |||      }|t        |t              s|j                  t              ro|sm|}!d|!d<   d|!d<    |j                  |jd                  D "cg c]+  }"|"j                  t              r |"j$                  di |!n|"- c}" jg                  dddd      }|j                  t              s|j5                  ||z         (|sIti        |      dk(  r; ||      jg                  dd      }|jj                  r | j8                  ||fi |c S ||j5                  ||z          y t+        | S # t
        $ r Y yw xY w# t        t        f$ r Y w xY w# t
        $ r Y w xY w# t
        $ r d}Y w xY w# t        $ r d}Y w xY w# t
        $ r tc        d       Y w xY wc c}"w # t        t        f$ r Y w xY w)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_sumrc   )excluderd   r   r   r!   )singularityintegrate)r   heurisch_wrapper)r   r   r   r   )multinomialr   	power_exp
power_base)mulr   r/   )6sympy.integrals.rischr  r  sympy.integrals.manualintegrater  r   rw   r.   ri   r%   r6   r$   r   r   piecewise_integrater   as_polyr   r   sympy.simplify.fur	  r   r   as_independentr   Onerv   getOr   removeOexprrn   is_Powexpr   basematchr   r   is_rational_functionr"   trigintegratedeltaintegratesingularityfunctionsr  sympy.integrals.heurischr   r  meijerint_indefiniter   r0   expandrN   is_Add)#rC   r   rx   r   r   r   r   r   r   r  r  r  resultr   polyrV   r	  partsr0   r   r   
order_termhh_order_exprh_order_termrc   rd   Mh1h2r  	heurisch_r  new_eval_kwargsr  s#                                      r=   r   zIntegral._eval_integral7  s   x 	QC&q!599 (A.%&++*A!M #*EV 52 a'U ;;q>! a#(1((:k:: uuQxQ3J yy|Vw%>>#++--"+AqD!	
  {4Q:??e?LL%U(;;;!M 	4}}Q g	A''*HE1 AEEz'U1W% J%'D''		QF+F=#64#6#6z#Y[#YL#/'6z((A+5+?+?(AUA,<%=> 
  xx		!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!!Qe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)*VX2N!::h/ /:O8=OH57<OG4%0V[[ ,2;;3 %( !$ 1 !) ;? ;7:!;3 &  &v%*/0516  &  8	 #  &zz(3!LL8$  Ta!!$++5+A88 /4..q!C{CC}UQY'Og	R E{g '  0 F ' ` / ! !$ + ! !	! + JHIJ&3 #O4 s   
W W. $X XX&<X8'AY?0Y
/A Y	W+*W+.X X	XXX#"X#&X54X58YYYY*)Y*c              #      K   | j                         }|}|j                  D ]  }||dd  v s|d   } n |j                  j                  ||      D ]  }t	        |g|j                     y wr   )as_dummyrB   r9   lseriesr   )rC   rx   logxcdirr  symbrS   terms           r=   _eval_lserieszIntegral._eval_lseries  sx     }} 	AAabEzt	 MM))$5 	0DD/4;;//	0s   )A.AA.c                 8   |}| j                   D ]  }||dd  v s|d   } n | j                  j                  |||      j                  t              \  }}|D 	cg c]  }	|	j                  ||       }}	t        |g| j                    t        | |z  z   S c c}	w )Nr!   r   )rx   nr6  )rB   r9   nseriesas_coeff_addr(   r_   r   r   )
rC   rx   r<  r6  r7  r8  rS   termsorderos
             r=   _eval_nserieszIntegral._eval_nseries  s     	AAabEzt	 }},,ad - $$0L$7 	u*/0Qa00--UA== 1s   Bc                     | j                   d   j                  |      }|D ]	  }|dk7  s	 n t        g| j                   dd   S )Nr   r!   )r0   r5  r   )rC   rx   r6  r7  
series_genleading_terms         r=   _eval_as_leading_termzIntegral._eval_as_leading_term  sP    YYq\))!,
& 	Lq 	 6		!"66r>   c           
          t        |       }t        |t              r4ddlm}  |j
                  |j                  D cg c]  } ||fi | c} S  |j                  di |S c c}w )Nr   )simplifyr/   )r   r6   r.   rt   rH  rw   r0   )rC   kwargsr  rH  rV   s        r=   _eval_simplifyzIntegral._eval_simplify  s]    D!dH%8499diiHx4V4HIIt}}&v&& Is   A"c           
         ddl m} | j                  }t        |      dkD  rt	        d      |d   }t        |      dk7  s"|d   j
                  du s|d   j
                  du rt        d      |t        d	d
d
      }nt        |      }|j                  du s|j                  du s|j
                  du rt        d|z        |\  }}}	|	|z
  |z  }
t        dd
d
      }| j                  }|dk(  r)|
 ||j                  |||dz
  |
z  z         |d|f      z  }n|dk(  r&|
 ||j                  ||||
z  z         |d|f      z  }n|dk(  r,|
 ||j                  ||||
z  z   |
dz  z
        |d|f      z  }ne|dk(  rR|
|j                  ||      |j                  ||	      z   dz   ||j                  ||||
z  z         |d|dz
  f      z   z  }nt        d|z        |r|j                         S |S )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 yetrK   FrL   z5Expecting a definite integral over a finite interval.r<  T)integerr   z$n must be a positive integer, got %sr   leftrightmidpoint	trapezoidzUnknown method %s)r   r   rB   rN   r   ra   ri   r   r   is_positive
is_integerr9   r_   r   )rC   r<  methodr   r   rB   r'   rx   rc   rd   dxr   r   r'  s                 r=   as_sumz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1a!eQY#td3MMVAFF1a1Q3(l3aAY??FwAFF1a!B$h/!Q;;Fz!AFF1a!B$hAo6Aq	BBF{"!&&A,15q8AFF1a!B$h'!QA78 9F 069:: (v{{}4f4r>   c           
         t        | j                        dk7  s$t        t        | j                  d               dk7  rt        d      | j                  d   \  }}}|j                  r|j                  r||k  st        d      ||k(  rt
        j                  S ddlm} t        d      }| j                  } |||      D cg c]   }|j                  s||cxk  r|k  sn n|" }	}|	D ]  }
|
||fv s
t        d|
z         t        ||fi |}|j                  t              r| S |t         u r.|t        u r&t        ||j!                  ||       z
  |t              }nt        |||d	      t        |||d
      z
  }|	D ]<  }|t        |j!                  |||z
        |j!                  |||z         z
  |dd
      z  }> |S c c}w )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   rK   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.-+)rN   rB   rh   ri   is_comparabler   r   sympy.calculus.singularitiesrW  r   r9   r   r   r.   r   r'   r_   )rC   rI  rx   rc   rd   rW  rX  r   r   singularities_listrV   rb   Is                r=   principal_valuezIntegral.principal_value>  s   @ t{{q CT[[^(<$=$B 8 9 9++a.1aAOOQ ^ _ _666M>#JMM)6q!)<`ATUYZT_^_T_a``# 	pAQF{ hlmnp p	p a%f%55?K8Ra!&&QB-'B/AaAs#eAq!S&99A# 	KA1q5)QVVAq1u-==1cJJA	K as    F=F=F=)NNNNr   Nr   )NrO  T)__name__
__module____qualname____doc__	__slots__tTupler   r   __annotations__r7   rE   propertyrH   rW   rr   r   r  r   r:  rB  rF  rJ  rU  r_  __classcell__)rI   s   @r=   r.   r.   #   s    *I
u
8tM $ $0!FZ.xYv
[z EI>BUn
0	>7'K5Z<r>   r.   Nr   )r   r   r   r   r   c                    d| ||||d}t        |i |}t        |t               r |j                  di |S |j                  D 	cg c]&  }	t        |	t               r |	j                  di |n|	( }
}	 |j                  |
 S c c}	w )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   r/   )r.   r6   r   r0   rw   )r   r   r   r   r   r0   rI  
doit_flagsintegralrc   new_argss              r=   r   r   ~  s    | 
J ((H(H%x}}*z** ]]$ -7q(,CFAFF(Z(J $ $x}}h''$s   +Bc                 :   ddl m} t        |       }|st        d      t	        ||      st        d      t        |      st        d      t        |j                        t        |      k7  rt        d      |j                  |v rt        d      |}d}t        |      D ]D  \  }}|j                  |   }	t        |	|j                        }
||
|
z  z   }|j                  ||	      }F |t        |      z  }t        ||j                        j                  d	      }|S )
a  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.geometryrn  r   ri   r6   r+   rN   	functions	parameter	enumerater	   r_   r   r.   rB   r   )fieldcurvevarsrn  rb   FtdldtrV   var_f_dnrk  s               r=   line_integrater{  -  s   & %ADF 	FeU#EFFtDEE
5??s4y(NOO$IJJ 
BDD/ 3__Q2u'sSy!WWS" 
d4jBELL)..E.:HOr>   c                 ,    t        | j                        S r@   )r)   r9   )r  s    r=   _r}  a  s    r>   )r!  )r   r$  r   )r   )Vtypingr   re  sympy.concrete.expr_with_limitsr   sympy.core.addr   sympy.core.basicr   sympy.core.containers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}  deltafunctionsr!  	meijerintr   r$  r   trigonometryr   r/   r>   r=   <module>r     s    " 9  " '   - $ '  % $ " 3 3 & K K 6 5 : = C ! % - 1 % $ ( @ 1 +W} Wv* "D4X\ l(^/h     + G G 'r>   