Ë
    7^(hïf ã                   óÚ  — d Z ddlmZmZmZ ddlmZmZmZm	Z	m
Z
mZmZmZ ddlmZ ddlmZ ddlmZmZ ddlmZ ddlmZmZmZ dd	lmZmZmZ dd
lm Z m!Z! ddl"m#Z# ddl$m%Z%m&Z&m'Z' ddl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z=m>Z> ddl?m@Z@ ddlAmBZB ddlCmDZD ddlEmFZF ddlGmHZH ddlImJZJ ddlKmLZL ddlMmNZN ddlOmPZP ddlQmRZR dd lSmTZTmUZUmVZV dd!lWmXZXmYZYmZZZm[Z[ d"„ Z\d#„ Z] G d$„ d%«      Z^ G d&„ d'«      Z_ G d(„ d)«      Z`d=d+„Zadd*d,e=fd-„Zb ed.«      Zcd/add/aedd0lfmgZg d>d1„Zhd?d2„Zid3„ Zjd4„ Zkd5„ Zld6„ Zmd7„ Znd@d8„Zodd/d/e=d,fd9„Zpd,e=fd:„Zqe=fd;„ZrdAd<„Zsy/)BzL
This module implements Holonomic Functions and
various operations on them.
é    )ÚAddÚMulÚPow)ÚNaNÚInfinityÚNegativeInfinityÚFloatÚIÚpiÚequal_valuedÚ
int_valued)ÚS)Úordered)ÚDummyÚSymbol)Úsympify)ÚbinomialÚ	factorialÚrf)Ú	exp_polarÚexpÚlog)ÚcoshÚsinh)Úsqrt)ÚcosÚsinÚsinc)ÚCiÚShiÚSiÚerfÚerfcÚerfi)Úgamma)ÚhyperÚmeijerg)Ú	meijerint)ÚMatrix)ÚPolyElement)ÚFracElement)ÚQQÚRR)ÚDMF)Úroots)ÚPoly)ÚDomainMatrix)Ússtr)Úlimit)ÚOrder)Úhyperexpand)Ú	nsimplify)Úsolveé   )ÚHolonomicSequenceÚRecurrenceOperatorÚRecurrenceOperators)ÚNotPowerSeriesErrorÚNotHyperSeriesErrorÚSingularityErrorÚNotHolonomicErrorc                 ó˜   ‡ — ˆ fd„}‰ j                  |«      \  }}|j                  d   } |d|f«      |z  }||z   j                  «       }|S )Nc                 óD   •— t        j                  | ‰j                  «      S ©N)r1   ÚonesÚdomain)ÚshapeÚrs    €úW/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/holonomic/holonomic.pyú<lambda>z(_find_nonzero_solution.<locals>.<lambda>+   s   ø€ œ×*Ñ*¨5°!·(±(Ó;€ ó    r   r8   )Ú_solverE   Ú	transpose)rF   ÚhomosysrC   Ú
particularÚ	nullspaceÚnullityÚnullpartÚsols   `       rG   Ú_find_nonzero_solutionrR   *   sT   ø€ Û;€DØŸH™H WÓ-Ñ€J�	Ø�o‰o˜aÑ €GÙ�Q˜�LÓ! IÑ-€HØ˜Ñ ×
+Ñ
+Ó
-€CØ€JrI   c                 ó6   — t        | |«      }||j                  fS )aµ  
    This function is used to create annihilators using ``Dx``.

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

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

    Parameters
    ==========

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

    Examples
    ========

    >>> from sympy import ZZ
    >>> from sympy.abc import x
    >>> from sympy.holonomic.holonomic import DifferentialOperators
    >>> R, Dx = DifferentialOperators(ZZ.old_poly_ring(x), 'Dx')
    >>> R
    Univariate Differential Operator Algebra in intermediate Dx over the base ring ZZ[x]
    >>> Dx*x
    (1) + (x)*Dx
    )ÚDifferentialOperatorAlgebraÚderivative_operator)ÚbaseÚ	generatorÚrings      rG   ÚDifferentialOperatorsrY   4   s"   € ôD ' t¨YÓ7€DØ�$×*Ñ*Ð+Ð+rI   c                   ó&   — e Zd ZdZd„ Zd„ ZeZd„ Zy)rT   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                 ó   — || _         t        |j                  |j                  g| «      | _        |€t        dd¬«      | _        y t        |t        «      rt        |d¬«      | _        y t        |t
        «      r|| _        y y )NÚDxF)Úcommutative)	rV   ÚDifferentialOperatorÚzeroÚonerU   r   Ú
gen_symbolÚ
isinstanceÚstr)ÚselfrV   rW   s      rG   Ú__init__z$DifferentialOperatorAlgebra.__init__�   sl   € àˆŒ	ä#7Ø�Y‰Y˜Ÿ™Ð! 4ó$)ˆÔ ð ÐÜ$ T°uÔ=ˆD�Oä˜)¤SÔ)Ü"(¨ÀÔ"F�•Ü˜I¤vÔ.Ø"+�•ð /rI   c                 ór   — dt        | j                  «      z   dz   | j                  j                  «       z   }|S )Nz9Univariate Differential Operator Algebra in intermediate z over the base ring )r2   ra   rV   Ú__str__)rd   Ústrings     rG   rg   z#DifferentialOperatorAlgebra.__str__�   s<   € ØLÜ�4—?‘?Ó#ñ$Ø&<ñ=à�Y‰Y×ÑÓ!ñ"ˆð ˆrI   c                 ój   — | j                   |j                   k(  xr | j                  |j                  k(  S rB   )rV   ra   ©rd   Úothers     rG   Ú__eq__z"DifferentialOperatorAlgebra.__eq__™   s.   € Ø�y‰y˜EŸJ™JÑ&ò 3Ø�‰ %×"2Ñ"2Ñ2ð	3rI   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__re   rg   Ú__repr__rl   © rI   rG   rT   rT   Z   s   „ ñ$òL,òð €Hó3rI   rT   c                   ód   — e Zd ZdZdZd„ Zd„ Zd„ Zd„ ZeZ	d„ Z
d„ Zd	„ Zd
„ Zd„ Zd„ ZeZd„ Zd„ Zy)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                 óà  — || _         | j                   j                  }t        |j                  d   t        «      r|j                  d   n|j                  d   d   | _        t        |«      D ]\  \  }}t        ||j                  «      s|j                  t        |«      «      ||<   Œ:|j                  |j                  |«      «      ||<   Œ^ || _        t        | j                  «      dz
  | _        y)zÍ
        Parameters
        ==========

        list_of_poly:
            List of polynomials belonging to the base ring of the algebra.
        parent:
            Parent algebra of the operator.
        r   r8   N)ÚparentrV   rb   Úgensr   ÚxÚ	enumerateÚdtypeÚ
from_sympyr   Úto_sympyÚ
listofpolyÚlenÚorder)rd   Úlist_of_polyrv   rV   ÚiÚjs         rG   re   zDifferentialOperator.__init__Ä   sÃ   € ð ˆŒØ�{‰{×ÑˆÜ!+¨D¯I©I°a©L¼&Ô!A�—‘˜1’ÀtÇyÁyÐQRÁ|ÐTUÁˆŒô
 ˜lÓ+ò 	D‰DˆAˆqÜ˜a §¡Ô,Ø"&§/¡/´'¸!³*Ó"=�˜Q’à"&§/¡/°$·-±-ÀÓ2BÓ"C�˜Q’ð		Dð 'ˆŒä˜Ÿ™Ó)¨AÑ-ˆ�
rI   c                 óÔ  ‡ — ‰ j                   }t        |t        «      r|j                   }n]t        |‰ j                  j                  j
                  «      r|g}n/‰ j                  j                  j                  t        |«      «      g}d„ } ||d   |«      }ˆ fd„}t        dt        |«      «      D ]   } ||«      }t        | |||   |«      «      }Œ" t        |‰ j                  «      S )z£
        Multiplies two DifferentialOperator and returns another
        DifferentialOperator instance using the commutation rule
        Dx*a = a*Dx + a'
        c                 ó^   — t        |t        «      r|D �cg c]  }|| z  ‘Œ	 c}S | |z  gS c c}w rB   )rb   Úlist)ÚbÚlistofotherr�   s      rG   Ú_mul_dmp_diffopz5DifferentialOperator.__mul__.<locals>._mul_dmp_diffopò   s3   € Ü˜+¤tÔ,Ø'2Ö3 !˜˜A›Ò3Ð3Ø˜‘OÐ$Ð$ùò 4s   •*r   c                 óÞ  •— ‰j                   j                  j                  g}g }t        | t        «      r8| D ]2  }|j                  |«       |j                  |j                  «       «       Œ4 nv|j                  ‰j                   j                  j                  | «      «       |j                  ‰j                   j                  j                  | «      j                  «       «       t        ||«      S rB   )	rv   rV   r_   rb   r…   ÚappendÚdiffr{   Ú
_add_lists)r†   Úsol1Úsol2r�   rd   s       €rG   Ú
_mul_Dxi_bz0DifferentialOperator.__mul__.<locals>._mul_Dxi_bú   s°   ø€ Ø—K‘K×$Ñ$×)Ñ)Ð*ˆDØˆDä˜!œTÔ"Øò *�AØ—K‘K ”NØ—K‘K §¡£Õ)ñ*ð —‘˜DŸK™K×,Ñ,×7Ñ7¸Ó:Ô;Ø—‘˜DŸK™K×,Ñ,×7Ñ7¸Ó:×?Ñ?ÓAÔBä˜d DÓ)Ð)rI   r8   )r}   rb   r^   rv   rV   rz   r{   r   Úranger~   rŒ   )rd   rk   Ú
listofselfr‡   rˆ   rQ   r�   r�   s   `       rG   Ú__mul__zDifferentialOperator.__mul__â   sÔ   ø€ ð —_‘_ˆ
Ü�eÔ1Ô2Ø×*Ñ*‰KÜ˜˜tŸ{™{×/Ñ/×5Ñ5Ô6Ø ˜'‰KàŸ;™;×+Ñ+×6Ñ6´w¸u³~ÓFÐGˆKò	%ñ
 ˜j¨™m¨[Ó9ˆô	*ô �qœ#˜j›/Ó*ò 	OˆAá$ [Ó1ˆKä˜S¡/°*¸Q±-ÀÓ"MÓN‰Cð		Oô $ C¨¯©Ó5Ð5rI   c                 óB  — t        |t        «      sŠt        || j                  j                  j                  «      s.| j                  j                  j                  t        |«      «      }| j                  D �cg c]  }||z  ‘Œ	 }}t        || j                  «      S y c c}w rB   )rb   r^   rv   rV   rz   r{   r   r}   )rd   rk   r‚   rQ   s       rG   Ú__rmul__zDifferentialOperator.__rmul__  s{   € Ü˜%Ô!5Ô6ä˜e T§[¡[×%5Ñ%5×%;Ñ%;Ô<ØŸ™×)Ñ)×5Ñ5´g¸e³nÓE�à&*§o¡oÖ6 �5˜1“9Ð6ˆCÐ6Ü'¨¨T¯[©[Ó9Ð9ð 7ùò
 7s   Á7Bc                 ó°  — t        |t        «      r6t        | j                  |j                  «      }t        || j                  «      S | j                  }t        || j                  j
                  j                  «      s0| j                  j
                  j                  t        |«      «      g}n|g}|d   |d   z   g|dd  z   }t        || j                  «      S )Nr   r8   )	rb   r^   rŒ   r}   rv   rV   rz   r{   r   )rd   rk   rQ   Ú	list_selfÚ
list_others        rG   Ú__add__zDifferentialOperator.__add__  s°   € Ü�eÔ1Ô2ä˜TŸ_™_¨e×.>Ñ.>Ó?ˆCÜ'¨¨T¯[©[Ó9Ð9à—O‘Oˆ	Ü˜% §¡×!1Ñ!1×!7Ñ!7Ô8Ø ŸK™K×-Ñ-×9Ñ9¼'À%».ÓIÐJ‰Jà˜ˆJØ˜‰|˜j¨™mÑ+Ð,¨y¸¸¨}Ñ<ˆÜ# C¨¯©Ó5Ð5rI   c                 ó   — | d|z  z   S ©Néÿÿÿÿrr   rj   s     rG   Ú__sub__zDifferentialOperator.__sub__)  s   € Ø�r˜U‘lÑ"Ð"rI   c                 ó   — d| z  |z   S rš   rr   rj   s     rG   Ú__rsub__zDifferentialOperator.__rsub__,  s   € Ø�d‰{˜UÑ"Ð"rI   c                 ó   — d| z  S rš   rr   ©rd   s    rG   Ú__neg__zDifferentialOperator.__neg__/  ó   € Ø�D‰yÐrI   c                 ó.   — | t         j                  |z  z  S rB   ©r   ÚOnerj   s     rG   Ú__truediv__z DifferentialOperator.__truediv__2  ó   € Ø”q—u‘u˜u‘}Ñ%Ð%rI   c                 óÔ  — |dk(  r| S t        | j                  j                  j                  g| j                  «      }|dk(  r|S | j                  | j                  j
                  j                  k(  r\| j                  j                  j                  g|z  | j                  j                  j                  gz   }t        || j                  «      S | }	 |dz  r||z  }|dz  }|s	 |S ||z  }Œ)Nr8   r   é   )r^   rv   rV   r`   r}   rU   r_   )rd   ÚnÚresultrQ   rx   s        rG   Ú__pow__zDifferentialOperator.__pow__5  sÛ   € Ø�Š6ØˆKÜ% t§{¡{×'7Ñ'7×';Ñ';Ð&<¸d¿k¹kÓJˆØ�Š6ØˆMà�?‰?˜dŸk™k×=Ñ=×HÑHÒHØ—;‘;×#Ñ#×(Ñ(Ð)¨!Ñ+¨t¯{©{×/?Ñ/?×/CÑ/CÐ.DÑDˆCÜ'¨¨T¯[©[Ó9Ð9ØˆØØ�1ŠuØ˜!‘�Ø�!‰GˆAÙØàˆð �‰FˆAð rI   c                 óò  — | j                   }d}t        |«      D ]Ú  \  }}|| j                  j                  j                  k(  rŒ*| j                  j                  j                  |«      }|dk(  r|dt        |«      z   dz   z  }Œi|r|dz  }|dk(  r,|dt        |«      z   d| j                  j                  z  z   z  }Œ¡|dt        |«      z   dz   d| j                  j                  z  z   t        |«      z   z  }ŒÜ |S )	NÚ r   ú(ú)z + r8   z)*%sz*%s**)r}   ry   rv   rV   r_   r|   r2   ra   )rd   r}   Ú	print_strr�   r‚   s        rG   rg   zDifferentialOperator.__str__I  sü   € Ø—_‘_ˆ
Øˆ	ä˜jÓ)ò 	[‰DˆAˆqØ�D—K‘K×$Ñ$×)Ñ)Ò)Øà—‘× Ñ ×)Ñ)¨!Ó,ˆAà�AŠvØ˜S¤4¨£7™]¨SÑ0Ñ0�	ØáØ˜UÑ"�	à�AŠvØ˜S¤4¨£7™]¨V°d·k±k×6LÑ6LÑ-MÑMÑM�	Øà˜œt A›w™¨Ñ,¨w¸¿¹×9OÑ9OÑ/PÑPÔSWÐXYÓSZÑZÑZ‰Ið#	[ð& ÐrI   c                 óö   ‡ — t        |t        «      r4‰ j                  |j                  k(  xr ‰ j                  |j                  k(  S ‰ j                  d   |k(  xr! t	        ˆ fd„‰ j                  dd  D «       «      S )Nr   c              3   ób   •K  — | ]&  }|‰j                   j                  j                  u –— Œ( y ­wrB   ©rv   rV   r_   )Ú.0r�   rd   s     €rG   ú	<genexpr>z.DifferentialOperator.__eq__.<locals>.<genexpr>i  s&   øè ø€ ÒH¨q��T—[‘[×%Ñ%×*Ñ*Ô*ÑHùs   ƒ,/r8   )rb   r^   r}   rv   Úallrj   s   ` rG   rl   zDifferentialOperator.__eq__d  sp   ø€ Ü�eÔ1Ô2Ø—?‘? e×&6Ñ&6Ñ6ò /Ø—;‘; %§,¡,Ñ.ð/à�‰˜qÑ! UÑ*ò IÜÓH°D·O±OÀAÀBÐ4GÔHÓHð	IrI   c                 ó–   — | j                   j                  }|t        |j                  | j                  d   «      | j
                  «      v S )zH
        Checks if the differential equation is singular at x0.
        r›   )rv   rV   r/   r|   r}   rx   )rd   Úx0rV   s      rG   Úis_singularz DifferentialOperator.is_singulark  s;   € ð
 �{‰{×ÑˆØ”U˜4Ÿ=™=¨¯©¸Ñ)<Ó=¸t¿v¹vÓFÐFÐFrI   N)rm   rn   ro   rp   Ú_op_priorityre   r’   r”   r˜   Ú__radd__rœ   rž   r¡   r¦   r¬   rg   rq   rl   rº   rr   rI   rG   r^   r^   ž   s\   „ ñ!ðF €Lò.ò<,6ò\:ò6ð €Hò#ò#òò&òò(ð2 €HòIóGrI   r^   c                   óÚ   — e Zd ZdZdZd!d„Zd„ ZeZd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd"d„Zd„ Zd„ Zd„ ZeZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd#d„Zd#d„Zd$d„Zd„ Zd%d„Zd„ Zd„ Zd&d„Z d„ Z!d'd„Z"d „ Z#y)(ÚHolonomicFunctiona’
  
    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

    rt   Nc                 ó<   — || _         || _        || _        || _        y)ap  

        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¹   Úannihilatorrx   )rd   rÁ   rx   r¹   rÀ   s        rG   re   zHolonomicFunction.__init__¹  s!   € ð, ˆŒàˆŒà&ˆÔØˆ�rI   c           
      ó>  — | j                  «       r]dt        | j                  «      ›dt        | j                  «      ›dt        | j
                  «      ›dt        | j                  «      ›d�	}|S dt        | j                  «      ›dt        | j                  «      ›d�}|S )NzHolonomicFunction(z, r°   )Ú_have_init_condrc   rÁ   r2   rx   r¹   rÀ   )rd   Ústr_sols     rG   rg   zHolonomicFunction.__str__Ö  sw   € Ø×ÑÕ!Ü=@À×AQÑAQÕ=RÜ�T—V‘V•œd 4§7¡7�m¬T°$·'±'­]ð<ˆGð ˆð "ô 69¸×9IÑ9IÕ5JÜ�T—V‘V•ðˆGð ˆrI   c                 óH  — | j                   j                  j                  }|j                   j                  j                  }|j                  }|j                  }||k(  r| |fS |j	                  |«      j                  | j                  «      }t        |t        | j                   j                  j                  «      «      \  }}| j                   j                  D �	cg c]  }	|j                  |	«      ‘Œ }
}	|j                   j                  D �	cg c]  }	|j                  |	«      ‘Œ }}	t        |
|«      }
t        ||«      }t        |
| j                  | j                  | j                  «      }
t        ||j                  |j                  |j                  «      }|
|fS c c}	w c c}	w )z^
        Unifies the base polynomial ring of a given two Holonomic
        Functions.
        )rÁ   rv   rV   ÚdomÚunifyÚold_poly_ringrx   rY   rc   ra   r}   r|   r^   r¾   r¹   rÀ   )rd   rk   ÚR1ÚR2Údom1Údom2ÚRÚ	newparentÚ_r�   r�   rŽ   s               rG   rÇ   zHolonomicFunction.unifyâ  sJ  € ð ×Ñ×$Ñ$×)Ñ)ˆØ×Ñ×%Ñ%×*Ñ*ˆà�v‰vˆØ�v‰vˆà�Š8Ø˜%�=Ð à�Z‰Z˜Ó×,Ñ,¨T¯V©VÓ4ˆä,¨Q´°D×4DÑ4D×4KÑ4K×4VÑ4VÓ0WÓX‰ˆ	�1à(,×(8Ñ(8×(CÑ(CÖD 1�—‘˜A•ÐDˆÐDØ(-×(9Ñ(9×(DÑ(DÖE 1�—‘˜A•ÐEˆÐEä# D¨)Ó4ˆÜ# D¨)Ó4ˆä   t§v¡v¨t¯w©w¸¿¹Ó@ˆÜ   u§w¡w°·±¸%¿(¹(ÓCˆà�dˆ|Ðùò EùÚEs   ÃFÄFc                 óp   — t        | j                  t        «      ryt        | j                  t        «      ryy)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)rb   rÀ   Údictr…   r    s    rG   Úis_singularicsz HolonomicFunction.is_singularics   s+   € ô �d—g‘gœtÔ$ØÜ˜Ÿ™¤Ô&Øð 'rI   c                 ó,   — t        | j                  «      S )z@
        Checks if the function have initial condition.
        )ÚboolrÀ   r    s    rG   rÃ   z!HolonomicFunction._have_init_cond  s   € ô �D—G‘G‹}ÐrI   c           
      ó®  — t        | j                  «      d   }| j                  |   }t        | j                  «      dk(  r�|t        |«      k(  r�|dkD  r{t        |«      }t        j
                  g|z  }|t        |«      D ��cg c]  \  }}|t        ||z   «      z  ‘Œ c}}z  }t        | j                  | j                  | j                  |«      S yyyc c}}w )zP
        Converts a singular initial condition to ordinary if possible.
        r   r8   N)r…   rÀ   r~   Úintr   ÚZerory   r   r¾   rÁ   rx   r¹   )rd   Úar†   rÀ   r�   r‚   s         rG   Ú_singularics_to_ordz%HolonomicFunction._singularics_to_ord  sµ   € ô �—‘‹M˜!ÑˆØ�G‰G�A‰Jˆäˆt�w‰w‹<˜1Ò ¤c¨!£f¢°°Q²Ü�A“ˆAÜ—&‘&�˜A‘ˆBØ´I¸a³L×A©D¨A¨q�1”y  Q¡Ó'Ó'ÓAÑAˆBä$ T×%5Ñ%5°t·v±v¸t¿w¹wÈÓKÐKð 27 Ðùó Bs   ÂCc                 óÊ  — | j                   j                  j                  |j                   j                  j                  k7  r| j                  |«      \  }}||z   S | j                   j                  }|j                   j                  }t        ||«      }| j                   j                  j                  }|j                  «       }| j                   g}	|j                   g}
