+
    if                       R t ^ RIHtHtHt ^ RIHtHtHtH	t	H
t
HtHtHt ^ RIHt ^ RIHt ^ RIHtHt ^ RIHt ^ RIHtHtHt ^ RIHtHtHt ^ R	IH t H!t! ^ R
I"H#t# ^ RI$H%t%H&t&H't' ^ RI(H)t)H*t*H+t+H,t,H-t-H.t. ^ RI/H0t0 ^ RI1H2t2H3t3 ^ RI4H5t5 ^ RI6H7t7 ^ RI8H9t9 ^ RI:H;t; ^ RI<H=t=H>t> ^ RI?H@t@ ^ RIAHBtB ^ RICHDtD ^ RIEHFtF ^ RIGHHtH ^ RIIHJtJ ^ RIKHLtL ^ RIMHNtN ^ RIOHPtP ^ RIQHRtR ^RISHTtTHUtUHVtV ^RIWHXtXHYtYHZtZH[t[ R  t\R! t] ! R" R#4      t^ ! R$ R%4      t_ ! R& R'4      t`R;R) lta^ R(R*]=3R+ ltb]! R,4      tcR-sdR-se^ R.IfHgtg R<R/ lthR=R0 ltiR1 tjR2 tkR3 tlR4 tmR5 tnR>R6 lto^ R-R-]=R*3R7 ltpR*]=3R8 ltq]=3R9 ltrR?R: ltsR-# )@zL
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                    a  V 3R  lpS P                  V4      w  r4VP                  ^ ,          pV! ^V34      V,          pW6,           P                  4       pV# )c                 F   < \         P                  ! V SP                  4      # N)r0   onesdomain)shapers   &y/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/holonomic/holonomic.py<lambda>(_find_nonzero_solution.<locals>.<lambda>+   s    **5!((;    )_solverC   	transpose)rD   homosysrA   
particular	nullspacenullitynullpartsols   f&      rE   _find_nonzero_solutionrQ   *   sP    ;DHHW-Jooa GQL!I-H 
+
+
-CJrH   c                2    \        W4      pW"P                  3# )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   && rE   DifferentialOperatorsrX   4   s    D 't7D**++rH   c                   :   a  ] tR t^Zt o RtR tR t]tR tRt	V t
R# )rS   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                    Wn         \        VP                  VP                  .V 4      V n        Vf   \        RRR7      V n        R # \        V\        4      '       d   \        VRR7      V n        R # \        V\
        4      '       d	   W n        R # R # )NDxF)commutative)	rU   DifferentialOperatorzeroonerT   r   
gen_symbol
isinstancestr)selfrU   rV   s   &&&rE   __init__$DifferentialOperatorAlgebra.__init__   sn    	#7YY!4$)  $Tu=DO)S))"("FIv.."+ /rH   c                    R \        V P                  4      ,           R,           V P                  P                  4       ,           pV# )z9Univariate Differential Operator Algebra in intermediate z over the base ring )r1   r`   rU   __str__)rc   strings   & rE   rg   #DifferentialOperatorAlgebra.__str__   s<    L4??#$&<=YY!" rH   c                v    V P                   VP                   8H  ;'       d    V P                  VP                  8H  # r@   )rU   r`   rc   others   &&rE   __eq__"DifferentialOperatorAlgebra.__eq__   s3    yyEJJ& 3 3%"2"22	3rH   )rU   rT   r`   N)__name__
__module____qualname____firstlineno____doc__rd   rg   __repr__rm   __static_attributes____classdictcell____classdict__s   @rE   rS   rS   Z   s&     $L, H3 3rH   rS   c                   x   a  ] tR t^t o Rt^tR tR tR tR t	]	t
R tR tR tR	 tR
 tR t]tR tR tRtV tR# )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                   W n         V P                   P                  p\        VP                  ^ ,          \        4      '       d   VP                  ^ ,          MVP                  ^ ,          ^ ,          V n        \        V4       F`  w  rE\        WSP                  4      '       g   VP                  \        V4      4      W&   K>  VP                  VP                  V4      4      W&   Kb  	  Wn        \        V P                  4      ^,
          V n        R# )z
Parameters
==========

list_of_poly:
    List of polynomials belonging to the base ring of the algebra.
parent:
    Parent algebra of the operator.
N)parentrU   ra   gensr   x	enumeratedtype
from_sympyr   to_sympy
listofpolylenorder)rc   list_of_polyr{   rU   ijs   &&&   rE   rd   DifferentialOperator.__init__   s     {{!+DIIaL&!A!A1tyyQR|TU
 l+DAa,,"&//'!*"="&//$--2B"C	 , ')A-
rH   c                  a  S P                   p\        V\        4      '       d   VP                   pMc\        VS P                  P                  P
                  4      '       d   V.pM/S P                  P                  P                  \        V4      4      .pR pV! V^ ,          V4      pV 3R lp\        ^\        V4      4       F#  pV! V4      p\        WT! W',          V4      4      pK%  	  \        VS P                  4      # )z
Multiplies two DifferentialOperator and returns another
DifferentialOperator instance using the commutation rule
Dx*a = a*Dx + a'
c                 z    \        V\        4      '       d   V Uu. uF  q"V ,          NK  	  up# W,          .# u upi r@   )ra   list)blistofotherr   s   && rE   _mul_dmp_diffop5DifferentialOperator.__mul__.<locals>._mul_dmp_diffop   s8    +t,,'23{!A{33O$$ 4s   8c                   < SP                   P                  P                  .p. p\        V \        4      '       d;   V  F3  pVP                  V4       VP                  VP                  4       4       K5  	  MvVP                  SP                   P                  P                  V 4      4       VP                  SP                   P                  P                  V 4      P                  4       4       \        W4      # r@   )	r{   rU   r^   ra   r   appenddiffr   
_add_lists)r   sol1sol2r   rc   s   &   rE   
_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))rH   )r   ra   r]   r{   rU   r   r   r   ranger   r   )rc   rl   
listofselfr   r   rP   r   r   s   f&      rE   __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5rH   c                b   \        V\        4      '       g   \        WP                  P                  P                  4      '       g/   V P                  P                  P                  \        V4      4      pV P                   Uu. uF  q!V,          NK  	  pp\        W0P                  4      # R # u upi r@   )ra   r]   r{   rU   r   r   r   r   )rc   rl   r   rP   s   &&  rE   __rmul__DifferentialOperator.__rmul__  s~    %!566e[[%5%5%;%;<<))55genE&*oo6o199oC6'[[99 7
 7s   B,c                   \        V\        4      '       d6   \        V P                  VP                  4      p\        W P                  4      # V P                  p\        WP                  P
                  P                  4      '       g1   V P                  P
                  P                  \        V4      4      .pMV.pV^ ,          V^ ,          ,           .VR,          ,           p\        W P                  4      # )       NN)	ra   r]   r   r   r{   rU   r   r   r   )rc   rl   rP   	list_self
list_others   &&   rE   __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5rH   c                "    V RV,          ,           # r    rk   s   &&rE   __sub__DifferentialOperator.__sub__)  s    rUl""rH   c                "    RV ,          V,           # r   r   rk   s   &&rE   __rsub__DifferentialOperator.__rsub__,  s    d{U""rH   c                    RV ,          # r   r   rc   s   &rE   __neg__DifferentialOperator.__neg__/      DyrH   c                >    V \         P                  V,          ,          # r@   r   Onerk   s   &&rE   __truediv__ DifferentialOperator.__truediv__2      quuu}%%rH   c                $   V^8X  d   V # \        V P                  P                  P                  .V P                  4      pV^ 8X  d   V# V P                  V P                  P
                  P                  8X  dd   V P                  P                  P                  .V,          V P                  P                  P                  .,           p\        W0P                  4      # T p V^,          '       d	   W$,          pV^,          pV'       g    V# WD,          pK6  r   )r]   r{   rU   r_   r   rT   r^   )rc   nresultrP   r}   s   &&   rE   __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1uu!GA FArH   c                   V P                   pR p\        V4       EF!  w  r4W@P                  P                  P                  8X  d   K,  V P                  P                  P                  V4      pV^ 8X  d#   VR\        V4      ,           R,           ,          pKz  V'       d
   VR,          pV^8X  d>   VR\        V4      ,           RV P                  P                  ,          ,           ,          pK  VR\        V4      ,           R,           RV P                  P                  ,          ,           \        V4      ,           ,          pEK$  	  V# ) ()z + z)*%sz*%s**)r   r~   r{   rU   r^   r   r1   r`   )rc   r   	print_strr   r   s   &    rE   rg   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# *& rH   c                  a  \        V\        4      '       d;   S P                  VP                  8H  ;'       d    S P                  VP                  8H  # S P                  ^ ,          V8H  ;'       d]    \        ;QJ d0    V 3R lS P                  R,           4       F  '       d   K   R# 	  R# ! V 3R lS P                  R,           4       4      # )r   c              3   f   <"   T F&  qSP                   P                  P                  J x  K(  	  R # 5ir@   r{   rU   r^   ).0r   rc   s   & rE   	<genexpr>.DifferentialOperator.__eq__.<locals>.<genexpr>i  s&     H4GqT[[%%***4Gs   .1r   FT)ra   r]   r   r{   allrk   s   f&rE   rm   DifferentialOperator.__eq__d  s    e122??e&6&66 / /;;%,,./q!U* I ICHDOOB4GHCC	I	IHDOOB4GHH	IrH   c                    V P                   P                  pV\        VP                  V P                  R,          4      V P
                  4      9   # )z8
