
    \hf                       S r SSKJrJrJr  SSKJrJr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Jr  SSKJrJrJr  SS	KJrJrJr  SS
KJ r J!r!  SSK"J#r#  SSK$J%r%J&r&J'r'  SSK(J)r)J*r*J+r+J,r,J-r-J.r.  SSK/J0r0  SSK1J2r2J3r3  SSK4J5r5  SSK6J7r7  SSK8J9r9  SSK:J;r;  SSK<J=r=J>r>  SSK?J@r@  SSKAJBrB  SSKCJDrD  SSKEJFrF  SSKGJHrH  SSKIJJrJ  SSKKJLrL  SSKMJNrN  SSKOJPrP  SSKQJRrR  SS KSJTrTJUrUJVrV  SS!KWJXrXJYrYJZrZJ[r[  S" r\S# r] " S$ S%5      r^ " S& S'5      r_ " S( S)5      r`S=S+ jraSS*S,\=4S- jrb\" S.5      rcS/qdS/qeSS0KfJgrg  S>S1 jrhS?S2 jriS3 rjS4 rkS5 rlS6 rmS7 rnS@S8 jroSS/S/\=S,4S9 jrpS,\=4S: jrq\=4S; jrrSAS< jrsg/)BzL
This module implements Holonomic Functions and
various operations on them.
    )AddMulPow)NaNInfinityNegativeInfinityFloatIpiequal_valued