| j                   j                  j                  }t        ||z
  «      D ]  }||	d   z  }|	j                  |«       Œ t        ||z
  «      D ]  }||
d   z  }|
j                  |«       Œ |	|
z   }g }|D ]—  }g }t        |dz   «      D ]q  }|t        |j                  «      k\  r|j                  |j                  «       Œ7|j                  |j                  |j                  |   j                  «       «      «       Œs |j                  |«       Œ™ t        |t        |«      |dz   f|«      j!                  «       }t        j"                  |dz   df|«      }t%        ||«      }|j&                  �r8|dz  }||	d   z  }|	j                  |«       ||
d   z  }|
j                  |«       |	|
z   }g }|D ]—  }g }t        |dz   «      D ]q  }|t        |j                  «      k\  r|j                  |j                  «       Œ7|j                  |j                  |j                  |   j                  «       «      «       Œs |j                  |«       Œ™ t        |t        |«      |dz   f|«      j!                  «       }t        j"                  |dz   df|«      }t%        ||«      }|j&                  r�Œ8|j)                  «       d |dz   |z
   }t+        || j                   j                  «      }|| j                   z  }t+        |j                  | j                   j                  d¬«      }| j-                  «       r|j-                  «       st/        || j0                  «      S | j3                  «       dk(  �rª|j3                  «       dk(  �r–| j4                  |j4                  k(  rot7        | |j                  «      }t7        ||j                  «      }t9        ||«      D ��cg c]
  \  }}||z   ‘Œ }}}t/        || j0                  | j4                  |«      S | j                   j;                  d«      }|j                   j;                  d«      }| j4                  dk(  r|s|s| |j=                  d«      z   S |j4                  dk(  r|s|s| j=                  d«      |z   S | j                   j;                  | j4                  «      }|j                   j;                  | j4                  «      }|s |s| |j=                  | j4                  «      z   S | j=                  |j4                  «      |z   S | j4                  |j4                  k7  rt/        || j0                  «      S d }d }| j3                  «       dk(  re|j3                  «       dk(  rRt?        | j@                  «      D ��cg c]  \  }}|tC        |«      z  ‘Œ }}}tD        jF                  |i}|j@                  }n¶| j3                  «       dk(  re|j3                  «       dk(  rRt?        |j@                  «      D ��cg c]  \  }}|tC        |«      z  ‘Œ }}}| j@                  }tD        jF                  |i}n>| j3                  «       dk(  r+|j3                  «       dk(  r| j@                  }|j@                  }i }|D ]:  }||v r,t9        ||   ||   «      D ��cg c]
  \  }}||z   ‘Œ c}}||<   Œ3||   ||<   Œ< |D ]  }||vsŒ||   ||<   Œ t/        || j0                  | j4                  |«      S c c}}w c c}}w c c}}w c c}}w )Nr›   r8   F©Únegativer   T)$rÁ   rv   rV   rÇ   r   ÚmaxÚ	get_fieldrU   r�   rŠ   r~   r}   r_   ÚnewÚto_listr1   rK   ÚzerosrR   Úis_zero_matrixÚflatÚ
_normalizerÃ   r¾   rx   rÒ   r¹   Ú
_extend_y0Úziprº   Ú
change_icsry   rÀ   r   r   r×   )rd   rk   rØ   r†   Údeg1Údeg2ÚdimrÍ   ÚKÚrowsselfÚ	rowsotherÚgenr�   Údiff1Údiff2ÚrowrF   ÚexprÚprL   rQ   r�   Úy1Úy2rÀ   Úselfat0Úotherat0Úselfatx0Ú	otheratx0r‚   Ú_y0s                                  rG   r˜   zHolonomicFunction.__add__$  s  € à×Ñ×"Ñ"×'Ñ'¨5×+<Ñ+<×+CÑ+C×+HÑ+HÒHØ—:‘:˜eÓ$‰DˆAˆqØ�q‘5ˆLà×Ñ×%Ñ%ˆØ× Ñ ×&Ñ&ˆÜ�$˜‹oˆØ×Ñ×#Ñ#×(Ñ(ˆØ�K‰K‹Mˆà×$Ñ$Ð%ˆØ×&Ñ&Ð'ˆ	Ø×Ñ×%Ñ%×9Ñ9ˆô �s˜T‘zÓ"ò 	#ˆAØ˜8 B™<Ñ'ˆEØ�O‰O˜EÕ"ð	#ô �s˜T‘zÓ"ò 	$ˆAØ˜9 R™=Ñ(ˆEØ×Ñ˜UÕ#ð	$ð ˜Ñ"ˆð ˆàò 	ˆDØˆAÜ˜3 ™7“^ò B�Øœ˜DŸO™OÓ,Ò,Ø—H‘H˜QŸV™VÕ$à—H‘H˜QŸU™U 4§?¡?°1Ñ#5×#=Ñ#=Ó#?Ó@ÕAð	Bð
 �H‰H�Q�Kð	ô ˜œS ›X s¨1¡uÐ-¨qÓ1×;Ñ;Ó=ˆÜ×$Ñ$ c¨!¡e¨Q Z°Ó3ˆÜ$ Q¨Ó0ˆð × Ó Ø�1‰HˆCà˜8 B™<Ñ'ˆEØ�O‰O˜EÔ"à˜9 R™=Ñ(ˆEØ×Ñ˜UÔ#à˜YÑ&ˆCØˆAàò �Ø�Ü˜s Q™w›ò F�AØœC §¡Ó0Ò0ØŸ™ §¡Õ(àŸ™ §¡ t§¡°qÑ'9×'AÑ'AÓ'CÓ!DÕEð	Fð
 —‘˜•ðô ˜Q¤ S£¨3¨q©5Ð 1°1Ó5×?Ñ?ÓAˆAÜ"×(Ñ(¨#¨a©%°¨°QÓ7ˆGÜ(¨¨GÓ4ˆCð1 × Ô ð: �h‰h‹j˜˜# ™' D™.Ð)ˆÜ˜#˜t×/Ñ/×6Ñ6Ó7ˆà�d×&Ñ&Ñ'ˆÜ˜Ÿ™¨×)9Ñ)9×)@Ñ)@È5ÔQˆà×$Ñ$Ô&¨5×+@Ñ+@Ô+BÜ$ S¨$¯&©&Ó1Ð1ð ×ÑÓ  EÓ)¨e×.BÑ.BÓ.DÈÓ.Mð �w‰w˜%Ÿ(™(Ò"ô    c§i¡iÓ0�Ü  s§y¡yÓ1�Ü(+¨B°«×4¡  1�a˜!“eÐ4�Ñ4Ü(¨¨d¯f©f°d·g±g¸rÓBÐBð ×&Ñ&×2Ñ2°1Ó5ˆGØ×(Ñ(×4Ñ4°QÓ7ˆHØ�w‰w˜!Š|¡G±HØ˜e×.Ñ.¨qÓ1Ñ1Ð1Ø�x‰x˜1Š}¡W±XØ—‘ qÓ)¨EÑ1Ð1à×'Ñ'×3Ñ3°D·G±GÓ<ˆHØ×)Ñ)×5Ñ5°d·g±gÓ>ˆIÙ¡IØ˜e×.Ñ.¨t¯w©wÓ7Ñ7Ð7Ø—?‘? 5§8¡8Ó,¨uÑ4Ð4à�7‰7�e—h‘hÒÜ$ S¨$¯&©&Ó1Ð1ð ˆØˆà×ÑÓ  EÒ)¨e×.BÑ.BÓ.DÈÒ.Lä09¸$¿'¹'Ó0B×C©¨¨1�1”y “|Ó#ÐCˆCÑCÜ—&‘&˜#�ˆBØ—‘‰BØ× Ñ Ó" dÒ*¨u×/CÑ/CÓ/EÈÒ/NÜ09¸%¿(¹(Ó0C×D©¨¨1�1”y “|Ó#ÐDˆCÑDØ—‘ˆBÜ—&‘&˜#�‰BØ× Ñ Ó" dÒ*¨u×/CÑ/CÓ/EÈÒ/MØ—‘ˆBØ—‘ˆBð ˆØò 	ˆAð �B‰wÜ+.¨r°!©u°b¸±eÓ+<×=¡4 1 a˜˜Q›Ó=��1’à˜1™��1’ð	ð ò 	ˆAØ˜Š{Ø˜1™��1’ð	ô !  d§f¡f¨d¯g©g°rÓ:Ð:ùóe 5ùó4 Dùó Eùó >s   Ò3_Ù&_Û_Ý6_c           	      ó‚	  — | j                   j                  j                  }| j                  «       dk(  �r| j	                  «       }|r|j                  ||¬«      S i }| j                  D ]Œ  }| j                  |   }g }t        |«      D ]c  \  }	}
|
dk(  r |j                  t        j                  «       Œ+||	z   dz   dk(  rt        d«      ‚|j                  |
t        ||	z   dz   «      z  «       Œe |||dz   <   ŒŽ t        |d«      rt        d«      ‚t        | j                   |z  | j                  | j                  |«      S | j!                  «       sc|r>t        | j                   |z  | j                  | j                  t        j                  g«      S t        | j                   |z  | j                  «      S t        |d«      r9t#        |«      dk(  r-|d   | j                  k(  r| j                  }|d   }|d	   }d}nd
}t        j                  g}|| j                  z  }t        | j                   |z  | j                  | j                  |«      }s|S k7  �r&	 |j%                  «       }|rI|j+                  | j                  |«      }t-        |t.        «      r.|j1                  | j                  |«      }n|j3                  |«      }| j                  k(  r0|d   |z
  |d<   t        | j                   |z  | j                  ||«      S t        |«      j4                  re|rM|j+                  | j                  |«      }t-        |t.        «      r|j1                  | j                  |«      }||z
  S |j3                  |«      }||z
  S | j                  k(  r%t        | j                   |z  | j                  ||«      S t        |«      j4                  r~	 t        | j                   |z  | j                  ||«      j%                  «       }|j+                  | j                  |«      }t-        |t.        «      s|S |j1                  | j                  |«      S t        | j                   |z  | j                  «      S # t&        t(        f$ r d}Y �Œw xY w# t&        t(        f$ r7 t        | j                   |z  | j                  ||«      j3                  |«      cY S w xY w)az  
        Integrates the given holonomic function.

        Examples
        ========

        >>> from sympy.holonomic.holonomic import HolonomicFunction, DifferentialOperators
        >>> from sympy import QQ
        >>> from sympy import symbols
        >>> x = symbols('x')
        >>> R, Dx = DifferentialOperators(QQ.old_poly_ring(x),'Dx')
        >>> HolonomicFunction(Dx - 1, x, 0, [1]).integrate((x, 0, x))  # e^x - 1
        HolonomicFunction((-1)*Dx + (1)*Dx**2, x, 0, [0, 1])
        >>> HolonomicFunction(Dx**2 + 1, x, 0, [1, 0]).integrate((x, 0, x))
        HolonomicFunction((1)*Dx + (1)*Dx**3, x, 0, [0, 1, 0])
        T)Úinitcondr   r8   z1logarithmic terms in the series are not supportedÚ__iter__z4Definite integration for singular initial conditionsé   r©   FN)rÁ   rv   rU   rÒ   rÙ   Ú	integraterÀ   ry   rŠ   r   r×   ÚNotImplementedErrorÚhasattrr¾   rx   r¹   rÃ   r~   Úto_exprr=   r<   Úsubsrb   r   r3   ÚevalfÚ	is_Number)rd   Úlimitsrü   ÚDrF   rÀ   r�   ÚcÚc2r‚   Úcjr¹   rØ   r†   ÚdefiniteÚindefinite_integralÚindefinite_exprÚlowerÚupperÚsÚ
indefinites                        rG   rÿ   zHolonomicFunction.integrateµ  sT  € ð& ×Ñ×#Ñ#×7Ñ7ˆð ×ÑÓ  DÓ(à×(Ñ(Ó*ˆAÙØ—{‘{ 6°H�{Ó=Ð=ð ˆBØ—W‘Wò �Ø—G‘G˜A‘J�Ø�Ü& q›\ò 	5‘E�A�rØ˜Q’wØŸ	™	¤!§&¡&Õ)ð ˜Q™ ™ ašÜ1Ð2eÓfÐfàŸ	™	 "¤q¨¨Q©°©£|Ñ"3Õ4ð	5ð ��1�q‘5’	ðô �v˜zÔ*Ü)Ð*`ÓaÐaä$ T×%5Ñ%5¸Ñ%9¸4¿6¹6À4Ç7Á7ÈBÓOÐOð ×#Ñ#Ô%ÙÜ(¨×)9Ñ)9¸AÑ)=¸t¿v¹vÀtÇwÁwÔQR×QWÑQWÐPXÓYÐYÜ$ T×%5Ñ%5¸Ñ%9¸4¿6¹6ÓBÐBô
 �6˜:Ô&ä�6‹{˜aÒ F¨1¡I°·±Ò$7Ø—W‘W�Ø˜1‘I�Ø˜1‘I�Ø‘ð ˆHä�f‰fˆXˆØ
ˆd�g‰g‰ˆä/°×0@Ñ0@À1Ñ0DÀdÇfÁfÈdÏgÉgÐWYÓZÐáØ&Ð&ð �‹7ð'Ø"5×"=Ñ"=Ó"?�ñ Ø'×,Ñ,¨T¯V©V°QÓ7�Ü˜e¤SÔ)Ø+×1Ñ1°$·&±&¸!Ó<‘Eà+×1Ñ1°!Ó4�à�D—F‘FŠ{Ø˜1™ ™��1‘Ü(¨×)9Ñ)9¸AÑ)=¸t¿v¹vÀrÈ2ÓNÐNä�1“—’Ù"Ø+×0Ñ0°·±¸Ó;�EÜ! %¬Ô-Ø /× 5Ñ 5°d·f±f¸aÓ @˜ð ˜u‘}Ð$ð 0×5Ñ5°aÓ8�Eà˜u‘}Ð$ð �—‘Š;Ü$ T×%5Ñ%5¸Ñ%9¸4¿6¹6À1ÀbÓIÐIô ˆq‹T�^Š^ð	WÜ% d×&6Ñ&6¸Ñ&:¸D¿F¹FÀAØóß™›	ð àŸV™V D§F¡F¨AÓ.�
Ü! *¬cÔ2Ø%Ð%àŸ7™7 4§6¡6¨1Ó-Ð-ô ! ×!1Ñ!1°AÑ!5°t·v±vÓ>Ð>øôU (Ô)<Ð=ò 'Ø"&“ð'ûôN (Ô)<Ð=ò WÜ(¨×)9Ñ)9¸AÑ)=¸t¿v¹vÀqÈ"ÓM×SÑSÐTUÓVÒVðWús,   ÉQ  Ï A Q8 Ð!Q8 Ñ Q5Ñ4Q5Ñ8AR>Ò=R>c                 ó   — |j                  dd«       |r[|d   | j                  k7  rt        j                  S t	        |«      dk(  r+| }t        |d   «      D ]  }|j                  |d   «      }Œ |S | j                  }|j                  d   |j                  j                  j                  k(  r|j                  dk(  rt        j                  S |j                  d   |j                  j                  j                  k(  r¡t        |j                  dd |j                  «      }| j                  «       rX| j                  «       dk(  r/t!        || j                  | j"                  | j$                  dd «      S t!        || j                  «      S t!        || j                  «      S |j                  j                  }|j'                  «       }|j                  D �cg c]!  }|j)                  |j+                  «       «      ‘Œ# }}|dd D �cg c]
  }||d   z  ‘Œ }	}|	j-                  d|j                  «       t/        |	|«      }t1        ||j                  |j2                  g«      }t5        |dd | j                  j                  d¬«      }| j                  «       r| j                  «       dk(  rt!        || j                  «      S t7        | |j                  dz   «      dd }
