§
    OŠtjÔÉ  ã                   ó”  — d Z ddlmZ ddlmZmZmZ ddlmZ ddl	m
Z
 ddlmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZmZmZ ddlmZ ddlm Z  ddl!m"Z"m#Z#m$Z$ ddl%m&Z& ddl'm(Z(m)Z)m*Z* ddl+m,Z,m-Z- ddl.m/Z/ ddl0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 dBd„Z:d„ Z;dCd„Z<d„ Z=d„ Z>d „ Z?d!„ Z@d"„ ZAd#„ ZBd$„ ZCd%„ ZDd&„ ZEd'„ ZFd(„ ZGd)„ ZHd*„ ZId+„ ZJd,„ ZKd-„ ZLd.„ ZMdCd/„ZNd0„ ZO	 	 dDd3„ZP G d4„ d5e¦  «        ZQ G d6„ d7e7¦  «        ZR G d8„ d9eR¦  «        ZS G d:„ d;eS¦  «        ZT G d<„ d=eS¦  «        ZU G d>„ d?eS¦  «        ZVdEdA„ZWd@S )FzFormal Power Seriesé    )Údefaultdict)ÚnanÚooÚzoo)ÚAdd)ÚExpr)Ú
DerivativeÚFunctionÚexpand)ÚMul)ÚRational)ÚEq)ÚInterval)ÚS)ÚWildÚDummyÚsymbolsÚSymbol)Úsympify)Úconvolution)ÚbinomialÚ	factorialÚrf)Úbell)ÚfloorÚfracÚceiling)ÚMinÚMax)Ú	Piecewise)ÚLimit)ÚOrder)Úsequence)Ú
SeriesBase)Úiterableé   Fc                 óž  — ddl m}m} ddlm} | }g }	t          |dz   ¦  «        D �]¦}
|
r|                     |¦  «        }|                     |¦  «        �rat          j	        t          j	        }} ||||¬¦  «        }| 
                    |¦  «        r|                     ¦   «         }t          j        |¦  «        D �]}|                     ¦   «         \  }}| 
                    |¦  «        s||z  }Œ5t          |t           ¦  «        r(|                     |¦  «        }|d         }||d         z  }|                     ¦   «         \  }}|                     |¦  «        \  }}|s||z  }Œ©|d                              |¦  «        }|| z  }|||z  z  }d|z  |z  t+          ||z   dz
  |¦  «                             t.          ¦  «        z  |||z   z  z  }||z  }�Œ|j        r dS | 
                    |¦  «        sN| 
                    t2          ¦  «        s4| 
                    t4          ¦  «        s| 
                    t6          ¦  «        r dS t          |
¦  «        D ]G}|||z   dz   z  } |||¦  «        }||	                     ¦   «         |z
                       |d¦  «        z  }ŒH|                     |||
z
  ¦  «        ||
fc S |	                     |¦  «         �Œ¨dS )a  
    Rational algorithm for computing
    formula of coefficients of Formal Power Series
    of a function.

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

    Applicable when f(x) or some derivative of f(x)
    is a rational function in x.

    :func:`rational_algorithm` uses :func:`~.apart` function for partial fraction
    decomposition. :func:`~.apart` by default uses 'undetermined coefficients
    method'. By setting ``full=True``, 'Bronstein's algorithm' can be used
    instead.

    Looks for derivative of a function up to 4'th order (by default).
    This can be overridden using order option.

    Parameters
    ==========

    x : Symbol
    order : int, optional
        Order of the derivative of ``f``, Default is 4.
    full : bool

    Returns
    =======

    formula : Expr
    ind : Expr
        Independent terms.
    order : int
    full : bool

    Examples
    ========

    >>> from sympy import log, atan
    >>> from sympy.series.formal import rational_algorithm as ra
    >>> from sympy.abc import x, k

    >>> ra(1 / (1 - x), x, k)
    (1, 0, 0)
    >>> ra(log(1 + x), x, k)
    (-1/((-1)**k*k), 0, 1)

    >>> ra(atan(x), x, k, full=True)
    ((-I/(2*(-I)**k) + I/(2*I**k))/k, 0, 1)

    Notes
    =====

    By setting ``full=True``, range of admissible functions to be solved using
    ``rational_algorithm`` can be increased. This option should be used
    carefully as it can significantly slow down the computation as ``doit`` is
    performed on the :class:`~.RootSum` object returned by the :func:`~.apart`
    function. Use ``full=False`` whenever possible.

    See Also
    ========

    sympy.polys.partfrac.apart

    References
    ==========

    .. [1] Formal Power Series - Dominik Gruntz, Wolfram Koepf
    .. [2] Power Series in Computer Algebra - Wolfram Koepf

    r   )ÚRootSumÚapart©Ú	integrateé   )ÚfulléÿÿÿÿN) Úsympy.polysr(   r)   Úsympy.integralsr+   ÚrangeÚdiffÚis_rational_functionr   ÚZeroÚhasÚdoitr   Ú	make_argsÚas_numer_denomÚ
isinstancer   Úas_independentÚas_base_expÚas_coeff_addÚcoeffr   Úrewriter   Úis_zeror   r   r   ÚpopÚlimitÚsubsÚappend)ÚfÚxÚkÚorderr-   r(   r)   r+   r2   ÚdsÚir=   ÚsepÚtermsÚtÚnumÚdenÚindÚjÚaÚxtermÚxcÚaks                          úQ/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/series/formal.pyÚrational_algorithmrV      s
  € ðR +Ð*Ð*Ð*Ð*Ð*Ð*Ð*Ø)Ð)Ð)Ð)Ð)Ð)à€DØ	€Bå�5˜1‘9ÑÔð 6ñ 6ˆØð 	 Ø—9’9˜Q‘<”<ˆDà×$Ò$ QÑ'Ô'ñ 2	Ýœ¥¤�3ˆEà�E˜$ ¨Ð-Ñ-Ô-ˆEØ�yŠy˜Ñ!Ô!ð %ØŸ
š
™œ�å”] 5Ñ)Ô)ð  ñ  �Ø×+Ò+Ñ-Ô-‘��SØ—w’w˜q‘z”zð  Ø˜1‘H�C�Cå! #¥sÑ+Ô+ð &à!×0Ò0°Ñ3Ô3˜Ø! !œf˜Ø˜s 1œv™˜ð !Ÿ_š_Ñ.Ô.‘F�C˜Ø"×/Ò/°Ñ2Ô2‘H�A�uð ð !Ø˜q™˜Ø à˜qœŸš¨Ñ*Ô*�BØ˜"˜‘H�AØ˜2˜q™5‘L�Cà ™' C™-Ý" 1 q¡5¨1¡9¨aÑ0Ô0×8Ò8½ÑCÔCñDà˜a !™e™*ñ%�Bð ˜R‘K�E‘Eð Œ}ð Ø�t�tØ—	’	˜!‘”ð  §	¢	­#¡¤ð °%·)²)½B±-´-ð Ø—I’I�c‘N”Nðà�t�tå˜1‘X”Xð 4ð 4�Ø ! a¡%¨!¡)Ñ,�Ø�i  QÑ'Ô'�Ø˜Ÿš™œ 3™×-Ò-¨a°Ñ3Ô3Ñ3��Ø—J’J˜q ! a¡%Ñ(Ô(¨#¨qÐ1Ð1Ð1Ð1ð �IŠI�d‰OŒOˆO‰Oàˆ4ó    c                 óx  — | sg S | dd…         }| dd…         D ] }|                      |¦  «        d         }t          |¦  «        D ]^\  }}|                      |¦  «        d         }||z                       ¦   «         }|                     |¦  «        r||xx         |z  cc<    nŒ_|                     |¦  «         Œ¡|S )aŠ  
    Returns a list of all the rationally independent terms.

    Examples
    ========

    >>> from sympy import sin, cos
    >>> from sympy.series.formal import rational_independent
    >>> from sympy.abc import x

    >>> rational_independent([cos(x), sin(x)], x)
    [cos(x), sin(x)]
    >>> rational_independent([x**2, sin(x), x*sin(x), x**3], x)
    [x**3 + x**2, x*sin(x) + sin(x)]
    r   r,   N)r:   Ú	enumerateÚcancelr3   rC   )	rK   rE   rO   rL   ÚnrI   ÚtermÚdÚqs	            rU   Úrational_independentr_   ¨   sÝ   € ð  ð Øˆ	à
��!�Œ*€Cà�1�2�2ŒYð 	ð 	ˆØ×Ò˜QÑÔ Ô"ˆÝ  ‘~”~ð 	ð 	‰GˆAˆtØ×#Ò# AÑ&Ô& qÔ)ˆAØ�Q‘—’Ñ Ô ˆAØ×%Ò% aÑ(Ô(ð Ø�A��”˜!‘��‘Ø�ðð �JŠJ�q‰MŒMˆMøØ€JrW   c              #   óâ  ‡ ‡‡‡K  — ddl m} t          d|z  ¦  «        Šˆˆ ˆˆfd„}d}t          d|dz   ¦  «        D �]1} ||¦  «        \  }}	|                     ¦   «         }|                     ¦   «         }
t          |
‰¦  «        }|st          |¦  «        |k    rÓt          t          ‰d„  ||‰d|…         ¦  «        D ¦   «         ¦  «        ¦  «        }|rd	}|	 
                    |¦  «        }	|	                     ¦   «         d         }	|	                     ¦   «                              t          ¦  «        d         d         }	|	                     t           ‰‰¦  «        ¦  «        ¦  «        |fV — �Œ3dS )
a„  
    Generates simple DE.

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

    DE is of the form

    .. math::
        f^k(x) + \sum\limits_{j=0}^{k-1} A_j f^j(x) = 0

    where :math:`A_j` should be rational function in x.

    Generates DE's upto order 4 (default). DE's can also have free parameters.

    By increasing order, higher order DE's can be found.

    Yields a tuple of (DE, order).
    r   ©Úlinsolveza:%dc                 ó  •— ‰                      ‰| ¦  «        t          ˆˆˆfd„t          d| ¦  «        D ¦   «         Ž z   } ‰‰¦  «                              ‰| ¦  «        t          ˆˆˆfd„t          d| ¦  «        D ¦   «         Ž z   }||fS )Nc                 óN   •— g | ]!}‰|         ‰                      ‰|¦  «        z  ‘Œ"S © ©r2   )Ú.0rI   rQ   rD   rE   s     €€€rU   ú
<listcomp>z-simpleDE.<locals>._makeDE.<locals>.<listcomp>ã   s.   ø€ Ð!IÐ!IÐ!I¸ ! A¤$ q§v¢v¨a°¡|¤|Ñ"3Ð!IÐ!IÐ!IrW   r   c                 ó`   •— g | ]*}‰|          ‰‰¦  «                              ‰|¦  «        z  ‘Œ+S re   rf   )rg   rI   rQ   ÚgrE   s     €€€rU   rh   z-simpleDE.<locals>._makeDE.<locals>.<listcomp>ä   s6   ø€ Ð$OÐ$OÐ$O¸a Q q¤T¨!¨!¨A©$¬$¯)ª)°A°q©/¬/Ñ%9Ð$OÐ$OÐ$OrW   )r2   r   r1   )rF   ÚeqÚDErQ   rD   rj   rE   s      €€€€rU   Ú_makeDEzsimpleDE.<locals>._makeDEâ   s�   ø€ Ø�VŠV�A�q‰\Œ\�CÐ!IÐ!IÐ!IÐ!IÐ!IÐ!I½UÀ1Àa¹[¼[Ð!IÑ!IÔ!IÐJÑJˆØˆQˆq‰TŒT�YŠY�q˜!‰_Œ_�sÐ$OÐ$OÐ$OÐ$OÐ$OÐ$OÅ5ÈÈAÁ;Ä;Ð$OÑ$OÔ$OÐPÑPˆØ�2ˆvˆrW   Fr,   c              3   ó$   K  — | ]}|D ]}|V — ŒŒd S ©Nre   ©rg   ÚsrI   s      rU   ú	<genexpr>zsimpleDE.<locals>.<genexpr>î   s/   è è € ÐJÐJ QÈÐJÐJÀ1˜qÐJÐJÐJÐJÐJÐJÐJrW   NT)Úsympy.solvers.solvesetrb   r   r1   r   Úas_ordered_termsr_   ÚlenÚdictÚziprB   r8   ÚfactorÚas_coeff_mulr	   Úcollect)rD   rE   rj   rG   rb   rm   ÚfoundrF   rk   rl   rK   rO   ÚsolrQ   s   ```          @rU   ÚsimpleDEr}   Ê   s™  øøøøè è € ð( 0Ð/Ð/Ð/Ð/Ð/å�˜%Ñ Ñ!Ô!€Aðð ð ð ð ð ð ð ð
 €EÝ�1�e˜a‘iÑ Ô ð 2ñ 2ˆØ�˜‘”‰ˆˆBØ�YŠY‰[Œ[ˆØ×#Ò#Ñ%Ô%ˆÝ" 5¨!Ñ,Ô,ˆØð 	2•C˜‘H”H ’M�MÝ•s˜1ÐJÐJ¨(¨(°3¸¸"¸1¸"¼Ñ*>Ô*>ÐJÑJÔJÑKÔKÑLÔLˆCØð "Ø�Ø—W’W˜S‘\”\�Ø×"Ò"Ñ$Ô$ QÔ'ˆBØ—’‘”×)Ò)­*Ñ5Ô5°aÔ8¸Ô;ˆBØ—*’*�Z¨¨¨!©¬Ñ-Ô-Ñ.Ô.°Ð1Ð1Ð1Ð1ùð2ð 2rW   c                 óˆ  — t           j        }|                      t          ¦  «                             ¦   «         }d}t          j        | ¦  «        D ]W}|                     |¦  «        \  }}t          |t          ¦  «        r|j
        }	nd}	|�|	|k     r|	}|| |||	z   ¦  «        z  z  }ŒX|r|                     |||z
  ¦  «        }|S )a›  Converts a DE with constant coefficients (explike) into a RE.

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

    Performs the substitution:

    .. math::
        f^j(x) \to r(k + j)

    Normalises the terms so that lowest order of a term is always r(k).

    Examples
    ========

    >>> from sympy import Function, Derivative
    >>> from sympy.series.formal import exp_re
    >>> from sympy.abc import x, k
    >>> f, r = Function('f'), Function('r')

    >>> exp_re(-f(x) + Derivative(f(x)), r, k)
    -r(k) + r(k + 1)
    >>> exp_re(Derivative(f(x), x) + Derivative(f(x), (x, 2)), r, k)
    r(k) + r(k + 1)

    See Also
    ========

    sympy.series.formal.hyper_re
    Nr   )r   r4   Úatomsr
   r@   r   r7   r:   r9   r	   Úderivative_countrB   )