int_valued)S)ordered)DummySymbol)sympify)binomial	factorialrf)	exp_polarexplog)coshsinh)sqrt)cossinsinc)CiShiSierferfcerfi)gamma)hypermeijerg)	meijerint)Matrix)PolyElement)FracElement)QQRR)DMF)roots)Poly)DomainMatrix)sstr)limit)Order)hyperexpand)	nsimplify)solve   )HolonomicSequenceRecurrenceOperatorRecurrenceOperators)NotPowerSeriesErrorNotHyperSeriesErrorSingularityErrorNotHolonomicErrorc                    ^  U 4S jnT R                  U5      u  p4UR                  S   nU" SU45      U-  nX6-   R                  5       nU$ )Nc                 F   > [         R                  " U TR                  5      $ N)r1   onesdomain)shapers    Q/var/www/auris/envauris/lib/python3.13/site-packages/sympy/holonomic/holonomic.py<lambda>(_find_nonzero_solution.<locals>.<lambda>+   s    **5!((;    r   r8   )_solverE   	transpose)rF   homosysrC   
particular	nullspacenullitynullpartsols   `       rG   _find_nonzero_solutionrS   *   sP    ;DHHW-Jooa GQL!I-H 
+
+
-CJrJ   c                 2    [        X5      nX"R                  4$ )aQ  
This function is used to create annihilators using ``Dx``.

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

Returns an Algebra of Differential Operators also called Weyl Algebra
and the operator for differentiation i.e. the ``Dx`` operator.

Parameters
==========

base:
    Base polynomial ring for the algebra.
    The base polynomial ring is the ring of polynomials in :math:`x` that
    will appear as coefficients in the operators.
generator:
    Generator of the algebra which can
    be either a noncommutative ``Symbol`` or a string. e.g. "Dx" or "D".

Examples
========

>>> from sympy import ZZ
>>> from sympy.abc import x
>>> from sympy.holonomic.holonomic import DifferentialOperators
>>> R, Dx = DifferentialOperators(ZZ.old_poly_ring(x), 'Dx')
>>> R
Univariate Differential Operator Algebra in intermediate Dx over the base ring ZZ[x]
>>> Dx*x
(1) + (x)*Dx
)DifferentialOperatorAlgebraderivative_operator)base	generatorrings      rG   DifferentialOperatorsrZ   4   s    D 't7D**++rJ   c                   .    \ rS rSrSrS rS r\rS rSr	g)rU   Z   a:  
An Ore Algebra is a set of noncommutative polynomials in the
intermediate ``Dx`` and coefficients in a base polynomial ring :math:`A`.
It follows the commutation rule:

.. math ::
   Dxa = \sigma(a)Dx + \delta(a)

for :math:`a \subset A`.

Where :math:`\sigma: A \Rightarrow A` is an endomorphism and :math:`\delta: A \rightarrow A`
is a skew-derivation i.e. :math:`\delta(ab) = \delta(a) b + \sigma(a) \delta(b)`.

If one takes the sigma as identity map and delta as the standard derivation
then it becomes the algebra of Differential Operators also called
a Weyl Algebra i.e. an algebra whose elements are Differential Operators.

This class represents a Weyl Algebra and serves as the parent ring for
Differential Operators.

Examples
========

>>> from sympy import ZZ
>>> from sympy import symbols
>>> from sympy.holonomic.holonomic import DifferentialOperators
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(ZZ.old_poly_ring(x), 'Dx')
>>> R
Univariate Differential Operator Algebra in intermediate Dx over the base ring
ZZ[x]

See Also
========

DifferentialOperator
c                    Xl         [        UR                  UR                  /U 5      U l        Uc  [        SSS9U l        g [        U[        5      (       a  [        USS9U l        g [        U[
        5      (       a  X l        g g )NDxF)commutative)	rW   DifferentialOperatorzeroonerV   r   
gen_symbol
isinstancestr)selfrW   rX   s      rG   __init__$DifferentialOperatorAlgebra.__init__   sn    	#7YY!4$)  $Tu=DO)S))"("FIv.."+ /rJ   c                 r    S[        U R                  5      -   S-   U R                  R                  5       -   nU$ )Nz9Univariate Differential Operator Algebra in intermediate z over the base ring )r2   rc   rW   __str__)rf   strings     rG   rj   #DifferentialOperatorAlgebra.__str__   s<    L4??#$&<=YY!" rJ   c                 t    U R                   UR                   :H  =(       a    U R                  UR                  :H  $ rB   )rW   rc   rf   others     rG   __eq__"DifferentialOperatorAlgebra.__eq__   s.    yyEJJ& 3%"2"22	3rJ   )rW   rV   rc   N)
__name__
__module____qualname____firstlineno____doc__rg   rj   __repr__rp   __static_attributes__ rJ   rG   rU   rU   Z   s    $L, H3rJ   rU   c                   l    \ rS rSrSrSrS rS rS rS r	\	r
S rS	 rS
 rS rS rS r\rS rS rSrg)r`      a  
Differential Operators are elements of Weyl Algebra. The Operators
are defined by a list of polynomials in the base ring and the
parent ring of the Operator i.e. the algebra it belongs to.

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

Takes a list of polynomials for each power of ``Dx`` and the
parent ring which must be an instance of DifferentialOperatorAlgebra.

A Differential Operator can be created easily using
the operator ``Dx``. See examples below.

Examples
========

>>> from sympy.holonomic.holonomic import DifferentialOperator, DifferentialOperators
>>> from sympy import ZZ
>>> from sympy import symbols
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(ZZ.old_poly_ring(x),'Dx')

>>> DifferentialOperator([0, 1, x**2], R)
(1)*Dx + (x**2)*Dx**2

>>> (x*Dx*x + 1 - Dx**2)**2
(2*x**2 + 2*x + 1) + (4*x**3 + 2*x**2 - 4)*Dx + (x**4 - 6*x - 2)*Dx**2 + (-2*x**2)*Dx**3 + (1)*Dx**4

See Also
========

DifferentialOperatorAlgebra
   c                    X l         U R                   R                  n[        UR                  S   [        5      (       a  UR                  S   OUR                  S   S   U l        [        U5       H_  u  pE[        XSR                  5      (       d  UR                  [        U5      5      X'   M=  UR                  UR                  U5      5      X'   Ma     Xl        [        U R                  5      S-
  U l        g)z
Parameters
==========

list_of_poly:
    List of polynomials belonging to the base ring of the algebra.
parent:
    Parent algebra of the operator.
r   r8   N)parentrW   rd   gensr   x	enumeratedtype
from_sympyr   to_sympy
listofpolylenorder)rf   list_of_polyr~   rW   ijs         rG   rg   DifferentialOperator.__init__   s     {{!+DIIaL&!A!A1tyyQR|TU
 l+DAa,,"&//'!*"="&//$--2B"C	 , ')A-
rJ   c                   ^  T R                   n[        U[        5      (       a  UR                   nOb[        UT R                  R                  R
                  5      (       a  U/nO/T R                  R                  R                  [        U5      5      /nS nU" US   U5      nU 4S jn[        S[        U5      5       H  nU" U5      n[        XT" X'   U5      5      nM!     [        UT R                  5      $ )z
Multiplies two DifferentialOperator and returns another
DifferentialOperator instance using the commutation rule
Dx*a = a*Dx + a'
c                 j    [        U[        5      (       a  U Vs/ s H  o"U -  PM	     sn$ X-  /$ s  snf rB   )rd   list)blistofotherr   s      rG   _mul_dmp_diffop5DifferentialOperator.__mul__.<locals>._mul_dmp_diffop   s6    +t,,'23{!A{33O$$ 4s   0r   c                   > TR                   R                  R                  /n/ n[        U [        5      (       a:  U  H3  nUR                  U5        UR                  UR                  5       5        M5     OvUR                  TR                   R                  R                  U 5      5        UR                  TR                   R                  R                  U 5      R                  5       5        [        X5      $ rB   )	r~   rW   ra   rd   r   appenddiffr   
_add_lists)r   sol1sol2r   rf   s       rG   
_mul_Dxi_b0DifferentialOperator.__mul__.<locals>._mul_Dxi_b   s    KK$$))*DD!T""AKKNKK)  DKK,,77:;DKK,,77:??ABd))rJ   r8   )r   rd   r`   r~   rW   r   r   r   ranger   r   )rf   ro   
listofselfr   r   rR   r   r   s   `       rG   __mul__DifferentialOperator.__mul__   s     __
e122**Kt{{//5566 'K;;++66wu~FGK	%
 jm[9	* q#j/*A$[1KS/*-"MNC	 + $C55rJ   c                 V   [        U[        5      (       d  [        XR                  R                  R                  5      (       d.  U R                  R                  R                  [        U5      5      nU R                   Vs/ s H  o!U-  PM	     nn[        X0R                  5      $ g s  snf rB   )rd   r`   r~   rW   r   r   r   r   )rf   ro   r   rR   s       rG   __rmul__DifferentialOperator.__rmul__  s|    %!566e[[%5%5%;%;<<))55genE&*oo6o19oC6'[[99 7
 7s    B&c                    [        U[        5      (       a5  [        U R                  UR                  5      n[        X R                  5      $ U R                  n[        XR                  R
                  R                  5      (       d0  U R                  R
                  R                  [        U5      5      /nOU/nUS   US   -   /USS  -   n[        X R                  5      $ )Nr   r8   )	rd   r`   r   r   r~   rW   r   r   r   )rf   ro   rR   	list_self
list_others        rG   __add__DifferentialOperator.__add__  s    e122T__e.>.>?C'[[99OO	%!1!1!7!788 KK--99'%.IJJJ|jm+,y}<#C55rJ   c                     U SU-  -   $ Nry   rn   s     rG   __sub__DifferentialOperator.__sub__)  s    rUl""rJ   c                     SU -  U-   $ r   ry   rn   s     rG   __rsub__DifferentialOperator.__rsub__,  s    d{U""rJ   c                     SU -  $ r   ry   rf   s    rG   __neg__DifferentialOperator.__neg__/      DyrJ   c                 .    U [         R                  U-  -  $ rB   r   Onern   s     rG   __truediv__ DifferentialOperator.__truediv__2      quuu}%%rJ   c                    US:X  a  U $ [        U R                  R                  R                  /U R                  5      nUS:X  a  U$ U R                  U R                  R
                  R                  :X  a[  U R                  R                  R                  /U-  U R                  R                  R                  /-   n[        X0R                  5      $ U n US-  (       a  X$-  nUS-  nU(       d   U$ XD-  nM#  )Nr8   r      )r`   r~   rW   rb   r   rV   ra   )rf   nresultrR   r   s        rG   __pow__DifferentialOperator.__pow__5  s    6K%t{{'7'7';';&<dkkJ6M??dkk==HHH;;##(()!+t{{/?/?/C/C.DDC'[[991u!GA FA rJ   c                    U R                   nSn[        U5       H  u  p4X@R                  R                  R                  :X  a  M*  U R                  R                  R                  U5      nUS:X  a  US[        U5      -   S-   -  nMk  U(       a  US-  nUS:X  a-  US[        U5      -   SU R                  R                  -  -   -  nM  US[        U5      -   S-   SU R                  R                  -  -   [        U5      -   -  nM     U$ )	N r   ()z + r8   z)*%sz*%s**)r   r   r~   rW   ra   r   r2   rc   )rf   r   	print_strr   r   s        rG   rj   DifferentialOperator.__str__I  s    __
	j)DAKK$$)))  ))!,AAvS47]S00	U"	AvS47]Vdkk6L6L-MMM	tAw,w9O9O/PPSWXYSZZZI# *& rJ   c                   ^  [        U[        5      (       a9  T R                  UR                  :H  =(       a    T R                  UR                  :H  $ T R                  S   U:H  =(       a"    [	        U 4S jT R                  SS   5       5      $ )Nr   c              3   f   >#    U  H&  oTR                   R                  R                  L v   M(     g 7frB   r~   rW   ra   ).0r   rf   s     rG   	<genexpr>.DifferentialOperator.__eq__.<locals>.<genexpr>i  s&     H4GqT[[%%***4Gs   .1r8   )rd   r`   r   r~   allrn   s   ` rG   rp   DifferentialOperator.__eq__d  ss    e122??e&6&66 /;;%,,./q!U* IHDOOAB4GHH	IrJ   c                     U R                   R                  nU[        UR                  U R                  S   5      U R
                  5      ;   $ )z8
Checks if the differential equation is singular at x0.
r   )r~   rW   r/   r   r   r   )rf   x0rW   s      rG   is_singular DifferentialOperator.is_singulark  s;    
 {{U4==)<=tvvFFFrJ   )r   r   r~   r   N)rr   rs   rt   ru   rv   _op_priorityrg   r   r   r   __radd__r   r   r   r   r   rj   rw   rp   r   rx   ry   rJ   rG   r`   r`      s\    !F L.<,6\:6 H##&(2 HIGrJ   r`   c                       \ rS rSrSrSrS#S jrS r\rS r	S r
S	 rS
 rS rS$S jrS rS rS r\rS rS rS rS rS rS rS rS%S jrS%S jrS&S jrS rS'S jrS rS r S(S jr!S r"S)S  jr#S! r$S"r%g)*HolonomicFunctionit  a	  
A Holonomic Function is a solution to a linear homogeneous ordinary
differential equation with polynomial coefficients. This differential
equation can also be represented by an annihilator i.e. a Differential
Operator ``L`` such that :math:`L.f = 0`. For uniqueness of these functions,
initial conditions can also be provided along with the annihilator.

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

Holonomic functions have closure properties and thus forms a ring.
Given two Holonomic Functions f and g, their sum, product,
integral and derivative is also a Holonomic Function.

For ordinary points initial condition should be a vector of values of
the derivatives i.e. :math:`[y(x_0), y'(x_0), y''(x_0) ... ]`.

For regular singular points initial conditions can also be provided in this
format:
:math:`{s0: [C_0, C_1, ...], s1: [C^1_0, C^1_1, ...], ...}`
where s0, s1, ... are the roots of indicial equation and vectors
:math:`[C_0, C_1, ...], [C^0_0, C^0_1, ...], ...` are the corresponding initial
terms of the associated power series. See Examples below.

Examples
========

>>> from sympy.holonomic.holonomic import HolonomicFunction, DifferentialOperators
>>> from sympy import QQ
>>> from sympy import symbols, S
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(QQ.old_poly_ring(x),'Dx')

>>> p = HolonomicFunction(Dx - 1, x, 0, [1])  # e^x
>>> q = HolonomicFunction(Dx**2 + 1, x, 0, [0, 1])  # sin(x)

>>> p + q  # annihilator of e^x + sin(x)
HolonomicFunction((-1) + (1)*Dx + (-1)*Dx**2 + (1)*Dx**3, x, 0, [1, 2, 1])

>>> p * q  # annihilator of e^x * sin(x)
HolonomicFunction((2) + (-2)*Dx + (1)*Dx**2, x, 0, [0, 1])

An example of initial conditions for regular singular points,
the indicial equation has only one root `1/2`.

>>> HolonomicFunction(-S(1)/2 + x*Dx, x, 0, {S(1)/2: [1]})
HolonomicFunction((-1/2) + (x)*Dx, x, 0, {1/2: [1]})

>>> HolonomicFunction(-S(1)/2 + x*Dx, x, 0, {S(1)/2: [1]}).to_expr()
sqrt(x)

To plot a Holonomic Function, one can use `.evalf()` for numerical
computation. Here's an example on `sin(x)**2/x` using numpy and matplotlib.

>>> import sympy.holonomic # doctest: +SKIP
>>> from sympy import var, sin # doctest: +SKIP
>>> import matplotlib.pyplot as plt # doctest: +SKIP
>>> import numpy as np # doctest: +SKIP
>>> var("x") # doctest: +SKIP
>>> r = np.linspace(1, 5, 100) # doctest: +SKIP
>>> y = sympy.holonomic.expr_to_holonomic(sin(x)**2/x, x0=1).evalf(r) # doctest: +SKIP
>>> plt.plot(r, y, label="holonomic function") # doctest: +SKIP
>>> plt.show() # doctest: +SKIP

r|   Nc                 4    X@l         X0l        Xl        X l        g)a  

Parameters
==========

annihilator:
    Annihilator of the Holonomic Function, represented by a
    `DifferentialOperator` object.
x:
    Variable of the function.
x0:
    The point at which initial conditions are stored.
    Generally an integer.
y0:
    The initial condition. The proper format for the initial condition
    is described in class docstring. To make the function unique,
    length of the vector `y0` should be equal to or greater than the
    order of differential equation.
N)y0r   annihilatorr   )rf   r   r   r   r   s        rG   rg   HolonomicFunction.__init__  s    , &rJ   c           
      T   U R                  5       (       aa  S[        U R                  5      < S[        U R                  5      < S[        U R
                  5      < S[        U R                  5      < S3	nU$ S[        U R                  5      < S[        U R                  5      < S3nU$ )NzHolonomicFunction(z, r   )_have_init_condre   r   r2   r   r   r   )rf   str_sols     rG   rj   HolonomicFunction.__str__  sz    !!=@AQAQ=RTVVd477mT$'']<G  " 699I9I5JTVVG rJ   c                 B   U R                   R                  R                  nUR                   R                  R                  nUR                  nUR                  nX#:X  a  X4$ UR	                  U5      R                  U R                  5      n[        U[        U R                   R                  R                  5      5      u  pxU R                   R                   V	s/ s H  oR                  U	5      PM     n
n	UR                   R                   V	s/ s H  oR                  U	5      PM     nn	[        X5      n
[        X5      n[        XR                  U R                  U R                  5      n
[        XR                  UR                  UR                  5      nX4$ s  sn	f s  sn	f )zF
Unifies the base polynomial ring of a given two Holonomic
Functions.
)r   r~   rW   domunifyold_poly_ringr   rZ   re   rc   r   r   r`   r   r   r   )rf   ro   R1R2dom1dom2R	newparent_r   r   r   s               rG   r   HolonomicFunction.unify  s<    $$))%%**vvvv8= ZZ,,TVV4,QD4D4D4K4K4V4V0WX	(,(8(8(C(CD(C1A(CD(-(9(9(D(DE(D1A(DE#D4#D4 vvtww@ ww%((C| EEs   FFc                     [        U R                  [        5      (       a  g[        U R                  [        5      (       a  gg)z
Returns True if the function have singular initial condition
in the dictionary format.

Returns False if the function have ordinary initial condition
in the list format.

Returns None for all other cases.
TFN)rd   r   dictr   r   s    rG   is_singularics HolonomicFunction.is_singularics   s1     dggt$$&& 'rJ   c                 ,    [        U R                  5      $ )z0
Checks if the function have initial condition.
)boolr   r   s    rG   r   !HolonomicFunction._have_init_cond  s     DGG}rJ   c           
         [        U R                  5      S   nU R                  U   n[        U R                  5      S:X  a  U[        U5      :X  a  US:  a|  [        U5      n[        R
                  /U-  nU[        U5       VVs/ s H  u  pEU[        X-   5      -  PM     snn-  n[        U R                  U R                  U R                  U5      $ gggs  snnf )z@
Converts a singular initial condition to ordinary if possible.
r   r8   N)r   r   r   intr   Zeror   r   r   r   r   r   )rf   ar   r   r   r   s         rG   _singularics_to_ord%HolonomicFunction._singularics_to_ord  s     M!GGAJtww<1c!fQAA&&ABIaLALDA1y''LAAB$T%5%5tvvtwwKK 27 Bs   Cc                 r   U R                   R                  R                  UR                   R                  R                  :w  a  U R                  U5      u  p#X#-   $ U R                   R                  nUR                   R                  n[        XE5      nU R                   R                  R                  nUR                  5       nU R                   /n	UR                   /n
U R                   R                  R                  n[        Xd-
  5       H  nXS   -  nU	R                  U5        M     [        Xe-
  5       H  nXS   -  nU
R                  U5        M     X-   n/ nU H  n/ n[        US-   5       Ht  nU[        UR                  5      :  a  UR                  UR                  5        M9  UR                  UR                  UR                  U   R                  5       5      5        Mv     UR                  U5        M     [        U[        U5      US-   4U5      R!                  5       n[        R"                  " US-   S4U5      n[%        UU5      nUR&                  (       GaB  US-  nXS   -  nU	R                  U5        XS   -  nU
R                  U5        X-   n/ nU H  n/ n[        US-   5       Ht  nU[        UR                  5      :  a  UR                  UR                  5        M9  UR                  UR                  UR                  U   R                  5       5      5        Mv     UR                  U5        M     [        U[        U5      US-   4U5      R!                  5       n[        R"                  " US-   S4U5      n[%        UU5      nUR&                  (       a  GMB  UR)                  5       S US-   U-
   n[+        UU R                   R                  5      nUU R                   -  n[+        UR                  U R                   R                  SS9nU R-                  5       (       a  UR-                  5       (       d  [/        UU R0                  5      $ U R3                  5       S:X  Ga  UR3                  5       S:X  Ga  U R4                  UR4                  :X  ap  [7        U UR                  5      n[7        UUR                  5      n[9        UU5       VVs/ s H	  u  p#X#-   PM     nnn[/        UU R0                  U R4                  U5      $ U R                   R;                  S5      nUR                   R;                  S5      nU R4                  S:X  a!  U(       d  U(       d  XR=                  S5      -   $ UR4                  S:X  a"  U(       d  U(       d  U R=                  S5      U-   $ U R                   R;                  U R4                  5      nUR                   R;                  U R4                  5      nU(       d$  U(       d  XR=                  U R4                  5      -   $ U R=                  UR4                  5      U-   $ U R4                  UR4                  :w  a  [/        UU R0                  5      $ S nS nU R3                  5       S:X  ai  UR3                  5       S:X  aU  [?        U R@                  5       VVs/ s H  u  nnU[C        U5      -  PM     nnn[D        RF                  U0nUR@                  nOU R3                  5       S:X  ai  UR3                  5       S:X  aU  [?        UR@                  5       VVs/ s H  u  nnU[C        U5      -  PM     nnnU R@                  n[D        RF                  U0nO@U R3                  5       S:X  a,  UR3                  5       S:X  a  U R@                  nUR@                  n0 nU H?  nUU;   a.  [9        UU   UU   5       VVs/ s H	  u  p#X#-   PM     snnUU'   M7  UU   UU'   MA     U H  nUU;  d  M  UU   UU'   M     [/        UU R0                  U R4                  U5      $ s  snnf s  snnf s  snnf s  snnf )Nr   r8   Fnegativer   T)$r   r~   rW   r   r   max	get_fieldrV   r   r   r   r   ra   newto_listr1   rL   zerosrS   is_zero_matrixflat
_normalizer   r   r   r   r   
_extend_y0zipr   
change_icsr   r   r   r   r   )rf   ro   r   r   deg1deg2dimr   Krowsself	rowsothergenr   diff1diff2rowrF   exprprM   rR   r   y1y2r   selfat0otherat0selfatx0	otheratx0r   _y0s                                  rG   r   HolonomicFunction.__add__$  s   ""''5+<+<+C+C+H+HH::e$DA5L%%  &&$o##((KKM$$%&&'	%%99 sz"AB<'EOOE" # sz"AR=(EU# # " DA37^DOO,,HHQVV$HHQUU4??1#5#=#=#?@A	 $
 HHQK  SXs1u-q1;;=$$c!eQZ3$Q0    1HCB<'EOOE"R=(EU#&CAsQwAC00(tq'9'A'A'C!DE	 (
   QS3q5 115??AA"((#a%Q7G(G4C1    : hhj#'D.)#t//667d&&')9)9)@)@5Q$$&&5+@+@+B+B$S$&&11  E)e.B.B.D.M ww%(("  cii0syy1(+B4ae4(dffdggrBB &&2215G((44Q7Hww!|GH..q111xx1}WXq)E11''33DGG<H))55dgg>II..tww777??588,u4477ehh$S$&&11  E)e.B.B.D.L09$''0BC0B11y|#0BCC&&#BB  "d*u/C/C/E/N09%((0CD0C11y|#0CCDB&&#B  "d*u/C/C/E/MBB A Bw+.r!ube+<=+<41+<=111  A{11  !dffdggr::e 54 D E >s   `!%`'"`-`3c           	      

   U R                   R                  R                  nU R                  5       S:X  Ga  U R	                  5       nU(       a  UR                  XS9$ 0 nU R                   H  nU R                  U   n/ n[        U5       Hd  u  pU
S:X  a!  UR                  [        R                  5        M,  Xi-   S-   S:X  a  [        S5      eUR                  U
[        Xi-   S-   5      -  5        Mf     XUS-   '   M     [        US5      (       a  [        S5      e[        U R                   U-  U R                  U R                  U5      $ U R!                  5       (       dh  U(       a>  [        U R                   U-  U R                  U R                  [        R                  /5      $ [        U R                   U-  U R                  5      $ [        US5      (       a;  [#        U5      S:X  a+  US   U R                  :X  a  U R                  nUS   nUS	   nSnOS
n[        R                  /nXPR                  -  n[        U R                   U-  U R                  U R                  U5      nW(       d  U$ WW:w  Ga?   UR%                  5       nU(       aN  UR+                  U R                  U5      n[-        U[.        5      (       a  UR1                  U R                  U5      nOUR3                  U5      nWU R                  :X  a/  US   U-
  US'   [        U R                   U-  U R                  X5      $ [        U5      R4                  (       ao  U(       aR  UR+                  U R                  U5      n[-        U[.        5      (       a  UR1                  U R                  U5      nUU-
  $ UR3                  U5      nUU-
  $ WU R                  :X  a$  [        U R                   U-  U R                  X5      $ [        U5      R4                  (       a   [        U R                   U-  U R                  UU5      R%                  5       nUR+                  U R                  U5      n[-        U[.        5      (       d  U$ UR1                  U R                  U5      $ [        U R                   U-  U R                  5      $ ! [&        [(        4 a    Sn GN7f = f! [&        [(        4 a6    [        U R                   U-  U R                  X5      R3                  U5      s $ f = f)a  
Integrates the given holonomic function.

Examples
========

>>> from sympy.holonomic.holonomic import HolonomicFunction, DifferentialOperators
>>> from sympy import QQ
>>> from sympy import symbols
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(QQ.old_poly_ring(x),'Dx')
>>> HolonomicFunction(Dx - 1, x, 0, [1]).integrate((x, 0, x))  # e^x - 1
HolonomicFunction((-1)*Dx + (1)*Dx**2, x, 0, [0, 1])
>>> HolonomicFunction(Dx**2 + 1, x, 0, [1, 0]).integrate((x, 0, x))
HolonomicFunction((1)*Dx + (1)*Dx**3, x, 0, [0, 1, 0])
T)initcondr   r8   z1logarithmic terms in the series are not supported__iter__z4Definite integration for singular initial conditions   r   FN)r   r~   rV   r   r   	integrater   r   r   r   r   NotImplementedErrorhasattrr   r   r   r   r   to_exprr=   r<   subsrd   r   r3   evalf	is_Number)rf   limitsr  DrF   r   r   cc2r   cjr   r   r   definiteindefinite_integralindefinite_exprloweruppers
indefinites                        rG   r  HolonomicFunction.integrate  sL   & ##77  D(((*A{{6{== BWWGGAJ&q\EAQw		!&&) a12eff		"q|"34 * 1q5	  vz**)*`aa$T%5%5%9466477BOO ##%%()9)9A)=tvvtwwQRQWQWPXYY$T%5%5%9466BB
 6:&&6{aF1I$7WW1I1I HffX
gg/0@0@10DdffdggWYZ&& 7'"5"="="? ',,TVVQ7eS))+11$&&!<E+11!4DFF{11()9)9A)=tvvrNN1"+00;E!%-- / 5 5dffa @ u}$ 055a8Eu}$ ;$T%5%5%94661II qT^^	W%d&6&6&:DFFA	 VVDFFA.
!*c22%%774661-- !!1!1A!5tvv>>U ()<= '"&'N ()<= W()9)9A)=tvvqMSSTUVVWs,   1R# >A%R< $R< #R98R9<ATTc                 "   UR                  SS5        U(       a_  US   U R                  :w  a  [        R                  $ [	        U5      S:X  a-  U n[        US   5       H  nUR                  US   5      nM     U$ U R                  nUR                  S   UR                  R                  R                  :X  a   UR                  S:X  a  [        R                  $ UR                  S   UR                  R                  R                  :X  a  [        UR                  SS UR                  5      nU R                  5       (       aW  U R                  5       S:X  a.  [!        X0R                  U R"                  U R$                  SS 5      $ [!        X0R                  5      $ [!        X0R                  5      $ UR                  R                  nUR'                  5       nUR                   Vs/ s H!  oGR)                  UR+                  5       5      PM#     nnUSS  Vs/ s H
  oDUS   -  PM     n	nU	R-                  SUR                  5        [/        X5      n[1        X7R                  UR2                  /5      n[5        USS U R                  R                  SS9nU R                  5       (       a  U R                  5       S:X  a  [!        X0R                  5      $ [7        XR                  S-   5      SS n
[!        X0R                  U R"                  U
5      $ s  snf s  snf )	a  
Differentiation of the given Holonomic function.

Examples
========

>>> from sympy.holonomic.holonomic import HolonomicFunction, DifferentialOperators
>>> from sympy import ZZ
>>> from sympy import symbols
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(ZZ.old_poly_ring(x),'Dx')
>>> HolonomicFunction(Dx**2 + 1, x, 0, [0, 1]).diff().to_expr()
cos(x)
>>> HolonomicFunction(Dx - 2, x, 0, [1]).diff().to_expr()
2*exp(2*x)

See Also
========

integrate
evaluateTr   r   r8   NFr   )
setdefaultr   r   r   r   r   r   r   r   r~   rW   ra   r   r`   r   r   r   r   r   r   r   r   insert_derivate_diff_eqr   rb   r  r  )rf   argskwargsrR   r   annr   r  seq_dmfrhsr   s              rG   r   HolonomicFunction.diff4  sb   , 	*d+Aw$&& vvTatAwA((47+C (
 >>!

 4 44a66M ^^A#**//"6"66&s~~ab'93::FC##%%&&(E1,S&&$''47712;OO(ff55(ff55 JJOOKKM/2~~>~!55%~> (/qr{3{!71:~{3

1aff  ' vvquuo.QR$"2"2"9"9EJ##%%)<)<)>$)F$S&&11ii!m,QR0 ffdggr::% ? 4s   (LLc                 4   U R                   UR                   :w  d  U R                  UR                  :w  a  gU R                  5       (       aN  UR                  5       (       a9  U R                  UR                  :H  =(       a    U R                  UR                  :H  $ g)NFT)r   r   r   r   r   rn   s     rG   rp   HolonomicFunction.__eq__  sm    u000DFFegg4E!!e&;&;&=&=77ehh&>477ehh+>>rJ   c                 ^  ^^^^^  U R                   n[        U[        5      (       d  [        U5      nUR	                  U R
                  5      (       a  [        S5      eU R                  5       (       d  U $ [        XR                  5      nU Vs/ s H0  n[        R                  " X@R
                  5      U-  R                  PM2     snm[        X R
                  U R                  T5      $ U R                   R                  R                  UR                   R                  R                  :w  a  U R!                  U5      u  mnTU-  $ UR                   nUR                  mUR                  nUR                  R                  nUR#                  5       nUR$                   Vs/ s H!  oHR                  UR'                  5       5      PM#     n	nUR$                   Vs/ s H!  oHR                  UR'                  5       5      PM#     n
n[)        T5       Vs/ s H  oU   * U	T   -  PM     nn[)        U5       Vs/ s H  oU   * X   -  PM     nn[)        TS-   5       VVs/ s H+  n[)        US-   5       Vs/ s H  oR*                  PM     snPM-     nnnUR,                  US   S'   [)        T5       VVs/ s H  n[)        U5        H
  oNU   U   PM     M     snn/n[/        USTU-  4U5      R1                  5       n[.        R2                  " TU-  S4U5      n[5        UU5      nUR6                  (       Ga  [)        TS-
  SS5       H  m[)        US-
  SS5       H  mUT   TS-   ==   UT   T   -  ss'   UTS-      T==   UT   T   -  ss'   [        UT   T   UR8                  5      (       a  [;        UT   T   U5      UT   T'   Mp  UT   T   R=                  U R
                  5      UT   T'   M     M     [)        TS-   5       H\  mUT   U   R>                  (       a  M  [)        U5       H  mUT   T==   UT   UT   U   -  -  ss'   M!     UR*                  UT   U'   M^     [)        U5       HQ  mUT   T   S:X  a  M  [)        T5       H  mUT   T==   UT   UT   T   -  -  ss'   M!     UR*                  UT   T'   MS     URA                  [)        T5       VVs/ s H  n[)        U5        H
  oNU   U   PM     M     snn5        [/        U[C        U5      TU-  4U5      R1                  5       n[5        UU5      nUR6                  (       a  GM  [E        URG                  5       U R                   R                  SS9nU R                  5       (       a  UR                  5       (       d  [        UU R
                  5      $ U RI                  5       S:X  Ga  URI                  5       S:X  Ga  U R                  UR                  :X  Ga_  [        U UR                  5      n[        UUR                  5      nUS   US   -  /n[)        S[K        [C        U5      [C        U5      5      5       H  m[)        TS-   5       Vs/ s H"  n[)        TS-   5       Vs/ s H  nSPM     snPM$     nn[)        TS-   5       H5  m[)        TS-   5       H   nTU-   T:X  d  M  [M        TT5      UT   U'   M"     M7     Sn[)        TS-   5       H/  m[)        TS-   5       H  nUUT   U   UT   -  UU   -  -  nM     M1     URA                  U5        M     [        UU R
                  U R                  U5      $ U R                   RO                  S5      nUR                   RO                  S5      nU R                  S:X  a!  U(       d  U(       d  XRQ                  S5      -  $ UR                  S:X  a"  U(       d  U(       d  U RQ                  S5      U-  $ U R                   RO                  U R                  5      nUR                   RO                  U R                  5      nU(       d$  U(       d  XRQ                  U R                  5      -  $ U RQ                  UR                  5      U-  $ U R                  UR                  :w  a  [        UU R
                  5      $ S mS m U RI                  5       S:X  ah  URI                  5       S:X  aT  [S        U RT                  5       VVs/ s H  u  pU[W        U5      -  PM     nnn[X        RZ                  U0mURT                  m OU RI                  5       S:X  ah  URI                  5       S:X  aT  [S        URT                  5       VVs/ s H  u  pU[W        U5      -  PM     nnnU RT                  m[X        RZ                  U0m O@U RI                  5       S:X  a,  URI                  5       S:X  a  U RT                  mURT                  m 0 nT H  mT  H  m[K        [C        TT   5      [C        T T   5      5      n[)        U5       V^s/ s H5  m[]        UUUUU 4S j[)        TS-   5       5       [X        RZ                  S	9PM7     nnTT-   U;  a
  UUTT-   '   M  [_        UUTT-      5       VVs/ s H  u  nnUU-   PM     snnUTT-   '   M     M     [        UU R
                  U R                  U5      $ s  snf s  snf s  snf s  snf s  snf s  snf s  snnf s  snnf s  snnf s  snf s  snf s  snnf s  snnf s  snf s  snnf )
Nz> Can't multiply a HolonomicFunction and expressions/functions.r8   r   r   Fr   Tc              3   L   >#    U  H  nTT   U   TT   TU-
     -  v   M     g 7frB   ry   )r   r   r   r   r   r  r  s     rG   r   ,HolonomicFunction.__mul__.<locals>.<genexpr>!  s*     H<a"Q%(RU1q5\1<s   !$start)0r   rd   r   r   hasr   r  r   r  r   r0   r   repr   r~   rW   r   r   r   r   r   ra   rb   r1   rL   r   rS   r   r   DMFdiffr   is_zeror   r   r  r   r   minr   r   r  r   r   r   r   r   sumr  )!rf   ro   ann_selfr   r   r   	ann_otherr   r  r   r   r   self_red	other_red	coeff_mullin_sys_elementslin_syshomo_sysrR   sol_anny0_selfy0_othercoeffkr  r  r  r  r  r   r&  r  r  s!       `      `                 ` @@rG   r   HolonomicFunction.__mul__  s	   ##%!233ENEyy  )*jkk''))D..1B=?@R488Avv&.33R@B$XvvtwwCC""''5+<+<+C+C+H+HH::e$DAqq5L%%	NNOOOO  KKM191D1DE1DAUU199;'1D	E2;2F2FG2FQeeAIIK(2F
G ;@(C(Qq\MIaL0(C=B1XFXm^jm3X	F >C1q5\J\eAEl3lffl3\	J%%	!Q 7<AhQha1q\!__hQR/!QqS1=GGI%%qsAh2$Wh7     1q5"b)q1ub"-AaLQ'9Q<?:'a!e$Q'9Q<?:'!)A,q/177;;*1)A,q/1*E	!Q*3A,q/*>*>tvv*F	!Q . * 1q5\Q<?**qAaLOy|il1o'EEO ""#&&	!Q " 1XQ<?a'qAaLOx{Yq\!_'DDO ""#&&	!Q  ##eAh$YhPUVWPX1q\!_PX_h$YZ"#3c:J6KQqS5QSTU__aG((;C?    B SXXZ)9)9)@)@5Q$$&&5+@+@+B+B$Wdff55 E)e.B.B.D.M ww%((" %T7==9%eW]];aj8A;./ q#c'lCM"BCA@Ea!eM1q1u6Aa6EM"1q5\!&q1uA 1uz.6q!na ". *
 C"1q5\!&q1uA58A;
#:Xa[#HHC ". * IIcN D )$&&$''2FF &&2215G((44Q7Hww!|GH..q111xx1}WXq)E11''33DGG<H))55dgg>II..tww777??588,u4477ehh$Wdff55  E)e.B.B.D.L09$''0BC0B1y|#0BCC&&#BB  "d*u/C/C/E/N09%((0CD0C1y|#0CCDB&&#B  "d*u/C/C/E/MBBABqE
C1J/05a:081 HH5Q<H vv'08  :1u{ !Bq1uI36q"QU)3D E3D41aQ3D EBq1uI   !$&&$''2>>g A FG DF 4J RH %Z. 7ML D E:
 !Fsr   7k(k#(k(
k-.k2k<+k7 k<*$l$l
0lll<l8l2<l$l)
7k<lc                     XS-  -   $ r   ry   rn   s     rG   r   HolonomicFunction.__sub__+  s    bj  rJ   c                     U S-  U-   $ r   ry   rn   s     rG   r   HolonomicFunction.__rsub__.  s    by5  rJ   c                     SU -  $ r   ry   r   s    rG   r   HolonomicFunction.__neg__1  r   rJ   c                 .    U [         R                  U-  -  $ rB   r   rn   s     rG   r   HolonomicFunction.__truediv__4  r   rJ   c                 2   U R                   R                  S::  a  U R                   nUR                  nU R                  c  S nO[	        U R                  5      S   U-  /nUR
                  S   nUR
                  S   n[        R                  " XPR                  5      U-  R                  nXV4 Vs/ s H  osR                  R                  U5      PM     nn[        X5      n	[        XR                  U R                  U5      $ US:  a  [        S5      eU R                   R                  R                   n
[        XR                  ["        R$                  ["        R&                  /5      nUS:X  a  U$ U n US-  (       a  X-  nUS-  nU(       d   U$ X-  nM#  s  snf )Nr8   r   z&Negative Power on a Holonomic Functionr   )r   r   r~   r   r   r   r0   r   r   rD  rW   r   r`   r   r   r?   rV   r   r   r   )rf   r   r8  r~   r   p0p1r   rR   ddr^   r   r   s                rG   r   HolonomicFunction.__pow__7  s^   !!Q&""CZZFww477mA&!+,"B"B((2vv&*//B57H=Hq;;''*HC=%c2B$R"==q5#$LMM$$88"2vvqvvw?6M1u!GA FA  >s   /$Fc                 N    [        S U R                  R                   5       5      $ )z6
Returns the highest power of `x` in the annihilator.
c              3   @   #    U  H  oR                  5       v   M     g 7frB   degreer   r   s     rG   r   +HolonomicFunction.degree.<locals>.<genexpr>]  s     C'B!88::'B   )r   r   r   r   s    rG   rg  HolonomicFunction.degreeY  s!     Ct'7'7'B'BCCCrJ   c                 
   U R                   R                  nU R                   R                  nUR                  U R                  5      nU R                   R
                  n[        U5       Hp  u  p[        XR                   R                  R                  R                  5      (       d  M?  U R                   R                  R                  R                  U	5      Xx'   Mr     Xu   R                  U R                  U05      n
[        U5       Vs/ s H&  oU   R                  U R                  U05      * U
-  PM(     nn[        U5       Vs/ s H  n[        R                  PM     nn[        R                  US'   U/n[!        [        U5       Vs/ s H  n[        R                  PM     sn/5      R#                  5       n U Vs/ s H  oR                  U R                  5      PM     nn[        US-
  5       H  nUUS-   ==   X   U-  -  ss'   M     [        U5       H  nUU==   US   X   -  U-  -  ss'   M     UnUR%                  U5        [!        U5      R#                  5       R'                  U5      u  nnUR(                  SLa  OM  [+        U5      S   nUR                  US5      n[-        USS USS9nU(       a  [/        UU R                  US   US   5      $ [/        UU R                  5      $ s  snf s  snf s  snf s  snf )a  
Returns function after composition of a holonomic
function with an algebraic function. The method cannot compute
initial conditions for the result by itself, so they can be also be
provided.

Examples
========

>>> from sympy.holonomic.holonomic import HolonomicFunction, DifferentialOperators
>>> from sympy import QQ
>>> from sympy import symbols
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(QQ.old_poly_ring(x),'Dx')
>>> HolonomicFunction(Dx - 1, x).composition(x**2, 0, [1])  # e^(x**2)
HolonomicFunction((-2*x) + (1)*Dx, x, 0, [1])
>>> HolonomicFunction(Dx**2 + 1, x).composition(x**2 - 1, 1, [1, 0])
HolonomicFunction((4*x**3) + (-1)*Dx + (x)*Dx**2, x, 1, [1, 0])

See Also
========

from_hyper
r   Tr8   r   NFr   )r   r~   r   r   r   r   r   rd   rW   r   r   r!  r   r   r   r   r)   rL   r   gauss_jordan_solver   r   r  r   )rf   r  r6  r7  r   r   r   r   r   r   rF   r!  coeffssystemhomogeneousr  coeffs_nextrR   taustaus                       rG   compositionHolonomicFunction.composition_  s   4 ##""yy %%00
j)DA!--4499??@@ $ 0 0 7 7 < < E Ea H
 * Mt}-@Eq	J	1A##TVVDM22Q6	J"'(+(Q!&&(+EEq	uQx8x!qvvx89:DDF39:6a66$&&>6K:1q5\AE"vy4'78" "1XA6":#7$#>?  FMM&!113$$[1 C!!-  4jmhhsAQR!e4 $S$&&$q'47CC dff--5 K+ 9:s   	-K1K6	K;>$L c           
      
  ^^^ U R                   S:w  a)  U R                  U R                   5      R                  5       $ U R                  R	                  U R                   5      (       a  U R                  US9$ 0 n[        SSS9mU R                  R                  R                  R                  n[        UR                  T5      S5      u  pE[        U R                  R                  5       H  u  nmTR                  5       n[        U5      S-
  n[!        US-   5       H|  n	XxU	-
     n
U
S:X  a  M  Xi-
  U	4U;   a5  X&U	-
  U	4==   UR#                  U
5      [%        TU	-
  S-   U5      -  -  ss'   MQ  UR#                  U
5      [%        TU	-
  S-   U5      -  X&U	-
  U	4'   M~     M     / nU Vs/ s H  ofS   PM	     nn['        U5      m[)        U5      nU R+                  5       nTU-   n0 n/ n/ n[!        TUS-   5       Hm  mTU;   aE  [-        UUU4S jUR/                  5        5       [0        R2                  S	9nUR5                  U5        MN  UR5                  [0        R2                  5        Mo     [7        X5      nUR8                  n[;        UR                  R#                  UR                  S
   5      TSS9nUR=                  5       nU(       a  [)        U5      S-   n[)        UU5      nUU-  n[?        U U5      n[        U5       VVs/ s H  u  nnU[A        U5      -  PM     nnn[        U5      U:  Ga  [!        U5       H  n[0        R2                  nU H  mUTS   -   S:  a  [0        R2                  XTS   -   '   OjUTS   -   [        U5      :  a  UUTS   -      XTS   -   '   OAUTS   -   U;  a5  [        SUTS   -   -  5      XTS   -   '   UR5                  XTS   -      5        TS   U::  d  M  UUT   RC                  TU5      XTS   -      -  -  nM     UR5                  U5        M     [E        U/UQ76 n[G        U[H        5      (       a  [!        [        U5      U5       HK  nXo;  a  [        SU-  5      X'   X   U;   a  UR5                  UX      5        M8  UR5                  X   5        MM     U(       a  [K        UU5      U4/$ [K        UU5      /$ [!        [        U5      U5       Ha  nXo;  a  [        SU-  5      X'   SnU H%  mX   T;   d  M  UR5                  TX      5        SnM'     U(       a  MN  UR5                  X   5        Mc     U(       a  [K        UU5      U4/$ [K        UU5      /$ s  snf s  snnf )a  
Finds recurrence relation for the coefficients in the series expansion
of the function about :math:`x_0`, where :math:`x_0` is the point at
which the initial condition is stored.

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

If the point :math:`x_0` is ordinary, solution of the form :math:`[(R, n_0)]`
is returned. Where :math:`R` is the recurrence relation and :math:`n_0` is the
smallest ``n`` for which the recurrence holds true.

If the point :math:`x_0` is regular singular, a list of solutions in
the format :math:`(R, p, n_0)` is returned, i.e. `[(R, p, n_0), ... ]`.
Each tuple in this vector represents a recurrence relation :math:`R`
associated with a root of the indicial equation ``p``. Conditions of
a different format can also be provided in this case, see the
docstring of HolonomicFunction class.

If it's not possible to numerically compute a initial condition,
it is returned as a symbol :math:`C_j`, denoting the coefficient of
:math:`(x - x_0)^j` in the power series about :math:`x_0`.

Examples
========

>>> from sympy.holonomic.holonomic import HolonomicFunction, DifferentialOperators
>>> from sympy import QQ
>>> from sympy import symbols, S
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(QQ.old_poly_ring(x),'Dx')
>>> HolonomicFunction(Dx - 1, x, 0, [1]).to_sequence()
[(HolonomicSequence((-1) + (n + 1)Sn, n), u(0) = 1, 0)]
>>> HolonomicFunction((1 + x)*Dx**2 + Dx, x, 0, [0, 1]).to_sequence()
[(HolonomicSequence((n**2) + (n**2 + n)Sn, n), u(0) = 0, u(1) = 1, u(2) = -1/2, 2)]
>>> HolonomicFunction(-S(1)/2 + x*Dx, x, 0, {S(1)/2: [1]}).to_sequence()
[(HolonomicSequence((n), n), u(0) = 1, 1/2, 1)]

See Also
========

HolonomicFunction.series

References
==========

.. [1] https://hal.inria.fr/inria-00070025/document
.. [2] https://www3.risc.jku.at/publications/download/risc_2244/DIPLFORM.pdf

r   )lbr   TintegerSnr8   c              3   h   >#    U  H'  u  pUS    T:X  d  M  UR                  TTT-
  5      v   M)     g7fr   Nr!  r   rU  vr   r,  r   s      rG   r   0HolonomicFunction.to_sequence.<locals>.<genexpr>  s9      C'4tq!	 1AFF1a%i00'4   22rA  r   ZfilterC_%sF)&r   shift_xto_sequencer   r   
_frobeniusr   r~   rW   r   r;   r   r   r   
all_coeffsr   r   r   r   rG  r   rg  rH  itemsr   r   r   r:   r   r/   keysr  r   r!  r7   rd   r   r9   )rf   rw  dict1r   r   r   r   	listofdmprg  rU  rT  rR   keylistr-  
smallest_ndummyseqsunknownstempr   	all_rootsmax_rootr   r   u0eqsoleqsr.  r,  r   s                          `    @@rG   r  HolonomicFunction.to_sequence  s   h 77a<<<(4466 ''00??b?))3%%%**.."3#4#4Q#7> d..99:DAqI^a'F6A:&!1*-A:E1:&q5!*%#,,u*=1q519a@P*PQ%),e)<r!a%!)Q?O)OEq5!*% ' ;" !&'AQ4'GG V^
 ueai(AG| C',{{}C!") 

4 

166" ) !( 		!&&//#..*<=qM	NN$	9~)HXz2Je$+4R=9=41aa)A,=9 r7U?6]VVA1Q4x!|+,661Q4x(QqTCG++-a!A$h<1Q4x(1X/+1&1qt82D+E1Q4x( 1Q4x(89tqyeAhmmAq1Fqt84DDD  

2% #* 3**F&$''s2w.A$*619$5	yF*		&"34 		&), / .sB7DEE)#r2333r7E*? &vqy 1FIAyA~		!FI,/    qIIfi( + &sB/<==!#r*++K (J :s   $U)=U.c                   ^^,^- U R                  5       n/ n/ n[        UR                  5       5       HX  nUR                  (       a  UR	                  U/X%   -  5        M-  UR                  5       u  pgUR	                  XVU4/X%   -  5        MZ     UR                  S S9  UR                  S S9  UR                  5         / nU Hk  n[        U5      S:X  a  UR                  U/5        M&  U H-  m[        TS   U-
  5      (       d  M  TR                  U5          MW     UR                  U/5        Mm     [        S U 5       5      n	[        S U 5       5      n
[        S U 5       5      nU R                  5       S:X  aq  / n[        U R                  R                  5       5       HG  n[        UR                  5       5       H'  m[        TU5      (       d  M  UR                  U5        M)     MI     OU
(       a  U(       a  [        U5      /nOU	(       a,  U Vs/ s H  oUS   PM	     snU Vs/ s H  oS   PM	     sn-   nOU(       d$  U Vs/ s H  n[        U5      U:X  a  M  UPM     nnOtU
(       dm  U R!                  5       (       a&  [#        U R                  S   5      R$                  S	:X  a  [        U5      /nO%U Vs/ s H  oUS:  d  M
  UPM     nn[        U5      /n['        S
SS9m-U R(                  R*                  R,                  R.                  n[1        UR3                  T-5      S5      u  nn/ n[5        S5      nW GH  n0 n[7        U R(                  R8                  5       H  u  nmTR;                  5       n[        U5      S-
  n[=        US-   5       H  nUUU-
     nUS:X  a  M  UU-
  UU-
  4U;   a<  UUU-
  UU-
  4==   UR?                  U5      [A        T-U-
  S-   U-   U5      -  -  ss'   M]  UR?                  U5      [A        T-U-
  S-   U-   U5      -  UUU-
  UU-
  4'   M     M     / nU Vs/ s H  oUS   PM	     nn[        U5      m,[C        U5      n[C        S U 5       5      n[        S U 5       5      nT,U-   n0 n/ n / n![=        T,US-   5       Hm  mTU;   aE  [E        UU,U-4S jURG                  5        5       ["        RH                  S9n"UR                  U"5        MN  UR                  ["        RH                  5        Mo     [K        UU5      nURL                  n#[O        UR,                  R?                  UR8                  S   5      T-SS9n$U$R                  5       n$U$(       a  [C        U$5      S-   n%[C        U%U5      nU#U-  n#/ n&U R                  5       S:X  a  U R                  U   n&OU R                  5       S	:X  a  US:  a  [        U5      U:X  a|  [        U5      S:X  am  [Q        U U#[        U5      -   5      n'[        U'5      [        U5      :  a=  [=        [        U5      [        U'5      5       Vs/ s H  nU'U   [S        U5      -  PM     n&n[        U&5      U#:  Ga{  [=        UU5       H  n["        RH                  n(U H  mUTS   -   S:  a  ["        RH                  UUTS   -   '   O{UTS   -   [        U&5      :  a  U&UTS   -      UUTS   -   '   OQUTS   -   U;  aE  [U        U5      SUTS   -   -  -   n)['        U)5      UUTS   -   '   U!R                  UUTS   -      5        TS   U::  d  M  U(UT   RW                  T-U5      UUTS   -      -  -  n(M     U R                  U(5        GM      [Y        U /U!Q76 n*[[        U*[\        5      (       a  [=        [        U&5      U#5       H^  nUU;  a  [U        U5      SU-  -   n)['        U)5      UU'   UU   U*;   a  U&R                  U*UU      5        MJ  U&R                  UU   5        M`     U(       a!  UR                  [_        UU&5      UU45        GM  UR                  [_        UU&5      U45        GM  [=        [        U&5      U#5       Ht  nUU;  a  [U        U5      SU-  -   n)['        U)5      UU'   S	n+U* H'  mUU   T;   d  M  U&R                  TUU      5        Sn+M)     U+(       a  M`  U&R                  UU   5        Mv     U(       a  UR                  [_        UU&5      UU45        OUR                  [_        UU&5      U45        US-  nGM     U$ s  snf s  snf s  snf s  snf s  snf s  snf )Nc                     U S   $ )Nr8   ry   r   s    rG   rH   .HolonomicFunction._frobenius.<locals>.<lambda>j      !A$rJ   )keyc                     U S   $ Nr   ry   r  s    rG   rH   r  k  r  rJ   r   c              3   >   #    U  H  n[        U5      S :H  v   M     g7fr8   N)r   rh  s     rG   r   /HolonomicFunction._frobenius.<locals>.<genexpr>~  s     3s!#a&A+ss   c              3   *   #    U  H	  oS :  v   M     g7fr|  ry   rh  s     rG   r   r    s     +U!VU   c              3   8   #    U  H  n[        U5      v   M     g 7frB   )r   rh  s     rG   r   r    s     2EqZ]]Es   TFr   rx  rz  Cr8   c              3   *   #    U  H	  oS    v   M     g7fr  ry   rh  s     rG   r   r    s     -u!1ur  c              3   *   #    U  H	  oS    v   M     g7fr  ry   rh  s     rG   r   r    s     .1A$r  c              3   h   >#    U  H'  u  pUS    T:X  d  M  UR                  TTT-
  5      v   M)     g7fr|  r}  r~  s      rG   r   r    s9       G+841AaDAI !5q!e) 4 4+8r  rA  r   r  r  z_%s)0	_indicialr   r  is_realextendas_real_imagsortr   r   r   r   r   r   r   rG  r   r   r   	is_finiter   r   r~   rW   r   r;   r   ordr   r   r  r   r   r   r   rH  r  r   r:   r   r/   r  r   chrr!  r7   rd   r   r9   ).rf   rw  indicialrootsrealscomplr   r   r   grpindependentallposallintrootstoconsiderr   posrootsr   r   r   finalsolcharr  r  r  rg  rU  rT  rR   r  r-  degree2r  r  r  r  r  r   r  r  r  r   r  letterr  r.  r,  r   s.                `                              @@rG   r  HolonomicFunction._frobenius\  si   (++-.AyyaS=#334~~'qQi[=+;;< / 	


'


'

 A3x1}

A3adQh''HHQK 
 

A3  3s33+U++2E22  D( OTWW\\^, !3!3!56A#Aq))'..q1 7 -
 "5zlO-01StS154I5aqT54IIO*/C%Qs1v{q%OCO''))Qtwwqz]-D-D-N#&u:, (-7u!QAu7#&x=/3%%%**.."3#4#4Q#7>13x AE!$"2"2"="=>1LLN	Y!+vz*A%fqj1Ez Aq1u~.q1ua!en-#,,u2E1q5ST9WX=Z[H\2\]-14e1Dr!a%RS)VW-YZG[1[q1ua!en- + ?  C%*+UtUG+LELE-u--F...GJFCH5%!),<  G+0;;= G%&VV-D JJt$JJqvv& - %S!,C IIEaffoocnnR.@A1SQI!(Iy>A- :6
ZEB""$,WWQZ$$&%/AFs1v{sSbOcghOhec!fn5r7SV#8=c!fc"g8NO8N1"Q%)A,.8NBO2ww/AB"qt8a</0vvF1qt8,1XB//1!ad(|F1qt8,!"QqTV!3%(YQqT1B%BF/5f~F1qt8,$OOF1qt8,<=Q419%(--1"5q1Q4x8H"HHB # JJrN% 0* s.X.fd++"3r7E2F?%(Y%9F(.vF1I!!9.IIfVAY&78 IIfQi0 3  ):3)CQ
(ST  ):3)CQ(GH s2w.A!$TUAX!5$*6Nq	A#!!9>IIaq	l3 $A $ 1		&), / !23!;Q
 KL !23!;Q ?@AIDA !B m 24I D 8< ,T Ps0   d&%d+d0d07	d5d5-d:/d?c                   ^^^^^ Uc  U R                  5       nOUn[        U[        5      (       a  [        U5      S:X  a  US   nSmO[        U[        5      (       a  [        U5      S:X  a  US   mUS   nO}[        U5      S:X  a  [        US   5      S:X  a  US   S   nSmOQ[        U5      S:X  a#  [        US   5      S:X  a  US   S   mUS   S   nOU Vs/ s H  o`R	                  US9PM     sn$ U[        T5      -
  n[        UR                  5      S-
  nUR                  R                  nU R                  mU R                  n	UR                  R                  n
UR                  R                  R                  nUR                  5       nU
 Vs/ s H!  oR                  UR!                  5       5      PM#     nn[#        U5       Vs/ s H  onU   * X   -  PM     snm[%        UR                  5      mUS-   U:  aY  [#        US-   U-
  X-
  5       HA  m['        UUU4S j[#        U5       5       [(        R*                  S9nTR-                  U5        MC     U(       a  T$ ['        UU4S j[/        T5       5       [(        R*                  S9nU(       a  U[1        TU[        T5      -   -  T5      -  nU	S:w  a  UR3                  TTU	-
  5      $ U$ s  snf s  snf s  snf )	a  
Finds the power series expansion of given holonomic function about :math:`x_0`.

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

A list of series might be returned if :math:`x_0` is a regular point with
multiple roots of the indicial equation.

Examples
========

>>> from sympy.holonomic.holonomic import HolonomicFunction, DifferentialOperators
>>> from sympy import QQ
>>> from sympy import symbols
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(QQ.old_poly_ring(x),'Dx')
>>> HolonomicFunction(Dx - 1, x, 0, [1]).series()  # e^x
1 + x + x**2/2 + x**3/6 + x**4/24 + x**5/120 + O(x**6)
>>> HolonomicFunction(Dx**2 + 1, x, 0, [0, 1]).series(n=8)  # sin(x)
x - x**3/6 + x**5/120 - x**7/5040 + O(x**8)

See Also
========

HolonomicFunction.to_sequence
r   r   r  r8   )_recurc              3   j   >#    U  H(  nTU-   S :  d  M  [        TU   T5      TTU-      -  v   M*     g7fr|  )DMFsubs)r   r   r   rR   subs     rG   r   +HolonomicFunction.series.<locals>.<genexpr>i  s<      =%-Q! =WSVQ/#a!e*<%-s   33rA  c              3   >   >#    U  H  u  pTUT-   -  U-  v   M     g 7frB   ry   )r   r   r   constantpowerr   s      rG   r   r  p  s"     I.$!1q=()A-.   )r  rd   tupler   seriesr   r  
recurrencer   r   r   r   r~   rW   r   r   r   r   r   rH  r   r   r   r   r4   r!  )rf   r   coefficientr   r  r  r   lrU  r   seq_dmpr   r  r   seqrT  serr  rR   r  r   s         `          @@@@rG   r  HolonomicFunction.series(  s   : >))+JJj%((S_-A#AJM
E**s:!/C&qMM#AJ_!c*Q-&8A&=#Aq)JM_!c*Q-&8A&=&qM!,M#Aq)J3=>:aKKqK):>>M""
"!!''FFWW''22!!((--KKM+237auuQYY[!73).q2AAw2:==!q5191q519ae, =%*1X=DEFFL

5! -
 JI)C.I 5Q]!334a88C788Aq2v&&
= ? 42s   K(K	Kc                   ^	^
^^^ U R                   S:w  a)  U R                  U R                   5      R                  5       $ U R                  R                  nU R                  R
                  R                  m	U R                  mT	R                  nT	R                  nU	U4S jm
[        S U 5       5      nS[        SU5      [        SU R                  R                  5      -   -  mU
U4S jm[        U4S j[        U5       5       5      n[        U5       H[  u  pgUR                  5       n[        U5      S-
  nSXe-   s=::  a  U::  a  O  OX(XF-
  U-
     U-  -   nUT	R!                  TU-
  5      -  nM]     [#        T	R%                  U5      T5      $ )z*
Computes roots of the Indicial equation.
r   c                 l   > [        TR                  U 5      TSS9nSUR                  5       ;   a  US   $ g)Nr  r  r   )r/   r   r  )polyroot_allr   r   s     rG   _pole_degree1HolonomicFunction._indicial.<locals>._pole_degree  s5    QZZ-q=HHMMO#{"rJ   c              3   @   #    U  H  oR                  5       v   M     g 7frB   rf  )r   r   s     rG   r   .HolonomicFunction._indicial.<locals>.<genexpr>  s     4AXXZZrj  
   r8   c                 :   > U R                   (       a  T$ T" U 5      $ rB   )rF  )qr  infs    rG   rH   -HolonomicFunction._indicial.<locals>.<lambda>  s    qyy=l1o=rJ   c              3   >   >#    U  H  u  pT" U5      U-
  v   M     g 7frB   ry   )r   r   r  degs      rG   r   r    s     ='<tqA
'<r  )r   r  r  r   r   r~   rW   r   ra   rb   r   r   rG  r   r  r   r   r/   r   )rf   
list_coeffr.  yrg  r   r   r   r  r   r  r  r  r   s            @@@@@rG   r  HolonomicFunction._indicialx  sG   
 77a<<<(2244%%00
##((FFFFEE	 444C6NSD,<,<,B,B%CCD==y'<==j)DAI^a'FAE#V#&*q.1A55a!e$$A * QZZ]A&&rJ   c                    SSK Jn  Sn[        US5      (       d  Sn[        U5      nU R                  U:X  a  U" X/X$S9S   $ UR
                  (       d  [        eU R                  nX:  a  U* n[        Xx-
  U-  5      n	X-   /n[        U	S-
  5       H  n
UR                  US   U-   5        M     [        U R                  R                  R                  R                  U R                  R                  S   5      U R                   5       H"  n
XR                  :X  d  X;   d  M  [#        X
5      e   U(       a
  U" XX$S9S   $ U" XX$S9$ )	a  
Finds numerical value of a holonomic function using numerical methods.
(RK4 by default). A set of points (real or complex) must be provided
which will be the path for the numerical integration.

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

The path should be given as a list :math:`[x_1, x_2, \dots x_n]`. The numerical
values will be computed at each point in this order
:math:`x_1 \rightarrow x_2 \rightarrow x_3 \dots \rightarrow x_n`.

Returns values of the function at :math:`x_1, x_2, \dots x_n` in a list.

Examples
========

>>> from sympy.holonomic.holonomic import HolonomicFunction, DifferentialOperators
>>> from sympy import QQ
>>> from sympy import symbols
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(QQ.old_poly_ring(x),'Dx')

A straight line on the real axis from (0 to 1)

>>> r = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]

Runge-Kutta 4th order on e^x from 0.1 to 1.
Exact solution at 1 is 2.71828182845905

>>> HolonomicFunction(Dx - 1, x, 0, [1]).evalf(r)
[1.10517083333333, 1.22140257085069, 1.34985849706254, 1.49182424008069,
1.64872063859684, 1.82211796209193, 2.01375162659678, 2.22553956329232,
2.45960141378007, 2.71827974413517]

Euler's method for the same

>>> HolonomicFunction(Dx - 1, x, 0, [1]).evalf(r, method='Euler')
[1.1, 1.21, 1.331, 1.4641, 1.61051, 1.771561, 1.9487171, 2.14358881,
2.357947691, 2.5937424601]

One can also observe that the value obtained using Runge-Kutta 4th order
is much more accurate than Euler's method.
r   )_evalfFr  T)methodderivativesr   r8   )sympy.holonomic.numericalr  r  r   r   r#  r  r   r   r   r/   r   r~   rW   r   r   r   r>   )rf   pointsr  hr  r  lpr   r   r   r   s              rG   r"  HolonomicFunction.evalf  s2   \ 	5 vz**B&	Aww!|dCPQSTT;;))AuBQUaK AeWF1q5\fRj1n- " t''..33<<T=M=M=X=XY[=\]_c_e_efAGG|q{&t// g $vOPRSSd6KKrJ   c                 h   U R                   R                  R                  R                  nUR	                  U5      n[        US5      u  pEU R                   R                   Vs/ s H  oc" UR                  5       5      PM     nn[        Xt5      n[        XqU R                  U R                  5      $ s  snf )z}
Changes only the variable of Holonomic Function, for internal
purposes. For composition use HolonomicFunction.composition()
r^   )r   r~   rW   r   r   rZ   r   r   r`   r   r   r   )rf   zr   r   r~   r   r   rR   s           rG   change_xHolonomicFunction.change_x  s     %%**..a )!T2	'+'7'7'B'BC'B!q~'BC#C0 $'':: Ds   "B/c           
         U R                   nU R                  R                  nU R                  R                  R                  nU Vs/ s H4  oTR                  UR                  U5      R                  X"U-   5      5      PM6     nn[        X`R                  R                  5      nU R                  U-
  nU R                  5       (       d  [        Xb5      $ [        XbXpR                  5      $ s  snf )z
Substitute `x + a` for `x`.
)r   r   r   r~   rW   r   r   r!  r`   r   r   r   r   )rf   r   r   listaftershiftrW   r   rR   r   s           rG   r  HolonomicFunction.shift_x  s    
 FF))44&&++IWXAt}}Q/44QA>?X"3(8(8(?(?@WWq[##%%$S,, WW55 Ys   ;C(c                 \  ^ Uc  U R                  5       nOUn[        U[        5      (       a  [        U5      S:X  a  US   nUS   nSnO[        U[        5      (       a  [        U5      S:X  a  US   nUS   nUS   nO[        U5      S:X  a%  [        US   5      S:X  a  US   S   nUS   S   nSnOk[        U5      S:X  a+  [        US   5      S:X  a  US   S   nUS   S   nUS   S   nO1U R	                  XS   S9nUSS  H  nX`R	                  XS9-  nM     U$ UR
                  nUR                  mU R                  n	U R                  n
TR                  nUS:X  Gak  [        TR                  R                  R                  TR                  S   5      UR                  SS9n[         R"                  n[%        U5       H  u  pUS:  d  ['        U5      (       d  M  [)        U5      nU[        U5      :  a?  [        X   [*        [,        45      (       a  X   R/                  5       X'   XhU   X-  -  -  nMv  U[1        S	U-  5      X-  -  -  nM     [        U[*        [,        45      (       a  UR/                  5       X-  -  nOXiU-  -  nU(       a   U
S:w  a  UR3                  XU
-
  5      4/$ U4/$ U
S:w  a  UR3                  XU
-
  5      $ U$ XK-   [        U5      :  a  [5        S
5      e[7        U4S jTR                  SS  5       5      (       a  [9        X R                  5      eTR                  S   nTR                  S   n[        UR;                  5       [*        [,        45      (       aw  [!        UR;                  5       R/                  5       5      XR=                  5       -  -  * [!        UR;                  5       R/                  5       5      XR=                  5       -  -  -  nOZ[!        UR;                  5       5      XR=                  5       -  -  * [!        UR;                  5       5      XR=                  5       -  -  -  nSn[        TR                  R                  R                  U5      UR                  5      n[        TR                  R                  R                  U5      UR                  5      nU(       a  / n[?        XK-   5       GH  nXt:  aV  U(       a8  WRA                  [!        X   5      XU-   -  -  R3                  XU
-
  5      45        OU[!        X   5      X-  -  -  nM_  [!        X   5      S:X  a  Mr  / n/ n[C        URE                  5       5       H*  nURG                  [I        UU-
  U-  5      /UU   -  5        M,     [C        URE                  5       5       H*  nURG                  [I        UU-
  U-  5      /UU   -  5        M,     SU;   a  URK                  S5        OURA                  S5        U(       a]  WRA                  [!        X   5      XU-   -  -  R3                  XU
-
  5      [M        UUUX-  -  5      R3                  XU
-
  5      45        GM  U[!        X   5      [M        UUUX-  -  5      -  X-  -  -  nGM     U(       a  W$ XiU-  -  nU
S:w  a  UR3                  XU
-
  5      $ U$ )a)  
Returns a hypergeometric function (or linear combination of them)
representing the given holonomic function.

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

Returns an answer of the form:
`a_1 \cdot x^{b_1} \cdot{hyper()} + a_2 \cdot x^{b_2} \cdot{hyper()} \dots`

This is very useful as one can now use ``hyperexpand`` to find the
symbolic expressions/functions.

Examples
========

>>> from sympy.holonomic.holonomic import HolonomicFunction, DifferentialOperators
>>> from sympy import ZZ
>>> from sympy import symbols
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(ZZ.old_poly_ring(x),'Dx')
>>> # sin(x)
>>> HolonomicFunction(Dx**2 + 1, x, 0, [0, 1]).to_hyper()
x*hyper((), (3/2,), -x**2/4)
>>> # exp(x)
>>> HolonomicFunction(Dx - 1, x, 0, [1]).to_hyper()
hyper((), (), x)

See Also
========

from_hyper, from_meijerg
Nr   r8   r   r  )as_listr  r   r  r  z+Can't compute sufficient Initial Conditionsc              3   h   >#    U  H'  oTR                   R                  R                  :g  v   M)     g 7frB   r   r   r   rF   s     rG   r   -HolonomicFunction.to_hyper.<locals>.<genexpr>m  s$     C0B1AHHMM&&&0Bs   /2r   )'r  rd   r  r   to_hyperr  r  r   r   r   r/   r~   rW   r   r   r   r   r   r   r   r   r*   r+   as_exprr   r!  r  anyr=   LCrg  r   r   r   r  r  r6   remover&   )rf   r  r  r  r  r  rR   r   r  r   r   mnonzerotermsr   r   r   r&  arg1arg2	listofsolapbqrU  rF   s                          @rG   r  HolonomicFunction.to_hyper  s   F >))+JJj%((S_-A#AJ#AJM
E**s:!/C#AJ&qMM#AJ_!c*Q-&8A&=#Aq)J#Aq)JM_!c*Q-&8A&=#Aq)J&qM!,M#Aq)J--1-FC^}}W}?? $J]]!!FFWW GG 6 !7!7Q!H*,,_bcL&&C!,/q5
1Fs2w;!"%+{)CDD "a514<'C 6&!),qt33C 0 #[9::kkma&66},,7 XXaR0344y Qwxxr6**J>CG#%&STT CQr0BCCC%dGG44LLOLL addf{K899QTTV^^%&XXZ89Qqttv~~?O=PSTW_W_WaSb=bcAQTTV9q88:./1QTTV9q88:3NOAQXX]]++A.
=QXX]]++A.
= Iz~&A ~$$qx!o2F'F&L&LQRTPT&U%XY1RU8ad?*C
 x1}BB TYY[)		9a!eq[12T!W<= * TYY[)		9a!eq[12T!W<= * Bw		!		!  1RU8A-,@#@"F"FqB$"ORWXZ\^`abcbf`fRgQmQmnosuquQv!wxqx%BAD"99AD@@K 'L }$$788A2v&&
rJ   c                 P    [        U R                  5       5      R                  5       $ )a  
Converts a Holonomic Function back to elementary functions.

Examples
========

>>> from sympy.holonomic.holonomic import HolonomicFunction, DifferentialOperators
>>> from sympy import ZZ
>>> from sympy import symbols, S
>>> x = symbols('x')
>>> R, Dx = DifferentialOperators(ZZ.old_poly_ring(x),'Dx')
>>> HolonomicFunction(x**2*Dx**2 + x*Dx + (x**2 - 1), x, 0, [0, S(1)/2]).to_expr()
besselj(1, x)
>>> HolonomicFunction((1 + x)*Dx**3 + Dx**2, x, 0, [1, 1, 1]).to_expr()
x*log(x + 1) + log(x + 1) + 1

)r5   r  simplifyr   s    rG   r   HolonomicFunction.to_expr  s    & 4==?+4466rJ   c                    SnUcB  [        U R                  5      U R                  R                  :  a  [        U R                  5      nU R                  R                  R
                  R                  n [        U R                  5       U R                  XUS9nU(       a  WR                  U:X  a  U$ U R                  USS9n[        U R                  U R                  X5      $ ! [        [        4 a    Sn N^f = f)a  
Changes the point `x0` to ``b`` for initial conditions.

Examples
========

>>> from sympy.holonomic import expr_to_holonomic
>>> from sympy import symbols, sin, exp
>>> x = symbols('x')

>>> expr_to_holonomic(sin(x)).change_ics(1)
HolonomicFunction((1) + (1)*Dx**2, x, 1, [sin(1), cos(1)])

>>> expr_to_holonomic(exp(x)).change_ics(2)
HolonomicFunction((-1) + (1)*Dx, x, 2, [exp(2)])
T)r   r   lenicsrD   F)r  )r   r   r   r   r~   rW   rD   expr_to_holonomicr   r   r<   r=   r   r"  r   )rf   r   r  symbolicr   rR   r   s          rG   r  HolonomicFunction.change_ics  s    $ >c$''lT-=-=-C-CC\F%%**11	#DLLNdffZ]^C !JZZtZ, !1!14661AA $%89 	H	s   3$C! !C65C6c                     U R                  SS9n[        R                  nU HB  n[        U5      S:X  a	  X#S   -  nM  [        U5      S:X  d  M,  X#S   [	        US   5      -  -  nMD     U$ )a  
Returns a linear combination of Meijer G-functions.

Examples
========

>>> from sympy.holonomic import expr_to_holonomic
>>> from sympy import sin, cos, hyperexpand, log, symbols
>>> x = symbols('x')
>>> hyperexpand(expr_to_holonomic(cos(x) + sin(x)).to_meijerg())
sin(x) + cos(x)
>>> hyperexpand(expr_to_holonomic(log(x)).to_meijerg()).simplify()
log(x)

See Also
========

to_hyper
T)r  r8   r   r   )r  r   r   r   _hyper_to_meijerg)rf   rD  rR   r   s       rG   
to_meijergHolonomicFunction.to_meijerg  sj    , mmDm)ffA1v{tQ1t/!555  
rJ   )r   r   r   r   r|  FT)   FTN)RK4g?F)FNrB   )&rr   rs   rt   ru   rv   r   rg   rj   rw   r   r   r   r   r   r  r   rp   r   r   r   r   r   r   r   rg  rt  r  r  r  r  r"  r  r  r  r   r  r  rx   ry   rJ   rG   r   r   t  s    @D L: H< LO;b}?~K;Z_?B H!!& DD>.@{,zJXN`"'HILV;6 n`7*!BF rJ   r   Fc           	         U R                   nU R                  nU R                  S   nUR                  [        5      R                  5       n[        [        R                  " U5      S5      u  pxXh-  n	Sn
U H
  nXU-   -  n
M     U	S-
  nUnU H
  nXU-   -  nM     X-
  n[        U 5      nU[        [        4;   a  [        X5      R                  U5      $ [        U[        5      (       d\  [!        UXaUR"                  SS9nU(       d$  US-  n[!        UXaUR"                  SS9nU(       d  M$  [        X5      R                  XQU5      $ [        U[        5      (       a`  Sn[!        UXaUR"                  USS9nU(       d%  US-  n[!        UXaUR"                  USS9nU(       d  M%  [        X5      R                  XQU5      $ [        X5      R                  U5      $ )a  
Converts a hypergeometric function to holonomic.
``func`` is the Hypergeometric Function and ``x0`` is the point at
which initial conditions are required.

Examples
========

>>> from sympy.holonomic.holonomic import from_hyper
>>> from sympy import symbols, hyper, S
>>> x = symbols('x')
>>> from_hyper(hyper([], [S(3)/2], x**2/4))
HolonomicFunction((-x) + (2)*Dx + (x)*Dx**2, x, 1, [sinh(1), -sinh(1) + cosh(1)])
r   r^   r8   F	use_limit)r  r  r6  atomsr   poprZ   r,   r   r5   r   r   r   rt  rd   r&   _find_conditionsr   )funcr   r"  r   r   r  r   r   r^   xDxr1aixDx_1r2birR   simpr   s                     rG   
from_hyperr&    s     	AA		!A	A!""2"21"5t<EA $C	
B
Bh !GE	B
bj 
'CtD*++ (44Q77 dE""dA399F !GB!$syyEJB " !(44QB??$dA399euM!GB!$syy%5QB " !(44QB??S$0033rJ   Tc           	      n   U R                   nU R                  n[        U R                  5      n[        U R                  5      n[        U5      n	U R
                  S   n
U
R                  [        5      R                  5       n[        UR                  U5      S5      u  pX-  nUS-   nUSX-   U	-
  -  -  nU H  nUUU-
  -  nM     SnU H  nUUU-
  -  nM     UU-
  nU(       d  [        UU5      R                  U
5      $ [        U 5      nU[        [        4;   a  [        UU5      R                  U
5      $ [!        U["        5      (       d]  [%        UXUR&                  SS9nU(       d$  US-  n[%        UXUR&                  SS9nU(       d  M$  [        UU5      R                  XU5      $ [!        U["        5      (       aa  Sn[%        UXUR&                  USS9nU(       d%  US-  n[%        UXUR&                  USS9nU(       d  M%  [        UU5      R                  XU5      $ [        UU5      R                  U
5      $ )a  
Converts a Meijer G-function to Holonomic.
``func`` is the G-Function and ``x0`` is the point at
which initial conditions are required.

Examples
========

>>> from sympy.holonomic.holonomic import from_meijerg
>>> from sympy import symbols, meijerg, S
>>> x = symbols('x')
>>> from_meijerg(meijerg(([], []), ([S(1)/2], [0]), x**2/4))
HolonomicFunction((1) + (1)*Dx**2, x, 0, [0, 1/sqrt(pi)])
r   r^   r8   r   Fr  )r  r  r   anbmr6  r  r   r  rZ   r   r   rt  r5   r   r   rd   r'   r  r   )r  r   r"  r  rD   r   r   r   r   r  r  r   r   r^   r  xDx1r   r!  r#  r$  rR   r%  r   s                          rG   from_meijergr+  N  s     	AADGGADGGAAA		!A	A!&"6"6q"94@EA $C7D	
B!%!)	B
dRi  
B
cBh 
r'C a(44Q77tD*++ a(44Q77 dG$$dA399F!GB!$syyEJB " !a(44QB??$  dA399euM!GB!$syy%5QB " !a(44QB??S!$0033rJ   x_1N)_mytypec           
      	   [        U 5      n U R                  nU(       d+  [        U5      S:X  a  UR                  5       nO![	        S5      eX;   a  UR                  U5        [        U5      nUcH  U R                  [        5      (       a  [        nO[        n[        U5      S:w  a  XX   R                  5       n[        XX#XEUS9n	U	(       a  U	$ [        (       d  Uq0 q[        [        US9  OU[        :w  a  Uq0 q[        [        US9  U R                   (       Ga  U R#                  U[$        5      n
['        U
[$        5      nU[        ;   a!  [        U   nUS   S   R)                  U5      nO[+        XSUS9nU(       d  [,        eU(       a  X=l        U(       d  U(       d  X-l        U$ U(       d  UR2                  R4                  n[7        XX$5      nU(       d  US-  n[7        XX$5      nU(       d  M  [9        UR2                  XU5      $ U(       d  U(       d3  UR;                  U R<                  S   5      nU(       a  X=l        X-l        U$ U(       d  UR2                  R4                  n[7        XX$5      nU(       d  US-  n[7        XX$5      nU(       d  M  UR;                  U R<                  S   X.5      $ U R<                  nU R>                  n
[A        US   USUS9nU
[B        L a/  [E        S[        U5      5       H  nU[A        UU   USUS9-  nM     OHU
[F        L a/  [E        S[        U5      5       H  nU[A        UU   USUS9-  nM     OU
[H        L a  XS   -  nX-l        U(       d  [,        eU(       a  X=l        U(       d  U(       d  U$ UR.                  (       a  U$ U(       d  UR2                  R4                  nUR2                  RK                  U5      (       a  URM                  5       n[        U5      n[        U5      S:X  a}  UUS      [N        RP                  :X  ac  US   nXU-
  U-  -  n[7        UXU5      n[S        U5       VVs/ s H  u  nnU[U        U5      -  PM     nnnUU0n[9        UR2                  XU5      $ [7        XX$5      nU(       d  US-  n[7        XX$5      nU(       d  M  [9        UR2                  XU5      $ s  snnf )	a  
Converts a function or an expression to a holonomic function.

Parameters
==========

func:
    The expression to be converted.
x:
    variable for the function.
x0:
    point at which initial condition must be computed.
y0:
    One can optionally provide initial condition if the method
    is not able to do it automatically.
lenics:
    Number of terms in the initial condition. By default it is
    equal to the order of the annihilator.
domain:
    Ground domain for the polynomials in ``x`` appearing as coefficients
    in the annihilator.
initcond:
    Set it false if you do not want the initial conditions to be computed.

Examples
========

>>> from sympy.holonomic.holonomic import expr_to_holonomic
>>> from sympy import sin, exp, symbols
>>> x = symbols('x')
>>> expr_to_holonomic(sin(x))
HolonomicFunction((1) + (1)*Dx**2, x, 0, [0, 1])
>>> expr_to_holonomic(exp(x))
HolonomicFunction((-1) + (1)*Dx, x, 0, [1])

See Also
========

sympy.integrals.meijerint._rewrite1, _convert_poly_rat_alg, _create_table
r8   z%Specify the variable for the functionr   )r   r   r  rD   r  )rD   Fr  rD   )r   r  rD   )+r   free_symbolsr   r  
ValueErrorr  r   rC  r	   r-   r,   r   _convert_poly_rat_alg_lookup_tabledomain_for_table_create_tableis_Functionr!  r,  r-  r  _convert_meijerintr  r   r   r   r   r  r   rt  r6  r  r  r   r   r   r   r   r  r   r   r   r   )r  r   r   r   r  rD   r  syms
extra_symssolpolyftr  rR   r  r6  r   rF   gsingular_icsr   s                        rG   r  r    s   R 4=DDt9>xxzADEE	
AdJ~88E??FFz?a'113F $D&bjkG =!mF3	#	#!mF3 IIaAsOa AA$q'""1%C$TuVLC))
.."4B7Ca&t; c %S__aSAAX//$))A,/CFJ__**Ft3!GB"4B7C # tyy|R55 99D		A
DGq5
HCCxq#d)$A$T!WE&QQC % 
cq#d)$A$T!WE&QQC % 
c7lF!!		

vv
&&
""2&&MMOGq6Q;1QqT7aee+!AB{"A+Aqf=L9B<9PQ9PAA	!,9PLQL!B$S__aR@@
4B
/C
at3 c S__aS99 Rs   S c                    / n/ nUR                   nUR                  5       nUR                  [        R                  5      n/ n[        U 5       H  u  p[        XR                  5      (       a/  UR                  UR                  U
R                  5       5      5        OU[        XR                  5      (       d*  UR                  UR                  [        U
5      5      5        OUR                  U
5        UR                  X   R                  5       5        UR                  X   R                  5       5        M     U H  n	U	R                  U5      nM     U(       a  U* nUR                  UR                  5       5      n[        U5       H  u  pX-  X'   M     U" US   R                  5       US   R                  5       -  R                  5       5      nU H  n	U	R                  U5      nM     UR                  UR                  5       5      n[        U5       H@  u  pX-  nU" UR                  5       UR                  5       -  R                  5       5      X'   MB     [!        X5      $ )z
Normalize a given annihilator
r   )rW   r   r   r   r   r   rd   r   r   r   r   r   numerdenomlcmgcdr`   )list_ofr~   r   numrA  rW   r  	lcm_denomlist_of_coeffr   r   	gcd_numerfrac_anss                rG   r  r  ;	  s   
 CE;;DA&IM '"a$$  qyy{!34Aww''  gaj!9:  # 	

=#))+, 	]%++-. # EE)$	  J	i'')*I -(= ) mB'--/-2C2I2I2KKTTVWI EE)$	  i'')*I -(=!1HNN4D!D M M OP )  66rJ   c                     / n[        U 5      S-
  nUR                  [        U S   U5      5        [        U SS 5       H$  u  pEUR                  [        XQ5      X   -   5        M&     UR                  X   5        U$ )a  
Let a differential equation a0(x)y(x) + a1(x)y'(x) + ... = 0
where a0, a1,... are polynomials or rational functions. The function
returns b0, b1, b2... such that the differential equation
b0(x)y(x) + b1(x)y'(x) +... = 0 is formed after differentiating the
former equation.
r8   r   N)r   r   rE  r   )r   r  rR   r   r   r   s         rG   r5  r5  t	  sq     CJ!AJJwz!}a()*QR.)

71=:=01 * JJz}JrJ   c                 |   U R                   nU R                  n[        S U 5       5      (       a  [        U 5      $ U R                  S   nS U 5       nSn[
        R                  4nS U 5       n[
        R                  nU H  n	U[        U	5      -  nM     U H  n	U[        U	5      -  nM     U[        XEXgU* 5      -  $ )z 
Converts a `hyper` to meijerg.
c              3   T   #    U  H  oS :*  =(       a    [        U5      U:H  v   M      g7fr|  )r   rh  s     rG   r   $_hyper_to_meijerg.<locals>.<genexpr>	  s"     
.2a6!c!fk!2s   &(r   c              3   ,   #    U  H
  nS U-
  v   M     g7fr  ry   rh  s     rG   r   rM  	  s     	A!a%   ry   c              3   ,   #    U  H
  nS U-
  v   M     g7fr  ry   rh  s     rG   r   rM  	  s     
"Q1q5"rO  )
r  r  r  r5   r6  r   r   r   r%   r'   )
r  r  r  r  r(  anpr)  bmqrU  r   s
             rG   r  r  	  s     
B	B

.2
...4  		!A 
	B
C
&&B
"
C	AaL  aL  wr!,,,rJ   c                    [        U 5      [        U5      ::  a3  [        X5       VVs/ s H	  u  p#X#-   PM     snnU[        U 5      S -   nU$ [        X5       VVs/ s H	  u  p#X#-   PM     snnU [        U5      S -   nU$ s  snnf s  snnf )znTakes polynomial sequences of two annihilators a and b and returns
the list of polynomials of sum of a and b.
N)r   r  )list1list2r   r   rR   s        rG   r   r   	  s     5zSZ!$U!23!2qu!23eCJK6HH J "%U!23!2qu!23eCJK6HHJ 43s   A?Bc                 :   U R                   R                  U R                  5      (       d  U R                  5       S:X  a  U R                  $ U R                   nUR
                  n/ nU R                  nUR                  R                  nUR                  5       nUR                   Ha  n[        XR                  R                  R                  5      (       d  M3  UR                  UR                  UR                  5       5      5        Mc     [        U5      U:  d  U[        U5      ::  a  U$ [!        U5       V	s/ s H  n	XI   * XC   -  PM     n
n	US[#        [        U5      U5       n[!        X-
  5       H  nSn[%        X5       Hd  u  p>['        XR                  5      n[)        USS5      (       d  Us  s  $ [        U[*        [,        45      (       a  UR/                  5       nXU-  -  nMf     UR                  U5        [1        X5      n
M     X[[        U5      S -   $ s  sn	f )zm
Tries to find more initial conditions by substituting the initial
value point in the differential equation.
TNr   r  )r   r   r   r   r   r   r~   rW   r   r   rd   r   r   r   r   r   r   rG  r  r  getattrr*   r+   r  r5  )	Holonomicr   r   r   r   r   r   r  r   r   list_redr  r   rR   r   rF   s                   rG   r  r  	  s    ((66):R:R:TX\:\||''KAJ	BA	A##a++006677aeeAIIK01 $ 2w{a3r7l	q#!A .!  #	SR!_	B15\%DA<<(A1k400	!k;788IIKq5LC & 			#$X1  3r78#s   5Hc                 4   [        U [        5      (       d  U R                  5       $ UR                  U 5      nUR	                  U 5      nU* UR                  5       -  X2R                  5       -  -   nUS-  nU" UR                  5       UR                  5       45      $ r  )rd   r.   r   r@  rA  r   )fracr  r  r  sol_num	sol_denoms         rG   rE  rE  	  s|    dC  yy{	A	AcAFFHnq668|+G1Igoo!2!2!4566rJ   c                    [        U [        5      (       d  U $ U R                  nU R                  n[        R
                  n[        R
                  nU(       a  SSKJn  [        [        U5      5       H9  u  pU(       a$  [        U	5      R                  WR                  5      n	XYX-  -  -  nM;     [        [        U5      5       H9  u  pU(       a$  [        U	5      R                  WR                  5      n	XiX-  -  -  nM;     [        U[        [        45      (       a  UR                  5       n[        U[        [        45      (       a  UR                  5       nXV-  $ )Nr   )mp)rd   r.   rE  denr   r   mpmathr_  r   reversedr   
_to_mpmathprecr*   r+   r  )
r[  r   mpmr  r  sol_psol_qr_  r   r   s
             rG   r  r  	  s    dC  AAFFEFFE
(1+&
%%bgg.ARU '
 (1+&
%%bgg.ARU '
 %+{344%+{344=rJ   c                 	   U R                  5       nU(       d  U R                  5       nOSnU(       d|  U(       du  U R                  5       u  pU	R                  5       (       aK  U
R                  (       a:  [	        U
[
        5      (       a  [        U
5      n
U
R                  U
R                  pSnOSnOSnU(       d  U(       d  U(       d  gUR                  U5      n[        US5      u  nnU R                  U5      (       d  [        UUSU /5      $ U(       Ga	  U U-  U R                  U5      -
  n[        UR                  UR                   SS9nUR#                  U5      nUc  US:X  a  U(       a  UR%                  U 5      R'                  5       n[)        [+        U5      5       H'  u  nnUS:X  a  M  [-        [+        U5      5      US nUn  O   [)        W5       H6  u  nn[	        U[.        [0        45      (       d  M#  UR3                  5       UU'   M8     W[5        U5      0nGOU(       af  U R7                  5       u  nnUU-  U-  UUR                  U5      -  -   UUR                  U5      -  -
  n[        UR                  UR                   SS9nGO*U(       Ga"  WUW-  -  U-  S-
  n[        UU5      R9                  W	5      R:                  nUR#                  U5      nUc  US:X  a  U(       a  Ub  US::  a  UR%                  U	5      R'                  5       n[)        [+        U5      5       HU  u  nnUS:X  a  M  [	        U[.        [0        45      (       a  UR3                  5       n[5        U5      W
-  n[5        U5      U
-  n  O   [	        W[.        [0        45      (       a  UR3                  5       nW[5        U/5      0nU(       d  U(       d  [        WXU5      $ U(       d  WR<                  nWR#                  U5      (       a  [        UX5      R?                  5       n[-        U5      n[A        U5      S:X  as  UUS      [4        RB                  :X  aY  US   nXU-
  U-  -  n[E        UXU5      n[)        U5       VVs/ s H  u  nnU[G        U5      -  PM     nnnUU0n[        UXU5      $ [E        XX$5      nU(       d  US-  n[E        XX$5      nU(       d  M  [        UXU5      $ s  snnf )zG
Converts polynomials, rationals and algebraic functions to holonomic.
TFNr^   r   r   r8   )$is_polynomialis_rational_functionas_base_expr#  rd   r	   r6   r  r  r   rZ   rC  r   r   r  r   r~   r   r   r   r   rb  r   r*   r+   r  r   as_numer_denomrt  r   r   r  r   r   r  r   )r  r   r   r   r  rD   r  ispolyisratbasepolyratexpr   r   is_algr   r   r^   rR   r   rD  r   r   rT  indicialr  r  rF   r  r=  r>  s                                 rG   r2  r2  
  s-   
 !F))+e++-!!##(8(8&%(("6*88VXXqFFevQA!!T*EAr 88A;; QD622Ri$))A,&eDoob) :"'k,,t$,,.C!(3-016Xc]+AB/ 1 "%(1a+{!;<< yy{E!H ) AeH%B	""$1!ebj1qvvay=(1qvvay=8eD	1q5kB"Q'33H=IIoob) :"'k^v{,,x(002C!(3-016a+{!;<<		A!fQ4&= 1 %+{!;<<AugJ'B	 aR00
rc1)335Gq6Q;1QqT7aee+!AB{"A+Aqf=L9B<9PQ9PAA	!,9PLQL!B$S!44	$2	.B
adr2 b S!,, Rs   /Sc           	      (  ^ [         R                  " U T5      nU(       a  Uu  pVpxOg U V	s/ s H
  oU	S   -  PM     n
n	UR                  5       nUS   T:X  a  US   O[        R                  nU V	s/ s H
  oU	S   -   PM     nn	U V	s/ s H  oS   PM	     nn	U4S jnU" US   US   5      u  nnU
S   U-  [        UX#S9-  n[        S[        U5      5       H(  n	U" X   X   5      u  nnUX   U-  [        UX#S9-  -  nM*     U$ s  sn	f s  sn	f s  sn	f )Nr   r8   r   c                 >  >^ U R                   S   nUR                  [        5      (       a  UR                  [        [
        5      nUR                  TSS9n[        U5      S   nX4   nUR                  5       nUS   T:X  a  US   O[        R                  nX-  mU4S jU R                   S   S    5       nU4S jU R                   S   S    5       nU4S jU R                   S   S    5       n	U4S	 jU R                   S   S    5       n
UT* -  [        Xx4X4U5      4$ )
Nr   F)r2  r   r8   c              3   ,   >#    U  H	  oT-   v   M     g 7frB   ry   r  s     rG   r   5_convert_meijerint.<locals>._shift.<locals>.<genexpr>
       -_!e_   c              3   ,   >#    U  H	  oT-   v   M     g 7frB   ry   r  s     rG   r   rv  
  rw  rx  c              3   ,   >#    U  H	  oT-   v   M     g 7frB   ry   r  s     rG   r   rv  
  rw  rx  c              3   ,   >#    U  H	  oT-   v   M     g 7frB   ry   r  s     rG   r   rv  
  rw  rx  )r6  rC  r
   r!  r   r   collectr   rk  r   r   r'   )r  r.  r  dr   r   r<  r(  r  r)  r  rF   r   s              @rG   _shift"_convert_meijerint.<locals>._shift~
  s    IIbM5588y#&AIIa%I(GAJDMMOaDAIAaD166E-TYYq\!_--TYYq\!_--TYYq\!_--TYYq\!_-1"ugrh!444rJ   r/  )r(   	_rewrite1rk  r   r   r+  r   r   )r  r   r  rD   r6  facpor=  r   r   fac_listr<  r.  po_listG_listr~  rT  r   rR   s    `                 rG   r7  r7  n
  s-   tQ'DA %&&Aqad
AH&
A!	!qvvA!"#A1Q4xG#AqdAF5& fQi,HE1
1+
Q Q
QC 1c&k"&)WZ0qx{U"\!h%VVV # JE ' $s   D0D
Dc                 L  ^  S	U 4S jjnUR                  [        5      n[        US5      u  pEU" [        [        5      US-  S-   [        SSS/5        U" [	        [        5      US-  S-   [        SSS/5        U" [        [        5      US-
  [        SS5        U" [        [        5      U[        US-  -  -   [        SSS/5        U" [        [        5      S[        -  U-  US-  -   [        SSS[        [        5      -  /5        U" [        [        5      S[        -  U-  US-  -   [        SSS[        [        5      -  /5        U" [        [        5      S[        -  U-  US-  -   [        SSS[        [        5      -  /5        U" [        [        5      US-  S-
  [        SSS/5        U" [        [        5      US-  S-
  [        SSS/5        U" [        [        5      [        SU-  -   [        US-  -  -   [        5        U" [        [        5      [        U-  SUS-  -  -   [        US-  -  -   [        5        U" [!        [        5      [        U-  SUS-  -  -   [        US-  -  -   [        5        U" [#        [        5      [        * U-  SUS-  -  -   [        US-  -  -   [        5        g)
z]
Creates the look-up table. For a similar implementation
see meijerint._create_lookup_table.
r   c           	      |   > TR                  [        U [        5      / 5      R                  U [	        XX45      45        g)z"
Adds a formula in the dictionary
N)r3  r-  r,  r   r   )formular   argr   r   tables        rG   add_create_table.<locals>.add
  s8     	#.3::Gk7<9 	:rJ   r^   r   r8   r  N)r   ry   )r   r,  rZ   r   r   r   r   r"   r   r   r#   r$   r   r   r   r!   r   r    )r  rD   r  r   r   r^   s   `     rG   r5  r5  
  s+   : 	S!A!!T*EA C"a%!)S!aV,C"a%!)S!aV,C"q&#q!$C"s2q5y.#q1a&1C!C%(RU"CQ$r(
O<S	1S58b!e#S!aDH-=>S	2c6"9r1u$c1q!DH*o>S	2q519c1q!f-S	2q519c1q!f-S	32:BE	)3/3R!BE'!CAI-s33R!BE'!CAI-s3C3$r'Ab!eG#c"a%i/5rJ   c                 ^   / n[        U5       H  nU R                  X5      nU(       a  UR                  5       nU(       a!  [        U[        5      (       a  [        XU5      nUR                  SL d  [        U[        5      (       a    g UR                  U5        U R                  U5      n M     U$ )NF)	r   r!  r"  rd   r   r3   r  r   r   )	r  r   r   r   r"  r  r   r   vals	            rG   r  r  
  s    	B5\ii))+CC--$C==E!ZS%9%9
		#yy|  IrJ   )r   F)Nr   NNNTr  r  )FT)trv   
sympy.corer   r   r   sympy.core.numbersr   r   r   r	   r
   r   r   r   sympy.core.singletonr   sympy.core.sortingr   sympy.core.symbolr   r   sympy.core.sympifyr   (sympy.functions.combinatorial.factorialsr   r   r   &sympy.functions.elementary.exponentialr   r   r   %sympy.functions.elementary.hyperbolicr   r   (sympy.functions.elementary.miscellaneousr   (sympy.functions.elementary.trigonometricr   r   r   'sympy.functions.special.error_functionsr   r    r!   r"   r#   r$   'sympy.functions.special.gamma_functionsr%   sympy.functions.special.hyperr&   r'   sympy.integralsr(   sympy.matricesr)   sympy.polys.ringsr*   sympy.polys.fieldsr+   sympy.polys.domainsr,   r-   sympy.polys.polyclassesr.   sympy.polys.polyrootsr/   sympy.polys.polytoolsr0   sympy.polys.matricesr1   sympy.printingr2   sympy.series.limitsr3   sympy.series.orderr4   sympy.simplify.hyperexpandr5   sympy.simplify.simplifyr6   sympy.solvers.solversr7   r  r9   r:   r;   holonomicerrorsr<   r=   r>   r?   rS   rZ   rU   r`   r   r&  r+  r,  r3  r4  sympy.integrals.meijerintr-  r  r  r5  r  r   r  rE  r  r2  r7  r5  r  ry   rJ   rG   <module>r     sQ  
 % $" " " " & + & L L F F > 9 E E R R 9 8 % ! ) * & ' ' & -  % $ 2 - ' R R) )#,LA3 A3HSG SGlX Xv4<4~ 54 @4F El  -_:H67r(-:&R	7> '(DbSW g-T *.b +\ !# "6JrJ   