t!        || j                  | j"                  |
«      S c c}w c c}w )	aK  
        Differentiation of the given Holonomic function.

        Examples
        ========

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

        See Also
        ========

        integrate
        ÚevaluateTr   r©   r8   NFrÛ   )Ú
setdefaultrx   r   r×   r~   r�   r‹   rÁ   r}   rv   rV   r_   r   r^   rÃ   rÒ   r¾   r¹   rÀ   rÞ   rß   rà   ÚinsertÚ_derivate_diff_eqrŒ   r`   rä   rå   )rd   ÚargsÚkwargsrQ   r�   ÚannrÍ   rë   Úseq_dmfÚrhsrÀ   s              rG   r‹   zHolonomicFunction.diff4  ss  € ð, 	×Ñ˜* dÔ+ÙØ�A‰w˜$Ÿ&™&Ò Ü—v‘v�Ü�T“˜a’Ø�Ü˜t A™w›ò ,�AØŸ(™( 4¨¡7Ó+‘Cð,à�
à×Ñˆð �>‰>˜!Ñ §
¡
§¡× 4Ñ 4Ò4¸¿¹ÀaºÜ—6‘6ˆMð �^‰^˜AÑ #§*¡*§/¡/×"6Ñ"6Ò6ä& s§~¡~°a°bÐ'9¸3¿:¹:ÓFˆCà×#Ñ#Ô%à×&Ñ&Ó(¨EÒ1Ü,¨S°$·&±&¸$¿'¹'À4Ç7Á7È1È2À;ÓOÐOä(¨¨d¯f©fÓ5Ð5ä(¨¨d¯f©fÓ5Ð5ð �J‰J�O‰OˆØ�K‰K‹Mˆà/2¯~©~Ö>¨!�1—5‘5˜Ÿ™›Õ%Ð>ˆÐ>ð (/¨q¨r {Ö3 !ˆq�7˜1‘:‹~Ð3ˆÐ3Ø�
‰
�1�a—f‘fÔô    QÓ'ˆô ˜˜qŸv™v q§u¡u˜oÓ.ˆä˜˜Q˜R˜ $×"2Ñ"2×"9Ñ"9ÀEÔJˆà×#Ñ#Ô%¨×)<Ñ)<Ó)>À$Ò)FÜ$ S¨$¯&©&Ó1Ð1ä˜˜cŸi™i¨!™mÓ,¨Q¨RÐ0ˆÜ   d§f¡f¨d¯g©g°rÓ:Ð:ùò% ?ùò 4s   Ç&K6Ç?K;c                 ó  — | j                   |j                   k7  s| j                  |j                  k7  ry| j                  «       rD|j                  «       r4| j                  |j                  k(  xr | j                  |j                  k(  S y)NFT)rÁ   rx   rÃ   r¹   rÀ   rj   s     rG   rl   zHolonomicFunction.__eq__�  sg   € Ø×Ñ˜u×0Ñ0Ò0°D·F±F¸e¿g¹gÒ4EØØ×ÑÔ! e×&;Ñ&;Ô&=Ø—7‘7˜eŸh™hÑ&Ò>¨4¯7©7°e·h±hÑ+>Ð>ØrI   c                 ó$  ‡‡‡‡‡ — | j                   }t        |t        «      s¶t        |«      }|j	                  | j
                  «      rt        d«      ‚| j                  «       s| S t        | |j                  «      }|D �cg c]/  }t        j                  || j
                  «      |z  j                  ‘Œ1 c}Št        || j
                  | j                  ‰«      S | j                   j                  j                  |j                   j                  j                  k7  r| j!                  |«      \  Š}‰|z  S |j                   }|j                  Š|j                  }|j                  j                  }|j#                  «       }|j$                  D �cg c]!  }|j                  |j'                  «       «      ‘Œ# }	}|j$                  D �cg c]!  }|j                  |j'                  «       «      ‘Œ# }
}t)        ‰«      D �cg c]  }|	|    |	‰   z  ‘Œ }}t)        |«      D �cg c]  }|
|    |
|   z  ‘Œ }}t)        ‰dz   «      D ��cg c](  }t)        |dz   «      D �cg c]  }|j*                  ‘Œ c}‘Œ* }}}|j,                  |d   d<   t)        ‰«      D ��cg c]  }t)        |«      D ]
  }||   |   ‘Œ Œ c}}g}t/        |d‰|z  f|«      j1                  «       }t/        j2                  ‰|z  df|«      }t5        ||«      }|j6                  �rùt)        ‰dz
  dd«      D ]¥  Št)        |dz
  dd«      D ]�  Š|‰   ‰dz   xx   |‰   ‰   z  cc<   |‰dz      ‰xx   |‰   ‰   z  cc<   t        |‰   ‰   |j8                  «      rt;        |‰   ‰   |«      |‰   ‰<   Œj|‰   ‰   j=                  | j
                  «      |‰   ‰<   Œ’ Œ§ t)        ‰dz   «      D ]S  Š|‰   |   j>                  rŒt)        |«      D ]  Š|‰   ‰xx   |‰   |‰   |   z  z  cc<   Œ  |j*                  |‰   |<   ŒU t)        |«      D ]L  Š|‰   ‰   dk(  rŒt)        ‰«      D ]  Š|‰   ‰xx   |‰   |‰   ‰   z  z  cc<   Œ  |j*                  |‰   ‰<   ŒN |jA                  t)        ‰«      D ��cg c]  }t)        |«      D ]
  }||   |   ‘Œ Œ c}}«       t/        |tC        |«      ‰|z  f|«      j1                  «       }t5        ||«      }|j6                  r�ŒùtE        |jG                  «       | j                   j                  d¬«      }| j                  «       r|j                  «       st        || j
                  «      S | jI                  «       dk(  �r‰|jI                  «       dk(  �ru| j                  |j                  k(  �rMt        | |j                  «      }t        ||j                  «      }|d   |d   z  g}t)        dtK        tC        |«      tC        |«      «      «      D ]È  Št)        ‰dz   «      D �cg c]  }t)        ‰dz   «      D �cg c]  }d‘Œ c}‘Œ  }}t)        ‰dz   «      D ]0  Št)        ‰dz   «      D ]  }‰|z   ‰k(  sŒtM        ‰‰«      |‰   |<   Œ Œ2 d}t)        ‰dz   «      D ],  Št)        ‰dz   «      D ]  }||‰   |   |‰   z  ||   z  z  }Œ Œ. |jA                  |«       ŒÊ t        || j
                  | j                  |«      S | j                   jO                  d«      }|j                   jO                  d«      }| j                  dk(  r|s|s| |jQ                  d«      z  S |j                  dk(  r|s|s| jQ                  d«      |z  S | j                   jO                  | j                  «      }|j                   jO                  | j                  «      }|s |s| |jQ                  | j                  «      z  S | jQ                  |j                  «      |z  S | j                  |j                  k7  rt        || j
                  «      S d Šd Š | jI                  «       dk(  re|jI                  «       dk(  rRtS        | jT                  «      D ��cg c]  \  }}|tW        |«      z  ‘Œ }}}tX        jZ                  |iŠ|jT                  Š n¶| jI                  «       dk(  re|jI                  «       dk(  rRtS        |jT                  «      D ��cg c]  \  }}|tW        |«      z  ‘Œ }}}| jT                  ŠtX        jZ                  |iŠ n>| jI                  «       dk(  r+|jI                  «       dk(  r| jT                  Š|jT                  Š i }‰D ]¶  Š‰ D ]¯  ŠtK        tC        ‰‰   «      tC        ‰ ‰   «      «      }t)        |«      D �‡cg c]6  Št]        ˆˆˆˆˆ fd„t)        ‰dz   «      D «       tX        jZ                  ¬	«      ‘Œ8 }}‰‰z   |vr	||‰‰z   <   Œ‚t_        ||‰‰z      «      D ��cg c]
  \  }}||z   ‘Œ c}}|‰‰z   <   Œ± Œ¸ t        || j
                  | j                  |«      S c c}w c c}w c c}w c c}w c c}w c c}w c c}}w c c}}w c c}}w c c}w c c}w c c}}w c c}}w c c}w c c}}w )
Nz> Can't multiply a HolonomicFunction and expressions/functions.r8   r   r›   FrÛ   Tc              3   óF   •K  — | ]  }‰‰   |   ‰‰   ‰|z
     z  –— Œ y ­wrB   rr   )rµ   r†   rØ   r�   r‚   rô   rõ   s     €€€€€rG   r¶   z,HolonomicFunction.__mul__.<locals>.<genexpr>!  s*   øè ø€ ÒH°a˜"˜Q™% ™( R¨¡U¨1¨q©5¡\Õ1ÑHùs   ƒ!©Ústart)0rÁ   rb   r¾   r   Úhasrx   r   rÃ   rå   r   r0   rß   Úrepr¹   rv   rV   rÇ   rÞ   r}   rà   r�   r_   r`   r1   rK   rá   rR   râ   rz   ÚDMFdiffr‹   Úis_zerorŠ   r~   rä   rã   rÒ   Úminr   rº   rç   ry   rÀ   r   r   r×   Úsumræ   )!rd   rk   Úann_selfrÀ   r‚   r†   Ú	ann_otherrÍ   rë   r–   r—   r�   Úself_redÚ	other_redÚ	coeff_mulÚlin_sys_elementsÚlin_sysÚhomo_sysrQ   Úsol_annÚy0_selfÚy0_otherÚcoeffÚkrö   r÷   rø   rù   rú   rØ   r  rô   rõ   s!       `      `                 ` @@rG   r’   zHolonomicFunction.__mul__ˆ  sÉ	  ü€ Ø×#Ñ#ˆä˜%Ô!2Ô3Ü˜E“NˆEà�y‰y˜Ÿ™Ô Ü)Ð*jÓkÐkà×'Ñ'Ô)Ø�Ü˜D (§.¡.Ó1ˆBØ=?Ö@¸”4—8‘8˜A˜tŸv™vÓ&¨Ñ.×3Ó3Ò@ˆBÜ$ X¨t¯v©v°t·w±wÀÓCÐCà×Ñ×"Ñ"×'Ñ'¨5×+<Ñ+<×+CÑ+C×+HÑ+HÒHØ—:‘:˜eÓ$‰DˆAˆqØ�q‘5ˆLà×%Ñ%ˆ	à�N‰NˆØ�O‰Oˆà�O‰O× Ñ ˆØ�K‰K‹Mˆà19×1DÑ1DÖE¨A�Q—U‘U˜1Ÿ9™9›;Õ'ÐEˆ	ÐEØ2;×2FÑ2FÖG¨Q�a—e‘e˜AŸI™I›KÕ(ÐGˆ
ÐGô ;@À»(ÖC°Q�Y˜q‘\�M I¨a¡LÓ0ÐCˆÐCä=BÀ1»XÖF¸�j ‘m�^ j°¡mÓ3ÐFˆ	ÐFô >CÀ1ÀqÁ5»\×J¸¤e¨A°©E£lÖ3 �a—f“fÔ3ÐJˆ	ÑJØŸ%™%ˆ	�!‰�Q‰ô 7<¸A³h×Q°ÌÈaËÒQÀ1˜Y q™\¨!›_ÐQ˜_ÓQÐRÐÜÐ/°!°Q°q±S°¸1Ó=×GÑGÓIˆä×%Ñ% q¨¡s¨A h°Ó2ˆä$ W¨hÓ7ˆð × Ó ô ˜1˜q™5 " bÓ)ò G�Ü˜q 1™u b¨"Ó-ò G�AØ˜a‘L  Q¡Ó'¨9°Q©<¸©?Ñ:Ó'Ø˜a !™eÑ$ QÓ'¨9°Q©<¸©?Ñ:Ó'Ü! )¨A¡,¨q¡/°1·7±7Ô;Ü*1°)¸A±,¸q±/À1Ó*E˜	 !™ Qšà*3°A©,°q©/×*>Ñ*>¸t¿v¹vÓ*F˜	 !™ QšñGðGô ˜1˜q™5“\ò )�Ø˜Q‘< ‘?×*Ò*ØÜ˜q›ò F�AØ˜a‘L “O y°¡|°iÀ±lÀ1±oÑ'EÑE”OðFà"#§&¡&�	˜!‘˜Q’ð)ô ˜1“Xò )�Ø˜Q‘< ‘? aÒ'ØÜ˜q›ò E�AØ˜a‘L “O x°¡{°Y¸q±\À!±_Ñ'DÑD”OðEà"#§&¡&�	˜!‘˜Q’ð)ð ×#Ñ#¼eÀA»h×$Y¸ÔPUÐVWÓPXÒ$YÈ1 Y¨q¡\°!£_Ð$Y _Ó$YÔZÜ"Ð#3´cÐ:JÓ6KÈQÈqÉSÐ5QÐSTÓU×_Ñ_ÓaˆGä(¨°(Ó;ˆCð? × Ô ôB ˜SŸX™X›Z¨×)9Ñ)9×)@Ñ)@È5ÔQˆà×$Ñ$Ô&¨5×+@Ñ+@Ô+BÜ$ W¨d¯f©fÓ5Ð5à×ÑÓ  EÓ)¨e×.BÑ.BÓ.DÈÓ.Mð �w‰w˜%Ÿ(™(Ó"ô % T¨7¯=©=Ó9�Ü% e¨W¯]©]Ó;�à˜a‘j 8¨A¡;Ñ.Ð/�ô ˜q¤#¤c¨'£l´C¸³MÓ"BÓCò #�AÜ@EÀaÈ!ÁeÃÖM¸1¬¨q°1©u«Ö6 AšaÔ6ÐM�EÐMÜ" 1 q¡5›\ò =˜Ü!& q¨1¡u£ò =˜AØ  1™u¨›zÜ.6°q¸!«n  a¡¨¢ñ=ð=ð
 �CÜ" 1 q¡5›\ò I˜Ü!& q¨1¡u£ò I˜AØ 5¨¡8¨A¡;°¸±
Ñ#:¸XÀa¹[Ñ#HÑH™CñIðIð —I‘I˜c•Nð#ô )¨°$·&±&¸$¿'¹'À2ÓFÐFð ×&Ñ&×2Ñ2°1Ó5ˆGØ×(Ñ(×4Ñ4°QÓ7ˆHà�w‰w˜!Š|¡G±HØ˜e×.Ñ.¨qÓ1Ñ1Ð1Ø�x‰x˜1Š}¡W±XØ—‘ qÓ)¨EÑ1Ð1à×'Ñ'×3Ñ3°D·G±GÓ<ˆHØ×)Ñ)×5Ñ5°d·g±gÓ>ˆIÙ¡IØ˜e×.Ñ.¨t¯w©wÓ7Ñ7Ð7Ø—?‘? 5§8¡8Ó,¨uÑ4Ð4à�7‰7�e—h‘hÒÜ$ W¨d¯f©fÓ5Ð5ð ˆØˆà×ÑÓ  EÒ)¨e×.BÑ.BÓ.DÈÒ.LÜ09¸$¿'¹'Ó0B×C©¨¨1�1”y “|Ó#ÐCˆCÑCÜ—&‘&˜#�ˆBØ—‘‰BØ× Ñ Ó" dÒ*¨u×/CÑ/CÓ/EÈÒ/NÜ09¸%¿(¹(Ó0C×D©¨¨1�1”y “|Ó#ÐDˆCÑDØ—‘ˆBÜ—&‘&˜#�‰BØ× Ñ Ó" dÒ*¨u×/CÑ/CÓ/EÈÒ/MØ—‘ˆBØ—‘ˆBàˆàò 	FˆAØò F�Üœ˜B˜q™E›
¤C¨¨1©£JÓ/�ä05°a³÷:Ø+,ô ×H¼5ÀÀQÁ»<ÔHÜ Ÿv™vö'ð :�ð :à˜1‘u ‘{Ø !�B�q˜1‘u’Iä36°q¸"¸QÀ¹U¹)Ó3D× E©4¨1¨a  Q£Ó E�B�q˜1‘u’IñFð	Fô ! ¨$¯&©&°$·'±'¸2Ó>Ð>ùòg Aùò FùÚGùò DùâFùò 4ùÓJùó RùóH %Zùò. 7ùÒMùóL Dùó Eùò:ùó
 !Fsr   Á?4iÆ
&iÇ &iÇ5iÈiÈ=iÉiÉ%iÊi%Òi+
Øi6Ø.	i1Ø7i6á2i;ã*jæ ;jèj
éié1i6c                 ó   — | |dz  z   S rš   rr   rj   s     rG   rœ   zHolonomicFunction.__sub__+  s   € Ø�e˜b‘jÑ Ð rI   c                 ó   — | dz  |z   S rš   rr   rj   s     rG   rž   zHolonomicFunction.__rsub__.  s   € Ø�b‰y˜5Ñ Ð rI   c                 ó   — d| z  S rš   rr   r    s    rG   r¡   zHolonomicFunction.__neg__1  r¢   rI   c                 ó.   — | t         j                  |z  z  S rB   r¤   rj   s     rG   r¦   zHolonomicFunction.__truediv__4  r§   rI   c                 ó  — | j                   j                  dk  ræ| j                   }|j                  }| j                  €d }nt	        | j                  «      d   |z  g}|j
                  d   }|j
                  d   }t        j                  || j                  «      |z  j                  }||fD �cg c]  }|j                  j                  |«      ‘Œ }}t        ||«      }	t        |	| j                  | j                  |«      S |dk  rt        d«      ‚| j                   j                  j                   }
t        |
| j                  t"        j$                  t"        j&                  g«      }|dk(  r|S | }	 |dz  r||z  }|dz  }|s	 |S ||z  }Œc c}w )Nr8   r   z&Negative Power on a Holonomic Functionr©   )rÁ   r   rv   rÀ   r…   r}   r0   rß   rx   r"  rV   r|   r^   r¾   r¹   r?   rU   r   r×   r¥   )rd   rª   r  rv   rÀ   Úp0Úp1r�   rQ   Úddr\   r«   rx   s                rG   r¬   zHolonomicFunction.__pow__7  sm  € Ø×Ñ×!Ñ! QÒ&Ø×"Ñ"ˆCØ—Z‘ZˆFà�w‰wˆØ‘ä˜4Ÿ7™7“m AÑ&¨!Ñ+Ð,�à—‘ Ñ"ˆBØ—‘ Ñ"ˆBä—(‘(˜2˜tŸv™vÓ&¨Ñ*×/Ñ/ˆBà57¸°HÖ=¨q�6—;‘;×'Ñ'¨Õ*Ð=ˆCÐ=Ü% c¨6Ó2ˆBÜ$ R¨¯©°·±¸"Ó=Ð=ØˆqŠ5Ü#Ð$LÓMÐMØ×Ñ×$Ñ$×8Ñ8ˆÜ" 2 t§v¡v¬q¯v©v¼¿¹°wÓ?ˆØ�Š6ØˆMØˆØØ�1ŠuØ˜!‘�Ø�!‰GˆAÙØàˆð �‰FˆAð ùò >s   Â."F	c                 óN   — t        d„ | j                  j                  D «       «      S )zF
        Returns the highest power of `x` in the annihilator.
        c              3   ó<   K  — | ]  }|j                  «       –— Œ y ­wrB   ©Údegree©rµ   r�   s     rG   r¶   z+HolonomicFunction.degree.<locals>.<genexpr>]  s   è ø€ ÒC !�1—8‘8—:ÑCùó   ‚)rÝ   rÁ   r}   r    s    rG   r?  zHolonomicFunction.degreeY  s!   € ô ÑC t×'7Ñ'7×'BÑ'BÔCÓCÐCrI   c                 óâ  — | j                   j                  }| j                   j                  }|j                  | j                  «      }| j                   j
                  }t        |«      D ]l  \  }}	t        |	| j                   j                  j                  j                  «      sŒ;| j                   j                  j                  j                  |	«      ||<   Œn ||   j                  | j                  |i«      }
t        |«      D �cg c]&  }||   j                  | j                  |i«       |
z  ‘Œ( }}t        |«      D �cg c]  }t        j                  ‘Œ }}t        j                  |d<   |g}t!        t        |«      D �cg c]  }t        j                  ‘Œ c}g«      j#                  «       }	 |D �cg c]  }|j                  | j                  «      ‘Œ }}t        |dz
  «      D ]  }||dz   xx   ||   |z  z  cc<   Œ t        |«      D ]  }||xx   |d   ||   z  |z  z  cc<   Œ |}|j%                  |«       t!        |«      j#                  «       j'                  |«      \  }}|j(                  durnŒÈt+        |«      d   }|j                  |d«      }t-        |dd |d¬«      }|rt/        || j                  |d   |d   «      S t/        || j                  «      S c c}w c c}w c c}w c c}w )a`  
        Returns function after composition of a holonomic
        function with an algebraic function. The method cannot compute
        initial conditions for the result by itself, so they can be also be
        provided.

        Examples
        ========

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

        See Also
        ========

        from_hyper
        r   Tr8   r›   NFrÛ   )rÁ   rv   r   r‹   rx   r}   ry   rb   rV   rz   r|   r  r�   r   r×   r¥   r)   rK   rŠ   Úgauss_jordan_solverâ   r…   rä   r¾   )rd   rò   r  r  rÍ   rØ   r‹   r}   r�   r‚   rF   r  ÚcoeffsÚsystemÚhomogeneousró   Úcoeffs_nextrQ   ÚtausÚtaus                       rG   ÚcompositionzHolonomicFunction.composition_  s¤  € ð4 ×Ñ×#Ñ#ˆØ×Ñ×"Ñ"ˆØ�y‰y˜Ÿ™Ó ˆØ×%Ñ%×0Ñ0ˆ