rl   ÚrrF   ÚRErj   ÚminirL   r=   r]   rP   s
             rU   Úexp_rer„   ÷   sÑ   € õ> 
Œ€Bà
�Š•ÑÔ×ÒÑ Ô €Aà€DÝŒ]˜2ÑÔð ð ˆØ×#Ò# AÑ&Ô&‰ˆˆqÝ�a�Ñ$Ô$ð 	ØÔ"ˆAˆAàˆAØˆ<˜1˜tš8˜8ØˆDØ
ˆe�a�a˜˜A™‘h”hÑÑˆˆØð "Ø�WŠW�Q˜˜D™Ñ!Ô!ˆØ€IrW   c                 ó  — t           j        }|                      t          ¦  «                             ¦   «         }|                     t
          ¦  «                             ¦   «         }d}t          j        |                      ¦   «         ¦  «        D ]ª}| 	                    |¦  «        \  }}	| 	                    |¦  «        \  }
}| 
                    |¦  «        d         }t          |	t          ¦  «        r|	j        }nd}||
t          |dz   |z
  |¦  «        z   |||z   |z
  ¦  «        z  z  }|�	||z
  |k     r||z
  }Œ«|                     |||z
  ¦  «        }t!          d¦  «        }|                      |||z   ¦  «        ¦  «        S )a£  
    Converts a DE into a RE.

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

    Performs the substitution:

    .. math::
        x^l f^j(x) \to (k + 1 - l)_j . a_{k + j - l}

    Normalises the terms so that lowest order of a term is always r(k).

    Examples
    ========

    >>> from sympy import Function, Derivative
    >>> from sympy.series.formal import hyper_re
    >>> from sympy.abc import x, k
    >>> f, r = Function('f'), Function('r')

    >>> hyper_re(-f(x) + Derivative(f(x)), r, k)
    (k + 1)*r(k + 1) - r(k)
    >>> hyper_re(-x*f(x) + Derivative(f(x), (x, 2)), r, k)
    (k + 2)*(k + 3)*r(k + 3) - r(k)

    See Also
    ========

    sympy.series.formal.exp_re
    Nr,   r   Úm)r   r4   r   r
   r@   r   r   r7   r   r:   Úas_coeff_exponentr9   r	   r€   r   rB   r   rz   )rl   r�   rF   r‚   rj   rE   rƒ   rL   r=   r]   ÚcÚvÚlrP   r†   s                  rU   Úhyper_rer‹   )  sb  € õ@ 