Checks if the differential equation is singular at x0.
r   )r{   rU   r.   r   r   r}   )rc   x0rU   s   && rE   is_singular DifferentialOperator.is_singulark  s;    
 {{U4==)<=tvvFFFrH   )r   r   r{   r}   N)ro   rp   rq   rr   rs   _op_priorityrd   r   r   r   __radd__r   r   r   r   r   rg   rt   rm   r   ru   rv   rw   s   @rE   r]   r]      se     !F L.<,6\:6 H##&(2 HIG GrH   r]   c                      a  ] tR tRt o Rt^tR"R ltR t]tR t	R t
R tR	 tR
 tR#R ltR tR tR t]tR tR tR tR tR tR tR tR$R ltR$R ltR%R ltR tR&R ltR tR t R'R lt!R t"R(R lt#R  t$R!t%V t&R# ))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

Nc                6    W@n         W0n        Wn        W n        R# )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}   )rc   r   r}   r   r   s   &&&&&rE   rd   HolonomicFunction.__init__  s    , &rH   c           
     V   V P                  4       '       db   R \        V P                  4      : R\        V P                  4      : R\        V P
                  4      : R\        V P                  4      : R2	pV# R \        V P                  4      : R\        V P                  4      : R2pV# )zHolonomicFunction(z, r   )_have_init_condrb   r   r1   r}   r   r   )rc   str_sols   & rE   rg   HolonomicFunction.__str__  sz    !!=@AQAQ=RTVVd477mT$'']<G  " 699I9I5JTVVG rH   c                @   V P                   P                  P                  pVP                   P                  P                  pVP                  pVP                  pW#8X  d   W3# VP	                  V4      P                  V P                  4      p\        V\        V P                   P                  P                  4      4      w  rxV P                   P                   U	u. uF  qP                  V	4      NK  	  p