ä˜jÓ)ò 	I‰DˆAˆqÜ˜!˜T×-Ñ-×4Ñ4×9Ñ9×?Ñ?Õ@Ø $× 0Ñ 0× 7Ñ 7× <Ñ <× EÑ EÀaÓ H�
˜1’ð	Ið �q‰M×Ñ §¡ t˜}Ó-ˆÜ@EÀqÃ	ÖJ¸1�˜A‘×#Ñ# T§V¡V¨D MÓ2Ð2°QÓ6ÐJˆÐJÜ"'¨£(Ö+˜Q”!—&“&Ð+ˆÐ+Ü—E‘Eˆˆq‰	Ø�ˆÜ¬u°Q«xÖ8¨!œqŸv›vÒ8Ð9Ó:×DÑDÓFˆØØ39Ö:¨a˜1Ÿ6™6 $§&¡&�>Ð:ˆKÐ:Ü˜1˜q™5“\ò 9�Ø˜A ™EÓ" v¨a¡y°4Ñ'7Ñ8Ô"ð9ä˜1“Xò @�Ø˜A“ 6¨"¡:°°Q±Ñ#7¸$Ñ#>Ñ?”ð@à ˆFà�M‰M˜&Ô!Ü ›×1Ñ1Ó3ß$Ñ$ [Ó1ñ ˆC�à×!Ñ!¨Ñ-Øð ô �4‹j˜‰mˆØ�h‰h�s˜AÓˆÜ˜˜Q˜R˜ !¨eÔ4ˆñ Ü$ S¨$¯&©&°$°q±'¸4À¹7ÓCÐCÜ   d§f¡fÓ-Ð-ùò5 KùÚ+ùò 9ùâ:s   Ä+KÄ?K"Æ K'Æ2"K,c           
      óŒ
  ‡‡‡— | j                   dk7  r)| j                  | j                   «      j                  «       S | j                  j	                  | j                   «      r| j                  |¬«      S i }t        dd¬«      Š| j                  j                  j                  j                  }t        |j                  ‰«      d«      \  }}t        | j                  j                  «      D ]®  \  }Š‰j                  «       }t        |«      dz
  }t!        |dz   «      D ]z  }	|||	z
     }
|
dk(  rŒ||	z
  |	f|v r5|||	z
  |	fxx   |j#                  |
«      t%        ‰|	z
  dz   |«      z  z  cc<   ŒO|j#                  |
«      t%        ‰|	z
  dz   |«      z  |||	z
  |	f<   Œ| Œ° g }|D �cg c]  }|d   ‘Œ	 }}t'        |«      Št)        |«      }| j+                  «       }‰|z   }i }g }g }t!        ‰|dz   «      D ]k  Š‰|v rFt-        ˆˆˆfd„|j/                  «       D «       t0        j2                  ¬	«      }|j5                  |«       ŒM|j5                  t0        j2                  «       Œm t7        ||«      }|j8                  }t;        |j                  j#                  |j                  d
   «      ‰d¬«      }|j=                  «       }|rt)        |«      dz   }t)        ||«      }||z  }t?        | |«      }t        |«      D ��cg c]  \  }}|tA        |«      z  ‘Œ }}}t        |«      |k  �r t!        |«      D ]æ  }t0        j2                  }|D ]¾  Š|‰d   z   dk  rt0        j2                  ||‰d   z   <   nj|‰d   z   t        |«      k  r||‰d   z      ||‰d   z   <   nA|‰d   z   |vr7t        d|‰d   z   z  «      ||‰d   z   <   |j5                  ||‰d   z      «       ‰d   |k  sŒ›||‰   jC                  ‰|«      ||‰d   z      z  z  }ŒÀ |j5                  |«       Œè tE        |g|¢­Ž }tG        |tH        «      r€t!        t        |«      |«      D ]J  }||vrt        d|z  «      ||<   ||   |v r|j5                  |||      «       Œ7|j5                  ||   «       ŒL |rtK        ||«      |fgS tK        ||«      gS t!        t        |«      |«      D ]X  }||vrt        d|z  «      ||<   d}|D ]#  Š||   ‰v sŒ|j5                  ‰||      «       d}Œ% |rŒE|j5                  ||   «       ŒZ |rtK        ||«      |fgS tK        ||«      gS c c}w c c}}w )aG  
        Finds recurrence relation for the coefficients in the series expansion
        of the function about :math:`x_0`, where :math:`x_0` is the point at
        which the initial condition is stored.

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

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

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

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

        Examples
        ========

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

        See Also
        ========

        HolonomicFunction.series

        References
        ==========

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

        r   )Úlbrª   T©ÚintegerÚSnr8   c              3   ó^   •K  — | ]$  \  }}|d    ‰k(  r|j                  ‰‰‰z
  «      –— Œ& y­w©r   N©r  ©rµ   r3  Úvr‚   r  rª   s      €€€rG   r¶   z0HolonomicFunction.to_sequence.<locals>.<genexpr>  s8   øè ø€ ò CÙ#˜q !¸¸!¹Àº	ð ŸF™F 1 a¨%¡i×0ñ Cùó   ƒ*-r  r›   ÚZ©ÚfilterúC_%sF)&r¹   Úshift_xÚto_sequencerÁ   rº   Ú
_frobeniusr   rv   rV   rÆ   r;   rÈ   ry   r}   Ú
all_coeffsr~   r�   r|   r   r%  rÝ   r?  r&  Úitemsr   r×   rŠ   r:   r   r/   Úkeysrå   r   r  r7   rb   rÑ   r9   )rd   rL  Údict1rÆ   rÍ   rÏ   r�   Ú	listofdmpr?  r3  r2  rQ   Úkeylistr  Ú
smallest_nÚdummysÚeqsÚunknownsÚtempr   Ú	all_rootsÚmax_rootrÀ   r‚   Úu0ÚeqÚsoleqsr  r  rª   s                          `    @@rG   r[  zHolonomicFunction.to_sequenceŸ  sf  ú€ ðh �7‰7�aŠ<Ø—<‘< §¡Ó(×4Ñ4Ó6Ð6ð ×Ñ×'Ñ'¨¯©Ô0Ø—?‘? b�?Ó)Ð)àˆÜ�3 Ô%ˆØ×Ñ×%Ñ%×*Ñ*×.Ñ.ˆÜ" 3×#4Ñ#4°QÓ#7¸Ó>‰ˆˆ1ô ˜d×.Ñ.×9Ñ9Ó:ò 	Q‰DˆAˆqàŸ™›ˆIÜ˜“^ aÑ'ˆFä˜6 A™:Ó&ò 	Q�Ø! &¨1¡*Ñ-�à˜A’:Øà˜‘E˜1�: Ñ&Ø˜1˜q™5 !˜*Ó%¨#¯,©,°uÓ*=ÄÀ1ÀqÁ5È1Á9ÈaÓ@PÑ*PÑQÔ%à),¯©°eÓ)<¼rÀ!ÀaÁ%È!Á)ÈQÓ?OÑ)O�E˜1˜q™5 !˜*Ò%ñ	Qð	Qð" ˆØ!&Ö'˜A�1�Q“4Ð'ˆÐ'Ü�G“ˆÜ�G“ˆØ—‘“ˆð ˜V‘^ˆ
ØˆØˆØˆô �u˜e a™iÓ(ò 	#ˆAØ�G‰|Üõ CØ',§{¡{£}ôCä!"§¡ô)�ð —
‘
˜4Õ à—
‘
œ1Ÿ6™6Õ"ð	#ô !  aÓ(ˆð —	‘	ˆÜ˜!Ÿ&™&Ÿ/™/¨#¯.©.¸Ñ*<Ó=¸qÈÔMˆ	Ø—N‘NÓ$ˆ	áÜ˜9“~¨Ñ)ˆHÜ˜X zÓ2ˆJØ�Ñˆä˜˜eÓ$ˆä+4°R«=×9¡4 1 aˆa”)˜A“,ÓÐ9ˆÑ9ô ˆr‹7�U‹?ä˜6“]ò �Ü—V‘V�àò E�Aà˜1˜Q™4‘x !’|Ü+,¯6©6˜˜q 1 Q¡4™xÒ(à˜Q˜q™T™¤C¨£GÒ+Ø+-¨a°!°A±$©h©<˜˜q 1 Q¡4™xÒ(à  1¡™X¨Ñ/Ü+1°&¸1¸qÀ¹t¹8Ñ2DÓ+E˜˜q 1 Q¡4™xÑ(Ø Ÿ™¨¨q°1°Q±4©xÑ(8Ô9à˜‘t˜q“yØ˜e A™hŸm™m¨A¨qÓ1°F¸1¸qÀ¹t¹8Ñ4DÑDÑD™ðEð —
‘
˜2•ð%ô* ˜3Ð* Ò*ˆFä˜&¤$Ô'äœs 2›w¨Ó.ò 	-�Aà ‘Ü$*¨6°1©9Ó$5˜˜q™	à˜a‘y FÑ*ØŸ	™	 &¨°©Ñ"3Õ4ð Ÿ	™	 &¨¡)Õ,ð	-ñ Ü.¨s°BÓ7¸ÐDÐEÐEÜ)¨#¨rÓ2Ð3Ð3äœ3˜r›7 EÓ*ò )�à˜F‘?Ü & v¨q¡yÓ 1�F˜1‘Ià�Øò !�AØ˜a‘y A’~ØŸ	™	 ! F¨1¡I¡,Ô/Ø ™ð!ò Ø—I‘I˜f Q™iÕ(ð)ñ Ü& s¨BÓ/°Ð<Ð=Ð=ä! # rÓ*Ð+Ð+ùòK (ùóJ :s   Æ T;Ë3U c                 óp  ‡‡,‡-— | j                  «       }g }g }t        |j                  «       «      D ]U  }|j                  r|j	                  |g||   z  «       Œ(|j                  «       \  }}|j	                  |||fg||   z  «       ŒW |j                  d„ ¬«       |j                  d„ ¬«       |j                  «        g }|D ]`  }t        |«      dk(  r|j                  |g«       Œ$|D ]&  Št        ‰d   |z
  «      sŒ‰j                  |«        ŒN |j                  |g«       Œb t        d„ |D «       «      }	t        d„ |D «       «      }
t        d„ |D «       «      }| j                  «       dk(  rgg }t        | j                  j                  «       «      D ]>  }t        |j                  «       «      D ]   Št        ‰|«      sŒ|j                  |«       Œ" Œ@ nÁ|
r|rt        |«      g}n°|	r(|D �cg c]  }|d   ‘Œ	 c}|D �cg c]  }|d   ‘Œ	 c}z   }n†|s|D �cg c]  }t        |«      |k(  rŒ|‘Œ }}ne|
sc| j!                  «       r%t#        | j                  d   «      j$                  d	k(  rt        |«      g}n!|D �cg c]
  }|dk\  sŒ	|‘Œ }}t        |«      g}t'        d