Œ€Bà
�Š•ÑÔ×ÒÑ Ô €AØ	�Š•‰Œ×ÒÑÔ€Aà€DÝŒ]˜2Ÿ9š9™;œ;Ñ'Ô'ð 
ð 
ˆØ×#Ò# AÑ&Ô&‰ˆˆqØ×#Ò# AÑ&Ô&‰ˆˆ1Ø×Ò Ñ"Ô" 1Ô%ˆÝ�a�Ñ$Ô$ð 	ØÔ"ˆAˆAàˆAØ
ˆa•"�Q˜‘U˜Q‘Y Ñ"Ô"Ñ" Q Q q¨1¡u¨q¡y¡\¤\Ñ1Ñ1ˆØˆ<˜1˜q™5 4š<˜<Ø�q‘5ˆDøà	�Š��A˜‘HÑ	Ô	€BåˆS‰	Œ	€AØ�:Š:�a�a˜˜A™‘h”hÑÔÐrW   c                 ó„   — | || z  z  } |                      |||z   ¦  «        }|                      |||z   ¦  «        }| |||fS ro   ©rB   )rD   rE   ÚPÚQrF   r†   Úshifts          rU   Ú_transformation_ar‘   a  sN   € ØˆˆeˆV‰Ñ€AØ	�Šˆq�!�e‘)ÑÔ€AØ	�Šˆq�!�e‘)ÑÔ€AØˆa��Aˆ:ÐrW   c                 ó®   — |                       |||z  ¦  «        } |                      |||z  ¦  «        }|                      |||z  ¦  «        }||z  }| |||fS ro   r�   )rD   rE   rŽ   r�   rF   r†   Úscales          rU   Ú_transformation_cr”   h  s^   € Ø	�Šˆq�!�U‘(ÑÔ€AØ	�Šˆq�!�e‘)ÑÔ€AØ	�Šˆq�!�e‘)ÑÔ€AØˆ�J€AØˆa��Aˆ:ÐrW   c                 óº   — |                       |¦  «        } |                     ||dz   ¦  «        ||z   dz   z  }|                     ||dz   ¦  «        |dz   z  }| |||fS ©Nr,   )r2   rB   )rD   rE   rŽ   r�   rF   r†   s         rU   Ú_transformation_er—   p  sc   € Ø	�Šˆq‰	Œ	€AØ	�Šˆq�!�a‘%ÑÔ˜A ™E A™IÑ&€AØ	�Šˆq�!�a‘%ÑÔ˜A ™EÑ"€AØˆa��Aˆ:ÐrW   c                 ó    ‡— ˆfd„| D ¦   «         S )Nc                 ó$   •— g | ]\  }}||‰z   f‘ŒS re   re   )rg   ÚresÚcondr�   s      €rU   rh   z _apply_shift.<locals>.<listcomp>x  ó&   ø€ Ð5Ð5Ð5¡I C¨ˆS�$˜‘,ÐÐ5Ð5Ð5rW   re   )r|   r�   s    `rU   Ú_apply_shiftr�   w  ó   ø€ Ø5Ð5Ð5Ð5°Ð5Ñ5Ô5Ð5rW   c                 ó    ‡— ˆfd„| D ¦   «         S )Nc                 ó$   •— g | ]\  }}||‰z  f‘ŒS re   re   )rg   rš   r›   r“   s      €rU   rh   z _apply_scale.<locals>.<listcomp>|  rœ   rW   re   )r|   r“   s    `rU   Ú_apply_scaler¡   {  rž   rW   c                 ó    ‡— ˆfd„| D ¦   «         S )Nc                 óŒ   •— g | ]@\  }}||d z   |                      ¦   «         d                               ‰¦  «        z  z  |d z   f‘ŒAS ©r,   )Úas_coeff_Addr=   )rg   rš   r›   rF   s      €rU   rh   z$_apply_integrate.<locals>.<listcomp>€  sc   ø€ ð "ð "ð "Ù��Tð �T˜A‘X × 1Ò 1Ñ 3Ô 3°AÔ 6× <Ò <¸QÑ ?Ô ?Ñ@ÑAÀ4È!Á8ÐLð "ð "ð "rW   re   )r|   rE   rF   s     `rU   Ú_apply_integrater¦     s.   ø€ ð"ð "ð "ð "Ø ð"ñ "ô "ð "rW   c           	      ó8  ‡— ddl m} g }t          |dz   ||z   dz   ¦  «        D �]u}	|	dk     dk    rŒ|                      ||	¦  «                             |d¦  «        t          |	¦  «        z  }
|
j        rŒP|‰z  |	z   }|
}|                     ‰|¦  «        }|                     ‰|¦  «        }|                     ‰d‰z  ¦  «                             ‰¦  «        d         }|                     ‰d‰z  ¦  «                             ‰¦  «        d         }|| |z  ‰z  z  }|t          ˆfd„ ||‰¦  «         
                    ¦   «         D ¦   «         Ž z  }|t          ˆfd„ ||‰¦  «         
                    ¦   «         D ¦   «         Ž z  }|                     ||f¦  «         �Œw|S )zComputes the formula for f.r   )Úrootsr,   Tc                 ó>   •— g | ]\  }}t          | ‰¦  «        |z  ‘ŒS re   ©r   ©rg   r�   ÚmulrF   s      €rU   rh   z$_compute_formula.<locals>.<listcomp>™  ó+   ø€ ÐFÐFÐF©¨¨3•R˜˜˜A‘Y”Y ‘^ÐFÐFÐFrW   c                 ó>   •— g | ]\  }}t          | ‰¦  «        |z  ‘ŒS re   rª   r«   s      €rU   rh   z$_compute_formula.<locals>.<listcomp>š  r­   rW   )r/   r¨   r1   r2   rA   r   r?   rB   Úleadtermr   ÚitemsrC   )rD   rE   rŽ   r�   rF   r†   Úk_maxr¨   r|   rI   r�   Úktermrš   Úpr^   Úc1Úc2s       `            rU   Ú_compute_formular¶   „  s¶  ø€ à!Ð!Ð!Ð!Ð!Ð!à
€CÝ�5˜1‘9˜e a™i¨!™mÑ,Ô,ð !ñ !ˆØ�ŠE�dŠ?ˆ?ØØ�FŠF�1�a‰LŒL×Ò˜q !Ñ$Ô$¥y°¡|¤|Ñ3ˆØŒ9ð 	Øà�!‘�a‘ˆØˆà�FŠF�1�eÑÔˆØ�FŠF�1�eÑÔˆØ�VŠV�A�q˜‘s‰^Œ^×$Ò$ QÑ'Ô'¨Ô*ˆØ�VŠV�A�q˜‘s‰^Œ^×$Ò$ QÑ'Ô'¨Ô*ˆØ���b‘˜1‰}Ñˆà�sÐFÐFÐFÐF°%°%¸¸1±+´+×2CÒ2CÑ2EÔ2EÐFÑFÔFÐGÑGˆØ�sÐFÐFÐFÐF°%°%¸¸1±+´+×2CÒ2CÑ2EÔ2EÐFÑFÔFÐGÑGˆà�
Š
�C˜�<Ñ Ô Ð Ñ à€JrW   c           
      óÂ  — ddl m}m} ddlm}  |||¦  «         |||¦  «        }
}	t          |	¦  «        }|                     |
¦  «          |d„ |                     ¦   «         D ¦   «         ¦  «        }t          | ||||||¦  «        \  } }}} |||¦  «        }
|
rt          |
 
                    ¦   «         Ž }nt          j        }||z   }t          | ||||||¦  «        \  } }}}|| z                       |d¦  «        }t          |t           ¦  «        s|dk    rdS  |||¦  «        }
|
rt#          |
 
                    ¦   «         Ž }nt          j        }t          j        t$           }}t'          ||z   dz   ¦  «        D �]}|                      ||¦  «                             |d¦  «        t+          |¦  «        z  }|j        du r¢| }t          | ||||||¦  «        \  } }}}t/          | |||||¦  «        \  } }}}t1          | |||||¦  «        \  }}}t3          |||¦  «        }t5          ||¦  «        } |||¦  «        }|||z
                       |d¦  «        z  }|dz  }|||fc S |r)|||||z   z  z  z  }t7          ||z   |¦  «        }||k    r|}�Œ|                     ||d|z  z  ¦  «        }t;          | ||||||¦  «        }t5          ||¦  «        }t=          ||¦  «        }|||fS )a  
    Recursive wrapper to rsolve_hypergeometric.

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

    Returns a Tuple of (formula, series independent terms,
    maximum power of x in independent terms) if successful
    otherwise ``None``.

    See :func:`rsolve_hypergeometric` for details.
    r   )Úlcmr¨   r*   c                 óV   — g | ]&\  }}|j         ¯|                     ¦   «         d          ‘Œ'S r¤   )Úis_rationalr8   )rg   r�   rL   s      rU   rh   z*_rsolve_hypergeometric.<locals>.<listcomp>µ  sC   € ð #ð #ð #©4¨1¨aØ”Mð#�×!Ò!Ñ#Ô# AÔ&ð #ð #ð #rW   Nr,   F)r/   r¸   r¨   r0   r+   rv   Úupdater°   r”   r   Úkeysr   r4   r‘   rA   r9   r!   r   r   r1   r2   r   Ú	is_finiter—   Ú_rsolve_hypergeometricr¦   r�   r   rB   r¶   r¡   )rD   rE   rŽ   r�   rF   r†   r¸   r¨   r+   ÚprootsÚqrootsÚ	all_rootsr“   Úk_minr�   rŠ   r±   rO   ÚmprI   r�   Úold_fr|   Úpow_xs                           rU   r¾   r¾   ¡  sY  € ð 'Ð&Ð&Ð&Ð&Ð&Ð&Ð&Ø)Ð)Ð)Ð)Ð)Ð)ð �U˜1˜a‘[”[ % %¨¨1¡+¤+ˆF€FÝ�V‘”€IØ×Ò�VÑÔÐØˆCð #ð #°9·?²?Ñ3DÔ3Dð #ñ #ô #ñ $ô $€Eå" 1 a¨¨A¨q°!°UÑ;Ô;�J€A€qˆ!ˆQð ˆU�1�a‰[Œ[€FØð Ý�V—[’[‘]”]Ð#ˆˆå”ˆØ�A‰I€EÝ" 1 a¨¨A¨q°!°UÑ;Ô;�J€A€qˆ!ˆQà	
ˆ1‰�Š�A�qÑÔ€AÝ�a�ÑÔð  A¨¢F FØˆtàˆU�1�a‰[Œ[€FØð Ý�V—[’[‘]”]Ð#ˆˆå”ˆåŒf•r�cˆ€CÝ�5˜1‘9˜q‘=Ñ!Ô!ð ñ ˆØ�FŠF�1�a‰LŒL×Ò˜q !Ñ$Ô$¥y°¡|¤|Ñ3ˆØŒ;˜%ÐÐØˆEÝ*¨1¨a°°A°q¸!¸QÑ?Ô?‰JˆAˆq�!�QÝ*¨1¨a°°A°q¸!Ñ<Ô<‰JˆAˆq�!�QÝ1°!°Q¸¸1¸aÀÑCÔC‰LˆC��bÝ" 3¨¨1Ñ-Ô-ˆCÝ˜s AÑ&Ô&ˆCØ�)˜C Ñ#Ô#ˆCØ�E˜C‘K×&Ò& q¨!Ñ,Ô,Ñ,ˆCØ�!‰GˆBØ˜˜R�<ÐÐÐØð 	Ø�1�Q˜˜U™‘^Ñ#Ñ#ˆCÝ˜a %™i¨%Ñ0Ô0ˆEØ�rŠzˆzØ�ùØ
�(Š(�1�a˜!˜E™'‘lÑ
#Ô
#€Cå
˜1˜a  A q¨!¨UÑ
3Ô
3€CÝ
�s˜EÑ
"Ô
"€CÝ
�s˜EÑ
"Ô
"€Cà��Rˆ<ÐrW   c           	      ó  — t          | |||||¦  «        }|€dS |\  }}}	t          d„ ¦  «        }
|D ] \  }}|                     ¦   «         \  }}|                     |¦  «        }|j        du r$||t          |¦  «        z  z  }t          |¦  «        }|                     |||z
  |z  ¦  «        }t          ||z  ||z  ¦  «        }|
|xx         |z  cc<   Œ¡d„ |
 	                    ¦   «         D ¦   «         }| 
                    t          j        df¦  «         t          |Ž }|	t           u rt          j        }n|	j        du rt          |	¦  «        }n|	dz   }|dk     r5|t!          t#          |||z  z  ||df¦  «        ¦  «        z  }t          j        }|||fS )	aÈ  
    Solves RE of hypergeometric type.

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

    Attempts to solve RE of the form

    Q(k)*a(k + m) - P(k)*a(k)

    Transformations that preserve Hypergeometric type:

        a. x**n*f(x): b(k + m) = R(k - n)*b(k)
        b. f(A*x): b(k + m) = A**m*R(k)*b(k)
        c. f(x**n): b(k + n*m) = R(k/n)*b(k)
        d. f(x**(1/m)): b(k + 1) = R(k*m)*b(k)
        e. f'(x): b(k + m) = ((k + m + 1)/(k + 1))*R(k + 1)*b(k)

    Some of these transformations have been used to solve the RE.

    Returns
    =======

    formula : Expr
    ind : Expr
        Independent terms.
    order : int

    Examples
    ========

    >>> from sympy import exp, ln, S
    >>> from sympy.series.formal import rsolve_hypergeometric as rh
    >>> from sympy.abc import x, k

    >>> rh(exp(x), x, -S.One, (k + 1), k, 1)
    (Piecewise((1/factorial(k), Eq(Mod(k, 1), 0)), (0, True)), 1, 1)

    >>> rh(ln(1 + x), x, k**2, k*(k + 1), k, 1)
    (Piecewise(((-1)**(k - 1)*factorial(k - 1)/RisingFactorial(2, k - 1),
     Eq(Mod(k, 1), 0)), (0, True)), x, 2)

    References
    ==========

    .. [1] Formal Power Series - Dominik Gruntz, Wolfram Koepf
    .. [2] Power Series in Computer Algebra - Wolfram Koepf
    Nc                  ó   — t           j        S ro   ©r   r4   re   rW   rU   ú<lambda>z'rsolve_hypergeometric.<locals>.<lambda>   s   € ¥1¤6€ rW   Fc                 ó   — g | ]	\  }}||f‘Œ
S re   re   )rg   r›   rš   s      rU   rh   z)rsolve_hypergeometric.<locals>.<listcomp>-  s    € Ð
9Ð
9Ð
9™9˜4 ˆC�ˆ;Ð
9Ð
9Ð
9rW   Tr,   r   r.   )r¾   r   r¥   r=   Ú
is_integerr   r   rB   r   r°   rC   r   r4   r    r   r   Úsumr#   )rD   rE   rŽ   r�   rF   r†   ÚresultÚsol_listrO   rÃ   Úsol_dictrš   r›   rP   Úmkrˆ   r|   rq   s                     rU   Úrsolve_hypergeometricrÑ   è  s«  € õb $ A q¨!¨Q°°1Ñ5Ô5€Fà€~ØˆtàÑ€Hˆc�2å˜>˜>Ñ*Ô*€HØð 
ð 
‰	ˆˆTØ×!Ò!Ñ#Ô#‰ˆˆ2Ø�HŠH�Q‰KŒKˆàŒ<˜5Ð Ð Ø�1•d˜1‘g”g‘:ÑˆCÝ�a‘”ˆAà�hŠh�q˜1˜q™5 A™+Ñ&Ô&ˆÝ�!�a‘%˜˜Q™ÑÔˆØ�ˆˆŒ˜#Ñˆˆ‰ˆà
9Ð
9¨¯ªÑ(8Ô(8Ð
9Ñ
9Ô
9€CØ‡J‚J•”˜ˆ~ÑÔÐÝ
�Sˆ/€Cà	�bˆS€y€yÝŒFˆˆØ	Œ˜%Ð	Ð	Ý�B‰KŒKˆˆà�‰Fˆð 	ˆ1‚u€uØ�s•8˜C ! Q¡$™J¨¨A¨r¨
Ñ3Ô3Ñ4Ô4Ñ4ˆÝŒFˆà��aˆ=ÐrW   c                 óz  — t          j        |¦  «        }t          |¦  «        dk    r“t          |                     t
          ¦  «        ¦  «        }t          |j        |¦  «        \  }}|d         j        d         |d         j        d         z
  }	|	dk     r||}}t          |	¦  «        }	t          | |||||	¦  «        S dS )z;See docstring of :func:`rsolve_hypergeometric` for details.é   r,   r   N)r   r7   ru   Úlistr   r
   Úmapr=   ÚargsÚabsrÑ   )
rD   rE   r‚   rj   rF   rK   ÚgsrŽ   r�   r†   s
             rU   Ú_solve_hyper_RErÙ   A  s¨   € åŒM˜"ÑÔ€Eå
ˆ5�z„z�Q‚€Ý�"—(’(�8Ñ$Ô$Ñ%Ô%ˆÝ�2”8˜RÑ Ô ‰ˆˆ1ØˆqŒEŒJ�qŒM˜B˜qœEœJ qœMÑ)ˆØˆqŠ5ˆ5Ø�aˆqˆAÝ�A‘”ˆAÝ$ Q¨¨1¨a°°AÑ6Ô6Ð6ð €rW   c                 ó(  — ddl m} t          j        |¦  «        D ]$}|                     |¦  «        \  }}|j        r dS Œ%t          |||¦  «        }	i }
t          t          t          j        |	¦  «        ¦  «        ¦  «        D ]O}|r|  	                    |¦  «        } |  
                    |d¦  «        |
 ||¦  «                             ||¦  «        <   ŒP ||	 ||¦  «        |
¦  «        }|r)|t          |¦  «        z  t          j        t          j        fS dS )z%Solves DE with constant coefficients.r   ©ÚrsolveN)Úsympy.solversrÜ   r   r7   r:   Úfree_symbolsr„   r1   ru   r2   rA   rB   r   r   r4   )rD   rE   rl   rj   rF   rÜ   rL   r=   r]   r‚   ÚinitrI   r|   s                rU   Ú_solve_explike_DErà   O  s)  € à$Ð$Ð$Ð$Ð$Ð$åŒ]˜2ÑÔð ð ˆØ×#Ò# AÑ&Ô&‰ˆˆqØÔð 	ØˆFˆFð	õ 
��A�qÑ	Ô	€Bà€DÝ•3•s”} RÑ(Ô(Ñ)Ô)Ñ*Ô*ð .ð .ˆØð 	Ø—’�q‘	”	ˆAØ !§¢¨¨1¡¤ˆˆQˆQˆq‰TŒT�YŠY�q˜!‰_Œ_ÑÐà
ˆ&��Q�Q�q‘T”T˜4Ñ
 Ô
 €Cà
ð 4Ø•i ‘l”lÑ"¥A¤F­A¬FÐ3Ð3ð4ð 4rW   c                 ó¶  — ddl m} t          |||¦  «        }i }t          t	          t          j        |¦  «        ¦  «        ¦  «        D ]_}|r|                      |¦  «        } |                      |d¦  «        t          |¦  «        z  | ||¦  «         
                    ||¦  «        <   Œ` || ||¦  «        |¦  «        }	|	r|	t          j        t          j        fS dS )z4Converts DE into RE and solves using :func:`rsolve`.r   rÛ   N)rÝ   rÜ   r‹   r1   ru   r   r7   r2   rA   r   rB   r   r4   )
rD   rE   rl   rj   rF   rÜ   r‚   rß   rI   r|   s
             rU   Ú_solve_simplerâ   f  sà   € à$Ð$Ð$Ð$Ð$Ð$å	�"�a˜Ñ	Ô	€Bà€DÝ•3•s”} RÑ(Ô(Ñ)Ô)Ñ*Ô*ð =ð =ˆØð 	Ø—’�q‘	”	ˆAØ !§¢¨¨1¡¤µ	¸!±´Ñ <ˆˆQˆQˆq‰TŒT�YŠY�q˜!‰_Œ_ÑÐà
ˆ&��Q�Q�q‘T”T˜4Ñ
 Ô
 €Cà
ð %Ø•Q”V�QœVÐ$Ð$ð%ð %rW   c                 ó¢  — ddl m} g }|                      t           ||¦  «        ||¦  «        ¦  «        }t	          |¦  «        D ]€}|                      t           ||¦  «        ||¦  «        ¦  «        }	|	|z                       ¦   «                              |¦  «        }	|                     t          j	        |	¦  «        ¦  «         Œ�g }
|D ]H}| 
                    |¦  «        r n2| 
                    t          ¦  «        r|
                     |¦  «         ŒI|
}|r¸t          t          |d„  ||t          |¦  «        ¦  «        D ¦   «         ¦  «        ¦  «        }|rx|                      |¦  «        } |                      ¦   «                              t          ¦  «        d         d         } |                      t           ||¦  «        ¦  «        ¦  «        } | S )zDConverts DE with free parameters into DE with constant coefficients.r   ra   c              3   ó$   K  — | ]}|D ]}|V — ŒŒd S ro   re   rp   s      rU   rr   z(_transform_explike_DE.<locals>.<genexpr>‹  s/   è è € ÐMÐM AÈ1ÐMÐMÀa˜aÐMÐMÐMÐMÐMÐMÐMrW   r,   )rs   rb   r=   r	   r1   r   rz   Úextendr   r7   r5   r   rC   rv   rw   rÔ   rB   rx   ry   )rl   rj   rE   rG   Úsymsrb   rk   Úhighest_coeffrI   r=   ÚtempÚer|   s                rU   Ú_transform_explike_DErê   x  s¯  € à/Ð/Ð/Ð/Ð/Ð/à	€BØ—H’H�Z¨¨¨!©¬¨a°Ñ7Ô7Ñ8Ô8€MÝ�5‰\Œ\ð (ð (ˆØ—’� A A a¡D¤D¨!¨QÑ/Ô/Ñ0Ô0ˆØ˜Ñ&×.Ò.Ñ0Ô0×8Ò8¸Ñ;Ô;ˆØ
�	Š	•#”- Ñ&Ô&Ñ'Ô'Ð'Ð'Ø€DØð ð ˆØ�5Š5�‰8Œ8ð 	ØˆEØ�UŠU•6‰]Œ]ð 	Ø�KŠK˜‰NŒNˆNøàˆØ	ð .Ý•3�tÐMÐM¨¨°"µd¸4±j´jÑ)AÔ)AÐMÑMÔMÑNÔNÑOÔOˆØð 	.Ø—’˜‘”ˆBØ—’‘”×)Ò)­*Ñ5Ô5°aÔ8¸Ô;ˆBØ—’�J q q¨¡t¤tÑ,Ô,Ñ-Ô-ˆBØ€IrW   c                 ó¶  ‡‡‡
— ddl m} t          | ‰‰¦  «        Š
ˆ
ˆˆfd„t          d|¦  «        D ¦   «         }t	          t          |d„  ||t          |¦  «        ¦  «        D ¦   «         ¦  «        ¦  «        }|ràt          d¦  «        }‰
                     |¦  «        Š