p	VP                   P                   U	u. uF  qP                  V	4      NK  	  pp	\        W4      p
\        W4      p\        WP                  V P                  V P                  4      p
\        WP                  VP                  VP                  4      pW3# u up	i u up	i )zF
Unifies the base polynomial ring of a given two Holonomic
Functions.
)r   r{   rU   domunifyold_poly_ringr}   rX   rb   r`   r   r   r]   r   r   r   )rc   rl   R1R2dom1dom2R	newparent_r   r   r   s   &&          rE   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                    \        V P                  \        4      '       d   R# \        V P                  \        4      '       d   R# R# )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)ra   r   dictr   r   s   &rE   is_singularics HolonomicFunction.is_singularics   s1     dggt$$&& 'rH   c                ,    \        V P                  4      # )z0
Checks if the function have initial condition.
)boolr   r   s   &rE   r   !HolonomicFunction._have_init_cond  s     DGG}rH   c           
        \        V P                  4      ^ ,          pV P                  V,          p\        V P                  4      ^8X  d   V\        V4      8X  d   V^ 8  d   \        V4      p\        P
                  .V,          pT\        V4       UUu. uF  w  rEV\        W,           4      ,          NK  	  upp,          p\        V P                  V P                  V P                  V4      # R# R# R# u uppi )z@
Converts a singular initial condition to ordinary if possible.
N)r   r   r   intr   Zeror~   r   r   r   r}   r   )rc   ar   r   r   r   s   &     rE   _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   #C2c                   V P                   P                  P                  VP                   P                  P                  8w  d   V P                  V4      w  r#W#,           # V P                   P                  pVP                   P                  p\        WE4      pV P                   P                  P                  pVP                  4       pV P                   .p	VP                   .p
V P                   P                  P                  p\        Wd,
          4       F#  pWR,          ,          pV	P                  V4       K%  	  \        We,
          4       F#  pWR,          ,          pV
P                  V4       K%  	  W,           p. pV F  p. p\        V^,           4       Fy  pV\        VP                  4      8  d   VP                  VP                  4       K:  VP                  VP                  VP                  V,          P                  4       4      4       K{  	  VP                  V4       K  	  \        V\        V4      V^,           3V4      P!                  4       p\        P"                  ! V^,           ^3V4      p\%        VV4      pVP&                  '       Ed[   V^,          pWR,          ,          pV	P                  V4       WR,          ,          pV
P                  V4       W,           p. pV F  p. p\        V^,           4       Fy  pV\        VP                  4      8  d   VP                  VP                  4       K:  VP                  VP                  VP                  V,          P                  4       4      4       K{  	  VP                  V4       K  	  \        V\        V4      V^,           3V4      P!                  4       p\        P"                  ! V^,           ^3V4      p\%        VV4      pEKm  VP)                  4       RV^,           V,
           p\+        VV P                   P                  4      pVV P                   ,          p\+        VP                  V P                   P                  RR7      pV P-                  4       '       d   VP-                  4       '       g   \/        VV P0                  4      # V P3                  4       R8X  Ed   VP3                  4       R8X  Ed   V P4                  VP4                  8X  dt   \7        V VP                  4      p\7        VVP                  4      p\9        VV4       UUu. uF  w  r#W#,           NK  	  ppp\/        VV P0                  V P4                  V4      # V P                   P;                  ^ 4      pVP                   P;                  ^ 4      pV P4                  ^ 8X  d(   V'       g    V'       g   WP=                  ^ 4      ,           # VP4                  ^ 8X  d)   V'       g!   V'       g   V P=                  ^ 4      V,           # V P                   P;                  V P4                  4      pVP                   P;                  V P4                  4      pV'       g*   V'       g"   WP=                  V P4                  4      ,           # V P=                  VP4                  4      V,           # V P4                  VP4                  8w  d   \/        VV P0                  4      # RpRpV P3                  4       R8X  dn   VP3                  4       R8X  dY   \?        V P@                  4       UUu. uF  w  ppV\C        V4      ,          NK  	  ppp\D        PF                  V/pVP@                  pMV P3                  4       R8X  dn   VP3                  4       R8X  dY   \?        VP@                  4       UUu. uF  w  ppV\C        V4      ,          NK  	  pppV P@                  p\D        PF                  V/pMBV P3                  4       R8X  d.   VP3                  4       R8X  d   V P@                  pVP@                  p/ pV FO  pVV9   d:   \9        VV,          VV,          4       UUu. uF  w  r#W#,           NK  	  uppVV&   KC  VV,          VV&   KQ  	  V F  pVV9  g   K  VV,          VV&   K  	  \/        VV P0                  V P4                  V4      # u uppi u uppi u uppi u uppi )r   NFnegativeTr   )$r   r{   rU   r   r   max	get_fieldrT   r   r   r   r   r^   newto_listr0   rJ   zerosrQ   is_zero_matrixflat
_normalizer   r   r}   r   r   
_extend_y0zipr   
change_icsr~   r   r   r   r   )rc   rl   r   r   deg1deg2dimr   Krowsself	rowsothergenr   diff1diff2rowrD   exprprK   rP   r   y1y2r   selfat0otherat0selfatx0	otheratx0r   _y0s   &&                             rE   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4C
 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aee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   /b="c$c	cc           	     
   V P                   P                  P                  pV P                  4       R8X  Ed9   V P	                  4       pV'       d   VP                  WR7      # / pV P                   F  pV P                  V,          p. p\        V4       Fz  w  rV
^ 8X  d"   VP                  \        P                  4       K-  Wi,           ^,           ^ 8X  d   \        R4      hVP                  V
\        Wi,           ^,           4      ,          4       K|  	  WV^,           &   K  	  \        VR4      '       d   \        R4      h\        V P                   V,          V P                  V P                  V4      # V P!                  4       '       gr   V'       dC   \        V P                   V,          V P                  V P                  \        P                  .4      # \        V P                   V,          V P                  4      # \        VR4      '       dJ   \#        V4      ^8X  d9   V^ ,          V P                  8X  d!   V P                  pV^,          pV^,          pRpMRp\        P                  .pWPP                  ,          p\        V P                   V,          V P                  V P                  V4      pX'       g   V# XX8w  EdZ    VP%                  4       pV'       dP   VP+                  V P                  V4      p\-        V\.        4      '       d   VP1                  V P                  V4      pMVP3                  V4      pXV P                  8X  d<   V^ ,          V,
          V^ &   \        V P                   V,          V P                  W4      # \        V4      P4                  '       dz   V'       dX   VP+                  V P                  V4      p\-        V\.        4      '       d   VP1                  V P                  V4      pVV,
          # VP3                  V4      pVV,
          # XV P                  8X  d)   \        V P                   V,          V P                  W4      # \        V4      P4                  '       d    \        V P                   V,          V P                  VV4      P%                  4       pVP+                  V P                  V4      p\-        V\.        4      '       g   V# VP1                  V P                  V4      # \        V P                   V,          V P                  4      #   \&        \(        3 d    Rp ELai ; i  \&        \(        3 d;    \        T P                   T,          T P                  Y4      P3                  T4      u # i ; i)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)initcondz1logarithmic terms in the series are not supported__iter__z4Definite integration for singular initial conditionsFN)r   r{   rT   r   r   	integrater   r~   r   r   r   NotImplementedErrorhasattrr   r}   r   r   r   to_exprr;   r:   subsra   r   r2   evalf	is_Number)rc   limitsr  DrD   r   r   cc2r   cjr   r   r   definiteindefinite_integralindefinite_exprloweruppers
indefinites   &&&                  rE   r  HolonomicFunction.integrate  sP   & ##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,   <T )A*T1 T1 T.-T.1AU<;U<c                   VP                  RR4       V'       dn   V^ ,          V P                  8w  d   \        P                  # \	        V4      ^8X  d6   T p\        V^,          4       F  pVP                  V^ ,          4      pK  	  V# V P                  pVP                  ^ ,          VP                  P                  P                  8X  d"   VP                  ^8X  d   \        P                  # VP                  ^ ,          VP                  P                  P                  8X  d   \        VP                  R,          VP                  4      pV P                  4       '       d]   V P                  4       R8X  d3   \!        W0P                  V P"                  V P$                  R,          4      # \!        W0P                  4      # \!        W0P                  4      # VP                  P                  pVP'                  4       pVP                   Uu. uF!  qGP)                  VP+                  4       4      NK#  	  ppVR,           Uu. uF  qDV^ ,          ,          NK  	  p	pV	P-                  ^ VP                  4       \/        W4      p\1        W7P                  VP2                  .4      p\5        VR,          V P                  P                  RR7      pV P                  4       '       d   V P                  4       R8X  d   \!        W0P                  4      # \7        WP                  ^,           4      R,          p
\!        W0P                  V P"                  V
4      # u upi u upi )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   Fr   )
setdefaultr}   r   r   r   r   r   r   r   r{   rU   r^   r   r]   r   r   r   r   r   r   r   r   insert_derivate_diff_eqr   r_   r  r  )rc   argskwargsrP   r   annr   r	  seq_dmfrhsr   s   &*,        rE   r   HolonomicFunction.diff4  sZ   , 	*d+Aw$&& vvTatAwA((47+C (
 >>!

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

1aff  ' vvquuo.R$"2"2"9"9EJ##%%)<)<)>$)F$S&&11ii!m,R0 ffdggr::% ? 4s   'M7Mc                B   V P                   VP                   8w  g   V P                  VP                  8w  d   R # V P                  4       '       dQ   VP                  4       '       d;   V P                  VP                  8H  ;'       d    V P                  VP                  8H  # R# FT)r   r}   r   r   r   rk   s   &&rE   rm   HolonomicFunction.__eq__  sp    u000DFFegg4E!!e&;&;&=&=77ehh&>>477ehh+>>rH   c                Z  aaaaa  V P                   p\        V\        4      '       g   \        V4      pVP	                  V P
                  4      '       d   \        R 4      hV P                  4       '       g   V # \        WP                  4      pV Uu. uF4  p\        P                  ! W@P
                  4      V,          P                  NK6  	  upo\        W P
                  V P                  S4      # V P                   P                  P                  VP                   P                  P                  8w  d   V P!                  V4      w  opSV,          # VP                   pVP                  oVP                  pVP                  P                  pVP#                  4       pVP$                   Uu. uF!  qHP                  VP'                  4       4      NK#  	  p	pVP$                   Uu. uF!  qHP                  VP'                  4       4      NK#  	  p
p\)        S4       Uu. uF  qV,          ) V	S,          ,          NK  	  pp\)        V4       Uu. uF  qV,          ) W,          ,          NK  	  pp\)        S^,           4       UUu. uF.  p\)        V^,           4       Uu. uF  qP*                  NK  	  upNK0  	  pppVP,                  V^ ,          ^ &   \)        S4       UUu. uF$  p\)        V4       F  qNV,          V,          NK  	  K&  	  upp.p\/        V^SV,          3V4      P1                  4       p\.        P2                  ! SV,          ^3V4      p\5        VV4      pVP6                  '       Ed   \)        S^,
          RR4       EF  o\)        V^,
          RR4       F  oVS,          S^,           ;;,          VS,          S,          ,          uu&   VS^,           ,          S;;,          VS,          S,          ,          uu&   \        VS,          S,          VP8                  4      '       d'   \;        VS,          S,          V4      VS,          S&   K  VS,          S,          P=                  V P
                  4      VS,          S&   K  	  EK  	  \)        S^,           4       F  oVS,          V,          P>                  '       d   K%  \)        V4       F;  oVS,          S;;,          VS,          VS,          V,          ,          ,          uu&   K=  	  VP*                  VS,          V&   K  	  \)        V4       Fz  oVS,          S,          ^ 8X  d   K  \)        S4       F;  oVS,          S;;,          VS,          VS,          S,          ,          ,          uu&   K=  	  VP*                  VS,          S&   K|  	  TPA                  \)        S4       UUu. uF$  p\)        V4       F  qNV,          V,          NK  	  K&  	  upp4       \/        V\C        V4      SV,          3V4      P1                  4       p\5        VV4      pEK  \E        VPG                  4       V P                   P                  RR7      pV P                  4       '       d   VP                  4       '       g   \        VV P
                  4      # V PI                  4       R8X  Ed   VPI                  4       R8X  Ed	   V P                  VP                  8X  Ed   \        V VP                  4      p\        VVP                  4      pV^ ,          V^ ,          ,          .p\)        ^\K        \C        V4      \C        V4      4      4       EF  o\)        S^,           4       Uu. uF%  p\)        S^,           4       Uu. uF  p^ NK  	  upNK'  	  pp\)        S^,           4       FB  o\)        S^,           4       F)  pSV,           S8X  g   K  \M        SS4      VS,          V&   K+  	  KD  	  ^ p\)        S^,           4       FO  o\)        S^,           4       F6  pVVS,          V,          VS,          ,          VV,          ,          ,          pK8  	  KQ  	  VPA                  V4       EK  	  \        VV P
                  V P                  V4      # V P                   PO                  ^ 4      pVP                   PO                  ^ 4      pV P                  ^ 8X  d(   V'       g    V'       g   WPQ                  ^ 4      ,          # VP                  ^ 8X  d)   V'       g!   V'       g   V PQ                  ^ 4      V,          # V P                   PO                  V P                  4      pVP                   PO                  V P                  4      pV'       g*   V'       g"   WPQ                  V P                  4      ,          # V PQ                  VP                  4      V,          # V P                  VP                  8w  d   \        VV P
                  4      # RoRo V PI                  4       R8X  dm   VPI                  4       R8X  dX   \S        V PT                  4       UUu. uF  w  rV\W        V4      ,          NK  	  ppp\X        PZ                  V/oVPT                  o MV PI                  4       R8X  dm   VPI                  4       R8X  dX   \S        VPT                  4       UUu. uF  w  rV\W        V4      ,          NK  	  pppV PT                  o\X        PZ                  V/o MBV PI                  4       R8X  d.   VPI                  4       R8X  d   V PT                  oVPT                  o / pS F  oS  F  o\K        \C        SS,          4      \C        S S,          4      4      p\)        V4       Uau. uF<  o\]        VVVVV 3R l\)        S^,           4       4       \X        PZ                  R7      NK>  	  ppSS,           V9   g   VVSS,           &   K  \_        VVSS,           ,          4       UUu. uF  w  ppVV,           NK  	  uppVSS,           &   K  	  K  	  \        VV P
                  V P                  V4      # u upi u upi u upi u upi u upi u upi u uppi u uppi u uppi u upi u upi u uppi u uppi u upi u uppi )z> Can't multiply a HolonomicFunction and expressions/functions.Fr   NTc              3   |   <"   T F1  pSS,          V,          SS,          SV,
          ,          ,          x  K3  	  R # 5ir@   r   )r   r   r   r   r   r  r  s   & rE   r   ,HolonomicFunction.__mul__.<locals>.<genexpr>!  s-     H<a"Q%(RU1q5\11<s   9<startr   )0r   ra   r   r   hasr}   r  r   r  r   r/   r   repr   r{   rU   r   r   r   r   r   r^   r_   r0   rJ   r   rQ   r   r   DMFdiffr   is_zeror   r   r  r  r   minr   r   r  r~   r   r   r   r   sumr  )!rc   rl   ann_selfr   r   r   	ann_otherr   r	  r   r   r   self_red	other_red	coeff_mullin_sys_elementslin_syshomo_sysrP   sol_anny0_selfy0_othercoeffkr  r  r  r  r  r   r&  r  r  s!   &&  `      `                 ` @@rE   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0(C=B1XFXm^jm3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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ss   :q&'q!'q& q+q08q:q5%q:*r ?*r
+rrr
rrAr"r'
5q:rc                     WR,          ,           # r   r   rk   s   &&rE   r   HolonomicFunction.__sub__+  s    bj  rH   c                "    V R,          V,           # r   r   rk   s   &&rE   r   HolonomicFunction.__rsub__.  s    by5  rH   c                    RV ,          # r   r   r   s   &rE   r   HolonomicFunction.__neg__1  r   rH   c                >    V \         P                  V,          ,          # r@   r   rk   s   &&rE   r   HolonomicFunction.__truediv__4  r   rH   c                   V P                   P                  ^8:  d   V P                   pVP                  pV P                  f   RpM$\	        V P                  4      ^ ,          V,          .pVP
                  ^ ,          pVP
                  ^,          p\        P                  ! WPP                  4      V,          P                  pWV3 Uu. uF  qsP                  P                  V4      NK  	  pp\        W4      p	\        WP                  V P                  V4      # V^ 8  d   \        R4      hV P                   P                  P                   p
\        WP                  \"        P$                  \"        P&                  .4      pV^ 8X  d   V# T p V^,          '       d	   W,          pV^,          pV'       g    V# W,          pK6  u upi )r   Nz&Negative Power on a Holonomic Function)r   r   r{   r   r   r   r/   r   r}   rE  rU   r   r]   r   r   r=   rT   r   r   r   )rc   r   r8  r{   r   p0p1r   rP   ddr[   r   r}   s   &&           rE   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1uu!GA FA! >s   #F=c                N    \        R V P                  P                   4       4      # )z6
Returns the highest power of `x` in the annihilator.
c              3   @   "   T F  qP                  4       x  K  	  R # 5ir@   degreer   r   s   & rE   r   +HolonomicFunction.degree.<locals>.<genexpr>]  s     C'B!88::'B   )r   r   r   r   s   &rE   rh  HolonomicFunction.degreeY  s!     Ct'7'7'B'BCCCrH   c                   V P                   P                  pV P                   P                  pVP                  V P                  4      pV P                   P
                  p\        V4       Fq  w  r\        WP                   P                  P                  P                  4      '       g   K@  V P                   P                  P                  P                  V	4      Wx&   Ks  	  Wu,          P                  V P                  V/4      p
\        V4       Uu. uF.  qV,          P                  V P                  V/4      ) V
,          NK0  	  pp\        V4       Uu. uF  p\        P                  NK  	  pp\        P                  V^ &   V.p\!        \        V4       Uu. uF  p\        P                  NK  	  up.4      P#                  4       p V Uu. uF  qP                  V P                  4      NK  	  pp\        V^,
          4       F,  pVV^,           ;;,          W,          V,          ,          uu&   K.  	  \        V4       F3  pVV;;,          VR,          W,          ,          V,          ,          uu&   K5  	  TpVP%                  V4       \!        V4      P#                  4       P'                  V4      w  ppVP(                  RJg   K   \+        T4      ^ ,          pTP                  T^4      p\-        TR,          TRR7      pT'       d'   \/        TT P                  T^ ,          T^,          4      # \/        TT P                  4      # u upi u upi u upi u upi )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