d¬«      Š-| j(                  j*                  j,                  j.                  }t1        |j3                  ‰-«      d«      \  }}g }t5        d«      }D �]™  }i }t7        | j(                  j8                  «      D ]½  \  }Š‰j;                  «       }t        |«      dz
  }t=        |dz   «      D ]‰  }|||z
     }|dk(  rŒ||z
  ||z
  f|v r;|||z
  ||z
  fxx   |j?                  |«      tA        ‰-|z
  dz   |z   |«      z  z  cc<   ŒX|j?                  |«      tA        ‰-|z
  dz   |z   |«      z  |||z
  ||z
  f<   Œ‹ Œ¿ g }|D �cg c]  }|d   ‘Œ	 }}t        |«      Š,tC        |«      }tC        d„ |D «       «      }t        d„ |D «       «      }‰,|z   }i }g } g }!t=        ‰,|dz   «      D ]k  Š‰|v rFtE        ˆˆ,ˆ-fd„|jG                  «       D «       t"        jH                  ¬«      }"|j                  |"«       ŒM|j                  t"        jH                  «       Œm tK        ||«      }|jL                  }#tO        |j,                  j?                  |j8                  d   «      ‰-d¬«      }$|$j                  «       }$|$rtC        |$«      dz   }%tC        |%|«      }|#|z  }#g }&| j                  «       dk(  r| j                  |   }&n�| j                  «       d	k(  rŠ|dk\  r…t        |«      |k(  rwt        |«      dk(  ritQ        | |#t        |«      z   «      }'t        |'«      t        |«      kD  r:t=        t        |«      t        |'«      «      D �cg c]  }|'|   tS        |«      z  ‘Œ }&}t        |&«      |#k  �rNt=        ||«      D ]ô  }t"        jH                  }(|D ]Ì  Š|‰d   z   dk  rt"        jH                  ||‰d   z   <   nx|‰d   z   t        |&«      k  r|&|‰d   z      ||‰d   z   <   nO|‰d   z   |vrEtU        |«      d|‰d   z   z  z   })t'        |)«      ||‰d   z   <   |!j                  ||‰d   z      «       ‰d   |k  sŒ©|(|‰   jW                  ‰-|«      ||‰d   z      z  z  }(ŒÎ | j                  |(«       Œö tY        | g|!¢­Ž }*t[        |*t\        «      r±t=        t        |&«      |#«      D ]X  }||vrtU        |«      d|z  z   })t'        |)«      ||<   ||   |*v r|&j                  |*||      «       ŒE|&j                  ||   «       ŒZ |r |j                  t_        ||&«      ||f«       �Œº|j                  t_        ||&«      |f«       �ŒÙt=        t        |&«      |#«      D ]f  }||vrtU        |«      d|z  z   })t'        |)«      ||<   d	}+|*D ]#  Š||   ‰v sŒ|&j                  ‰||      «       d}+Œ% |+rŒS|&j                  ||   «       Œh |r|j                  t_        ||&«      ||f«       n|j                  t_        ||&«      |f«       |dz  }�Œœ |S c c}w c c}w c c}w c c}w c c}w c c}w )Nc                 ó   — | d   S )Nr8   rr   ©rx   s    rG   rH   z.HolonomicFunction._frobenius.<locals>.<lambda>j  ó
   €  ! A¡$€ rI   )Úkeyc                 ó   — | d   S ©Nr©   rr   ro  s    rG   rH   z.HolonomicFunction._frobenius.<locals>.<lambda>k  rp  rI   r   c              3   ó8   K  — | ]  }t        |«      d k(  –— Œ y­w©r8   N)r~   r@  s     rG   r¶   z/HolonomicFunction._frobenius.<locals>.<genexpr>~  s   è ø€ Ò3¨!œ#˜a›& A�+Ñ3ùs   ‚c              3   ó&   K  — | ]	  }|d k\  –— Œ y­wrQ  rr   r@  s     rG   r¶   z/HolonomicFunction._frobenius.<locals>.<genexpr>€  s   è ø€ Ò+ �Q˜!•VÑ+ùó   ‚c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wrB   )r   r@  s     rG   r¶   z/HolonomicFunction._frobenius.<locals>.<genexpr>�  s   è ø€ Ò2 q”Z —]Ñ2ùs   ‚TFrª   rM  rO  ÚCr8   c              3   ó&   K  — | ]	  }|d    –— Œ y­wru  rr   r@  s     rG   r¶   z/HolonomicFunction._frobenius.<locals>.<genexpr>¼  s   è ø€ Ò- !˜˜1�Ñ-ùrw  c              3   ó&   K  — | ]	  }|d    –— Œ y­wru  rr   r@  s     rG   r¶   z/HolonomicFunction._frobenius.<locals>.<genexpr>½  s   è ø€ Ò. 1˜!˜A�$Ñ.ùrw  c              3   ó^   •K  — | ]$  \  }}|d    ‰k(  r|j                  ‰‰‰z
  «      –— Œ& y­wrQ  rR  rS  s      €€€rG   r¶   z/HolonomicFunction._frobenius.<locals>.<genexpr>Æ  s8   øè ø€ ò  GÙ#' 1 a¸A¸a¹DÀAºIð !"§¡ q¨!¨e©)× 4ñ  GùrU  r  r›   rV  rW  z_%s)0Ú	_indicialr   r_  Úis_realÚextendÚas_real_imagÚsortr~   rŠ   r   r·   rÒ   rÀ   r   r%  rÖ   rÃ   r   Ú	is_finiter   rÁ   rv   rV   rÆ   r;   rÈ   Úordry   r}   r]  r�   r|   r   rÝ   r&  r^  r×   r:   r   r/   rå   r   Úchrr  r7   rb   rÑ   r9   ).rd   rL  ÚindicialrootsÚrealsÚcomplr�   rØ   r†   ÚgrpÚindependentÚallposÚallintÚrootstoconsiderr‚   ÚposrootsrÆ   rÍ   rÏ   ÚfinalsolÚcharró   r`  ra  r?  r3  r2  rQ   rb  r  Údegree2rc  rd  re  rf  rg  r   rh  ri  rj  rÀ   rk  Úletterrl  r  r  rª   s.                `                              @@rG   r\  zHolonomicFunction._frobenius\  s©  ú€ àŸ™Ó(ˆàˆØˆÜ˜×+Ñ+Ó-Ó.ò 	=ˆAØ�yŠyØ—‘˜a˜S =°Ñ#3Ñ3Õ4à—~‘~Ó'‘��1Ø—‘˜q ! Q˜i˜[¨=¸Ñ+;Ñ;Õ<ð	=ð 	�
‰
‘ˆ
Ô'Ø�
‰
‘ˆ
Ô'Ø�
‰
Œð ˆàò 		 ˆAÜ�3‹x˜1Š}Ø—
‘
˜A˜3”ØØò  �Ü˜a ™d Q™hÕ'Ø—H‘H˜Q”KÙð ð
 —
‘
˜A˜3•ð		 ô Ñ3¨sÔ3Ó3ˆäÑ+ UÔ+Ó+ˆÜÑ2¨EÔ2Ó2ˆð ×ÑÓ  DÒ(Ø ˆOÜ˜TŸW™WŸ\™\›^Ó,ò 2�Ü  ×!3Ñ!3Ó!5Ó6ò 2�AÜ# A qÕ)Ø'×.Ñ.¨qÕ1ñ2ñ2ñ
 ™Ü" 5›z˜l‰OáØ-0Ö1¨˜q ›tÒ1À5Ö4I¸a°Q°q³TÒ4IÑI‰OáØ*/ÖC Q´s¸1³vÀ³{šqÐCˆOÑCáà×'Ñ'Ô)¬Q¨t¯w©w°q©z«]×-DÑ-DÈÒ-NÜ#& u£: ,‘ð (-Ö7 !°°Q³šAÐ7�Ð7Ü#& x£= /�ä�3 Ô%ˆØ×Ñ×%Ñ%×*Ñ*×.Ñ.ˆÜ" 3×#4Ñ#4°QÓ#7¸Ó>‰ˆˆ1àˆÜ�3‹xˆà ó @	ˆAØˆEä! $×"2Ñ"2×"=Ñ"=Ó>ò ]‘��1àŸL™L›N�	Ü˜Y›¨!Ñ+�ä˜v¨™zÓ*ò 	]�AØ% f¨q¡jÑ1�Eà ’zØ à˜A™˜q 1™u�~¨Ñ.Ø˜q 1™u a¨!¡e˜nÓ-°#·,±,¸uÓ2EÌÈ1ÈqÉ5ÐSTÉ9ÐWXÉ=ÐZ[ÓH\Ñ2\Ñ]Ô-à14·±¸eÓ1DÄrÈ!ÈaÉ%ÐRSÉ)ÐVWÉ-ÐYZÓG[Ñ1[˜˜q 1™u a¨!¡e˜nÒ-ñ	]ð]ð  ˆCØ%*Ö+ �q˜“tÐ+ˆGÐ+Ü˜“LˆEÜ˜“LˆEÜÑ- uÔ-Ó-ˆFÜÑ.¨Ô.Ó.ˆGà ™ˆJØˆFØˆCØˆHä˜5 %¨!¡)Ó,ò '�Ø˜‘<Üõ  GØ+0¯;©;«=ô Gä%&§V¡Vô-�Dð —J‘J˜tÕ$à—J‘JœqŸv™vÕ&ð'ô % S¨!Ó,ˆCð —I‘IˆEÜ˜aŸf™fŸo™o¨c¯n©n¸RÑ.@ÓAÀ1ÈSÔQˆIØ!Ÿ™Ó(ˆIáÜ˜y›>¨AÑ-�Ü  ¨:Ó6�
Ø�ZÑˆEàˆBà×"Ñ"Ó$¨Ò,Ø—W‘W˜Q‘Z‘à×$Ñ$Ó&¨%Ò/°A¸²F¼sÀ1»vÈº{ÌsÐSbÓOcÐghÒOhÜ  e¬c°!«f¡nÓ5�ä�r“7œS ›VÒ#Ü8=¼cÀ!»fÄcÈ"ÃgÓ8NÖO°1˜"˜Q™%¤)¨A£,Ó.ÐO�BÐOä�2‹w˜‹ä˜w¨Ó/ò #�AÜŸ™�Bà"ò I˜Ø˜q ™t™8 aš<Ü/0¯v©v˜F 1 q¨¡t¡8Ò,à  1¡™X¬¨B«Ò/Ø/1°!°a¸±d±(©|˜F 1 q¨¡t¡8Ò,à!" Q q¡T¡¨VÑ!3Ü%(¨£Y°¸¸Q¸q¹T¹Ñ1BÑ%B˜FÜ/5°f«~˜F 1 q¨¡t¡8Ñ,Ø$ŸO™O¨F°1°q¸±t±8Ñ,<Ô=à˜Q™4 1›9Ø %¨¡(§-¡-°°1Ó"5¸¸qÀ1ÀQÁ4¹xÑ8HÑ"HÑH™BðIð —J‘J˜r•Nð%#ô* ˜sÐ. XÒ.�ä˜f¤dÔ+ä"¤3 r£7¨EÓ2ò 
1˜à F™?Ü%(¨£Y°¸±Ñ%9˜FÜ(.¨v«˜F 1™Ià! !™9¨Ñ.ØŸI™I f¨V°A©YÑ&7Õ8ð ŸI™I f¨Q¡iÕ0ð
1ñ Ø Ÿ™Ô):¸3ÀÓ)CÀQÈ
Ð(SÔTÙ à Ÿ™Ô):¸3ÀÓ)CÀQÐ(GÔHÙ äœs 2›w¨Ó.ò -�Aà ‘Ü!$ T£¨U°A©XÑ!5˜Ü$*¨6£N˜˜q™	à�AØ#ò %˜Ø! !™9¨š>ØŸI™I a¨¨q©	¡lÔ3Ø $™Að%ò ØŸ	™	 &¨¡)Õ,ð-ñ Ø—‘Ô!2°3¸Ó!;¸QÀ
Ð KÕLð —‘Ô!2°3¸Ó!;¸QÐ ?Ô@Ø�A‰IŠDðA@	ðB ˆùòm 2ùÒ4Iùò Dùò 8ùò< ,ùòT Ps0   Ç-bÇ?bÈb$È+b$É:
b)Êb)Ï&b.×b3c                 ó‚  ‡‡‡‡‡— |€| j                  «       }n|}t        |t        «      rt        |«      dk(  r|d   }dŠn£t        |t        «      rt        |«      dk(  r|d   Š|d   }nzt        |«      dk(  rt        |d   «      dk(  r|d   d   }dŠnPt        |«      dk(  r"t        |d   «      dk(  r|d   d   Š|d   d   }n |D �cg c]  }| j	                  |¬«      ‘Œ c}S |t        ‰«      z
  }t        |j                  «      dz
  }|j                  j                  }| j                  Š| j                  }	|j                  j                  }
|j                  j                  j                  }|j                  «       }|
D �cg c]!  }|j                  |j!                  «       «      ‘Œ# }}t#        |«      D �cg c]  }||    ||   z  ‘Œ c}Št%        |j                  «      Š|dz   |k  rZt#        |dz   |z
  ||z
  «      D ]B  Št'        ˆˆˆfd„t#        |«      D «       t(        j*                  ¬«      }‰j-                  |«       ŒD |r‰S t'        ˆˆfd„t/        ‰«      D «       t(        j*                  ¬«      }|r|t1        ‰|t        ‰«      z   z  ‰«      z  }|	dk7  r|j3                  ‰‰|	z
  «      S |S c c}w c c}w c c}w )	a€  
        Finds the power series expansion of given holonomic function about :math:`x_0`.

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

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

        Examples
        ========

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

        See Also
        ========

        HolonomicFunction.to_sequence
        r©   r   rþ   r8   )Ú_recurc              3   ó^   •K  — | ]$  }‰|z   d k\  rt        ‰|   ‰«      ‰‰|z      z  –— Œ& y­wrQ  )ÚDMFsubs)rµ   r‚   r�   rQ   Úsubs     €€€rG   r¶   z+HolonomicFunction.series.<locals>.<genexpr>i  s;   øè ø€ ò =Ø !°°Q±¸!²ô % S¨¡V¨QÓ/°#°a¸!±e±*Õ<ñ =ùrU  r  c              3   ó:   •K  — | ]  \  }}‰|‰z   z  |z  –— Œ y ­wrB   rr   )rµ   r�   r‚   Úconstantpowerrx   s      €€rG   r¶   z+HolonomicFunction.series.<locals>.<genexpr>p  s$   øè ø€ ÒI±$°!°Q�1�q˜=Ñ(Ñ)¨AÕ-ÑIùó   ƒ)r[  rb   Útupler~   ÚseriesrÖ   rj  Ú
recurrencer   rx   r¹   r}   rv   rV   rÞ   rß   rà   r�   r…   r&  r   r×   rŠ   ry   r4   r  )rd   rª   Úcoefficientr   r“  rœ  r�   Úlr3  r¹   Úseq_dmprÍ   rë   r‚   Úseqr2  Úserr˜  rQ   r–  rx   s         `          @@@@rG   r›  zHolonomicFunction.series(  s‰  ü€ ð: ˆ>Ø×)Ñ)Ó+‰JàˆJä�j¤%Ô(¬S°«_ÀÒ-AØ# A™ˆJØ‰MÜ˜
¤EÔ*¬s°:«À!Ò/CØ& q™MˆMØ# A™‰Jä�‹_ Ò!¤c¨*°Q©-Ó&8¸AÒ&=Ø# A™ qÑ)ˆJØ‰MÜ�‹_ Ò!¤c¨*°Q©-Ó&8¸AÒ&=Ø& q™M¨!Ñ,ˆMØ# A™ qÑ)‰Jà3=Ö>¨a�D—K‘K q�KÕ)Ò>Ð>à”�MÓ"Ñ"ˆÜ�
—‘Ó Ñ"ˆØ×!Ñ!×'Ñ'ˆØ�F‰FˆØ�W‰WˆØ×'Ñ'×2Ñ2ˆØ×!Ñ!×(Ñ(×-Ñ-ˆØ�K‰K‹MˆØ+2Ö3 aˆq�u‰u�Q—Y‘Y“[Õ!Ð3ˆÐ3Ü).¨q«Ö2 A��A‘ˆw˜˜Q™ÓÒ2ˆÜ�:—=‘=Ó!ˆàˆq‰5�1Š9ä˜1˜q™5 1™9 a¨!¡eÓ,ò "�Üõ =Ü%*¨1£Xô=ÜDEÇFÁFôL�à—
‘
˜5Õ!ð"ñ
 ØˆJäÔI¼)ÀC».ÔIÜŸ™ô ˆáØ”5˜˜Q¤ ]Ó!3Ñ3Ñ4°aÓ8Ñ8ˆCØ�Š7Ø—8‘8˜A˜q 2™vÓ&Ð&Øˆ
ùò= ?ùò 4ùÚ2s   ÃJ2Æ&J7Æ7J<c                 ó  ‡	‡
‡‡‡— | j                   dk7  r)| j                  | j                   «      j                  «       S | j                  j                  }| j                  j
                  j                  Š	| j                  Š‰	j                  }‰	j                  }ˆ	ˆfd„Š
t        d„ |D «       «      }dt        d|«      t        d| j                  j                  «      z   z  Šˆ
ˆfd„Št        ˆfd„t        |«      D «       «      }t        |«      D ]\  \  }}|j                  «       }t        |«      dz
  }d||z   cxk  r|k  rn n||||z
  |z
     |z  z   }|‰	j!                  ‰|z
  «      z  }Œ^ t#        ‰	j%                  |«      ‰«      S )z:
        Computes roots of the Indicial equation.
        r   c                 ón   •— t        ‰j                  | «      ‰d¬«      }d|j                  «       v r|d   S y)NrV  rW  r   )r/   r|   r_  )ÚpolyÚroot_allrÍ   rx   s     €€rG   Ú_pole_degreez1HolonomicFunction._indicial.<locals>._pole_degree†  s5   ø€ Ü˜QŸZ™Z¨Ó-¨q¸Ô=ˆHØ�H—M‘M“OÑ#Ø ‘{Ð"àrI   c              3   ó<   K  — | ]  }|j                  «       –— Œ y ­wrB   r>  )rµ   r‚   s     rG   r¶   z.HolonomicFunction._indicial.<locals>.<genexpr>�  s   è ø€ Ò4 A�Q—X‘X—ZÑ4ùrA  é
   r8   c                 ó0   •— | j                   r‰S  ‰| «      S rB   )r$  )Úqr¦  Úinfs    €€rG   rH   z-HolonomicFunction._indicial.<locals>.<lambda>�  s   ø€ ˜qŸyšy˜€ ©l¸1«o€ rI   c              3   ó:   •K  — | ]  \  }} ‰|«      |z
  –— Œ y ­wrB   rr   )rµ   r‚   rª  Údegs      €rG   r¶   z.HolonomicFunction._indicial.<locals>.<genexpr>‘  s   øè ø€ Ò=™t˜q !‘�A“˜•
Ñ=ùr™  )r¹   rZ  r}  rÁ   r}   rv   rV   rx   r_   r`   rÝ   r   r%  ry   r]  r~   r{   r/   r|   )rd   Ú
list_coeffr  Úyr?  r†   r�   r‚   ra  rÍ   r¦  r­  r«  rx   s            @@@@@rG   r}  zHolonomicFunction._indicialx  sT  ü€ ð
 �7‰7�aŠ<Ø—<‘< §¡Ó(×2Ñ2Ó4Ð4à×%Ñ%×0Ñ0ˆ
Ø×Ñ×#Ñ#×(Ñ(ˆØ�F‰FˆØ�F‰FˆØ�E‰Eˆõ	ô Ñ4¨Ô4Ó4ˆØ”C˜˜6“N¤S¨¨D×,<Ñ,<×,BÑ,BÓ%CÑCÑDˆä=ˆÜÓ=¤y°Ó'<Ô=Ó=ˆä˜jÓ)ò 	%‰DˆAˆqØŸ™›ˆIÜ˜“^ aÑ'ˆFØ�A˜‘EÔ#˜VÕ#Ø˜	 &¨1¡*¨q¡.Ñ1°AÑ5Ñ5�Ø�—‘˜a !™eÓ$Ñ$‰Að	%ô �Q—Z‘Z “] AÓ&Ð&rI   c                 ó†  — ddl m} d}t        |d«      s“d}t        |«      }| j                  |k(  r || |g||¬«      d   S |j
                  st        ‚| j                  }||kD  r| }t        ||z
  |z  «      }	||z   g}t        |	dz
  «      D ]  }