‰
 	                    ¦   «          
                    ¦   «         d                               ‰‰|z   ¦  «        ¦  «        Š
‰
                     ‰¦  «        d         d         Š
t          |¦  «        D ]@}	‰
                      ‰‰|	z   ¦  «        ¦  «        r|	r‰
                     ‰‰|	z
  ¦  «        Š
 nŒA‰
S )z@Converts DE with free parameters into RE of hypergeometric type.r   ra   c                 óR   •— g | ]#}‰                       ‰‰|z   ¦  «        ¦  «        ‘Œ$S re   )r=   )rg   rI   r‚   rj   rF   s     €€€rU   rh   z$_transform_DE_RE.<locals>.<listcomp>™  s1   ø€ Ð	6Ð	6Ð	6 ˆ"�(Š(�1�1�Q˜‘U‘8”8Ñ
Ô
Ð	6Ð	6Ð	6rW   r,   c              3   ó$   K  — | ]}|D ]}|V — ŒŒd S ro   re   rp   s      rU   rr   z#_transform_DE_RE.<locals>.<genexpr>š  s/   è è € ÐIÐI ÀqÐIÐIÀ!˜!ÐIÐIÐIÐIÐIÐIÐIrW   r†   )rs   rb   r‹   r1   rv   rw   rÔ   r   rB   rx   r8   rz   ry   r=   )rl   rj   rF   rG   ræ   rb   rk   r|   r†   rI   r‚   s    ``       @rU   Ú_transform_DE_RErî   “  sZ  øøø€ à/Ð/Ð/Ð/Ð/Ð/å	�"�a˜Ñ	Ô	€Bà	6Ð	6Ð	6Ð	6Ð	6Ð	6¥e¨A¨u¡o¤oÐ	6Ñ	6Ô	6€BÝ
�s�4ÐIÐI X X¨bµ$°t±*´*Ñ%=Ô%=ÐIÑIÔIÑJÔJÑ
KÔ
K€CØ
ð Ý�‰IŒIˆØ�WŠW�S‰\Œ\ˆØ�YŠY‰[Œ[×'Ò'Ñ)Ô)¨!Ô,×4Ò4°Q°Q°q¸1±u±X´XÑ>Ô>ˆØ�_Š_˜QÑÔ Ô" 1Ô%ˆÝ�u‘”ð 	ð 	ˆAØ�xŠx˜˜˜!˜a™%™œÑ!Ô!ð  að Ø—W’W˜Q  A¡Ñ&Ô&�Ø�øØ€IrW   c                 ó‚  — d}|j                              ||h¦  «        }|rt          |||||¦  «        }nt          |||¦  «        }|j                              |h¦  «        st	          | ||||¦  «        }|r|S |rt          |||||¦  «        }|j                              |h¦  «        st          | ||||¦  «        }|r|S dS )aA  
    Solves the DE.

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

    Tries to solve DE by either converting into a RE containing two terms or
    converting into a DE having constant coefficients.

    Returns
    =======

    formula : Expr
    ind : Expr
        Independent terms.
    order : int

    Examples
    ========

    >>> from sympy import Derivative as D, Function
    >>> from sympy import exp, ln
    >>> from sympy.series.formal import solve_de
    >>> from sympy.abc import x, k
    >>> f = Function('f')

    >>> solve_de(exp(x), x, D(f(x), x) - f(x), 1, f, k)
    (Piecewise((1/factorial(k), Eq(Mod(k, 1), 0)), (0, True)), 1, 1)

    >>> solve_de(ln(1 + x), x, (x + 1)*D(f(x), x, 2) + D(f(x)), 2, f, k)
    (Piecewise(((-1)**(k - 1)*factorial(k - 1)/RisingFactorial(2, k - 1),
     Eq(Mod(k, 1), 0)), (0, True)), x, 2)
    N)rÞ   Ú
differencerî   r‹   rÙ   rê   rà   )	rD   rE   rl   rG   rj   rF   r|   ræ   r‚   s	            rU   Úsolve_derñ   §  sò   € ðD €CØŒ?×%Ò% q¨! fÑ-Ô-€Dàð  Ý˜b ! Q¨¨tÑ4Ô4ˆˆå�b˜!˜QÑÔˆØŒ?×%Ò% q cÑ*Ô*ð .Ý˜a  B¨¨1Ñ-Ô-ˆà
ð Øˆ
àð :Ý" 2 q¨!¨U°DÑ9Ô9ˆØŒ?×%Ò% q cÑ*Ô*ð 0Ý  1 b¨!¨QÑ/Ô/ˆà
ð Øˆ
ðð rW   c           	      ó0  — t          d¦  «        }g }d}t          | |||¦  «        D ]Q\  }}|�t          | |||||¦  «        }|r|c S |j                             |h¦  «        s|                     |¦  «         ŒR|D ]}t          | ||||¦  «        }|r|c S ŒdS )aÄ  
    Hypergeometric algorithm for computing Formal Power Series.

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

    Steps:
        * Generates DE
        * Convert the DE into RE
        * Solves the RE

    Examples
    ========

    >>> from sympy import exp, ln
    >>> from sympy.series.formal import hyper_algorithm

    >>> from sympy.abc import x, k

    >>> hyper_algorithm(exp(x), x, k)
    (Piecewise((1/factorial(k), Eq(Mod(k, 1), 0)), (0, True)), 1, 1)

    >>> hyper_algorithm(ln(1 + x), x, k)
    (Piecewise(((-1)**(k - 1)*factorial(k - 1)/RisingFactorial(2, k - 1),
     Eq(Mod(k, 1), 0)), (0, True)), x, 2)

    See Also
    ========

    sympy.series.formal.simpleDE
    sympy.series.formal.solve_de
    rj   N)r
   r}   rñ   rÞ   rð   rC   râ   )	rD   rE   rF   rG   rj   Údesr|   rl   rI   s	            rU   Úhyper_algorithmrô   ß  sØ   € õB 	�‰Œ€Aà
€CØ
€CÝ˜!˜Q  5Ñ)Ô)ð ð ‰ˆˆAØˆ>Ý˜1˜a  Q¨¨1Ñ-Ô-ˆCØð 	ØˆJˆJˆJØŒ×)Ò)¨1¨#Ñ.Ô.ð 	Ø�JŠJ�r‰NŒNˆNøð ð ð ˆÝ˜A˜q " a¨Ñ+Ô+ˆØð 	ØˆJˆJˆJð	ðð rW   c                 óJ  — |t           j        t           j        fv rŸ|t           j        u rt           j        nt           j         }|                      |d|z  ¦  «        }t          ||d|||||¦  «        }	|	€dS |	d         |	d                              |d|z  ¦  «        |	d                              |d|z  ¦  «        fS |s|t           j         k    r¦|t           j         k    r| |z   }
| }|}n
||z   }
|}| }|                      ||
¦  «        }t          ||dt           j        ||||¦  «        }	|	€dS |	d         |	d                              |||z   ¦  «        |	d                              |||z   ¦  «        fS |                      |¦  «        rlt          d¦  «        }t          t          | ||¦  «        |dt          f¦  «        }t          ||z  |dt          f¦  «        }|                      |d¦  «        }|||fS t          | t          ¦  «        �rd}	t          t           j        dt          f¦  «        }t           j        d}}t          j        | ¦  «        D ]Ì}t          ||dt           j        ||||¦  «        }|r£|	s
d}	|d         }|d         j        |j        k    r|}|j        |d         j        } }n|d         }|d         j        |j        } }t          d„ t#          |d| |z
  …         ||| …         ¦  «        D ¦   «         Ž }||d         z  }||d         |z   z  }ŒÇ||z  }ŒÍ|	r|||fS dS | j                             |h¦  «        } t)          | ¦  «        j        |Ž \  } }d}	t          d¦  «        }|rt-          | ||||¦  «        }	|	€|rt/          | |||¦  «        }	|	€dS dd	lm} |j        rt           j        }n ||¦  «        }t          |	d         ||	d         t          f¦  «        } |||z  |z  ¦  «        }t          ||dt          f¦  «        } ||	d         |z  ¦  «        }|||fS )
zPRecursive wrapper to compute fps.

    See :func:`compute_fps` for details.
    r,   r   NrÓ   rF   FTc                 ó0   — g | ]}|d          |d         z  ‘ŒS ©r   r,   re   ©rg   Úzs     rU   rh   z _compute_fps.<locals>.<listcomp>K  s$   € ÐMÐMÐM¨1˜Q˜qœT ! A¤$™YÐMÐMÐMrW   )Úpowsimp)r   ÚInfinityÚNegativeInfinityÚOnerB   Ú_compute_fpsÚis_polynomialr   r#   ÚCoeffr   r=   r9   r   r4   r7   Ústartrw   rÞ   rð   r   r:   rV   rô   Úsympy.simplify.powsimprú   r?   )rD   rE   Úx0ÚdirÚhyperrG   Úrationalr-   rè   rÍ   ÚrepÚrep2Úrep2brF   rT   ÚxkrO   rL   rš   Úseqrq   Úsaveræ   Úsymbrú   Ú
xk_formulas                             rU   rþ   rþ     s_  € ð
 
�aŒj�!Ô,Ð-Ð-Ð-Ø�QœZÐ'Ð'�aŒeˆe­a¬e¨VˆØ�vŠv�a˜˜1™‰~Œ~ˆÝ˜d A q¨#¨u°e¸XÀtÑLÔLˆØˆ>Ø�4Ø�q”	˜6 !œ9Ÿ>š>¨!¨Q¨q©SÑ1Ô1°6¸!´9·>²>À!ÀQÀqÁSÑ3IÔ3IÐJÐJØ	ð 1ˆs•q”u�fŠ}ˆ}Ø•1”5�&Š=ˆ=Ø�"�r‘'ˆCØ�2ˆDØˆEˆEà�b‘&ˆCØˆDØ�CˆEØ�vŠv�a˜‰~Œ~ˆÝ˜d A q­!¬%°¸¸xÈÑNÔNˆØˆ>Ø�4Ø�q”	˜6 !œ9Ÿ>š>¨!¨T°E©\Ñ:Ô:Ø�q”	—’˜q $¨¡,Ñ/Ô/ð1ð 	1ð 	‡‚�qÑÔð Ý�#‰JŒJˆÝ•e˜A˜q !‘n”n q¨!­R jÑ1Ô1ˆÝ�a˜‘d˜Q ¥2˜JÑ'Ô'ˆØ�gŠg�a˜‰mŒmˆØ�2�sˆ{Ðõ �!•SÑÔñ ØˆÝ•a”f˜q¥"˜gÑ&Ô&ˆÝ”&˜$ˆRˆÝ”˜qÑ!Ô!ð 	ð 	ˆAÝ˜q ! Q­¬¨u°e¸XÀtÑLÔLˆCØð Øð  Ø!�FØ˜Qœ�BØ�q”6”< "¤(Ò*Ð*Ø�CØœ8 S¨¤V¤\�q�A�Aà˜aœ&�CØ˜qœ6œ<¨¬�q�AÝÐMÐMµ°C¸¸1¸q¹5¸	´NÀBÀqÈÀsÄGÑ0LÔ0LÐMÑMÔMÐN�Ø�c˜!”f‘�Ø�s˜1”v ‘}Ñ$��à�q‘��Øð 	Ø�r˜3�;ÐØˆtð Œ>×$Ò$ a SÑ)Ô)€DØ(•�q‘	”	Ô(¨$Ð/�I€Qˆà€Fõ 	ˆc‰
Œ
€AØð :Ý# A q¨!¨U°DÑ9Ô9ˆà€~˜%€~Ý   A q¨%Ñ0Ô0ˆà€~Øˆtà.Ð.Ð.Ð.Ð.Ð.Ø„|ð ÝŒuˆˆàˆw�t‰}Œ}ˆÝ	�&˜”)˜a ¨¤­BÐ/Ñ	0Ô	0€BØ�˜˜A™ ™Ñ%Ô%€JÝ	�*˜q !¥R˜jÑ	)Ô	)€BØ
ˆ'�&˜”)˜dÑ"Ñ
#Ô
#€Càˆr�3ˆ;ÐrW   r,   Tc           
      óv  — t          | ¦  «        } t          |¦  «        }|                      |¦  «        sdS t          |¦  «        }|dk    rt          j        }nM|dk    rt          j         }n9|t          j        t          j         fvrt	          d¦  «        ‚t          |¦  «        }t          | |||||||¦  «        S )aá  
    Computes the formula for Formal Power Series of a function.

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

    Tries to compute the formula by applying the following techniques
    (in order):

    * rational_algorithm
    * Hypergeometric algorithm

    Parameters
    ==========

    x : Symbol
    x0 : number, optional
        Point to perform series expansion about. Default is 0.
    dir : {1, -1, '+', '-'}, optional
        If dir is 1 or '+' the series is calculated from the right and
        for -1 or '-' the series is calculated from the left. For smooth
        functions this flag will not alter the results. Default is 1.
    hyper : {True, False}, optional
        Set hyper to False to skip the hypergeometric algorithm.
        By default it is set to False.
    order : int, optional
        Order of the derivative of ``f``, Default is 4.
    rational : {True, False}, optional
        Set rational to False to skip rational algorithm. By default it is set
        to True.
    full : {True, False}, optional
        Set full to True to increase the range of rational algorithm.
        See :func:`rational_algorithm` for details. By default it is set to
        False.

    Returns
    =======

    ak : sequence
        Sequence of coefficients.
    xk : sequence
        Sequence of powers of x.
    ind : Expr
        Independent terms.
    mul : Pow
        Common terms.

    See Also
    ========

    sympy.series.formal.rational_algorithm
    sympy.series.formal.hyper_algorithm
    Nú+ú-zDir must be '+' or '-')r   r5   r   rý   Ú