T:r   NNFr   r   )r   r{   r   r   r}   r   r~   ra   rU   r   r   r!  r   r   r   r   r(   rJ   r   gauss_jordan_solver   r   r  r   )rc   r  r6  r7  r   r   r   r   r   r   rD   r!  coeffssystemhomogeneousr  coeffs_nextrP   taustaus   &&*,                rE   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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R!e4 $S$&&$q'47CC dff--5 K+ 9:s   4L?MM	#Mc           
       aaa V P                   ^ 8w  d*   V P                  V P                   4      P                  4       # V P                  P	                  V P                   4      '       d   V P                  VR7      # / p\        RRR7      oV P                  P                  P                  P                  p\        VP                  S4      R4      w  rE\        V P                  P                  4       F  w  poSP                  4       p\        V4      ^,
          p\!        V^,           4       F  p	WxV	,
          ,          p
V
^ 8X  d   K  Wi,
          V	3V9   dN   W&V	,
          V	3;;,          VP#                  V
4      \%        SV	,
          ^,           V4      ,          ,          uu&   Kw  VP#                  V
4      \%        SV	,
          ^,           V4      ,          W&V	,
          V	3&   K  	  K  	  . pV Uu. uF  qf^ ,          NK  	  pp\'        V4      o\)        V4      pV P+                  4       pSV,           p/ p. p. p\!        SV^,           4       Fq  oSV9   dI   \-        VVV3R lVP/                  4        4       \0        P2                  R7      pVP5                  V4       KR  VP5                  \0        P2                  4       Ks  	  \7        W4      pVP8                  p\;        VP                  P#                  VP                  R,          4      SRR	7      pVP=                  4       pV'       d   \)        V4      ^,           p\)        VV4      pVV,          p\?        V V4      p\        V4       UUu. uF  w  ppV\A        V4      ,          NK  	  ppp\        V4      V8  Ed   \!        V4       EFa  p\0        P2                  pV EF5  oVS^ ,          ,           ^ 8  d"   \0        P2                  WS^ ,          ,           &   MVS^ ,          ,           \        V4      8  d)   VVS^ ,          ,           ,          WS^ ,          ,           &   MjVS^ ,          ,           V9   gV   \        R
VS^ ,          ,           ,          4      WS^ ,          ,           &   VP5                  WS^ ,          ,           ,          4       S^,          V8:  g   K  VVS,          PC                  SV4      WS^ ,          ,           ,          ,          ,          pEK8  	  VP5                  V4       EKd  	  \E        V.VO5!  p\G        V\H        4      '       d   \!        \        V4      V4       Fa  pWo9  d   \        R
V,          4      W&   W,          V9   d!   VP5                  VW,          ,          4       KJ  VP5                  W,          4       Kc  	  V'       d   \K        VV4      V3.# \K        VV4      .# \!        \        V4      V4       Fx  pWo9  d   \        R
V,          4      W&   RpV F2  oW,          S9   g   K  VP5                  SW,          ,          4       RpK4  	  V'       d   Ka  VP5                  W,          4       Kz  	  V'       d   \K        VV4      V3.# \K        VV4      .# u upi u uppi )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

)lbr   TintegerSnc              3   z   <"   T F0  w  rV^ ,          S8X  g   K  VP                  SSS,
          4      x  K2  	  R# 5ir   Nr!  r   rV  vr   r,  r   s   &  rE   r   0HolonomicFunction.to_sequence.<locals>.<genexpr>  s9      C'4tq!	 1AFF1a%i00'4   ;!;rB  ZfilterC_%sFr   )&r   shift_xto_sequencer   r   