|j                  |d   |z   «       Œ t        | j                  j                  j                  j                  | j                  j                  d   «      | j                   «      D ]!  }
|
| j                  k(  s|
|v sŒt#        | |
«      ‚ |r || |||¬«      d   S  || |||¬«      S )	a±  
        Finds numerical value of a holonomic function using numerical methods.
        (RK4 by default). A set of points (real or complex) must be provided
        which will be the path for the numerical integration.

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

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

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

        Examples
        ========

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

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

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

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

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

        Euler's method for the same

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

        One can also observe that the value obtained using Runge-Kutta 4th order
        is much more accurate than Euler's method.
        r   )Ú_evalfFrý   T)ÚmethodÚderivativesr›   r8   )Úsympy.holonomic.numericalr±  r  r   r¹   r  r   rÖ   r�   rŠ   r/   rÁ   rv   rV   r|   r}   rx   r>   )rd   Úpointsr²  Úhr³  r±  Úlpr†   rØ   rª   r�   s              rG   r  zHolonomicFunction.evalfœ  sP  € õ\ 	5Øˆô �v˜zÔ*ØˆBÜ�&“	ˆAØ�w‰w˜!Š|Ù˜d Q C°ÀKÔPÐQSÑTÐTà—;’;Ü)Ð)à—‘ˆAØ�1ŠuØ�B�Ü�Q˜‘U˜a‘KÓ ˆAØ˜!‘e�WˆFÜ˜1˜q™5“\ò .�Ø—‘˜f R™j¨1™nÕ-ð.ô �t×'Ñ'×.Ñ.×3Ñ3×<Ñ<¸T×=MÑ=M×=XÑ=XÐY[Ñ=\Ó]Ð_c×_eÑ_eÓfò 	0ˆAØ�D—G‘GŠ|˜q Fš{Ü& t¨QÓ/Ð/ð	0ñ Ù˜$ ¨vÀ;ÔOÐPRÑSÐSÙ�d˜F¨6¸{ÔKÐKrI   c                 ój  — | j                   j                  j                  j                  }|j	                  |«      }t        |d«      \  }}| j                   j                  D �cg c]  } ||j                  «       «      ‘Œ }}t        ||«      }t        ||| j                  | j                  «      S c c}w )z•
        Changes only the variable of Holonomic Function, for internal
        purposes. For composition use HolonomicFunction.composition()
        r\   )rÁ   rv   rV   rÆ   rÈ   rY   r}   rà   r^   r¾   r¹   rÀ   )rd   ÚzrÆ   rÍ   rv   rÏ   r‚   rQ   s           rG   Úchange_xzHolonomicFunction.change_xç  s•   € ð ×Ñ×%Ñ%×*Ñ*×.Ñ.ˆØ×Ñ˜aÓ ˆÜ)¨!¨TÓ2‰	ˆ�Ø'+×'7Ñ'7×'BÑ'BÖC !‰q�—‘“�~ÐCˆÐCÜ# C¨Ó0ˆÜ   a¨¯©°$·'±'Ó:Ð:ùò Ds   Á#B0c           
      óÖ  — | j                   }| j                  j                  }| j                  j                  j                  }|D �cg c]5  }|j                  |j                  |«      j                  |||z   «      «      ‘Œ7 }}t        || j                  j                  «      }| j                  |z
  }| j                  «       st        ||«      S t        |||| j                  «      S c c}w )z-
        Substitute `x + a` for `x`.
        )rx   rÁ   r}   rv   rV   r{   r|   r  r^   r¹   rÃ   r¾   rÀ   )rd   rØ   rx   ÚlistaftershiftrV   r�   rQ   r¹   s           rG   rZ  zHolonomicFunction.shift_xô  sÄ   € ð
 �F‰FˆØ×)Ñ)×4Ñ4ˆØ×Ñ×&Ñ&×+Ñ+ˆàIWÖXÀAˆt�‰˜tŸ}™}¨QÓ/×4Ñ4°Q¸¸A¹Ó>Õ?ÐXˆÐXÜ" 3¨×(8Ñ(8×(?Ñ(?Ó@ˆØ�W‰W�q‰[ˆØ×#Ñ#Ô%Ü$ S¨!Ó,Ð,Ü   a¨¨T¯W©WÓ5Ð5ùò Ys   Á:C&c                 óþ  ‡— |€| j                  «       }n|}t        |t        «      rt        |«      dk(  r|d   }|d   }d}nÐt        |t        «      rt        |«      dk(  r|d   }|d   }|d   }n¢t        |«      dk(  r$t        |d   «      dk(  r|d   d   }|d   d   }d}npt        |«      dk(  r*t        |d   «      dk(  r|d   d   }|d   d   }|d   d   }n8| j	                  ||d   ¬«      }|dd D ]  }|| j	                  ||¬«      z  }Œ |S |j
                  }|j                  Š| j                  }	| j                  }
‰j                  }|dk(  �r]t        ‰j                  j                  j                  ‰j                  d   «      |j                  d¬«      }t         j"                  }t%        |«      D ]„  \  }}|dk  st'        |«      sŒt)        |«      }|t        |«      k  r>t        ||   t*        t,        f«      r||   j/                  «       ||<   |||   |	|z  z  z  }Œn|t1        d	|z  «      |	|z  z  z  }Œ† t        |t*        t,        f«      r|j/                  «       |	|z  z  }n||	|z  z  }|r |
dk7  r|j3                  |	|	|
z
  «      fgS |fgS |
dk7  r|j3                  |	|	|
z
  «      S |S ||z   t        |«      kD  rt5        d
«      ‚t7        ˆfd„‰j                  dd D «       «      rt9        | | j                  «      ‚‰j                  d   }‰j                  d   }t        |j;                  «       t*        t,        f«      ryt!        |j;                  «       j/                  «       «      ||j=                  «       z  z   t!        |j;                  «       j/                  «       «      ||j=                  «       z  z  z  }n\t!        |j;                  «       «      ||j=                  «       z  z   t!        |j;                  «       «      ||j=                  «       z  z  z  }d}t        ‰j                  j                  j                  |«      |j                  «      }t        ‰j                  j                  j                  |«      |j                  «      }|rg }t?        ||z   «      D �]²  }||k  rU|r;jA                  t!        ||   «      |	||z   z  z  j3                  |	|	|
z
  «      f«       n|t!        ||   «      |	|z  z  z  }Œ^t!        ||   «      dk(  rŒpg }g }tC        |jE                  «       «      D ])  }|jG                  tI        ||z
  |z  «      g||   z  «       Œ+ tC        |jE                  «       «      D ])  }|jG                  tI        ||z
  |z  «      g||   z  «       Œ+ d|v r|jK                  d«       n|jA                  d«       |rajA                  t!        ||   «      |	||z   z  z  j3                  |	|	|
z
  «      tM        ||||	|z  z  «      j3                  |	|	|
z
  «      f«       �Œˆ|t!        ||   «      tM        ||||	|z  z  «      z  |	|z  z  z  }�Œµ |rS ||	|z  z  }|
dk7  r|j3                  |	|	|
z
  «      S |S )añ  
        Returns a hypergeometric function (or linear combination of them)
        representing the given holonomic function.

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

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

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

        Examples
        ========

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

        See Also
        ========

        from_hyper, from_meijerg
        Nr©   r8   r   rþ   )Úas_listr“  rÍ   rW  rY  z+Can't compute sufficient Initial Conditionsc              3   ód   •K  — | ]'  }|‰j                   j                  j                  k7  –— Œ) y ­wrB   r´   ©rµ   r�   rF   s     €rG   r¶   z-HolonomicFunction.to_hyper.<locals>.<genexpr>m  s$   øè ø€ ÒC¨1ˆq�A—H‘H—M‘M×&Ñ&Õ&ÑCùs   ƒ-0r›   )'r[  rb   rš  r~   Úto_hyperrj  rœ  rx   r¹   r   r/   rv   rV   r|   r}   rª   r   r×   ry   r   rÖ   r*   r+   Úas_exprr   r  r   Úanyr=   ÚLCr?  r�   rŠ   r   r_  r  r6   Úremover&   )rd   r¾  r“  rœ  rc  r˜  rQ   r�   rj  rx   r¹   ÚmÚnonzerotermsr‚   rØ   r†   r  Úarg1Úarg2Ú	listofsolÚapÚbqr3  rF   s                          @rG   rÁ  zHolonomicFunction.to_hyper  sK  ø€ ðF ˆ>Ø×)Ñ)Ó+‰JàˆJä�j¤%Ô(¬S°«_ÀÒ-AØ# A™ˆJØ# A™ˆJØ‰MÜ˜
¤EÔ*¬s°:«À!Ò/CØ# A™ˆJØ& q™MˆMØ# A™‰JÜ�‹_ Ò!¤c¨*°Q©-Ó&8¸AÒ&=Ø# A™ qÑ)ˆJØ# A™ qÑ)ˆJØ‰MÜ�‹_ Ò!¤c¨*°Q©-Ó&8¸AÒ&=Ø# A™ qÑ)ˆJØ& q™M¨!Ñ,ˆMØ# A™ qÑ)‰Jà—-‘-¨¸
À1¹�-ÓFˆCØ  �^ò @�Ø�t—}‘}¨W¸Q�}Ó?Ñ?‘ð@àˆJà�]‰]ˆØ×!Ñ!ˆØ�F‰FˆØ�W‰Wˆð �G‰Gˆð �‹6Ü  §¡§¡×!7Ñ!7¸¿¹ÀQ¹Ó!HÈ*Ï,É,Ð_bÔcˆLä—&‘&ˆCÜ! ,Ó/ò 4‘��1à�q’5¤
¨1¤Øä˜“F�Ø”s˜2“w’;Ü! " Q¡%¬+´{Ð)CÔDØ " 1¡§¡£˜˜1™Ø˜2˜a™5 1 a¡4™<Ñ'‘Cð œ6 &¨!¡)Ó,¨q°!©tÑ3Ñ3‘Cð4ô ˜#¤¬[Ð9Ô:Ø—k‘k“m a¨Ñ&6Ñ6‘à˜A˜}Ñ,Ñ,�ÙØ˜’7Ø ŸX™X a¨¨R©Ó0Ð3Ð4Ð4Ø˜�yÐ Ø�QŠwØ—x‘x  1 r¡6Ó*Ð*ØˆJà˜‰>œC ›GÒ#Ü%Ð&SÓTÐTô ÓC°·±¸Q¸rÐ0BÔCÔCÜ% d¨D¯G©GÓ4Ð4à�L‰L˜‰OˆØ�L‰L˜Ñˆô �a—d‘d“fœ{¬KÐ8Ô9Ü�Q—T‘T“V—^‘^Ó%Ó&¨¨Q¯X©X«Z©Ñ8Ð9¼Q¸q¿t¹t»v¿~¹~Ó?OÓ=PÐSTÐWX×W_ÑW_ÓWaÑSbÑ=bÑc‰Aä�Q—T‘T“V“9˜q 1§8¡8£:™Ñ.Ð/´1°Q·T±T³V³9¸qÀ1Ç8Á8Ã:¹Ñ3NÑOˆAàˆä�Q—X‘X—]‘]×+Ñ+¨AÓ.°
·±Ó=ˆÜ�Q—X‘X—]‘]×+Ñ+¨AÓ.°
·±Ó=ˆñ ØˆIÜ�z A‘~Ó&ó %	AˆAð �:Š~ÙØ×$Ñ$¤q¨¨A©£x°!°a¸±oÑ2FÑ'F×&LÑ&LÈQÐPQÐRTÑPTÓ&UÐ%XÕYàœ1˜R ™U›8 a¨¡d™?Ñ*�CØô
 ��A‘‹x˜1Š}ØàˆBØˆBô ˜TŸY™Y›[Ó)ò >�Ø—	‘	œ9 a¨!¡e¨q¡[Ó1Ð2°T¸!±WÑ<Õ=ð>ô ˜TŸY™Y›[Ó)ò >�Ø—	‘	œ9 a¨!¡e¨q¡[Ó1Ð2°T¸!±WÑ<Õ=ð>ð �B‰wØ—	‘	˜!•à—	‘	˜!”ÙØ× Ñ ¤1 R¨¡U£8¨A°°-±Ñ,@Ñ#@×"FÑ"FÀqÈ!ÈBÉ$Ó"OÔRWÐXZÐ\^Ð`aÐbcÐefÑbfÑ`fÓRg×QmÑQmÐnoÐqrÐsuÑquÓQvÐ!wÖxà”q˜˜A™“x¤%¨¨B°°A°q±D±Ó"9Ñ9¸A¸q¹DÑ@Ñ@’ðK%	AñL ØÐØ�A�}Ñ$Ñ$ˆØ�Š7Ø—8‘8˜A˜q 2™vÓ&Ð&àˆ
rI   c                 óP   — t        | j                  «       «      j                  «       S )a_  
        Converts a Holonomic Function back to elementary functions.

        Examples
        ========

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

        )r5   rÁ  Úsimplifyr    s    rG   r  zHolonomicFunction.to_expr´  s   € ô& ˜4Ÿ=™=›?Ó+×4Ñ4Ó6Ð6rI   c                 óð  — d}|€At        | j                  «      | j                  j                  kD  rt        | j                  «      }| j                  j                  j
                  j                  }	 t        | j                  «       | j                  |||¬«      }|rj                  |k(  r|S | j                  |d¬«      }t        | j                  | j                  ||«      S # t        t        f$ r d}Y Œ[w xY w)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)rx   r¹   ÚlenicsrD   F)r³  )r~   rÀ   rÁ   r   rv   rV   rD   Úexpr_to_holonomicr  rx   r<   r=   r¹   r  r¾   )rd   r†   rÐ  ÚsymbolicrÆ   rQ   rÀ   s          rG   rç   zHolonomicFunction.change_icsÉ  sÒ   € ð$ ˆàˆ>œc $§'¡'›l¨T×-=Ñ-=×-CÑ-CÒCÜ˜Ÿ™“\ˆFØ×Ñ×%Ñ%×*Ñ*×1Ñ1ˆð	Ü# D§L¡L£N°d·f±fÀÈ6ÐZ]Ô^ˆCñ ˜Ÿ™ !šØˆJà�Z‰Z˜ tˆZÓ,ˆÜ  ×!1Ñ!1°4·6±6¸1¸bÓAÐAøô $Ô%8Ð9ò 	ØŠHð	ús   Á1(C! Ã!C5Ã4C5c                 óÒ   — | j                  d¬«      }t        j                  }|D ]?  }t        |«      dk(  r	||d   z  }Œt        |«      dk(  sŒ)||d   t	        |d   «      z  z  }ŒA |S )aò  
        Returns a linear combination of Meijer G-functions.

        Examples
        ========

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

        See Also
        ========

        to_hyper
        T)r¾  r8   r   r©   )rÁ  r   r×   r~   Ú_hyper_to_meijerg)rd   r"  rQ   r�   s       rG   Ú
to_meijergzHolonomicFunction.to_meijergì  ss   € ð, �m‰m DˆmÓ)ˆÜ�f‰fˆàò 	6ˆAÜ�1‹v˜Š{Ø�q˜‘t‘‘ä�Q“˜1“Ø�q˜‘tÔ/°°!±Ó5Ñ5Ñ5‘ð	6ð ˆ
rI   rQ  ©F©T)é   FTN)ÚRK4gš™™™™™©?F)FNrB   )$rm   rn   ro   rp   r»   re   rg   rq   rÇ   rÒ   rÃ   rÙ   r˜   rÿ   r‹   rl   r’   r”   rœ   rž   r¡   r¦   r¬   r?  rJ  r[  r\  r›  r}  r  rº  rZ  rÁ  r  rç   rÕ  rr   rI   rG   r¾   r¾   t  sÉ   „ ñ@ðD €Lóò:ð €Hòò<ò òLòO;ób}?ò~K;òZò_?ðB €Hò!ò!òò&ò òDDò>.ó@{,ózJóXNò`"'óHILòV;ò6ó nò`7ó*!BóF rI   r¾   Fc                 óŽ  — | j                   }| j                  }| j                  d   }|j                  t        «      j                  «       }t        t        j                  |«      d«      \  }}||z  }	d}
|D ]
  }|
|	|z   z  }
Œ |	dz
  }|}|D ]
  }|||z   z  }Œ |
|z
  }t        | «      }|t        t        fv rt        ||«      j                  |«      S t        |t        «      s[t!        ||||j"                  d¬«      }|s"|dz  }t!        ||||j"                  d¬«      }|sŒ"t        ||«      j                  |||«      S t        |t        «      r_d}t!        ||||j"                  |d¬«      }|s#|dz  }t!        ||||j"                  |d¬«      }|sŒ#t        ||«      j                  |||«      S t        ||«      j                  |«      S )aÌ  
    Converts a hypergeometric function to holonomic.
    ``func`` is the Hypergeometric Function and ``x0`` is the point at
    which initial conditions are required.

    Examples
    ========

    >>> from sympy.holonomic.holonomic import from_hyper
    >>> from sympy import symbols, hyper, S
    >>> x = symbols('x')
    >>> from_hyper(hyper([], [S(3)/2], x**2/4))
    HolonomicFunction((-x) + (2)*Dx + (x)*Dx**2, x, 1, [sinh(1), -sinh(1) + cosh(1)])
    r©   r\   r8   F©Ú	use_limit)rË  rÌ  r  Úatomsr   ÚpoprY   r,   rÈ   r5   r   r   r¾   rJ  rb   r&   Ú_find_conditionsr   )Úfuncr¹   r  rØ   r†   r¹  rx   rÍ   r\   ÚxDxÚr1ÚaiÚxDx_1Úr2ÚbirQ   ÚsimprÀ   s                     rG   Ú
from_hyperrè    sÓ  € ð  	�‰€AØ�‰€AØ�	‰	�!‰€AØ	�‰”‹×ÑÓ€AÜ!¤"×"2Ñ"2°1Ó"5°tÓ<�E€A€rð ˆB‰$€CØ	
€BØò ˆØ
ˆc�B‰h‰‰ðà�!‰G€Eà	€BØò ˆØ
ˆe�b‰jÑ‰ðà
ˆr‰'€Cä�tÓ€Dà”Ô*Ð+Ñ+Ü   aÓ(×4Ñ4°QÓ7Ð7ô �dœEÔ"Ü˜d A r¨3¯9©9ÀÔFˆÙð �!‰GˆBÜ! $¨¨2¨s¯y©yÀEÔJˆBò ô !  aÓ(×4Ñ4°Q¸¸BÓ?Ð?ä�$œÔØˆä˜d A r¨3¯9©9°eÀuÔMˆÙØ�!‰GˆBÜ! $¨¨2¨s¯y©y¸%È5ÔQˆBò ô !  aÓ(×4Ñ4°Q¸¸BÓ?Ð?ä˜S !Ó$×0Ñ0°Ó3Ð3rI   Tc                 óB  — | j                   }| j                  }t        | j                  «      }t        | j                  «      }t        |«      }	| j
                  d   }