ValueErrorrþ   )rD   rE   r  r  r  rG   r  r-   s           rU   Úcompute_fpsr  s  s®   € õn 	�‰
Œ
€AÝ�‰
Œ
€Aà�5Š5�‰8Œ8ð Øˆtå	�‰Œ€Bà
ˆc‚z€zÝŒeˆˆØ	�ŠˆÝŒuˆfˆˆØ	•Q”U�QœU˜F�OÐ	#Ð	#ÝÐ1Ñ2Ô2Ð2å�c‰lŒlˆå˜˜1˜b # u¨e°X¸tÑDÔDÐDrW   c                   ó(   — e Zd ZdZed„ ¦   «         ZdS )r   zP
    Coeff(p, x, n) represents the nth coefficient of the polynomial p in x
    c                 ón   — |                      |¦  «        r|j        r|                     ||¦  «        S d S d S ro   )rÿ   rË   r=   )Úclsr³   rE   r[   s       rU   Úevalz
Coeff.evalÂ  sE   € à�?Š?˜1ÑÔð 	! !¤,ð 	!Ø—7’7˜1˜a‘=”=Ð ð	!ð 	!ð 	!ð 	!rW   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úclassmethodr  re   rW   rU   r   r   ¾  s9   € € € € € ðð ð ð!ð !ñ „[ð!ð !ð !rW   r   c                   óª  — e Zd ZdZd„ Zd„ Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	ed„ ¦   «         Z
ed„ ¦   «         Zed	„ ¦   «         Zed
„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zd„ Zd&d„Zd&d„Zd„ Zd„ Zd„ Zd„ Zd„ Zd'd„Zd(d„Zd„ Zd(d„Zd(d„Zd„ Z d „ Z!d!„ Z"d"„ Z#d#„ Z$d$„ Z%d%„ Z&dS ))ÚFormalPowerSeriesa5  
    Represents Formal Power Series of a function.

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

    No computation is performed. This class should only to be used to represent
    a series. No checks are performed.

    For computing a series use :func:`fps`.

    See Also
    ========

    sympy.series.formal.fps
    c                 óP   — t          t          |¦  «        }t          j        | g|¢R Ž S ro   )rÕ   r   r   Ú__new__)r  rÖ   s     rU   r   zFormalPowerSeries.__new__Ù  s)   € Ý•7˜DÑ!Ô!ˆÝŒ|˜CÐ' $Ð'Ð'Ð'Ð'rW   c                 ó6  — |d         d         }|j         d         }t          |j        |dt          f¦  «        | _        t          t          |¦  «        |dt          f¦  «        | _        | j        | j        z  | _        t          d|dt          f¦  «        | _        d S )Nr&   r   r,   )r.   r,   )	Ú	variablesr#   Úformular   Úak_seqr   Úfact_seqÚbell_coeff_seqÚsign_seq)ÚselfrÖ   rT   rF   s       rU   Ú__init__zFormalPowerSeries.__init__Ý  s|   € Ø�!ŒW�QŒZˆØŒL˜ŒOˆÝ˜rœz¨A¨qµ"¨:Ñ6Ô6ˆŒÝ ¥¨1¡¤°°1µb¨zÑ:Ô:ˆŒØ"œk¨D¬MÑ9ˆÔÝ  ¨1¨aµ¨*Ñ5Ô5ˆŒˆˆrW   c                 ó   — | j         d         S ©Nr   ©rÖ   ©r(  s    rU   ÚfunctionzFormalPowerSeries.functionå  ó   € àŒy˜Œ|ÐrW   c                 ó   — | j         d         S r–   r,  r-  s    rU   rE   zFormalPowerSeries.xé  r/  rW   c                 ó   — | j         d         S )NrÓ   r,  r-  s    rU   r  zFormalPowerSeries.x0í  r/  rW   c                 ó   — | j         d         S )Né   r,  r-  s    rU   r  zFormalPowerSeries.dirñ  r/  rW   c                 ó(   — | j         d         d         S )Nr&   r   r,  r-  s    rU   rT   zFormalPowerSeries.akõ  ó   € àŒy˜Œ|˜AŒÐrW   c                 ó(   — | j         d         d         S )Nr&   r,   r,  r-  s    rU   r
  zFormalPowerSeries.xkù  r5  rW   c                 ó(   — | j         d         d         S )Nr&   rÓ   r,  r-  s    rU   rO   zFormalPowerSeries.indý  r5  rW   c                 ó,   — t          dt          ¦  «        S r+  )r   r   r-  s    rU   ÚintervalzFormalPowerSeries.interval  s   € å˜�2‰ŒÐrW   c                 ó   — | j         j        S ro   )r9  Úinfr-  s    rU   r  zFormalPowerSeries.start  ó   € àŒ}Ô Ð rW   c                 ó   — | j         j        S ro   )r9  Úsupr-  s    rU   ÚstopzFormalPowerSeries.stop	  r<  rW   c                 ó   — t           S ro   )r   r-  s    rU   ÚlengthzFormalPowerSeries.length  s   € åˆ	rW   c                 ó¤   — ddl m} | j        | j        }}|j        d         } ||j        |j        z  ||j        |j        f¦  «        }| j        |z   S )z0Returns an infinite representation of the seriesr   )ÚSum)	Úsympy.concreterC  rT   r
  r"  r#  r  r?  rO   )r(  rC  rT   r
  rF   Úinf_sums         rU   ÚinfinitezFormalPowerSeries.infinite  s`   € ð 	'Ð&Ð&Ð&Ð&Ð&Ø”˜$œ'ˆBˆØŒL˜ŒOˆØ�#�b”j 2¤:Ñ-°°2´8¸R¼WÐ/EÑFÔFˆàŒx˜'Ñ!Ð!rW   c                 ó¼   — |                      | j        ¦  «        d                              ¦   «         \  }}|                     | j        ¦  «        st          j        S |S )z!Returns the power of x in a term.r,   )r:   rE   r;   r5   r   r4   )r(  r\   rR   rÅ   s       rU   Ú
_get_pow_xzFormalPowerSeries._get_pow_x  sN   € à×*Ò*¨4¬6Ñ2Ô2°1Ô5×AÒAÑCÔC‰ˆˆuØ�yŠy˜œÑ Ô ð 	Ý”6ˆMØˆrW   é   c                 ó,  — g }| j         }t          | ¦  «        D ]s\  }}|                      |¦  «        } |j        |Ž r |j        |Ž d         }||k    r n8|j        du r||dz   k    r n$|t          j        ur|                     |¦  «         Œtt          |Ž S )zÉ
        Truncated series as polynomial.

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

        Returns series expansion of ``f`` upto order ``O(x**n)``
        as a polynomial(without ``O`` term).
        r   Tr,   )
rÞ   rY   rH  r5   r<   rË   r   r4   rC   r   )r(  r[   rK   ÚsymrI   rL   Úxps          rU   Ú
polynomialzFormalPowerSeries.polynomial"  s¯   € ð ˆØÔˆÝ˜d‘O”Oð 		 ð 		 ‰DˆAˆqØ—’ Ñ#Ô#ˆBØˆrŒv�sˆ|ð .Ø$�R”_ cÐ*¨1Ô-�Ø�QŠwˆwØ�Ø” $Ð&Ð&¨1°°A±ª:¨:Ø�Ø�!œ&��Ø—’˜Q‘”�øå�Eˆ{ÐrW   c                 óø   — |€t          | ¦  «        S | j        | j        }}| j                             |¦  «        }|t
          j        u rt
          j        }|                      |¦  «        t          |||f¦  «        z   S )zÖ
        Truncated series.

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

        Returns truncated series expansion of f upto
        order ``O(x**n)``.

        If n is ``None``, returns an infinite iterator.
        )
ÚiterrE   r  r
  r=   r   rü   rû   rM  r"   )r(  r[   rE   r  Úpt_xks        rU   ÚtruncatezFormalPowerSeries.truncate;  so   € ð ˆ9Ý˜‘:”:Ðà”˜œˆ2ˆØ”—’˜aÑ Ô ˆØ•Ô#Ð#Ð#Ý”ˆBà�Š˜qÑ!Ô!¥E¨%°!°R°Ñ$9Ô$9Ñ9Ð9rW   c                 ó,   — |                       d¦  «        S r+  )Ú
_eval_termr-  s    rU   Ú
zero_coeffzFormalPowerSeries.zero_coeffQ  s   € Ø�Š˜qÑ!Ô!Ð!rW   c                 ó(  — 	 | j                              |¦  «        }| j                             |¦  «                             ¦   «         }||z  }n# t          $ r t
          j        }Y nw xY w| j        r‰t
          j        }| j        }t          j
        | j        ¦  «        D ]W}|                      |¦  «        } |j        |Ž r |j        |Ž d         }|dk    r|dk     r||z  }ŒC||k    r||dz   k     r||z  }ŒX||z  }|                     | j        ¦  «        S ©Nr   r,   )r
  r=   rT   ÚsimplifyÚ
IndexErrorr   r4   rO   rÞ   r   r7   rH  r5   r<   rz   rE   )	r(  ÚptrP  Úpt_akr\   rO   rK  rL   rÅ   s	            rU   rS  zFormalPowerSeries._eval_termT  s1  € ð	#Ø”G—M’M "Ñ%Ô%ˆEØ”G—M’M "Ñ%Ô%×.Ò.Ñ0Ô0ˆEð ˜E‘MˆDˆDøõ ð 	ð 	ð 	Ý”6ˆDˆDˆDð	øøøð
 Œ8ð 	Ý”&ˆCØÔ#ˆCÝ”] 4¤8Ñ,Ô,ð ð �ØŸš¨Ñ*Ô*�Ø�5”9˜c�?ð 8Ø.˜EÔ.°Ð4°QÔ7�EØ˜’7�7˜u qšy˜yØ˜1‘H�C�CØ˜b’[�[ U¨R°!©V¢^ ^Ø˜1‘H�CøØ�C‰KˆDà�|Š|˜DœFÑ#Ô#Ð#s   ‚AA ÁA'Á&A'c                 óB   — | j         }|                     |¦  «        r| S d S ro   )rE   r5   )r(  ÚoldÚnewrE   s       rU   Ú
_eval_subszFormalPowerSeries._eval_subsl  s*   € ØŒFˆØ�7Š7�1‰:Œ:ð 	ØˆKð	ð 	rW   c                 ó4   — | D ]}|t           j        ur|c S Œd S ro   rÈ   )r(  rE   ÚlogxÚcdirrL   s        rU   Ú_eval_as_leading_termz'FormalPowerSeries._eval_as_leading_termq  s4   € Øð 	ð 	ˆAØ�œˆˆØ���ð ð	ð 	rW   c           	      ó@  — | j                              |¦  «        }| j                             |¦  «        }|                      | j        j        ¦  «        }| j        }|j        d         }|j                             |¦  «        r¯g }|j        j	        D ]_\  }}	t          j        }
t          j        |¦  «        D ]"}|                      |¦  «        }|
|||z   z  z  }
Œ#|                     |
|	f¦  «         Œ`t          |Ž }t!          |                     ||dz   ¦  «        ||j        dz
  |j        f¦  «        }n?t!          |j        |z                       ||dz   ¦  «        ||j        dz
  |j        f¦  «        }|                      || j        | j        | j        || j        |f¦  «        S rV  )r.  r2   rO   rH  r
  r#  rT   r"  r5   rÖ   r   r4   r   r7   rC   r    r#   rB   r  r?  ÚfuncrE   r  r  )r(  rE   rD   rO   Úpow_xkrT   rF   Úformré   rˆ   rè   rL   rÅ   s                rU   Ú_eval_derivativez"FormalPowerSeries._eval_derivativev  s‡  € ØŒM×Ò˜qÑ!Ô!ˆØŒh�mŠm˜AÑÔˆà—’ ¤¤Ñ1Ô1ˆØŒWˆØŒL˜ŒOˆØŒ:�>Š>˜!ÑÔð 	6ØˆDØœ