_frobeniusr   r{   rU   r   r9   r   r~   r   
all_coeffsr   r   r   r   rH  r   rh  rI  itemsr   r   r   r8   r   r.   keysr  r   r!  r6   ra   r   r7   )rc   rx  dict1r   r   r   r   	listofdmprh  rV  rU  rP   keylistr-  
smallest_ndummyseqsunknownstempr   	all_rootsmax_rootr   r   u0eqsoleqsr.  r,  r   s   &&                     `    @@rE   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!*% ' ;" !&'AQ44'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   *Y;"Z c                P  aa,a- V P                  4       p. p. p\        VP                  4       4       Fi  pVP                  '       d"   VP	                  V.W%,          ,          4       K6  VP                  4       w  rgVP	                  WVV3.W%,          ,          4       Kk  	  VP                  R  R7       VP                  R R7       VP                  4        . pV Fu  p\        V4      ^ 8X  d   VP                  V.4       K'  V F6  o\        S^ ,          V,
          4      '       g   K$  SP                  V4        Ka  	  VP                  V.4       Kw  	  \        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      p	\        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      p
\        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      pV P                  4       R8X  dt   . p\        V P                  P                  4       4       FH  p\        VP                  4       4       F(  o\        SV4      '       g   K  VP                  V4       K*  	  KJ  	  EMV
'       d   V'       d   \        V4      .pMV	'       d7   V Uu. uF  qU^ ,          NK  	  upV Uu. uF  q^ ,          NK  	  up,           pMV'       g%   V Uu. uF  p\        V4      V8X  d   K  VNK  	  ppM{V
'       gt   V P!                  4       '       d,   \#        V P                  ^ ,          4      P$                  R8X  d   \        V4      .pM%V Uu. uF  qU^ 8  g   K  VNK  	  pp\        V4      .p\'        RRR	7      o-V P(                  P*                  P,                  P.                  p\1        VP3                  S-4      R
4      w  pp. p\5        R4      pX EF(  p/ p\7        V P(                  P8                  4       EF  w  poSP;                  4       p\        V4      ^,
          p\=        V^,           4       F  pVVV,
          ,          pV^ 8X  d   K  VV,
          VV,
          3V9   d]   VVV,
          VV,
          3;;,          VP?                  V4      \A        S-V,
          ^,           V,           V4      ,          ,          uu&   K  VP?                  V4      \A        S-V,
          ^,           V,           V4      ,          VVV,
          VV,
          3&   K  	  EK  	  . pV Uu. uF  qU^ ,          NK  	  pp\        V4      o,\C        V4      p\C        R V 4       4      p\        R V 4       4      pS,V,           p/ p. p . p!\=        S,V^,           4       Fq  oSV9   dI   \E        VV,V-3R lVPG                  4        4       \"        PH                  R7      p"VP                  V"4       KR  VP                  \"        PH                  4       Ks  	  \K        VV4      pVPL                  p#\O        VP,                  P?                  VP8                  R,          4      S-RR7      p$V$P                  4       p$V$'       d   \C        V$4      ^,           p%\C        V%V4      pV#V,          p#. p&V P                  4       R8X  d   V P                  V,          p&MV P                  4       R8X  d   V^ 8  d   \        V4      V8X  d   \        V4      ^8X  dz   \Q        V V#\        V4      ,           4      p'\        V'4      \        V4      8  dE   \=        \        V4      \        V'4      4       Uu. uF  pV'V,          \S        V4      ,          NK  	  p&p\        V&4      V#8  Ed0   \=        VV4       EFy  p\"        PH                  p(V EFM  oVS^ ,          ,           ^ 8  d#   \"        PH                  VVS^ ,          ,           &   MVS^ ,          ,           \        V&4      8  d*   V&VS^ ,          ,           ,          VVS^ ,          ,           &   M~VS^ ,          ,           V9   gj   \U        V4      RVS^ ,          ,           ,          ,           p)\'        V)4      VVS^ ,          ,           &   V!P                  VVS^ ,          ,           ,          4       S^,          V8:  g   EK  V(VS,          PW                  S-V4      VVS^ ,          ,           ,          ,          ,          p(EKP  	  V P                  V(4       EK|  	  \Y        V .V!O5!  p*\[        V*\\        4      '       d   \=        \        V&4      V#4       Fx  pVV9  d(   \U        V4      RV,          ,           p)\'        V)4      VV&   VV,          V*9   d"   V&P                  V*VV,          ,          4       K`  V&P                  VV,          4       Kz  	  V'       d"   VP                  \_        VV&4      VV34       EK  VP                  \_        VV&4      V34       EK3  \=        \        V&4      V#4       F  pVV9  d(   \U        V4      RV,          ,           p)\'        V)4      VV&   Rp+V* F4  oVV,          S9   g   K  V&P                  SVV,          ,          4       Rp+K6  	  V+'       d   Kw  V&P                  VV,          4       K  	  V'       d    VP                  \_        VV&4      VV34       MVP                  \_        VV&4      V34       V^,          pEK+  	  V# u upi u upi u upi u upi u upi u upi )c                     V ^,          # r   r   r}   s   &rE   rF   .HolonomicFunction._frobenius.<locals>.<lambda>j      !A$rH   )keyc                     V ^,          #    r   r  s   &rE   rF   r  k  r  rH   c              3   >   "   T F  p\        V4      ^8H  x  K  	  R# 5ir   N)r   ri  s   & rE   r   /HolonomicFunction._frobenius.<locals>.<genexpr>~  s     3s!#a&A+ss   FTc              3   *   "   T F	  q^ 8  x  K  	  R# 5ir}  r   ri  s   & rE   r   r    s     +U!VUs   c              3   8   "   T F  p\        V4      x  K  	  R # 5ir@   )r   ri  s   & rE   r   r    s     2EqZ]]Es   r   ry  r{  Cc              3   2   "   T F  q^,          x  K  	  R# 5ir  r   ri  s   & rE   r   r    s     -u!1u   c              3   2   "   T F  q^,          x  K  	  R# 5ir  r   ri  s   & rE   r   r    s     .1A$$r  c              3   z   <"   T F0  w  rV^ ,          S8X  g   K  VP                  SSS,
          4      x  K2  	  R# 5ir}  r~  r  s   &  rE   r   r    s9       G+841AaDAI !5q!e) 4 4+8r  rB  r  r  z_%sr   )0	_indicialr   r  is_realextendas_real_imagsortr   r   r   r   r   r   r   rH  r   r   r   	is_finiter   r   r{   rU   r   r9   r   ordr~   r   r  r   r   r   r   rI  r  r   r8   r   r.   r  r   chrr!  r6   ra   r   r7   ).rc   rx  indicialrootsrealscomplr   r   r   grpindependentallposallintrootstoconsiderr   posrootsr   r   r   finalsolcharr  r  r  rh  rV  rU  rP   r  r-  degree2r  r  r  r  r  r   r  r  r  r   r  letterr  r.  r,  r   s.   &&           `                              @@rE   r  HolonomicFunction._frobenius\  s   (++-.AyyyaS=#334~~'qQi[=+;;< / 	


'


'

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

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

A3  c3s3ccc3s33+U++U++2E22E22  D( OTWW\\^, !3!3!56A#Aq))'..q1 7 -
 "5zlO-01SttS154I5aqTT54IIO*/C%Qs1v{qq%OCO''))Qtwwqz]-D-D-N#&u:, (-7u!QAAu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ttUG+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   l
5ll3ll#l#l"l#c                  aaaaa Vf   V P                  4       pMTp\        V\        4      '       d   \        V4      ^8X  d   V^ ,          p^ oM\        V\        4      '       d$   \        V4      ^8X  d   V^,          oV^ ,          pM\        V4      ^8X  d+   \        V^ ,          4      ^8X  d   V^ ,          ^ ,          p^ oMi\        V4      ^8X  d9   \        V^ ,          4      ^8X  d"   V^ ,          ^,          oV^ ,          ^ ,          pM!V Uu. uF  q`P	                  VR7      NK  	  up# V\        S4      ,
          p\        VP                  4      ^,
          pVP                  P                  pV P                  oV P                  p	VP                  P                  p
VP                  P                  P                  pVP                  4       pV
 Uu. uF!  qP                  VP!                  4       4      NK#  	  pp\#        V4       Uu. uF  qnV,          ) W,          ,          NK  	  upo\%        VP                  4      oV^,           V8  di   \#        V^,           V,
          W,
          4       FD  o\'        VVV3R l\#        V4       4       \(        P*                  R7      pSP-                  V4       KF  	  V'       d   S# \'        VV3R l\/        S4       4       \(        P*                  R7      pV'       d+   V\1        SV\        S4      ,           ,          S4      ,          pV	^ 8w  d   VP3                  SSV	,
          4      # V# u upi u upi u upi )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
)_recurc              3      <"   T F=  pSV,           ^ 8  g   K  \        SV,          S4      SSV,           ,          ,          x  K?  	  R# 5ir}  )DMFsubs)r   r   r   rP   subs   & rE   r   +HolonomicFunction.series.<locals>.<genexpr>i  s?      =%-Q! =WSVQ/#a!e*<<%-s
   A0ArB  c              3   V   <"   T F  w  rSVS,           ,          V,          x  K   	  R # 5ir@   r   )r   r   r   constantpowerr}   s   &  rE   r   r  p  s%     I.$!1q=()A--.s   &))r  ra   tupler   seriesr   r  