|
j                  t        «      j                  «       }t        |j                  |«      d«      \  }}||z  }|dz   }|d||z   |	z
  z  z  }|D ]
  }|||z
  z  }Œ d}|D ]
  }|||z
  z  }Œ ||z
  }|st        ||«      j                  |
«      S t        | «      }|t        t        fv rt        ||«      j                  |
«      S t!        |t"        «      s[t%        ||||j&                  d¬«      }|s"|dz  }t%        ||||j&                  d¬«      }|sŒ"t        ||«      j                  |
||«      S t!        |t"        «      r_d}t%        ||||j&                  |d¬«      }|s#|dz  }t%        ||||j&                  |d¬«      }|sŒ#t        ||«      j                  |
||«      S t        ||«      j                  |
«      S )a¶  
    Converts a Meijer G-function to Holonomic.
    ``func`` is the G-Function and ``x0`` is the point at
    which initial conditions are required.

    Examples
    ========

    >>> from sympy.holonomic.holonomic import from_meijerg
    >>> from sympy import symbols, meijerg, S
    >>> x = symbols('x')
    >>> from_meijerg(meijerg(([], []), ([S(1)/2], [0]), x**2/4))
    HolonomicFunction((1) + (1)*Dx**2, x, 0, [0, 1/sqrt(pi)])
    r©   r\   r8   r›   FrÛ  )rË  rÌ  r~   ÚanÚbmr  rÝ  r   rÞ  rY   rÈ   r¾   rJ  r5   r   r   rb   r'   rß  r   )rà  r¹   r  rü   rD   rØ   r†   rª   rÆ  ró   r¹  rx   rÍ   r\   rá  ÚxDx1râ  rã  rå  ræ  rQ   rç  rÀ   s                          rG   Úfrom_meijergrí  N  s"  € ð  	�‰€AØ�‰€AÜˆD�G‰G‹€AÜˆD�G‰G‹€AÜˆA‹€AØ�	‰	�!‰€AØ	�‰”‹×ÑÓ€AÜ! &×"6Ñ"6°qÓ"9¸4Ó@�E€A€rð ˆB‰$€CØ�‰7€DØ	
ˆB�!�a‘%˜!‘)ÑÑ	€BØò ˆØ
ˆd�R‰i‰‰ðð 
€BØò ˆØ
ˆc�B‰h‰‰ðà
ˆr‰'€CáÜ   aÓ(×4Ñ4°QÓ7Ð7ä�tÓ€Dà”Ô*Ð+Ñ+Ü   aÓ(×4Ñ4°QÓ7Ð7ô �dœGÔ$Ü˜d A r¨3¯9©9ÀÔFˆÙØ�!‰GˆBÜ! $¨¨2¨s¯y©yÀEÔJˆBò ô !  aÓ(×4Ñ4°Q¸¸BÓ?Ð?ä�$œÔ ØˆÜ˜d A r¨3¯9©9°eÀuÔMˆÙØ�!‰GˆBÜ! $¨¨2¨s¯y©y¸%È5ÔQˆBò ô !  aÓ(×4Ñ4°Q¸¸BÓ?Ð?ä˜S !Ó$×0Ñ0°Ó3Ð3rI   Úx_1N)Ú_mytypec           	      ó¸  — t        | «      } | j                  }|s*t        |«      dk(  r|j                  «       }n t	        d«      ‚||v r|j                  |«       t        |«      }|€C| j                  t        «      rt        }nt        }t        |«      dk7  r||   j                  «       }t        | ||||||¬«      }	|	r|	S t        s|ai at        t        |¬«       n|t        k7  r|ai at        t        |¬«       | j                   �rd| j#                  |t$        «      }
t'        |
t$        «      }|t        v r!t        |   }|d   d   j)                  |«      }nƒt+        | |d|¬«      }|st,        ‚|r||_        |s|s	||_        |S |s|j2                  j4                  }t7        | |||«      }|s|dz  }t7        | |||«      }|sŒt9        |j2                  |||«      S |s|s0|j;                  | j<                  d   «      }|r||_        ||_        |S |s|j2                  j4                  }t7        | |||«      }|s|dz  }t7        | |||«      }|sŒ|j;                  | j<                  d   ||«      S | j<                  }| j>                  }
tA        |d   |d|¬«      }|
tB        u r0tE        dt        |«      «      D ]  }|tA        ||   |d|¬«      z  }Œ nH|
tF        u r0tE        dt        |«      «      D ]  }|tA        ||   |d|¬«      z  }Œ n|
tH        u r||d   z  }||_        |st,        ‚|r||_        |s|s|S |j.                  r|S |s|j2                  j4                  }|j2                  jK                  |«      r¥|jM                  «       }t        |«      }t        |«      dk(  r|||d      tN        jP                  k(  rc|d   }| ||z
  |z  z  }t7        ||||«      }tS        |«      D ��cg c]  \  }}|tU        |«      z  ‘Œ }}}||i}t9        |j2                  |||«      S t7        | |||«      }|s|dz  }t7        | |||«      }|sŒt9        |j2                  |||«      S c c}}w )	a�  
    Converts a function or an expression to a holonomic function.

    Parameters
    ==========

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

    Examples
    ========

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

    See Also
    ========

    sympy.integrals.meijerint._rewrite1, _convert_poly_rat_alg, _create_table
    r8   z%Specify the variable for the functionr   )r¹   rÀ   rÐ  rD   rü   )rD   F©rü   rD   )rx   rü   rD   )+r   Úfree_symbolsr~   rÞ  Ú
ValueErrorrÅ  r…   r!  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¾   rJ  r  rà  rÑ  r   r�   r   r   rº   r}  r   r¥   ry   r   )rà  rx   r¹   rÀ   rÐ  rD   rü   ÚsymsÚ
extra_symsÚsolpolyÚfÚtrž  rQ   rú   r  r�   rF   ÚgÚsingular_icsr‚   s                        rG   rÑ  rÑ  —  sX  € ôR �4‹=€DØ×Ñ€DáÜˆt‹9˜Š>Ø�x‰x‹z‰AäÐDÓEÐEØ	
ˆd‰Ø�‰�AŒä�d“€Jà€~Ø�8‰8”EŒ?Ü‰FäˆFÜˆz‹?˜aÒØ˜JÑ'×1Ñ1Ó3ˆFô $ D¨!°°rÀ&ÐQWÐbjÔk€GÙØˆõ Ø!ÐØˆÜ”m¨FÖ3Ø	Ô#Ò	#Ø!ÐØˆÜ”m¨FÕ3ð ×ÓØ�I‰I�aœÓˆÜ�A”s‹OˆØ”ÑÜ˜aÑ ˆAØ�A‘$�q‘'×"Ñ" 1Ó%‰Cä$ T¨1°uÀVÔLˆCÙÜ)Ð)ÙØ�”Ù™Ø�”Ø�
ÙØŸ™×.Ñ.�Ü" 4¨¨B°Ó7ˆCÙØ�a‘�Ü& t¨Q°°FÓ;�ò ô % S§_¡_°a¸¸SÓAÐAá‘XØ—/‘/ $§)¡)¨A¡,Ó/ˆCÙØ�”ØˆCŒFØˆJÙØ—_‘_×*Ñ*ˆFä˜t Q¨¨FÓ3ˆÙØ�!‰GˆBÜ" 4¨¨B°Ó7ˆCò ð �‰˜tŸy™y¨™|¨R°Ó5Ð5ð �9‰9€DØ�	‰	€AÜ
˜D ™G q°5ÀÔ
H€CàŒC�xÜ�qœ#˜d›)Ó$ò 	RˆAØÔ$ T¨!¡W°¸EÈ&ÔQÑQ‰Cñ	Rð 
Œc‰Ü�qœ#˜d›)Ó$ò 	RˆAØÔ$ T¨!¡W°¸EÈ&ÔQÑQ‰Cñ	Rð 
Œc‰Ø�4˜‘7‰lˆØ€C„FÙÜ!Ð!Ù	ØˆŒÙ	‘Øˆ
Ø
‡v‚vØˆ
ÙØ—‘×&Ñ&ˆØ
‡�×"Ñ" 2Ô&Ø�M‰M‹OˆÜ�‹GˆÜˆq‹6�QŠ;˜1˜Q˜q™T™7¤a§e¡eÒ+Ø�!‘ˆAØ˜˜B™ ‘{Ñ"ˆAÜ+¨A¨q°"°fÓ=ˆLÜ9BÀ<Ó9P×Q±°°A˜A¤	¨!£Ó,ÐQˆLÑQØ�LÐ!ˆBÜ$ S§_¡_°a¸¸RÓ@Ð@ä
˜4  B¨Ó
/€CÙØ
ˆa‰ˆÜ˜t Q¨¨FÓ3ˆò ô ˜SŸ_™_¨a°°SÓ9Ð9ùó Rs   Ï!Qc                 ó¨  — g }g }|j                   }|j                  «       }|j                  t        j                  «      }g }t        | «      D ]ß  \  }	}
t        |
|j                  «      r/|j                  |j                  |
j                  «       «      «       nQt        |
|j                  «      s*|j                  |j                  t        |
«      «      «       n|j                  |
«       |j                  ||	   j                  «       «       |j                  ||	   j                  «       «       Œá |D ]  }	|	j                  |«      }Œ |r| }|j                  |j                  «       «      }t        |«      D ]  \  }	}
|
|z  ||	<   Œ  ||d   j                  «       |d   j                  «       z  j                  «       «      }|D ]  }	|	j                  |«      }Œ |j                  |j                  «       «      }t        |«      D ]B  \  }	}
|
|z  } ||j                  «       |j                  «       z  j                  «       «      ||	<   ŒD t!        ||«      S )z'
    Normalize a given annihilator
    r›   )rV   rÞ   r{   r   r¥   ry   rb   rz   rŠ   rß   rà   r   ÚnumerÚdenomÚlcmÚgcdr^   )Úlist_ofrv   rÜ   Únumr  rV   rë   Ú	lcm_denomÚlist_of_coeffr�   r‚   Ú	gcd_numerÚfrac_anss                rG   rä   rä   ;	  s%  € ð
 €CØ€EØ�;‰;€DØ�‰Ó€AØ—‘¤§¡Ó&€IØ€Mô ˜'Ó"ò /‰ˆˆ1Ü�a˜Ÿ™Ô$Ø× Ñ  §¡ q§y¡y£{Ó!3Õ4Ü˜A˜qŸw™wÔ'Ø× Ñ  §¡¬g°a«jÓ!9Õ:à× Ñ  Ô#ð 	�
‰
�= Ñ#×)Ñ)Ó+Ô,ð 	�‰�] 1Ñ%×+Ñ+Ó-Õ.ð/ð ò %ˆØ—E‘E˜)Ó$‰	ð%ñ Ø�Jˆ	à—‘�i×'Ñ'Ó)Ó*€Iô ˜-Ó(ò )‰ˆˆ1Ø˜y™=ˆ�aÒð)ñ �m BÑ'×-Ñ-Ó/°-ÀÑ2C×2IÑ2IÓ2KÑK×TÑTÓVÓW€Ið ò %ˆØ—E‘E˜)Ó$‰	ð%ð —‘�i×'Ñ'Ó)Ó*€Iô ˜-Ó(ò Q‰ˆˆ1Ø�y‘=ˆÙ §¡Ó!1°H·N±NÓ4DÑ!D× MÑ MÓ OÓPˆ�aÒðQô   ¨vÓ6Ð6rI   c                 óø   — g }t        | «      dz
  }|j                  t        | d   |«      «       t        | dd «      D ]&  \  }}|j                  t        ||«      | |   z   «       Œ( |j                  | |   «       |S )a*  
    Let a differential equation a0(x)y(x) + a1(x)y'(x) + ... = 0
    where a0, a1,... are polynomials or rational functions. The function
    returns b0, b1, b2... such that the differential equation
    b0(x)y(x) + b1(x)y'(x) +... = 0 is formed after differentiating the
    former equation.
    r8   r   N)r~   rŠ   r#  ry   )r}   rë   rQ   rØ   r�   r‚   s         rG   r  r  t	  s~   € ð €CÜˆJ‹˜!Ñ€AØ‡J�JŒw�z !‘} aÓ(Ô)ä˜* Q R˜.Ó)ò 2‰ˆˆ1Ø�
‰
”7˜1˜a“= :¨a¡=Ñ0Õ1ð2ð ‡J�Jˆz˜!‰}ÔØ€JrI   c                 ón  — | j                   }| j                  }t        d„ |D «       «      rt        | «      S | j                  d   }d„ |D «       }d}t
        j                  f}d„ |D «       }t
        j                  }|D ]  }	|t        |	«      z  }Œ |D ]  }	|t        |	«      z  }Œ |t        ||||| «      z  S )z(
    Converts a `hyper` to meijerg.
    c              3   óF   K  — | ]  }|d k  xr t        |«      |k(  –— Œ y­wrQ  )rÖ   r@  s     rG   r¶   z$_hyper_to_meijerg.<locals>.<genexpr>�	  s$   è ø€ Ò
. aˆ1�‰6Ò!”c˜!“f ‘kÓ!Ñ
.ùs   ‚!r©   c              3   ó&   K  — | ]	  }d |z
  –— Œ y­wru  rr   r@  s     rG   r¶   z$_hyper_to_meijerg.<locals>.<genexpr>•	  s   è ø€ Ò	�Aˆ!ˆa�%Ñ	ùrw  rr   c              3   ó&   K  — | ]	  }d |z
  –— Œ y­wru  rr   r@  s     rG   r¶   z$_hyper_to_meijerg.<locals>.<genexpr>˜	  s   è ø€ Ò
�Qˆ1ˆq�5Ñ
ùrw  )
rË  rÌ  rÃ  r5   r  r   r×   r¥   r%   r'   )
rà  rË  rÌ  r¹  rê  Úanprë  Úbmqr3  r�   s
             rG   rÔ  rÔ  ˆ	  sÁ   € ð 
�‰€BØ	�‰€Bä
Ñ
.¨2Ô
.Ô.Ü˜4Ó Ð à�	‰	�!‰€Añ 
˜Ô	€BØ
€CÜ
�&‰&ˆ€BÙ
˜"Ô
€Cä	�‰€Aàò ˆØ”�a“‰L‰ðð ò ˆØ”�a“‰L‰ðð Œw�r˜3  C¨!¨Ó,Ñ,Ð,rI   c                 ó  — t        | «      t        |«      k  r3t        | |«      D ��cg c]
  \  }}||z   ‘Œ c}}|t        | «      d z   }|S t        | |«      D ��cg c]
  \  }}||z   ‘Œ c}}| t        |«      d z   }|S c c}}w c c}}w )zvTakes 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†   rQ   s        rG   rŒ   rŒ   ¥	  sˆ   € ô ˆ5ƒz”S˜“ZÒÜ!$ U¨EÓ!2×3™˜˜Aˆq�1‹uÓ3°e¼CÀ»J¸KÐ6HÑHˆð €Jô "% U¨EÓ!2×3™˜˜Aˆq�1‹uÓ3°e¼CÀ»J¸KÐ6HÑHˆØ€Jùó 4ùã3s   §A>ÁBc                 ó  — | j                   j                  | j                  «      s| j                  «       dk(  r| j                  S | j                   }|j
                  }g }| j                  }|j                  j                  }|j                  «       }|j                  D ][  }t        ||j                  j                  j                  «      sŒ.|j                  |j                  |j                  «       «      «       Œ] t        |«      |k  s|t        |«      k  r|S t!        |«      D �	cg c]  }	||	    ||   z  ‘Œ }
}	|dt#        t        |«      |«       }t!        ||z
  «      D ]Œ  }d}t%        ||
«      D ]\  \  }}t'        || j                  «      }t)        |dd«      s|c c S t        |t*        t,        f«      r|j/                  «       }|||z  z  }Œ^ |j                  |«       t1        |
|«      }
ŒŽ ||t        |«      d z   S c c}	w )zy
    Tries to find more initial conditions by substituting the initial
    value point in the differential equation.
    TNr   r‚  )rÁ   rº   r¹   rÒ   rÀ   r   rv   rV   rÞ   r}   rb   rz   rŠ   rß   rà   r~   r�   r%  ræ   r•  Úgetattrr*   r+   rÂ  r  )Ú	Holonomicrª   rÁ   rØ   r}   rÀ   rÍ   rë   r‚   r�   Úlist_redrô   rÏ   rQ   r†   rF   s                   rG   rå   rå   °	  sÛ  € ð ×Ñ×(Ñ(¨¯©Ô6¸)×:RÑ:RÓ:TÐX\Ò:\Ø�|‰|Ðà×'Ñ'€KØ×Ñ€Aà€Jà	�‰€BØ×Ñ×Ñ€AØ	�‰‹€Aà×#Ñ#ò 2ˆÜ�a˜×+Ñ+×0Ñ0×6Ñ6Õ7Ø×Ñ˜aŸe™e A§I¡I£KÓ0Õ1ð2ô ˆ2ƒw�‚{�aœ3˜r›7’lØˆ	ä˜q›ö#Øð ˜A‘� ¨A¡Ó.ð #€Hð #à	ÐŒS”�R“˜!‹_Ð	€BÜ�1�q‘5‹\ò 
2ˆØˆÜ˜˜HÓ%ò 	‰DˆAˆqÜ˜˜9Ÿ<™<Ó(ˆAÜ˜1˜k¨4Ô0Ø”	Ü˜!œk¬;Ð7Ô8Ø—I‘I“K�Ø�1�q‘5‰L‰Cð	ð 	�	‰	�#ŒÜ$ X¨qÓ1‰ð
2ð �”3�r“7�8�ÑÐùò#s   Ä&Hc                 ó,  — t        | t        «      s| j                  «       S |j                  | «      }|j	                  | «      }| |j                  «       z  ||j                  «       z  z   }|dz  } ||j                  «       |j                  «       f«      S rs  )rb   r.   r‹   r  r  rà   )Úfracrë   ró   rª  Úsol_numÚ	sol_denoms         rG   r#  r#  Ù	  s{   € ä�dœCÔ Ø�y‰y‹{Ðà	�‰�‹€AØ	�‰�‹€AØˆc�A—F‘F“H‰n˜q 1§6¡6£8™|Ñ+€GØ�1‘€IÙˆg�o‰oÓ ×!2Ñ!2Ó!4Ð5Ó6Ð6rI   c                 ó|  — t        | t        «      s| S | j                  }| j                  }t        j
                  }t        j
                  }|rddlm} t        t        |«      «      D ]6  \  }}	|r$t        |	«      j                  j                  «      }	||	||z  z  z  }Œ8 t        t        |«      «      D ]6  \  }}	|r$t        |	«      j                  j                  «      }	||	||z  z  z  }Œ8 t        |t        t        f«      r|j                  «       }t        |t        t        f«      r|j                  «       }||z  S )Nr   )Úmp)rb   r.   r  Údenr   r×   Úmpmathr  ry   Úreversedr   Ú