œð 'ð '‘��1Ý”v�Ýœ qÑ)Ô)ð 1ð 1�AØ ŸOšO¨AÑ.Ô.�EØ˜A ¨%¡Ñ0Ñ0�D�DØ—’˜T 1˜IÑ&Ô&Ð&Ð&Ý˜dÐ#ˆDÝ˜$Ÿ)š) A q¨1¡uÑ-Ô-°°2´8¸a±<ÀÄÐ/IÑJÔJˆBˆBå˜2œ:¨Ñ.×4Ò4°Q¸¸A¹Ñ>Ô>Ø˜bœh¨™l¨B¬GÐ4ñ6ô 6ˆBð �yŠy˜˜DœF D¤G¨T¬X¸¸D¼GÀSÐ7IÑJÔJÐJrW   Nc           	      óÀ  — ddl m} |€| j        }n t          |¦  «        r || j        |¦  «        S  || j        |¦  «        } || j        |¦  «        }|||z
                       |d¦  «        z  }|                      | j        j	        ¦  «        }| j
        }|j        d         }|j	                             |¦  «        r²g }	|j	        j        D ]b\  }
}t          j        }t!          j        |
¦  «        D ]%}|                      |¦  «        }||||z   dz   z  z  }Œ&|	                     ||f¦  «         Œct'          |	Ž }	t)          |	                     ||dz
  ¦  «        ||j        dz   |j        f¦  «        }nBt)          |j	        |dz   z                       ||dz
  ¦  «        ||j        dz   |j        f¦  «        }|                      || j        | j        | j        || j        |f¦  «        S )aK  
        Integrate Formal Power Series.

        Examples
        ========

        >>> from sympy import fps, sin, integrate
        >>> from sympy.abc import x
        >>> f = fps(sin(x))
        >>> f.integrate(x).truncate()
        -1 + x**2/2 - x**4/24 + O(x**6)
        >>> integrate(f, (x, 0, 1))
        1 - cos(1)
        r   r*   Nr,   )r0   r+   rE   r%   r.  rO   rA   rH  r
  r#  rT   r"  r5   rÖ   r   r4   r   r7   rC   r    r#   rB   r  r?  rd  r  r  )r(  rE   Úkwargsr+   rD   rO   re  rT   rF   rf  ré   rˆ   rè   rL   rÅ   s                  rU   r+   zFormalPowerSeries.integrate�  sî  € ð 	.Ð-Ð-Ð-Ð-Ð-àˆ9Ø”ˆAˆAÝ�a‰[Œ[ð 	/Ø�9˜Tœ]¨AÑ.Ô.Ð.àˆI�d”m QÑ'Ô'ˆØˆi˜œ !Ñ$Ô$ˆØ��C‘�Š˜q !Ñ$Ô$Ñ$ˆà—’ ¤¤Ñ1Ô1ˆØŒWˆØŒL˜ŒOˆØŒ:�>Š>˜!ÑÔð 	6ØˆDØœ
œð 'ð '‘��1Ý”v�Ýœ qÑ)Ô)ð 5ð 5�AØ ŸOšO¨AÑ.Ô.�EØ˜A ¨%¡°!Ñ!3Ñ4Ñ4�D�DØ—’˜T 1˜IÑ&Ô&Ð&Ð&Ý˜dÐ#ˆDÝ˜$Ÿ)š) A q¨1¡uÑ-Ô-°°2´8¸a±<ÀÄÐ/IÑJÔJˆBˆBå˜2œ:¨°!©Ñ4×:Ò:¸1¸aÀ!¹eÑDÔDØ˜bœh¨™l¨B¬GÐ4ñ6ô 6ˆBð �yŠy˜˜DœF D¤G¨T¬X¸¸D¼GÀSÐ7IÑJÔJÐJrW   c                 ód  — |€t          | ¦  «        S t          |¦  «        }t          |t          ¦  «        st	          d¦  «        ‚| j        |j        k    rt	          d¦  «        ‚| j        |j        k    rt	          d¦  «        ‚| j        |j        k    rt	          d¦  «        ‚t          | |¦  «        S )aµ  
        Multiplies two Formal Power Series, using discrete convolution and
        return the truncated terms upto specified order.

        Parameters
        ==========

        n : Number, optional
            Specifies the order of the term up to which the polynomial should
            be truncated.

        Examples
        ========

        >>> from sympy import fps, sin, exp
        >>> from sympy.abc import x
        >>> f1 = fps(sin(x))
        >>> f2 = fps(exp(x))

        >>> f1.product(f2, x).truncate(4)
        x + x**2 + x**3/3 + O(x**4)

        See Also
        ========

        sympy.discrete.convolutions
        sympy.series.formal.FormalPowerSeriesProduct

        Nú=Both series should be an instance of FormalPowerSeries class.ú9Both series should be calculated from the same direction.ú6Both series should be calculated about the same point.ú(Both series should have the same symbol.)	rO  r   r9   r  r  r  r  rE   ÚFormalPowerSeriesProduct©r(  ÚotherrE   r[   s       rU   ÚproductzFormalPowerSeries.productº  sÈ   € ð> ˆ9Ý˜‘:”:Ðå˜‘”ˆå˜%Õ!2Ñ3Ô3ð 	(Ýð 'ñ (ô (ð (ð Œ8�u”yÒ Ð Ýð 0ñ 1ô 1ð 1àŒW˜œÒ Ð Ýð ,ñ -ô -ð -ð ŒV�u”wÒÐÝÐGÑHÔHÐHå'¨¨eÑ4Ô4Ð4rW   c                 ó®   ‡ ‡— ˆˆ fd„t          d‰dz   ¦  «        D ¦   «         }t          d¦  «        }t          t          |¦  «        |dt          f¦  «        S )au  
        self.coeff_bell(n) returns a sequence of Bell polynomials of the second kind.
        Note that ``n`` should be a integer.

        The second kind of Bell polynomials (are sometimes called "partial" Bell
        polynomials or incomplete Bell polynomials) are defined as

        .. math::
            B_{n,k}(x_1, x_2,\dotsc x_{n-k+1}) =
                \sum_{j_1+j_2+j_2+\dotsb=k \atop j_1+2j_2+3j_2+\dotsb=n}
                \frac{n!}{j_1!j_2!\dotsb j_{n-k+1}!}
                \left(\frac{x_1}{1!} \right)^{j_1}
                \left(\frac{x_2}{2!} \right)^{j_2} \dotsb
                \left(\frac{x_{n-k+1}}{(n-k+1)!} \right) ^{j_{n-k+1}}.

        * ``bell(n, k, (x1, x2, ...))`` gives Bell polynomials of the second kind,
          `B_{n,k}(x_1, x_2, \dotsc, x_{n-k+1})`.

        See Also
        ========

        sympy.functions.combinatorial.numbers.bell

        c                 ór   •— g | ]3}t          ‰|t          ‰j        d ‰|z
  dz   …         ¦  «        ¦  «        ‘Œ4S r–   )r   Útupler&  )rg   rP   r[   r(  s     €€rU   rh   z0FormalPowerSeries.coeff_bell.<locals>.<listcomp>  sA   ø€ Ð^Ð^Ð^È1�˜Q ¥5¨Ô)<¸V¸aÀ¹cÀ!¹e¸VÔ)DÑ#EÔ#EÑFÔFÐ^Ð^Ð^rW   r,   rF   )r1   r   r#   ru  r   )r(  r[   Úinner_coeffsrF   s   ``  rU   Ú
coeff_bellzFormalPowerSeries.coeff_bellî  s_   øø€ ð4 _Ð^Ð^Ð^Ð^ÕPUÐVWÐYZÐ[\ÑY\ÑP]ÔP]Ð^Ñ^Ô^ˆå�#‰JŒJˆÝ�˜lÑ+Ô+¨a°µB¨ZÑ8Ô8Ð8rW   c                 ó   — |€t          | ¦  «        S t          |¦  «        }t          |t          ¦  «        st	          d¦  «        ‚| j        |j        k    rt	          d¦  «        ‚| j        |j        k    rt	          d¦  «        ‚| j        |j        k    rt	          d¦  «        ‚|                     d¦  «         	                    |j        ¦  «        d         t          j        urt	          d¦  «        ‚t          | |¦  «        S )a  
        Returns the truncated terms of the formal power series of the composed function,
        up to specified ``n``.

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

        If ``f`` and ``g`` are two formal power series of two different functions,
        then the coefficient sequence ``ak`` of the composed formal power series `fp`
        will be as follows.

        .. math::
            \sum\limits_{k=0}^{n} b_k B_{n,k}(x_1, x_2, \dotsc, x_{n-k+1})

        Parameters
        ==========

        n : Number, optional
            Specifies the order of the term up to which the polynomial should
            be truncated.

        Examples
        ========

        >>> from sympy import fps, sin, exp
        >>> from sympy.abc import x
        >>> f1 = fps(exp(x))
        >>> f2 = fps(sin(x))

        >>> f1.compose(f2, x).truncate()
        1 + x + x**2/2 - x**4/8 - x**5/15 + O(x**6)

        >>> f1.compose(f2, x).truncate(8)
        1 + x + x**2/2 - x**4/8 - x**5/15 - x**6/240 + x**7/90 + O(x**8)

        See Also
        ========

        sympy.functions.combinatorial.numbers.bell
        sympy.series.formal.FormalPowerSeriesCompose

        References
        ==========

        .. [1] Comtet, Louis: Advanced combinatorics; the art of finite and infinite expansions. Reidel, 1974.

        Nrk  rl  rm  rn  r   z\The formal power series of the inner function should not have any constant coefficient term.)rO  r   r9   r  r  r  r  rE   rS  ry   r   r4   ÚFormalPowerSeriesComposerp  s       rU   ÚcomposezFormalPowerSeries.compose  s  € ðb ˆ9Ý˜‘:”:Ðå˜‘”ˆå˜%Õ!2Ñ3Ô3ð 	(Ýð 'ñ (ô (ð (ð Œ8�u”yÒ Ð Ýð 0ñ 1ô 1ð 1àŒW˜œÒ Ð Ýð ,ñ -ô -ð -ð ŒV�u”wÒÐÝÐGÑHÔHÐHà×Ò˜AÑÔ×+Ò+¨E¬GÑ4Ô4°QÔ7½q¼vÐEÐEÝð -ñ .ô .ð .õ (¨¨eÑ4Ô4Ð4rW   c                 ó”   — |€t          | ¦  «        S |                      d¦  «        j        rt          d¦  «        ‚t	          | ¦  «        S )a  
        Returns the truncated terms of the inverse of the formal power series,
        up to specified ``n``.

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

        If ``f`` and ``g`` are two formal power series of two different functions,
        then the coefficient sequence ``ak`` of the composed formal power series ``fp``
        will be as follows.

        .. math::
            \sum\limits_{k=0}^{n} (-1)^{k} x_0^{-k-1} B_{n,k}(x_1, x_2, \dotsc, x_{n-k+1})

        Parameters
        ==========

        n : Number, optional
            Specifies the order of the term up to which the polynomial should
            be truncated.

        Examples
        ========

        >>> from sympy import fps, exp, cos
        >>> from sympy.abc import x
        >>> f1 = fps(exp(x))
        >>> f2 = fps(cos(x))

        >>> f1.inverse(x).truncate()
        1 - x + x**2/2 - x**3/6 + x**4/24 - x**5/120 + O(x**6)

        >>> f2.inverse(x).truncate(8)
        1 + x**2/2 + 5*x**4/24 + 61*x**6/720 + O(x**8)

        See Also
        ========

        sympy.functions.combinatorial.numbers.bell
        sympy.series.formal.FormalPowerSeriesInverse

        References
        ==========

        .. [1] Comtet, Louis: Advanced combinatorics; the art of finite and infinite expansions. Reidel, 1974.

        Nr   zSConstant coefficient should exist for an inverse of a formal power series to exist.)rO  rS  r?   r  ÚFormalPowerSeriesInverse)r(  rE   r[   s      rU   ÚinversezFormalPowerSeries.inverseW  sT   € ðb ˆ9Ý˜‘:”:Ðà�?Š?˜1ÑÔÔ%ð 	+Ýð *ñ +ô +ð +õ (¨Ñ-Ô-Ð-rW   c           	      óì  — t          |¦  «        }t          |t          ¦  «        �r]| j        |j        k    rt	          d¦  «        ‚| j        |j        k    rt	          d¦  «        ‚| j        |j        }}| j        |j                             ||¦  «        z   }| j        |j	        vr|S | j
        |j
        z   }| j
        j        |j
        j        k    r |j
        }|j
        j        | j
        j        }}n| j
        }| j
        j        |j
        j        }}t          d„ t          |d||z
  …         | j        ||…         ¦  «        D ¦   «         Ž }	| j        |j        z   |	z   }