recurrencer   r}   r   r   r{   rU   r   r   r   r   r   rI  r   r   r   r~   r3   r!  )rc   r   coefficientr   r  r  r   lrV  r   seq_dmpr   r	  r   seqrU  serr  rP   r  r}   s   &&&&& `          @@@@rE   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   M'MMc                v  a	a
aaa V P                   ^ 8w  d*   V P                  V P                   4      P                  4       # V P                  P                  pV P                  P
                  P                  o	V P                  oS	P                  pS	P                  pV	V3R lo
\        R V 4       4      p^
\        ^V4      \        ^V P                  P                  4      ,           ,          oV
V3R lo\        V3R l\        V4       4       4      p\        V4       F  w  rgVP                  4       p\        V4      ^,
          p^ We,           u;8:  d   V8:  d'   M M#W(WF,
          V,
          ,          V,          ,           pVS	P!                  SV,
          4      ,          pK  	  \#        S	P%                  V4      S4      # )z*
Computes roots of the Indicial equation.
c                 ~   < \        SP                  V 4      SR R7      p^ VP                  4       9   d
   V^ ,          # ^ # )r  r  )r.   r   r  )polyroot_allr   r}   s   & rE   _pole_degree1HolonomicFunction._indicial.<locals>._pole_degree  s5    QZZ-q=HHMMO#{"rH   c              3   @   "   T F  qP                  4       x  K  	  R # 5ir@   rg  )r   r   s   & rE   r   .HolonomicFunction._indicial.<locals>.<genexpr>  s     4AXXZZrk  c                 <   < V P                   '       d   S# S! V 4      # r@   )rG  )qr  infs   &rE   rF   -HolonomicFunction._indicial.<locals>.<lambda>  s    qyyy=l1o=rH   c              3   F   <"   T F  w  rS! V4      V,
          x  K  	  R # 5ir@   r   )r   r   r  degs   &  rE   r   r    s     ='<tqA

'<s   !)r   r  r  r   r   r{   rU   r}   r^   r_   r   r   rH  r~   r  r   r   r.   r   )rc   
list_coeffr.  yrh  r   r   r   r  r   r  r  r  r}   s   &        @@@@@rE   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&&rH   c                   ^ RI Hp Rp\        VR4      '       g   Rp\        V4      pV P                  V8X  d   V! W.W$R7      R,          # VP
                  '       g   \        hV P                  pW8  d   V) p\        Wx,
          V,          4      p	W,           .p\        V	^,
          4       F"  p
VP                  VR,          V,           4       K$  	  \        V P                  P                  P                  P                  V P                  P                  R,          4      V P                   4       F$  p
WP                  8X  g	   W9   g   K  \#        W
4      h	  V'       d   V! WW$R7      R,          # V! WW$R7      # )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.
)_evalfFr  T)methodderivativesr   )sympy.holonomic.numericalr  r  r   r   r#  r  r   r   r   r.   r   r{   rU   r   r   r}   r<   )rc   pointsr  hr  r  lpr   r   r   r   s   &&&&&      rE   r"  HolonomicFunction.evalf  s4   \ 	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KrH   c                f   V P                   P                  P                  P                  pVP	                  V4      p\        VR4      w  rEV P                   P                   Uu. uF  qc! VP                  4       4      NK  	  pp\        Wt4      p\        WqV P                  V P                  4      # u upi )z}
Changes only the variable of Holonomic Function, for internal
purposes. For composition use HolonomicFunction.composition()
r[   )r   r{   rU   r   r   rX   r   r   r]   r   r   r   )rc   zr   r   r{   r   r   rP   s   &&      rE   change_xHolonomicFunction.change_x  s     %%**..a )!T2	'+'7'7'B'BC'B!q~'BC#C0 $'':: Ds   "B.c           
        V P                   pV P                  P                  pV P                  P                  P                  pV Uu. uF8  qTP                  VP                  V4      P                  W"V,           4      4      NK:  	  pp\        W`P                  P                  4      pV P                  V,
          pV P                  4       '       g   \        Wb4      # \        WbWpP                  4      # u upi )z