_to_mpmathÚprecr*   r+   rÂ  )
r  r¹   Úmpmró   rª  Úsol_pÚsol_qr  r�   r‚   s
             rG   r•  r•  å	  s  € ä�dœCÔ Øˆà�‰€AØ�‰€AÜ�F‰F€EÜ�F‰F€Eá
Ýäœ( 1›+Ó&ò ‰ˆˆ1ÙÜ˜“
×%Ñ% b§g¡gÓ.ˆAØ��R˜‘U‘Ñ‰ðô
 œ( 1›+Ó&ò ‰ˆˆ1ÙÜ˜“
×%Ñ% b§g¡gÓ.ˆAØ��R˜‘U‘Ñ‰ðô
 �%œ+¤{Ð3Ô4Ø—‘“ˆÜ�%œ+¤{Ð3Ô4Ø—‘“ˆà�5‰=ÐrI   c                 óÊ  — | j                  «       }|s| j                  «       }nd}|sj|sh| j                  «       \  }	}
|	j                  «       rB|
j                  r6t	        |
t
        «      rt        |
«      }
|
j                  |
j                  }}d}nd}nd}|s|s|sy|j                  |«      }t        |d«      \  }}| j                  |«      st        ||d| g«      S |rý| |z  | j                  |«      z
  }t        |j                  |j                   d¬«      }|j#                  |«      }|�€*|dk(  �r$|�r!|j%                  | «      j'                  «       }t)        t+        |«      «      D ]%  \  }}|dk(  rŒt-        t+        |«      «      |d }|} n t)        «      D ]/  \  }}t	        |t.        t0        f«      sŒ|j3                  «       ||<   Œ1 t5        |«      i}�nz|ri| j7                  «       \  }}||z  |z  ||j                  |«      z  z   ||j                  |«      z  z
  }t        |j                  |j                   d¬«      }�n|�r|z  z  |z  dz
  }t        ||«      j9                  	«      j:                  }|j#                  |«      }|€Æ|dk(  rÁ|r¿|�|dk  r¸|j%                  |	«      j'                  «       }t)        t+        |«      «      D ]N  \  }}|dk(  rŒt	        |t.        t0        f«      r|j3                  «       }t5        |«      
z  }t5        |«      |
z  } n t	        t.        t0        f«      r|j3                  «       }t5        |g«      i}|s|st        |||«      S |sj<                  }j#                  |«      r¦t        |||«      j?                  «       }t-        |«      }tA        |«      dk(  rr||d      t4        jB                  k(  rY|d   }| ||z
  |z  z  }tE        ||||«      }t)        |«      D ��cg c]  \  }}|tG        |«      z  ‘Œ }}}||i}t        ||||«      S tE        | |||«      }|s|dz  }tE        | |||«      }|sŒt        ||||«      S c c}}w )zO
    Converts polynomials, rationals and algebraic functions to holonomic.
    TFNr\   r   rÛ   r8   )$Úis_polynomialÚis_rational_functionÚas_base_expr  rb   r	   r6   ró   rª  rÈ   rY   r!  r¾   r‹   rä   r}   rv   rº   r{   rà   ry   r"  r…   r*   r+   rÂ  r   Úas_numer_denomrJ  rÁ   r   r}  r~   r¥   rß  r   )rà  rx   r¹   rÀ   rÐ  rD   rü   ÚispolyÚisratÚbasepolyÚratexprÆ  rª   Úis_algrÍ   rÏ   r\   rQ   rº   r"  r�   r‚   r2  Úindicialró   rª  rF   rž  rÿ  r   s                                 rG   rô  rô  
  s:  € ð
 ×ÑÓ!€FÙØ×)Ñ)Ó+‰àˆá‘eØ×+Ñ+Ó-Ñˆ�&Ø×!Ñ!Ô#¨×(8Ò(8Ü˜&¤%Ô(Ü" 6Ó*�Ø—8‘8˜VŸX™XˆqˆAØ‰Fà‰Fàˆá‘e™vØà×Ñ˜QÓ€AÜ! ! TÓ*�E€A€rð �8‰8�AŒ;Ü   Q¨¨D¨6Ó2Ð2áà�R‰i˜$Ÿ)™) A›,Ñ&ˆÜ˜Ÿ™¨¯©¸eÔDˆØ—o‘o bÓ)ˆð ‰:˜" ›'¢kØ—,‘,˜tÓ$×,Ñ,Ó.ˆCÜ!¤(¨3£-Ó0ò ‘��1Ø˜’6ØÜœX c›]Ó+¨A¨BÐ/�Ø�Ùðô " %Ó(ò +‘��1Ü˜a¤+¬{Ð!;Õ<Ø Ÿy™y›{�E˜!’Hð+ð œA˜e›HÐ%ŠBá	Ø×"Ñ"Ó$‰ˆˆ1à�!‰e�b‰j˜1˜qŸv™v a›y™=Ñ(¨1¨q¯v©v°a«y©=Ñ8ˆÜ˜Ÿ™¨¯©¸eÔDŠâ	Ø�1�q‘5‰k˜BÑ Ñ"ˆÜ  QÓ'×3Ñ3°HÓ=×IÑIˆØ—o‘o bÓ)ˆð ˆ:˜" š'¡kØˆ^˜v¨š{Ø—,‘,˜xÓ(×0Ñ0Ó2ˆCÜ!¤(¨3£-Ó0ò ‘��1Ø˜’6ØÜ˜a¤+¬{Ð!;Ô<ØŸ	™	›�Aä˜!›˜f™�Ü˜Q›4 &™=�Ùðô ˜%¤+¬{Ð!;Ô<ØŸ™›�ØœA˜u˜g›JÐ'ˆBá	‘Ü   a¨¨RÓ0Ð0áØ—‘ˆà
‡��rÔÜ˜c 1 bÓ)×3Ñ3Ó5ˆÜ�‹GˆÜˆq‹6�QŠ;˜1˜Q˜q™T™7¤a§e¡eÒ+Ø�!‘ˆAØ˜˜B™ ‘{Ñ"ˆAÜ+¨A¨q°"°fÓ=ˆLÜ9BÀ<Ó9P×Q±°°A˜A¤	¨!£Ó,ÐQˆLÑQØ�LÐ!ˆBÜ$ S¨!¨R°Ó4Ð4ä	˜$  2 vÓ	.€BÙØ
ˆa‰ˆÜ˜d A r¨6Ó2ˆò ô ˜S ! R¨Ó,Ð,ùó Rs   Ï>Qc                 ó"  ‡— t        j                  | ‰«      }|r|\  }}}}ny |D �	cg c]
  }	||	d   z  ‘Œ }
}	|j                  «       }|d   ‰k(  r|d   nt        j                  }|D �	cg c]
  }	||	d   z   ‘Œ }}	|D �	cg c]  }	|	d   ‘Œ	 }}	ˆfd„} ||d   |d   «      \  }}|
d   |z  t        |||¬«      z  }t        dt        |«      «      D ].  }	 |||	   ||	   «      \  }}||
|	   |z  t        |||¬«      z  z  }Œ0 |S c c}	w c c}	w c c}	w )Nr   r8   r©   c                 ó8  •‡— | j                   d   }|j                  t        «      r|j                  t        t
        «      }|j                  ‰d¬«      }t        |«      d   }||   }|j                  «       }|d   ‰k(  r|d   nt        j                  }||z  Šˆfd„| j                   d   d   D «       }ˆfd„| j                   d   d   D «       }ˆfd„| j                   d   d   D «       }	ˆfd	„| j                   d   d   D «       }
|‰ z  t        ||f|	|
f|«      fS )
Nr›   F)r  r   r8   c              3   ó(   •K  — | ]	  }|‰z   –— Œ y ­wrB   rr   rÀ  s     €rG   r¶   z5_convert_meijerint.<locals>._shift.<locals>.<genexpr>Š
  ó   øè ø€ Ò-˜ˆa�!�eÑ-ùó   ƒc              3   ó(   •K  — | ]	  }|‰z   –— Œ y ­wrB   rr   rÀ  s     €rG   r¶   z5_convert_meijerint.<locals>._shift.<locals>.<genexpr>‹
  r6  r7  c              3   ó(   •K  — | ]	  }|‰z   –— Œ y ­wrB   rr   rÀ  s     €rG   r¶   z5_convert_meijerint.<locals>._shift.<locals>.<genexpr>Œ
  r6  r7  c              3   ó(   •K  — | ]	  }|‰z   –— Œ y ­wrB   rr   rÀ  s     €rG   r¶   z5_convert_meijerint.<locals>._shift.<locals>.<genexpr>�
  r6  r7  )r  r!  r
   r  r   r   Úcollectr…   r+  r   r×   r'   )rà  r  r¹  Údr†   rØ   rþ  rê  rË  rë  rÌ  rF   rx   s              @€rG   Ú_shiftz"_convert_meijerint.<locals>._shift~
  sú   ù€ Ø�I‰I�b‰MˆØ�5‰5”Œ8Ø—‘”y¤#Ó&ˆAà�I‰I�a %ˆIÓ(ˆÜ�‹G�A‰JˆØˆa‰Dˆà�M‰M‹OˆØ�a‘D˜A’IˆAˆaŠD¤1§6¡6ˆØ�‰EˆÛ-˜TŸY™Y q™\¨!™_Ô-ˆÛ-˜TŸY™Y q™\¨!™_Ô-ˆÛ-˜TŸY™Y q™\¨!™_Ô-ˆÛ-˜TŸY™Y q™\¨!™_Ô-ˆà�1�"‰u”g˜r 2˜h¨¨R¨°!Ó4Ð4Ð4rI   rñ  )r(   Ú	_rewrite1r+  r   r×   rí  r�   r~   )rà  rx   rü   rD   r  ÚfacÚporÿ  rÏ   r�   Úfac_listrþ  r  Úpo_listÚG_listr=  r2  rÆ  rQ   s    `                 rG   rù  rù  n
  sC  ø€ Ü×Ñ˜t QÓ'€DáØ‰ˆˆR�‘Aàð %&Ö&˜q��a˜‘d“
Ð&€HÐ&Ø
�‰Ó€AØ�!‘˜’	ˆˆ!ŠœqŸv™v€AØ!"Ö#˜Aˆq�1�Q‘4‹xÐ#€GÐ#ØÖ�qˆa�‹dÐ€FÐô5ñ& �f˜Q‘i ¨¡Ó,�H€Eˆ1Ø
�1‰+˜Ñ
¤¨Q¸È&Ô QÑ
Q€Cô �1”c˜&“kÓ"ò WˆÙ˜& ™) W¨Q¡ZÓ0‰ˆˆqØˆx˜‰{˜UÑ"¤\°!¸hÈvÔ%VÑVÑV‰ðWð €JùòE 'ùò $ùÚs   §DÁ)DÁ>Dc                 óJ  ‡ — d	ˆ fd„	}|j                  t        «      }t        |d«      \  }} |t        t        «      |dz  dz   t        dddg«        |t	        t        «      |dz  dz   t        dddg«        |t        t        «      |dz
  t        dd«        |t        t        «      |t        |dz  z  z   t        dddg«        |t        t        «      dt        z  |z  |dz  z   t        dddt        t        «      z  g«        |t        t        «      dt        z  |z  |dz  z   t        dddt        t        «      z  g«        |t        t        «      dt        z  |z  |dz  z   t        dddt        t        «      z  g«        |t        t        «      |dz  dz
  t        dddg«        |t        t        «      |dz  dz
  t        dddg«        |t        t        «      t        d|z  z   t        |dz  z  z   t        «        |t        t        «      t        |z  d|dz  z  z   t        |dz  z  z   t        «        |t!        t        «      t        |z  d|dz  z  z   t        |dz  z  z   t        «        |t#        t        «      t         |z  d|dz  z  z   t        |dz  z  z   t        «       y)
zi
    Creates the look-up table. For a similar implementation
    see meijerint._create_lookup_table.
    r   c           	      ó€   •— ‰j                  t        | t        «      g «      j                  | t	        ||||«      f«       y)z2
        Adds a formula in the dictionary
        N)r  rï  rî  rŠ   r¾   )ÚformularÁ   Úargr¹   rÀ   Útables        €rG   Úaddz_create_table.<locals>.add¢
  s<   ø€ ð 	×Ñœ ¬#Ó.°Ó3×:Ñ:¸GÜ˜k¨3°°BÓ7ð<9õ 	:rI   r\   r©   r8   éþÿÿÿrþ   N)r   rr   )rÈ   rî  rY   r   r   r   r   r"   r   r   r#   r$   r   r   r   r!   r   r    )rH  rD   rI  rÍ   rÏ   r\   s   `     rG   r÷  r÷  œ
  s-  ø€ õ:ð 	×ÑœSÓ!€AÜ! ! TÓ*�E€A€rñ ŒŒC‹�"�a‘%˜!‘)œS ! a¨ VÔ,ÙŒŒC‹�"�a‘%˜!‘)œS ! a¨ VÔ,ÙŒŒC‹�"�q‘&œ#˜q !Ô$ÙŒŒC‹�"”s˜2˜q™5‘y‘.¤# q¨1¨a¨&Ô1áŒŒC‹�!”C‘%˜‘(˜R ™UÑ"¤C¨¨Q°´$´r³(±
¨OÔ<ÙŒŒS‹	�1”S‘5˜‘8˜b !™eÑ#¤S¨!¨a°´D¼³H±Ð-=Ô>ÙŒŒS‹	�2”c‘6˜"‘9˜r 1™uÑ$¤c¨1¨q°!´D¼³H±*¨oÔ>áŒŒS‹	�2�q‘5˜1‘9œc 1 q¨! fÔ-ÙŒŒS‹	�2�q‘5˜1‘9œc 1 q¨! 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‘'˜A˜b !™e™GÑ#¤c¨"¨a©%¡iÑ/´Õ5rI   c                 ó4  — g }t        |«      D ]‡  }| j                  ||«      }|r|j                  «       }|rt        |t        «      rt        | ||«      }|j                  du st        |t        «      r y |j                  |«       | j                  |«      } Œ‰ |S )NF)	r�   r  r  rb   r   r3   r‚  rŠ   r‹   )	rà  rx   r¹   r   r  rÜ  rÀ   rÏ   Úvals	            rG   rß  rß  Á
  s‰   € Ø	€BÜ�5‹\ò 	ˆØ�i‰i˜˜2ÓˆÙØ—)‘)“+ˆCÙœ C¬Ô-Ü˜˜a Ó$ˆCØ�=‰=˜EÑ!¤Z°´SÔ%9ÙØ
�	‰	�#ŒØ�y‰y˜‹|‰ð	ð €IrI   )r   F)Nr   NNNTr×  rÖ  )FT)trp   Ú
sympy.corer   r   r   Úsympy.core.numbersr   r   r   r	   r
   r   r   r   Úsympy.core.singletonr   Úsympy.core.sortingr   Úsympy.core.symbolr   r   Úsympy.core.sympifyr   Ú(sympy.functions.combinatorial.factorialsr   r   r   Ú&sympy.functions.elementary.exponentialr   r   r   Ú%sympy.functions.elementary.hyperbolicr   r   Ú(sympy.functions.elementary.miscellaneousr   Ú(sympy.functions.elementary.trigonometricr   r   r   Ú'sympy.functions.special.error_functionsr   r    r!   r"   r#   r$   Ú'sympy.functions.special.gamma_functionsr%   Úsympy.functions.special.hyperr&   r'   Úsympy.integralsr(   Úsympy.matricesr)   Úsympy.polys.ringsr*   Úsympy.polys.fieldsr+   Úsympy.polys.domainsr,   r-   Úsympy.polys.polyclassesr.   Úsympy.polys.polyrootsr/   Úsympy.polys.polytoolsr0   Úsympy.polys.matricesr1   Úsympy.printingr2   Úsympy.series.limitsr3   Úsympy.series.orderr4   Úsympy.simplify.hyperexpandr5   Úsympy.simplify.simplifyr6   Úsympy.solvers.solversr7   rœ  r9   r:   r;   Úholonomicerrorsr<   r=   r>   r?   rR   rY   rT   r^   r¾   rè  rí  rî  rõ  rö  Úsympy.integrals.meijerintrï  rÑ  rä   r  rÔ  rŒ   rå   r#  r•  rô  rù  r÷  rß  rr   rI   rG   ú<module>rl     sQ  ðñ÷
 %Ñ $÷"÷ "ó "å "Ý &ß +Ý &ß LÑ Lß FÑ Fß >Ý 9ß EÑ Eß R× RÝ 9ß 8Ý %Ý !Ý )Ý *ß &Ý 'Ý 'Ý &Ý -Ý Ý %Ý $Ý 2Ý -Ý 'ç RÑ R÷)ó )òò#,÷LA3ñ A3÷HSGñ SG÷lXñ Xóv4<4ð~  5°4Àó @4ñF ˆEƒl€Ø€ØÐ Ý -ó_:óH67òrò(-ò:ò&òR	7óð> '(¨D¸ÀbÐSWó g-ðT *.°bó +ð\ !#ó "6ôJrI   