|                      ||| j        | j        || j        |
f¦  «        S |                     | j        ¦  «        sI| j        |z   }| j        |z   }
|                      || j        | j        | j        | j
        | j        |
f¦  «        S t          | |¦  «        S )Nrl  rm  c                 ó0   — g | ]}|d          |d         z  ‘ŒS r÷   re   rø   s     rU   rh   z-FormalPowerSeries.__add__.<locals>.<listcomp>©  s$   € ÐNÐNÐN q˜˜1œ˜a œd™ÐNÐNÐNrW   r   )r   r9   r  r  r  r  rE   r.  rB   rÞ   rT   r  r   rw   r
  rO   rd  r5   )r(  rq  rE   ÚyrD   rT   r  rq   ré   r  rO   s              rU   Ú__add__zFormalPowerSeries.__add__‘  så  € Ý˜‘”ˆå�eÕ.Ñ/Ô/ñ 	6ØŒx˜5œ9Ò$Ð$Ý ð "4ñ 5ô 5ð 5à”˜EœHÒ$Ð$Ý ð "0ñ 1ô 1ð 1ð ”6˜5œ7ˆqˆAØ” ¤× 3Ò 3°A°qÑ 9Ô 9Ñ9ˆAàŒv˜Qœ^Ð+Ð+Ø�à”˜5œ8Ñ#ˆBØŒwŒ}˜uœxœ~Ò-Ð-Ø”h�Ø”x”~ t¤w¤}�1��à”g�Ø”w”} e¤h¤n�1�ÝÐNÐN­C°°A°q¸1±u°I´ÀÄÈÈ!ÈÄÑ,MÔ,MÐNÑNÔNÐOˆDØ”(˜UœYÑ&¨Ñ-ˆCà—9’9˜Q  4¤7¨D¬H°r¸4¼7ÀCÐ6HÑIÔIÐIà—’˜4œ6Ñ"Ô"ð 	6Ø” Ñ%ˆAØ”(˜UÑ"ˆCà—9’9˜Q ¤¨¬°´Ø"œg t¤w°Ð4ñ6ô 6ð 6õ �4˜ÑÔÐrW   c                 ó,   — |                       |¦  «        S ro   ©r�  ©r(  rq  s     rU   Ú__radd__zFormalPowerSeries.__radd__·  ó   € Ø�|Š|˜EÑ"Ô"Ð"rW   c           	      ó†   — |                       | j         | j        | j        | j        | j         | j        | j         f¦  «        S ro   )rd  r.  rE   r  r  rT   r
  rO   r-  s    rU   Ú__neg__zFormalPowerSeries.__neg__º  s>   € Ø�yŠy˜$œ-˜¨¬°´¸$¼(Øœ7˜( D¤G¨d¬h¨YÐ7ñ9ô 9ð 	9rW   c                 ó.   — |                       | ¦  «        S ro   rƒ  r„  s     rU   Ú__sub__zFormalPowerSeries.__sub__¾  s   € Ø�|Š|˜U˜FÑ#Ô#Ð#rW   c                 ó.   — |                        |¦  «        S ro   rƒ  r„  s     rU   Ú__rsub__zFormalPowerSeries.__rsub__Á  s   € Ø��Š˜uÑ%Ô%Ð%rW   c           	      ó0  — t          |¦  «        }|                     | j        ¦  «        rt          | |¦  «        S | j        |z  }| j                             |¦  «        }| j        |z  }|                      || j        | j	        | j
        || j        |f¦  «        S ro   )r   r5   rE   r   r.  rT   Ú	coeff_mulrO   rd  r  r  r
  )r(  rq  rD   rT   rO   s        rU   Ú__mul__zFormalPowerSeries.__mul__Ä  s‰   € Ý˜‘”ˆà�9Š9�T”VÑÔð 	$Ý�t˜UÑ#Ô#Ð#àŒM˜EÑ!ˆØŒW×Ò˜uÑ%Ô%ˆØŒh˜Ñˆà�yŠy˜˜DœF D¤G¨T¬X¸¸D¼GÀSÐ7IÑJÔJÐJrW   c                 ó,   — |                       |¦  «        S ro   )r�  r„  s     rU   Ú__rmul__zFormalPowerSeries.__rmul__Ð  r†  rW   ©rI  ro   )NrI  )'r  r  r  r  r   r)  Úpropertyr.  rE   r  r  rT   r
  rO   r9  r  r?  rA  rF  rH  rM  rQ  rT  rS  r^  rb  rg  r+   rr  rw  rz  r}  r�  r…  rˆ  rŠ  rŒ  r�  r‘  re   rW   rU   r  r  È  sÝ  € € € € € ðð ð (ð (ð (ð6ð 6ð 6ð ðð ñ „Xðð ðð ñ „Xðð ðð ñ „Xðð ðð ñ „Xðð ðð ñ „Xðð ðð ñ „Xðð ðð ñ „Xðð ðð ñ „Xðð ð!ð !ñ „Xð!ð ð!ð !ñ „Xð!ð ðð ñ „Xðð ð"ð "ñ „Xð"ðð ð ðð ð ð ð2:ð :ð :ð :ð,"ð "ð "ð$ð $ð $ð0ð ð ð
ð ð ð
Kð Kð Kð.+Kð +Kð +Kð +KðZ25ð 25ð 25ð 25ðh9ð 9ð 9ð>H5ð H5ð H5ð H5ðT8.ð 8.ð 8.ð 8.ðt$ ð $ ð $ ðL#ð #ð #ð9ð 9ð 9ð$ð $ð $ð&ð &ð &ð
Kð 
Kð 
Kð#ð #ð #ð #ð #rW   r  c                   ó¬   — e Zd ZdZd„ Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Z	ed„ ¦   «         Z
d„ Zd	„ Zd
„ Zdd„Zd„ Zd„ ZdS )ÚFiniteFormalPowerSeriesz3Base Class for Product, Compose and Inverse classesc                 ó   — d S ro   re   )r(  rÖ   s     rU   r)  z FiniteFormalPowerSeries.__init__×  s   € ØˆrW   c                 ó   — | j         d         S r+  r,  r-  s    rU   ÚffpszFiniteFormalPowerSeries.ffpsÚ  r/  rW   c                 ó   — | j         d         S r–   r,  r-  s    rU   ÚgfpszFiniteFormalPowerSeries.gfpsÞ  r/  rW   c                 ó   — | j         j        S ro   )r˜  r.  r-  s    rU   rD   zFiniteFormalPowerSeries.fâ  ó   € àŒyÔ!Ð!rW   c                 ó   — | j         j        S ro   )rš  r.  r-  s    rU   rj   zFiniteFormalPowerSeries.gæ  rœ  rW   c                 ó    — t          d¦  «        ‚)NzCNo infinite version for an object of FiniteFormalPowerSeries class.©ÚNotImplementedErrorr-  s    rU   rF  z FiniteFormalPowerSeries.infiniteê  s   € å!ð #7ñ 8ô 8ð 	8rW   c                 ó&   — t          d| z  ¦  «        ‚)Nz(%s)._eval_terms()rŸ  ©r(  r[   s     rU   Ú_eval_termsz#FiniteFormalPowerSeries._eval_termsï  s   € Ý!Ð"6¸Ñ"=Ñ>Ô>Ð>rW   c                 ó    — t          d¦  «        ‚)Nz]By the current logic, one can get termsupto a certain order, instead of getting term by term.rŸ  )r(  rY  s     rU   rS  z"FiniteFormalPowerSeries._eval_termò  s   € Ý!ð #\ñ ]ô ]ð 	]rW   c                 ó,   — |                       |¦  «        S ro   )r£  r¢  s     rU   rM  z"FiniteFormalPowerSeries.polynomialö  s   € Ø×Ò Ñ"Ô"Ð"rW   rI  c                 ó°   — | j         }|j                             |¦  «        }|j        |j        }}|                      |¦  «        t          |||f¦  «        z   S ro   )r˜  r
  r=   rE   r  rM  r"   )r(  r[   r˜  rP  rE   r  s         rU   rQ  z FiniteFormalPowerSeries.truncateù  sN   € ØŒyˆØ”—’˜aÑ Ô ˆØ”˜œˆ2ˆà�Š˜qÑ!Ô!¥E¨%°!°R°Ñ$9Ô$9Ñ9Ð9rW   c                 ó   — t           ‚ro   rŸ  ©r(  rE   s     rU   rg  z(FiniteFormalPowerSeries._eval_derivative   ó   € Ý!Ð!rW   c                 ó   — t           ‚ro   rŸ  r¨  s     rU   r+   z!FiniteFormalPowerSeries.integrate  r©  rW   Nr’  )r  r  r  r  r)  r“  r˜  rš  rD   rj   rF  r£  rS  rM  rQ  rg  r+   re   rW   rU   r•  r•  Ô  s  € € € € € Ø=Ð=ðð ð ð ðð ñ „Xðð ðð ñ „Xðð ð"ð "ñ „Xð"ð ð"ð "ñ „Xð"ð ð8ð 8ñ „Xð8ð?ð ?ð ?ð]ð ]ð ]ð#ð #ð #ð:ð :ð :ð :ð"ð "ð "ð"ð "ð "ð "ð "rW   r•  c                   ó4   — e Zd ZdZd„ Zed„ ¦   «         Zd„ ZdS )ro  a   Represents the product of two formal power series of two functions.

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

    No computation is performed. Terms are calculated using a term by term logic,
    instead of a point by point logic.

    There are two differences between a :obj:`FormalPowerSeries` object and a
    :obj:`FormalPowerSeriesProduct` object. The first argument contains the two
    functions involved in the product. Also, the coefficient sequence contains
    both the coefficient sequence of the formal power series of the involved functions.

    See Also
    ========

    sympy.series.formal.FormalPowerSeries
    sympy.series.formal.FiniteFormalPowerSeries

    c                 ó  — | j         | j        }}|j        j        d         }t	          |j        j        |dt          f¦  «        | _        |j        j        d         }t	          |j        j        |dt          f¦  «        | _        d S r+  )	r˜  rš  rT   r"  r#   r#  r   Úcoeff1Úcoeff2)r(  rÖ   r˜  rš  rF   s        rU   r)  z!FormalPowerSeriesProduct.__init__  sg   € Ø”Y ¤	ˆdˆàŒGÔ˜aÔ ˆÝ˜tœwœ°°Aµr°