Substitute `x + a` for `x`.
)r}   r   r   r{   rU   r   r   r!  r]   r   r   r   r   )rc   r   r}   listaftershiftrU   r   rP   r   s   &&      rE   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   >C0c                  a Vf   V P                  4       pMTp\        V\        4      '       d'   \        V4      ^8X  d   V^,          pV^ ,          p^ pEM'\        V\        4      '       d-   \        V4      ^8X  d   V^,          pV^,          pV^ ,          pM\        V4      ^8X  d;   \        V^ ,          4      ^8X  d$   V^ ,          ^,          pV^ ,          ^ ,          p^ pM\        V4      ^8X  dI   \        V^ ,          4      ^8X  d2   V^ ,          ^,          pV^ ,          ^,          pV^ ,          ^ ,          pMCV P	                  W^ ,          R7      pVR,           F  pW`P	                  WR7      ,          pK  	  V# VP
                  pVP                  oV P                  p	V P                  p
SP                  pV^ 8X  Ed   \        SP                  P                  P                  SP                  ^ ,          4      VP                  RR7      p\         P"                  p\%        V4       F  w  rV^ 8  g   \'        V4      '       g   K  \)        V4      pV\        V4      8  dY   \        W,          \*        \,        34      '       d   W,          P/                  4       W&   WhV,          W,          ,          ,          pK  V\1        RV,          4      W,          ,          ,          pK  	  \        V\*        \,        34      '       d   VP/                  4       W,          ,          pMWiV,          ,          pV'       d&   V
^ 8w  d   VP3                  WV
,
          4      3.# V3.# V
^ 8w  d   VP3                  WV
,
          4      # V# WK,           \        V4      8  d   \5        R4      h\6        ;QJ d,    V3R lSP                  ^R
  4       F  '       g   K   RM!	  R	M! V3R lSP                  ^R
  4       4      '       d   \9        W P                  4      hSP                  ^ ,          pSP                  R
,          p\        VP;                  4       \*        \,        34      '       d   \!        VP;                  4       P/                  4       4      WP=                  4       ,          ,          ) \!        VP;                  4       P/                  4       4      WP=                  4       ,          ,          ,          pMn\!        VP;                  4       4      WP=                  4       ,          ,          ) \!        VP;                  4       4      WP=                  4       ,          ,          ,          p^ p\        SP                  P                  P                  V4      VP                  4      p\        SP                  P                  P                  V4      VP                  4      pV'       d   . p\?        WK,           4       EFB  pWt8  d|   V'       dM   XPA                  \!        W,          4      WV,           ,          ,          P3                  WV
,
          4      34       M%V\!        W,          4      W,          ,          ,          pK  \!        W,          4      ^ 8X  d   K  . p. p\C        VPE                  4       4       F:  pVPG                  \I        VV,
          V,          4      .VV,          ,          4       K<  	  \C        VPE                  4       4       F:  pVPG                  \I        VV,
          V,          4      .VV,          ,          4       K<  	  ^V9   d   VPK                  ^4       MVPA                  ^4       V'       d~   XPA                  \!        W,          4      WV,           ,          ,          P3                  WV
,
          4      \M        VVVW,          ,          4      P3                  WV
,
          4      34       EK  V\!        W,          4      \M        VVVW,          ,          4      ,          W,          ,          ,          pEKE  	  V'       d   X# WiV,          ,          pV
^ 8w  d   VP3                  WV
,
          4      # V# )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
)as_listr  r   r   r  r  z+Can't compute sufficient Initial Conditionsc              3   h   <"   T F'  qSP                   P                  P                  8g  x  K)  	  R # 5ir@   r   r   r   rD   s   & rE   r   -HolonomicFunction.to_hyper.<locals>.<genexpr>m  s$     C0B1AHHMM&&&0Bs   /2TFr   )'r  ra   r  r   to_hyperr  r  r}   r   r   r.   r{   rU   r   r   r   r   r   r~   r   r   r)   r*   as_exprr   r!  r  anyr;   LCrh  r   r   r   r  r  r5   remover%   )rc   r  r  r  r  r  rP   r   r  r}   r   mnonzerotermsr   r   r   r&  arg1arg2	listofsolapbqrV  rD   s   &&&                    @rE   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 3CQr0BC333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&&
rH   c                P    \        V P                  4       4      P                  4       # )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

)r4   r  simplifyr   s   &rE   r   HolonomicFunction.to_expr  s    & 4==?+4466rH   c                   RpVfD   \        V P                  4      V P                  P                  8  d   \        V P                  4      pV P                  P                  P
                  P                  p \        V P                  4       V P                  WVR7      pV'       d   XP                  V8X  d   V# V P                  VRR7      p\        V P                  V P                  W4      #   \        \        3 d    Rp Ldi ; i)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   lenicsrB   F)r  )r   r   r   r   r{   rU   rB   expr_to_holonomicr   r}   r:   r;   r   r"  r   )rc   r   r  symbolicr   rP   r   s   &&&    rE   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   5'C+ +D Dc                   V P                  RR7      p\        P                  pV F\  p\        V4      ^8X  d   W#^ ,          ,          pK$  \        V4      ^8X  g   K6  W#^ ,          \	        V^,          4      ,          ,          pK^  	  V# )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  )r  r   r   r   _hyper_to_meijerg)rc   rE  rP   r   s   &   rE   
to_meijergHolonomicFunction.to_meijerg  sj    , mmDm)ffA1v{tQ1t/!555  
rH   )r   r}   r   r   r}  FT)   FTN)RK4g?FFNr@   )'ro   rp   rq   rr   rs   r   rd   rg   rt   r   r   r   r   r   r  r   rm   r   r   r   r   r   r   r   rh  ru  r  r  r  r  r"  r  r  r  r   r  r  ru   rv   rw   s   @rE   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   rH   r   Fc           	        V P                   pV P                  pV P                  ^,          pVP                  \        4      P                  4       p\        \        P                  ! V4      R4      w  rxWh,          p	^p
V F  pWV,           ,          p
K  	  V	^,
          pTpV F  pWV,           ,          pK  	  W,
          p\        V 4      pV\        \        39   d   \        W4      P                  V4      # \        V\        4      '       ga   \!        VWaVP"                  RR7      pV'       g%   V^,          p\!        VWaVP"                  RR7      pK,  \        W4      P                  WQV4      # \        V\        4      '       de   ^p\!        VWaVP"                  VRR7      pV'       g&   V^,          p\!        VWaVP"                  VRR7      pK-  \        W4      P                  WQV4      # \        W4      P                  V4      # )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[   F	use_limit)r  r  r6  atomsr   poprX   r+   r   r4   r   r   r   ru  ra   r%   _find_conditionsr   )funcr   r"  r   r   r  r}   r   r[   xDxr1aixDx_1r2birP   simpr   s   &&&               rE   
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3rH   Tc           	        V P                   pV P                  p\        V P                  4      p\        V P                  4      p\        V4      p	V P
                  ^,          p
V
P                  \        4      P                  4       p\        VP                  V4      R4      w  rW,          pV^,           pVRW,           V	,
          ,          ,          pV F  pVVV,
          ,          pK  	  ^pV F  pVVV,
          ,          pK  	  VV,
          pV'       g   \        VV4      P                  V
4      # \        V 4      pV\        \        39   d   \        VV4      P                  V
4      # \!        V\"        4      '       gb   \%        VWVP&                  RR7      pV'       g%   V^,          p\%        VWVP&                  RR7      pK,  \        VV4      P                  WV4      # \!        V\"        4      '       df   ^p\%        VWVP&                  VRR7      pV'       g&   V^,          p\%        VWVP&                  VRR7      pK-  \        VV4      P                  WV4      # \        VV4      P                  V
4      # )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[   Fr  r   )r  r  r   anbmr6  r  r   r  rX   r   r   ru  r4   r   r   ra   r&   r  r   )r  r   r"  r  rB   r   r   r   r   r  r  r}   r   r[   r   xDx1r!  r"  r$  r%  rP   r&  r   s   &&&&&                  rE   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3rH   x_1N)_mytypec           
     
   \        V 4      p V P                  pV'       g-   \        V4      ^8X  d   VP                  4       pM"\	        R4      hW9   d   VP                  V4       \        V4      pVfO   V P                  \        4      '       d   \        pM\        p\        V4      ^ 8w  d   WX,          P                  4       p\        WW#WEVR7      p	V	'       d   V	# \        '       g   Vs/ s\        \        VR7       M V\        8w  d   Vs/ s\        \        VR7       V P                   '       Ed   V P#                  V\$        4      p
\'        V
\$        4      pV\        9   d.   \        V,          pV^ ,          ^,          P)                  V4      pM\+        WRVR7      pV'       g   \,        hV'       d   W=n        V'       g	   V'       g	   W-n        V# V'       g   VP2                  P4                  p\7        WW$4      pV'       g   V^,          p\7        WW$4      pK  \9        VP2                  WV4      # V'       g	   V'       g9   VP;                  V P<                  ^ ,          4      pV'       d   W=n        W-n        V# V'       g   VP2                  P4                  p\7        WW$4      pV'       g   V^,          p\7        WW$4      pK  VP;                  V P<                  ^ ,          W.4      # V P<                  pV P>                  p
\A        V^ ,          VRVR7      pV
\B        J d;   \E        ^\        V4      4       F   pV\A        VV,          VRVR7      ,          pK"  	  M]V
\F        J d;   \E        ^\        V4      4       F   pV\A        VV,          VRVR7      ,          pK"  	  MV
\H        J d   W^,          ,          pW-n        V'       g   \,        hV'       d   W=n        V'       g	   V'       g   V# VP.                  '       d   V# V'       g   VP2                  P4                  pVP2                  PK                  V4      '       d   VPM                  4       p\        V4      p\        V4      ^8X  d   VV^ ,          ,          \N        PP                  8X  dw   V^ ,          pWV,
          V,          ,          p\7        VWV4      p\S        V4       UUu. uF  w  ppV\U        V4      ,          NK  	  pppVV/p\9        VP2                  WV4      # \7        WW$4      pV'       g   V^,          p\7        WW$4      pK  \9        VP2                  WV4      # u uppi )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
z%Specify the variable for the function)r   r   r  rB   r  )rB   Fr  rB   )r}   r  rB   )+r   free_symbolsr   r  
ValueErrorr  r   rD  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   ru  r6  r  r  r   r   r   r   r   r  r   r   r~   r   )r  r}   r   r   r  rB   r  syms
extra_symssolpolyftr  rP   r  r6  r   rD   gsingular_icsr   s   &&&&&&&              rE   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;$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!!		

vvv
&&
""2&&MMOGq6Q;1QqT7aee+!AB{"A+Aqf=L9B<9PQ9PAA	!,,9PLQL!B$S__aR@@
4B
/C
at3S__aS99 Rs    T>c                   . p. pVP                   pVP                  4       pVP                  \        P                  4      p. p\        V 4       F  w  r\        WP                  4      '       d0   VP                  VP                  V
P                  4       4      4       MV\        WP                  4      '       g+   VP                  VP                  \        V
4      4      4       MVP                  V
4       VP                  W,          P                  4       4       VP                  W,          P                  4       4       K  	  V F  p	V	P                  V4      pK  	  V'       d   V) pVP                  VP                  4       4      p\        V4       F  w  rW,          W&   K  	  V! VR,          P                  4       VR,          P                  4       ,          P                  4       4      pV F  p	V	P                  V4      pK  	  VP                  VP                  4       4      p\        V4       FH  w  rW,          pV! VP                  4       VP                  4       ,          P                  4       4      W&   KJ  	  \!        W4      # )z
Normalize a given annihilator
r   )rU   r   r   r   r   r~   ra   r   r   r   r   r   numerdenomlcmgcdr]   )list_ofr{   r   numrB  rU   r	  	lcm_denomlist_of_coeffr   r   	gcd_numerfrac_anss   &&&          rE   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6rH   c                $   . p\        V 4      ^,
          pVP                  \        V ^ ,          V4      4       \        V R,          4       F,  w  rEVP                  \        WQ4      W,          ,           4       K.  	  VP                  W,          4       V# )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.
r   )r   r   rF  r~   )r   r	  rP   r   r   r   s   &&    rE   r5  r5  t	  so     CJ!AJJwz!}a()*R.)

71=:=01 * JJz}JrH   c                   V P                   pV P                  p\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \        V 4      # V P                  ^,          pR V 4       pRp\
        P                  3pR V 4       p\
        P                  pV F  p	V\        V	4      ,          pK  	  V F  p	V\        V	4      ,          pK  	  V\        WEWgV) 4      ,          # )z 
Converts a `hyper` to meijerg.
c              3   V   "   T F  q^ 8*  ;'       d    \        V4      V8H  x  K!  	  R# 5ir}  )r   ri  s   & rE   r   $_hyper_to_meijerg.<locals>.<genexpr>	  s%     
.2a6!!c!fk!2s   ))TFc              3   4   "   T F  p^V,
          x  K  	  R# 5ir  r   ri  s   & rE   r   rN  	  s     	A!a%%   c              3   4   "   T F  p^V,
          x  K  	  R# 5ir  r   ri  s   & rE   r   rN  	  s     
"Q1q55"rP  r   )
r  r  r  r4   r6  r   r   r   r$   r&   )
r  r  r  r  r)  anpr*  bmqrV  r   s
   &         rE   r  r  	  s     
B	B
s
.2
.sss
.2
...4  		!A 
	B
C
&&B
"
C	AaL  aL  wr!,,,rH   c                4   \        V 4      \        V4      8:  d;   \        W4       UUu. uF  w  r#W#,           NK  	  uppV\        V 4      R ,           pV# \        W4       UUu. uF  w  r#W#,           NK  	  uppV \        V4      R ,           pV# u uppi u uppi )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   rP   s   &&   rE   r   r   	  s     5zSZ!$U!23!2quu!23eCJK6HH J "%U!23!2quu!23eCJK6HHJ 43s   B"Bc                ~   V P                   P                  V P                  4      '       g   V P                  4       R8X  d   V P                  # V P                   pVP
                  p. pV P                  pVP                  P                  pVP                  4       pVP                   Fb  p\        WP                  P                  P                  4      '       g   K4  VP                  VP                  VP                  4       4      4       Kd  	  \        V4      V8  g   V\        V4      8:  d   V# \!        V4       U	u. uF  p	WI,          ) WC,          ,          NK  	  p
p	VR\#        \        V4      V4       p\!        W,
          4       F  p^ p\%        W4       Fn  w  r>\'        WP                  4      p\)        VRR4      '       g   Vu u # \        V\*        \,        34      '       d   VP/                  4       pWV,          ,          pKp  	  VP                  V4       \1        W4      p
K  	  W[\        V4      R ,           # u up	i )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{   rU   r   r   ra   r   r   r   r   r   r   rH  r  r  getattrr)   r*   r  r5  )	Holonomicr   r   r   r   r   r   r	  r   r   list_redr  r   rP   r   rD   s   &&              rE   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   :H:c                 V   \        V \        4      '       g   V P                  4       # VP                  V 4      pVP	                  V 4      pV) VP                  4       ,          W2P                  4       ,          ,           pV^,          pV! VP                  4       VP                  4       34      # r  )ra   r-   r   rA  rB  r   )fracr	  r  r  sol_num	sol_denoms   &&    rE   rF  rF  	  s|    dC  yy{	A	AcAFFHnq668|+G1Igoo!2!2!4566rH   c                    \        V \        4      '       g   V # V P                  pV P                  p\        P
                  p\        P
                  pV'       d   ^ RIHp \        \        V4      4       FF  w  rV'       d%   \        V	4      P                  XP                  4      p	WYW,          ,          ,          pKH  	  \        \        V4      4       FF  w  rV'       d%   \        V	4      P                  XP                  4      p	WiW,          ,          ,          pKH  	  \        V\        \        34      '       d   VP                  4       p\        V\        \        34      '       d   VP                  4       pWV,          # )r   )mp)ra   r-   rF  denr   r   mpmathr`  r~   reversedr   