Ñ;Ô;ˆŒàŒGÔ˜aÔ ˆÝ˜tœwœ°°Aµr°
Ñ;Ô;ˆŒˆˆrW   c                 ó    — | j         | j        z  S )z3Function of the product of two formal power series.)rD   rj   r-  s    rU   r.  z!FormalPowerSeriesProduct.function&  s   € ð Œv˜œ‰ÐrW   c                 ó  — | j         | j        }}t          |d|…         |d|…         ¦  «        }g }t          d|¦  «        D ]=}|                     ||         | j        j                             |¦  «        z  ¦  «         Œ>t          |Ž S )aî  
        Returns the first ``n`` terms of the product formal power series.
        Term by term logic is implemented here.

        Examples
        ========

        >>> from sympy import fps, sin, exp
        >>> from sympy.abc import x
        >>> f1 = fps(sin(x))
        >>> f2 = fps(exp(x))
        >>> fprod = f1.product(f2, x)

        >>> fprod._eval_terms(4)
        x**3/3 + x**2 + x

        See Also
        ========

        sympy.series.formal.FormalPowerSeries.product

        Nr   )	r­  r®  r   r1   rC   r˜  r
  r=   r   )r(  r[   r­  r®  ÚaksrK   rI   s          rU   r£  z$FormalPowerSeriesProduct._eval_terms+  s†   € ð. œ d¤k�ˆå˜&  ! œ* f¨R¨a¨R¤jÑ1Ô1ˆàˆÝ�q˜!‘”ð 	9ð 	9ˆAØ�LŠL˜˜Qœ $¤)¤,×"4Ò"4°QÑ"7Ô"7Ñ7Ñ8Ô8Ð8Ð8å�Eˆ{ÐrW   N)r  r  r  r  r)  r“  r.  r£  re   rW   rU   ro  ro    sW   € € € € € ðð ð*<ð <ð <ð ðð ñ „Xððð ð ð ð rW   ro  c                   ó.   — e Zd ZdZed„ ¦   «         Zd„ ZdS )ry  a  
    Represents the composed formal power series of two functions.

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

    No computation is performed. Terms are calculated using a term by term logic,
    instead of a point by point logic.

    There are two differences between a :obj:`FormalPowerSeries` object and a
    :obj:`FormalPowerSeriesCompose` object. The first argument contains the outer
    function and the inner function involved in the omposition. Also, the
    coefficient sequence contains the generic sequence which is to be multiplied
    by a custom ``bell_seq`` finite sequence. The finite terms will then be added up to
    get the final terms.

    See Also
    ========

    sympy.series.formal.FormalPowerSeries
    sympy.series.formal.FiniteFormalPowerSeries

    c                 ób   — | j         | j        | j        j        }}}|                     ||¦  «        S )z.Function for the composed formal power series.)rD   rj   r˜  rE   rB   )r(  rD   rj   rE   s       rU   r.  z!FormalPowerSeriesCompose.functionf  s+   € ð ”&˜$œ& $¤)¤+ˆaˆ1ˆØ�vŠv�a˜‰|Œ|ÐrW   c                 ó^  — | j         | j        }}|                     ¦   «         g}t          d|¦  «        D ]q}|                     |¦  «        }|j        |z  }|                     t          |d|…         Ž |j        |dz
           z  |j	         
                    |¦  «        z  ¦  «         Œrt          |Ž S )a²  
        Returns the first `n` terms of the composed formal power series.
        Term by term logic is implemented here.

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

        The coefficient sequence of the :obj:`FormalPowerSeriesCompose` object is the generic sequence.
        It is multiplied by ``bell_seq`` to get a sequence, whose terms are added up to get
        the final terms for the polynomial.

        Examples
        ========

        >>> from sympy import fps, sin, exp
        >>> from sympy.abc import x
        >>> f1 = fps(exp(x))
        >>> f2 = fps(sin(x))
        >>> fcomp = f1.compose(f2, x)

        >>> fcomp._eval_terms(6)
        -x**5/15 - x**4/8 + x**2/2 + x + 1

        >>> fcomp._eval_terms(8)
        x**7/90 - x**6/240 - x**5/15 - x**4/8 + x**2/2 + x + 1

        See Also
        ========

        sympy.series.formal.FormalPowerSeries.compose
        sympy.series.formal.FormalPowerSeries.coeff_bell

        r,   N)r˜  rš  rT  r1   rw  r&  rC   r   r%  r
  r=   )r(  r[   r˜  rš  rK   rI   Úbell_seqr  s           rU   r£  z$FormalPowerSeriesCompose._eval_termsl  s©   € ðF ”Y ¤	ˆdˆØ—’Ñ"Ô"Ð#ˆå�q˜!‘”ð 	Rð 	RˆAØ—’ qÑ)Ô)ˆHØÔ&¨Ñ1ˆCØ�LŠL�˜s 2 A 2œw˜¨4¬=¸¸1¹Ô+=Ñ=ÀÄÇÂÈaÑ@PÔ@PÑPÑQÔQÐQÐQå�Eˆ{ÐrW   N)r  r  r  r  r“  r.  r£  re   rW   rU   ry  ry  M  sH   € € € € € ðð ð0 ðð ñ „Xðð
+ð +ð +ð +ð +rW   ry  c                   ó`   — e Zd ZdZd„ Zed„ ¦   «         Zed„ ¦   «         Zed„ ¦   «         Zd„ Z	dS )r|  aŒ  
    Represents the Inverse of a formal power series.

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

    No computation is performed. Terms are calculated using a term by term logic,
    instead of a point by point logic.

    There is a single difference between a :obj:`FormalPowerSeries` object and a
    :obj:`FormalPowerSeriesInverse` object. The coefficient sequence contains the
    generic sequence which is to be multiplied by a custom ``bell_seq`` finite sequence.
    The finite terms will then be added up to get the final terms.

    See Also
    ========

    sympy.series.formal.FormalPowerSeries
    sympy.series.formal.FiniteFormalPowerSeries

    c                 óÌ   — | j         }|j        j        d         }|                     ¦   «         }t	          ||dz    z  |dt
          f¦  «        }|j        |j        z  |z  | _        d S rV  )	r˜  r
  r"  rT  r#   r   r'  r%  Úaux_seq)r(  rÖ   r˜  rF   ÚinvÚinv_seqs         rU   r)  z!FormalPowerSeriesInverse.__init__°  s`   € ØŒyˆØŒGÔ˜aÔ ˆà�oŠoÑÔˆÝ˜3 Q¨¡U 8Ñ,¨q°!µR¨jÑ9Ô9ˆØ”} t¤}Ñ4°wÑ>ˆŒˆˆrW   c                 ó   — | j         }d|z  S )z2Function for the inverse of a formal power series.r,   )rD   )r(  rD   s     rU   r.  z!FormalPowerSeriesInverse.function¸  s   € ð ŒFˆØ�1‰uˆrW   c                 ó    — t          d¦  «        ‚©NzQOnly one function is considered while performinginverse of a formal power series.©r  r-  s    rU   rj   zFormalPowerSeriesInverse.g¾  ó   € åð <ñ =ô =ð 	=rW   c                 ó    — t          d¦  «        ‚r½  r¾  r-  s    rU   rš  zFormalPowerSeriesInverse.gfpsÃ  r¿  rW   c                 óP  — | j         }|                     ¦   «         g}t          d|¦  «        D ]q}|                     |¦  «        }| j        |z  }|                     t          |d|…         Ž |j        |dz
           z  |j         	                    |¦  «        z  ¦  «         Œrt          |Ž S )a¸  
        Returns the first ``n`` terms of the composed formal power series.
        Term by term logic is implemented here.

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

        The coefficient sequence of the `FormalPowerSeriesInverse` object is the generic sequence.
        It is multiplied by ``bell_seq`` to get a sequence, whose terms are added up to get
        the final terms for the polynomial.

        Examples
        ========

        >>> from sympy import fps, exp, cos
        >>> from sympy.abc import x
        >>> f1 = fps(exp(x))
        >>> f2 = fps(cos(x))
        >>> finv1, finv2 = f1.inverse(), f2.inverse()

        >>> finv1._eval_terms(6)
        -x**5/120 + x**4/24 - x**3/6 + x**2/2 - x + 1

        >>> finv2._eval_terms(8)
        61*x**6/720 + 5*x**4/24 + x**2/2 + 1

        See Also
        ========

        sympy.series.formal.FormalPowerSeries.inverse
        sympy.series.formal.FormalPowerSeries.coeff_bell

        r,   N)
r˜  rT  r1   rw  r¸  rC   r   r%  r
  r=   )r(  r[   r˜  rK   rI   rµ  r  s          rU   r£  z$FormalPowerSeriesInverse._eval_termsÈ  s¢   € ðD ŒyˆØ—’Ñ"Ô"Ð#ˆå�q˜!‘”ð 	Rð 	RˆAØ—’ qÑ)Ô)ˆHØ”< (Ñ*ˆCØ�LŠL�˜s 2 A 2œw˜¨4¬=¸¸1¹Ô+=Ñ=ÀÄÇÂÈaÑ@PÔ@PÑPÑQÔQÐQÐQå�Eˆ{ÐrW   N)
r  r  r  r  r)  r“  r.  rj   rš  r£  re   rW   rU   r|  r|  š  s�   € € € € € ðð ð*?ð ?ð ?ð ðð ñ „Xðð
 ð=ð =ñ „Xð=ð ð=ð =ñ „Xð=ð*ð *ð *ð *ð *rW   r|  Nc           
      ó  — t          | ¦  «        } |€B| j        }t          |¦  «        dk    r|                     ¦   «         }n|s| S t	          d¦  «        ‚t          | |||||||¦  «        }	|	€| S t          | ||||	¦  «        S )aå  
    Generates Formal Power Series of ``f``.

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

    Returns the formal series expansion of ``f`` around ``x = x0``
    with respect to ``x`` in the form of a ``FormalPowerSeries`` object.

    Formal Power Series is represented using an explicit formula
    computed using different algorithms.

    See :func:`compute_fps` for the more details regarding the computation
    of formula.

    Parameters
    ==========

    x : Symbol, optional
        If x is None and ``f`` is univariate, the univariate symbols will be
        supplied, otherwise an error will be raised.
    x0 : number, optional
        Point to perform series expansion about. Default is 0.
    dir : {1, -1, '+', '-'}, optional
        If dir is 1 or '+' the series is calculated from the right and
        for -1 or '-' the series is calculated from the left. For smooth
        functions this flag will not alter the results. Default is 1.
    hyper : {True, False}, optional
        Set hyper to False to skip the hypergeometric algorithm.
        By default it is set to False.
    order : int, optional
        Order of the derivative of ``f``, Default is 4.
    rational : {True, False}, optional
        Set rational to False to skip rational algorithm. By default it is set
        to True.
    full : {True, False}, optional
        Set full to True to increase the range of rational algorithm.
        See :func:`rational_algorithm` for details. By default it is set to
        False.

    Examples
    ========

    >>> from sympy import fps, ln, atan, sin
    >>> from sympy.abc import x, n

    Rational Functions

    >>> fps(ln(1 + x)).truncate()
    x - x**2/2 + x**3/3 - x**4/4 + x**5/5 + O(x**6)

    >>> fps(atan(x), full=True).truncate()
    x - x**3/3 + x**5/5 + O(x**6)

    Symbolic Functions

    >>> fps(x**n*sin(x**2), x).truncate(8)
    -x**(n + 6)/6 + x**(n + 2) + O(x**(n + 8))

    See Also
    ========

    sympy.series.formal.FormalPowerSeries
    sympy.series.formal.compute_fps
    Nr,   z multivariate formal power series)r   rÞ   ru   r@   r   r  r  )
rD   rE   r  r  r  rG   r  r-   ÚfreerÍ   s
             rU   ÚfpsrÄ  õ  s’   € õD 	�‰
Œ
€Aà€yØŒ~ˆÝˆt‰9Œ9˜Š>ˆ>Ø—’‘
”
ˆAˆAØð 	JØˆHå%Ð&HÑIÔIÐIå˜˜A˜r 3¨¨u°hÀÑEÔE€Fà€~Øˆå˜Q  2 s¨FÑ3Ô3Ð3rW   )r&   F)r&   )r   r,   Tr&   TF)Nr   r,   Tr&   TF)Xr  Úcollectionsr   Úsympy.core.numbersr   r   r   Úsympy.core.addr   Úsympy.core.exprr   Úsympy.core.functionr	   r
   r   Úsympy.core.mulr   r   Úsympy.core.relationalr   Úsympy.sets.setsr   Úsympy.core.singletonr   Úsympy.core.symbolr   r   r   r   Úsympy.core.sympifyr   Úsympy.discrete.convolutionsr   Ú(sympy.functions.combinatorial.factorialsr   r   r   Ú%sympy.functions.combinatorial.numbersr   Ú#sympy.functions.elementary.integersr   r   r   Ú(sympy.functions.elementary.miscellaneousr   r   Ú$sympy.functions.elementary.piecewiser    Úsympy.series.limitsr!   Úsympy.series.orderr"   Úsympy.series.sequencesr#   Úsympy.series.series_classr$   Úsympy.utilities.iterablesr%   rV   r_   r}   r„   r‹   r‘   r”   r—   r�   r¡   r¦   r¶   r¾   rÑ   rÙ   rà   râ   rê   rî   rñ   rô   rþ   r  r   r  r•  ro  ry  r|  rÄ  re   rW   rU   ú<module>rÛ     sÑ  ðØ Ð à #Ð #Ð #Ð #Ð #Ð #à -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ð -Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  Ø <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ø Ð Ð Ð Ð Ð Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø $Ð $Ð $Ð $Ð $Ð $Ø $Ð $Ð $Ð $Ð $Ð $Ø "Ð "Ð "Ð "Ð "Ð "Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ø &Ð &Ð &Ð &Ð &Ð &Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ LÐ LØ 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DØ =Ð =Ð =Ð =Ð =Ð =Ð =Ð =Ø :Ð :Ð :Ð :Ð :Ð :Ø %Ð %Ð %Ð %Ð %Ð %Ø $Ð $Ð $Ð $Ð $Ð $Ø +Ð +Ð +Ð +Ð +Ð +Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø .Ð .Ð .Ð .Ð .Ð .ðGð Gð Gð GðTð ð ðD*2ð *2ð *2ð *2ðZ/ð /ð /ðd5 ð 5 ð 5 ðpð ð ðð ð ðð ð ð6ð 6ð 6ð6ð 6ð 6ð"ð "ð "ð
ð ð ð:Dð Dð DðNVð Vð Vðr7ð 7ð 7ð4ð 4ð 4ð.%ð %ð %ð$ð ð ð6ð ð ð(5ð 5ð 5ðp2ð 2ð 2ð 2ðj\ð \ð \ð~ BFØðHEð HEð HEð HEðV!ð !ð !ð !ð !ˆHñ !ô !ð !ðI#ð I#ð I#ð I#ð I#˜
ñ I#ô I#ð I#ðX0"ð 0"ð 0"ð 0"ð 0"Ð/ñ 0"ô 0"ð 0"ðfCð Cð Cð Cð CÐ6ñ Cô Cð CðLJð Jð Jð Jð JÐ6ñ Jô Jð JðZXð Xð Xð Xð XÐ6ñ Xô Xð XðvR4ð R4ð R4ð R4ð R4ð R4rW   