_to_mpmathprecr)   r*   r  )
r\  r   mpmr  r  sol_psol_qr`  r   r   s
   &&&       rE   r  r  	  s    dC  AAFFEFFE
(1+&
%%bgg.ARU '
 (1+&
%%bgg.ARU '
 %+{344%+{344=rH   c                
   V P                  4       pV'       g   V P                  4       pMRpV'       g   V'       gy   V P                  4       w  rV	P                  4       '       dN   V
P                  '       d<   \	        V
\
        4      '       d   \        V
4      p
V
P                  V
P                  rRpMRpMRpV'       g   V'       g   V'       g   R# VP                  V4      p\        VR4      w  ppV P                  V4      '       g   \        VV^ V .4      # V'       Ed   V V,          V P                  V4      ,
          p\        VP                  VP                   RR7      pVP#                  V4      pVf   V^ 8X  d   V'       d   VP%                  V 4      P'                  4       p\)        \+        V4      4       F(  w  ppV^ 8X  d   K  \-        \+        V4      4      VR pTp M	  \)        X4       F7  w  pp\	        V\.        \0        34      '       g   K$  VP3                  4       VV&   K9  	  X\5        V4      /pEMV'       d   V P7                  4       w  ppVV,          V,          VVP                  V4      ,          ,           VVP                  V4      ,          ,
          p\        VP                  VP                   RR7      pEMKV'       EdC   XVX,          ,          V,          ^,
          p\        VV4      P9                  X	4      P:                  pVP#                  V4      pVf   V^ 8X  d   V'       d   Ve   V^8:  d   VP%                  V	4      P'                  4       p\)        \+        V4      4       F_  w  ppV^ 8X  d   K  \	        V\.        \0        34      '       d   VP3                  4       p\5        V4      X
,          p\5        V4      V
,          p M	  \	        X\.        \0        34      '       d   VP3                  4       pX\5        V.4      /pV'       g	   V'       g   \        XWV4      # V'       g   XP<                  pXP#                  V4      '       d   \        VW4      P?                  4       p\-        V4      p\A        V4      ^8X  d   VV^ ,          ,          \4        PB                  8X  dm   V^ ,          pWV,
          V,          ,          p\E        VWV4      p\)        V4       UUu. uF  w  ppV\G        V4      ,          NK  	  pppVV/p\        VWV4      # \E        WW$4      pV'       g   V^,          p\E        WW$4      pK  \        VWV4      # u uppi )zG
Converts polynomials, rationals and algebraic functions to holonomic.
TFNr[   r   )$is_polynomialis_rational_functionas_base_expr#  ra   r   r5   r  r  r   rX   rD  r   r   r  r   r{   r   r   r   r~   rc  r   r)   r*   r  r   as_numer_denomru  r   r   r  r   r   r  r   )r  r}   r   r   r  rB   r  ispolyisratbasepolyratexpr   r   is_algr   r   r[   rP   r   rE  r   r   rU  indicialr  r  rD   r  r>  r?  s   &&&&&&&                       rE   r3  r3  
  s.   
 !F))+e++-!!##(8(8(8&%(("6*88VXXqFFevQA!!T*EAr 88A;; QD622v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S!,, Rs   &Uc           	        a \         P                  ! V S4      pV'       d   Vw  rVrxMR # V U	u. uF  qV	^ ,          ,          NK  	  p
p	VP                  4       pV^ ,          S8X  d
   V^,          M\        P                  pV U	u. uF  qV	^,          ,           NK  	  pp	V U	u. uF  q^,          NK  	  pp	V3R lpV! V^ ,          V^ ,          4      w  ppV
^ ,          V,          \        VW#R7      ,          p\        ^\        V4      4       FC  p	V! W,          W,          4      w  ppVW,          V,          \        VW#R7      ,          ,          pKE  	  V# u up	i u up	i u up	i )Nc                   <a V P                   R,          pVP                  \        4      '       d   VP                  \        \
        4      pVP                  SRR7      p\        V4      ^ ,          pW4,          pVP                  4       pV^ ,          S8X  d
   V^,          M\        P                  pW,          oV3R lV P                   ^ ,          ^ ,           4       pV3R lV P                   ^ ,          ^,           4       pV3R lV P                   ^,          ^ ,           4       p	V3R lV P                   ^,          ^,           4       p
VS) ,          \        Wx3W3V4      3# )r   F)r2  c              3   4   <"   T F  qS,           x  K  	  R # 5ir@   r   r  s   & rE   r   5_convert_meijerint.<locals>._shift.<locals>.<genexpr>
       -_!ee_   c              3   4   <"   T F  qS,           x  K  	  R # 5ir@   r   r  s   & rE   r   rw  
  rx  ry  c              3   4   <"   T F  qS,           x  K  	  R # 5ir@   r   r  s   & rE   r   rw  
  rx  ry  c              3   4   <"   T F  qS,           x  K  	  R # 5ir@   r   r  s   & rE   r   rw  
  rx  ry  r   )r6  rD  r	   r!  r   r   collectr   rl  r   r   r&   )r  r.  r  dr   r   r=  r)  r  r*  r  rD   r}   s   &&         @rE   _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4rH   r0  )r'   	_rewrite1rl  r   r   r,  r   r   )r  r}   r  rB   r6  facpor>  r   r   fac_listr=  r.  po_listG_listr  rU  r   rP   s   &f&&               rE   r8  r8  n
  s3   tQ'DA %&&Aqad

AH&
A!	!qvvA!"#A1Q4xxG#AqddAF5& fQi,HE1
1+
Q Q
QC 1c&k"&)WZ0qx{U"\!h%VVV # JE ' $s   EE Ec                  a  RV 3R llpVP                  \        4      p\        VR4      w  rEV! \        \        4      V^,          ^,           \        ^ ^ ^.4       V! \	        \        4      V^,          ^,           \        ^ ^^ .4       V! \        \        4      V^,
          \        ^ ^4       V! \        \        4      V\        V^,          ,          ,           \        ^^ ^.4       V! \        \        4      ^\        ,          V,          V^,          ,           \        ^ ^ ^\        \        4      ,          .4       V! \        \        4      ^\        ,          V,          V^,          ,           \        ^ ^R\        \        4      ,          .4       V! \        \        4      R\        ,          V,          V^,          ,           \        ^ ^ ^\        \        4      ,          .4       V! \        \        4      V^,          ^,
          \        ^ ^ ^.4       V! \        \        4      V^,          ^,
          \        ^ ^^ .4       V! \        \        4      \        ^V,          ,           \        V^,          ,          ,           \        4       V! \        \        4      \        V,          ^V^,          ,          ,           \        V^,          ,          ,           \        4       V! \!        \        4      \        V,          ^V^,          ,          ,           \        V^,          ,          ,           \        4       V! \#        \        4      \        ) V,          ^V^,          ,          ,           \        V^,          ,          ,           \        4       R# )z]
Creates the look-up table. For a similar implementation
see meijerint._create_lookup_table.
c           	     ~   < SP                  \        V \        4      . 4      P                  V \	        WW44      34       R# )z"
Adds a formula in the dictionary
N)r3  r.  r-  r   r   )formular   argr   r   tables   &&&&&rE   add_create_table.<locals>.add
  s8     	#.3::Gk7<9 	:rH   r[   N)r   r   )r   r-  rX   r   r   r   r   r!   r   r
   r"   r#   r   r   r   r    r   r   )r  rB   r  r   r   r[   s   f&    rE   r6  r6  
  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/5rH   c                 j   . p\        V4       F  pV P                  W4      pV'       d   VP                  4       pV'       d#   \        V\        4      '       d   \        WV4      pVP                  R J g   \        V\        4      '       d    R# VP                  V4       V P                  V4      p K  	  V# r  )	r   r!  r"  ra   r   r2   r  r   r   )	r  r}   r   r   r"  r  r   r   vals	   &&&&&&   rE   r  r  
  s    	B5\ii))+CC--$C==E!ZS%9%9
		#yy|  IrH   )r   F)Nr   NNNTr  r  r=  )trs   
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.polytoolsr/   sympy.polys.matricesr0   sympy.printingr1   sympy.series.limitsr2   sympy.series.orderr3   sympy.simplify.hyperexpandr4   sympy.simplify.simplifyr5   sympy.solvers.solversr6   r  r7   r8   r9   holonomicerrorsr:   r;   r<   r=   rQ   rX   rS   r]   r   r'  r,  r-  r4  r5  sympy.integrals.meijerintr.  r  r  r5  r  r   r  rF  r  r3  r8  r6  r  r   rH   rE   <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rH   