403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.156
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/sympy/series/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/sympy/series/__pycache__/sequences.cpython-310.pyc
o

�8Va��@s�ddlmZddlmZddlmZmZmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZmZddlmZmZmZdd
lmZddlm Z m!Z!ddl"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,Gdd�de�Z-Gdd�de-ed�Z.Gdd�de-�Z/Gdd�de/�Z0Gdd�de/�Z1Gdd �d e-�Z2d*d"d#�Z3Gd$d%�d%e-�Z4Gd&d'�d'e4�Z5Gd(d)�d)e4�Z6d!S)+�)�Basic)�cacheit)�is_sequence�iterable�ordered)�Tuple)�call_highest_priority)�global_parameters)�AppliedUndef��Mul)�Integer)�Eq)�S�	Singleton)�Dummy�Symbol�Wild��sympify)�lcm�factor)�Interval�Intersection)�simplify)�Idx)�flatten)�expandc@seZdZdZdZdZedd��Zdd�Ze	dd	��Z
e	d
d��Ze	dd
��Ze	dd��Z
e	dd��Ze	dd��Ze	dd��Zedd��Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zed$�d%d&��Zd'd(�Zed)�d*d+��Zd,d-�Zd.d/�Zed0�d1d2��Zd3d4�Z d5d6�Z!d:d8d9�Z"d7S);�SeqBasezBase class for sequencesT�c
Cs.z|j}W|Stttfytj}Y|Sw)z[Return start (if possible) else S.Infinity.

        adapted from Set._infimum_key
        )�start�NotImplementedError�AttributeError�
ValueErrorr�Infinity)�exprr �r&�8/usr/lib/python3/dist-packages/sympy/series/sequences.py�
_start_key!s�
��zSeqBase._start_keycCst|j|j�}|j|jfS)zTReturns start and stop.

        Takes intersection over the two intervals.
        )r�interval�inf�sup)�self�otherr)r&r&r'�_intersect_interval.szSeqBase._intersect_intervalcC�td|��)z&Returns the generator for the sequencez(%s).gen�r!�r,r&r&r'�gen6�zSeqBase.gencCr/)z-The interval on which the sequence is definedz
(%s).intervalr0r1r&r&r'r);r3zSeqBase.intervalcCr/)�:The starting point of the sequence. This point is includedz
(%s).startr0r1r&r&r'r @r3z
SeqBase.startcCr/)z8The ending point of the sequence. This point is includedz	(%s).stopr0r1r&r&r'�stopEr3zSeqBase.stopcCr/)zLength of the sequencez(%s).lengthr0r1r&r&r'�lengthJr3zSeqBase.lengthcC�dS)z-Returns a tuple of variables that are boundedr&r&r1r&r&r'�	variablesOszSeqBase.variablescs�fdd��jD�S)aG
        This method returns the symbols in the object, excluding those
        that take on a specific value (i.e. the dummy symbols).

        Examples
        ========

        >>> from sympy import SeqFormula
        >>> from sympy.abc import n, m
        >>> SeqFormula(m*n**2, (n, 0, 5)).free_symbols
        {m}
        cs$h|]}|j��j�D]}|�qqSr&)�free_symbols�
differencer8)�.0�i�jr1r&r'�	<setcomp>bs�z'SeqBase.free_symbols.<locals>.<setcomp>��argsr1r&r1r'r9TszSeqBase.free_symbolscCs0||jks
||jkrtd||jf��|�|�S)z#Returns the coefficient at point ptzIndex %s out of bounds %s)r r5�
IndexErrorr)�_eval_coeff�r,�ptr&r&r'�coeffes
z
SeqBase.coeffcCstd|j��)NzhThe _eval_coeff method should be added to%s to return coefficient so it is availablewhen coeff calls it.)r!�funcrCr&r&r'rBls�zSeqBase._eval_coeffcCs<|jtjur
|j}n|j}|jtjurd}nd}|||S)a�Returns the i'th point of a sequence.

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

        If start point is negative infinity, point is returned from the end.
        Assumes the first point to be indexed zero.

        Examples
        =========

        >>> from sympy import oo
        >>> from sympy.series.sequences import SeqPer

        bounded

        >>> SeqPer((1, 2, 3), (-10, 10))._ith_point(0)
        -10
        >>> SeqPer((1, 2, 3), (-10, 10))._ith_point(5)
        -5

        End is at infinity

        >>> SeqPer((1, 2, 3), (0, oo))._ith_point(5)
        5

        Starts at negative infinity

        >>> SeqPer((1, 2, 3), (-oo, 0))._ith_point(5)
        -5
        ����)r r�NegativeInfinityr5)r,r<�initial�stepr&r&r'�
_ith_pointrs zSeqBase._ith_pointcCr7)aI
        Should only be used internally.

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

        self._add(other) returns a new, term-wise added sequence if self
        knows how to add with other, otherwise it returns ``None``.

        ``other`` should only be a sequence object.

        Used within :class:`SeqAdd` class.
        Nr&�r,r-r&r&r'�_add��zSeqBase._addcCr7)aS
        Should only be used internally.

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

        self._mul(other) returns a new, term-wise multiplied sequence if self
        knows how to multiply with other, otherwise it returns ``None``.

        ``other`` should only be a sequence object.

        Used within :class:`SeqMul` class.
        Nr&rMr&r&r'�_mul�rOzSeqBase._mulcCs
t||�S)a�
        Should be used when ``other`` is not a sequence. Should be
        defined to define custom behaviour.

        Examples
        ========

        >>> from sympy import SeqFormula
        >>> from sympy.abc import n
        >>> SeqFormula(n**2).coeff_mul(2)
        SeqFormula(2*n**2, (n, 0, oo))

        Notes
        =====

        '*' defines multiplication of sequences with sequences only.
        rrMr&r&r'�	coeff_mul�s
zSeqBase.coeff_mulcC�$t|t�s
tdt|���t||�S)a4Returns the term-wise addition of 'self' and 'other'.

        ``other`` should be a sequence.

        Examples
        ========

        >>> from sympy import SeqFormula
        >>> from sympy.abc import n
        >>> SeqFormula(n**2) + SeqFormula(n**3)
        SeqFormula(n**3 + n**2, (n, 0, oo))
        zcannot add sequence and %s��
isinstancer�	TypeError�type�SeqAddrMr&r&r'�__add__�s


zSeqBase.__add__rXcCs||S�Nr&rMr&r&r'�__radd__��zSeqBase.__radd__cCs&t|t�s
tdt|���t||�S)a7Returns the term-wise subtraction of ``self`` and ``other``.

        ``other`` should be a sequence.

        Examples
        ========

        >>> from sympy import SeqFormula
        >>> from sympy.abc import n
        >>> SeqFormula(n**2) - (SeqFormula(n))
        SeqFormula(n**2 - n, (n, 0, oo))
        zcannot subtract sequence and %srSrMr&r&r'�__sub__�s

zSeqBase.__sub__r\cCs
||SrYr&rMr&r&r'�__rsub__��
zSeqBase.__rsub__cCs
|�d�S)z�Negates the sequence.

        Examples
        ========

        >>> from sympy import SeqFormula
        >>> from sympy.abc import n
        >>> -SeqFormula(n**2)
        SeqFormula(-n**2, (n, 0, oo))
        rG)rQr1r&r&r'�__neg__�s
zSeqBase.__neg__cCrR)a{Returns the term-wise multiplication of 'self' and 'other'.

        ``other`` should be a sequence. For ``other`` not being a
        sequence see :func:`coeff_mul` method.

        Examples
        ========

        >>> from sympy import SeqFormula
        >>> from sympy.abc import n
        >>> SeqFormula(n**2) * (SeqFormula(n))
        SeqFormula(n**3, (n, 0, oo))
        zcannot multiply sequence and %s)rTrrUrV�SeqMulrMr&r&r'�__mul__	s

zSeqBase.__mul__racCs||SrYr&rMr&r&r'�__rmul__r[zSeqBase.__rmul__ccs,�t|j�D]
}|�|�}|�|�VqdSrY)�ranger6rLrE)r,r<rDr&r&r'�__iter__s
�
�zSeqBase.__iter__cstt|t�r��|�}��|�St|t�r8|j|j}}|dur!d}|dur(�j}�fdd�t|||j	p4d�D�SdS)Nrcsg|]
}����|���qSr&)rErL)r;r<r1r&r'�
<listcomp>.�z'SeqBase.__getitem__.<locals>.<listcomp>rH)
rT�intrLrE�slicer r5r6rcrK)r,�indexr r5r&r1r'�__getitem__$s




��zSeqBase.__getitem__NcCs(ddlm}dd�|d|�D�}t|�}|dur|d}nt||d�}g}td|d�D]r}	d|	}
g}t|	�D]
}|�||||	��q:||�}
|
��dkr�t|
�|||	|
����}||
krnt	|ddd��}n3g}t|	||	�D]
}|�||||	��qw||�}
|
||||
d��kr�t	|ddd��}nq.|dur�|St|�}	|	dkr�gdfS||	d||	dd||	d||	}}t|	d�D]5}|||||7}t|	|d�D]}||||||||d8}q�|||||d8}q�|tt
|�t
|��fS)	a�
        Finds the shortest linear recurrence that satisfies the first n
        terms of sequence of order `\leq` ``n/2`` if possible.
        If ``d`` is specified, find shortest linear recurrence of order
        `\leq` min(d, n/2) if possible.
        Returns list of coefficients ``[b(1), b(2), ...]`` corresponding to the
        recurrence relation ``x(n) = b(1)*x(n-1) + b(2)*x(n-2) + ...``
        Returns ``[]`` if no recurrence is found.
        If gfvar is specified, also returns ordinary generating function as a
        function of gfvar.

        Examples
        ========

        >>> from sympy import sequence, sqrt, oo, lucas
        >>> from sympy.abc import n, x, y
        >>> sequence(n**2).find_linear_recurrence(10, 2)
        []
        >>> sequence(n**2).find_linear_recurrence(10)
        [3, -3, 1]
        >>> sequence(2**n).find_linear_recurrence(10)
        [2]
        >>> sequence(23*n**4+91*n**2).find_linear_recurrence(10)
        [5, -10, 10, -5, 1]
        >>> sequence(sqrt(5)*(((1 + sqrt(5))/2)**n - (-(1 + sqrt(5))/2)**(-n))/5).find_linear_recurrence(10)
        [1, 1]
        >>> sequence(x+y*(-2)**(-n), (n, 0, oo)).find_linear_recurrence(30)
        [1/2, 1/2]
        >>> sequence(3*5**n + 12).find_linear_recurrence(20,gfvar=x)
        ([6, -5], 3*(5 - 21*x)/((x - 1)*(5*x - 1)))
        >>> sequence(lucas(n)).find_linear_recurrence(15,gfvar=x)
        ([1, 1], (x - 2)/(x**2 + x - 1))
        r)�MatrixcSsg|]}tt|���qSr&)rr)r;�tr&r&r'reTsz2SeqBase.find_linear_recurrence.<locals>.<listcomp>N�rHrG)�sympy.matricesrk�len�minrc�append�detr�LUsolverr)r,�n�d�gfvarrk�x�lx�r�coeffs�l�l2�mlist�k�m�yr<r=r&r&r'�find_linear_recurrence1sL"
�2&zSeqBase.find_linear_recurrence)NN)#�__name__�
__module__�__qualname__�__doc__�is_commutative�_op_priority�staticmethodr(r.�propertyr2r)r r5r6r8r9rrErBrLrNrPrQrXrrZr\r]r_rarbrdrjr�r&r&r&r'rsR








,




rc@s8eZdZdZedd��Zedd��Zdd�Zdd	�Zd
S)�
EmptySequencea�Represents an empty sequence.

    The empty sequence is also available as a singleton as
    ``S.EmptySequence``.

    Examples
    ========

    >>> from sympy import EmptySequence, SeqPer
    >>> from sympy.abc import x
    >>> EmptySequence
    EmptySequence
    >>> SeqPer((1, 2), (x, 0, 10)) + EmptySequence
    SeqPer((1, 2), (x, 0, 10))
    >>> SeqPer((1, 2)) * EmptySequence
    EmptySequence
    >>> EmptySequence.coeff_mul(-1)
    EmptySequence
    cC�tjSrY)r�EmptySetr1r&r&r'r)��zEmptySequence.intervalcCr�rY)r�Zeror1r&r&r'r6�r�zEmptySequence.lengthcCs|S)�"See docstring of SeqBase.coeff_mulr&)r,rEr&r&r'rQ�szEmptySequence.coeff_mulcCstg�SrY)�iterr1r&r&r'rd�szEmptySequence.__iter__N)	r�r�r�r�r�r)r6rQrdr&r&r&r'r�|s

r�)�	metaclassc@�XeZdZdZedd��Zedd��Zedd��Zedd	��Zed
d��Z	edd
��Z
dS)�SeqExpra�Sequence expression class.

    Various sequences should inherit from this class.

    Examples
    ========

    >>> from sympy.series.sequences import SeqExpr
    >>> from sympy.abc import x
    >>> s = SeqExpr((1, 2, 3), (x, 0, 10))
    >>> s.gen
    (1, 2, 3)
    >>> s.interval
    Interval(0, 10)
    >>> s.length
    11

    See Also
    ========

    sympy.series.sequences.SeqPer
    sympy.series.sequences.SeqFormula
    cC�
|jdS�Nrr?r1r&r&r'r2�r^zSeqExpr.gencCst|jdd|jdd�S)NrHrm)rr@r1r&r&r'r)�szSeqExpr.intervalcC�|jjSrY�r)r*r1r&r&r'r �r[z
SeqExpr.startcCr�rY�r)r+r1r&r&r'r5�r[zSeqExpr.stopcC�|j|jdS�NrH�r5r r1r&r&r'r6��zSeqExpr.lengthcCs|jddfS)NrHrr?r1r&r&r'r8�r�zSeqExpr.variablesN)r�r�r�r�r�r2r)r r5r6r8r&r&r&r'r��s




r�c@sReZdZdZddd�Zedd��Zedd��Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)�SeqPera�
    Represents a periodic sequence.

    The elements are repeated after a given period.

    Examples
    ========

    >>> from sympy import SeqPer, oo
    >>> from sympy.abc import k

    >>> s = SeqPer((1, 2, 3), (0, 5))
    >>> s.periodical
    (1, 2, 3)
    >>> s.period
    3

    For value at a particular point

    >>> s.coeff(3)
    1

    supports slicing

    >>> s[:]
    [1, 2, 3, 1, 2, 3]

    iterable

    >>> list(s)
    [1, 2, 3, 1, 2, 3]

    sequence starts from negative infinity

    >>> SeqPer((1, 2, 3), (-oo, 0))[0:6]
    [1, 2, 3, 1, 2, 3]

    Periodic formulas

    >>> SeqPer((k, k**2, k**3), (k, 0, oo))[0:6]
    [0, 1, 8, 3, 16, 125]

    See Also
    ========

    sympy.series.sequences.SeqFormula
    NcCs"t|�}dd�}d\}}}|dur||�dtj}}}t|t�r;t|�dkr-|\}}}nt|�dkr;||�}|\}}t|ttf�rJ|dusJ|durRt	dt
|���|tjur`|tjur`t	d��t|||f�}t|t�ruttt
|���}nt	d	|��t|d
|d�tjur�tjSt�|||�S)NcSs$|j}t|j�dkr|��Std�S)NrHr~)r9ro�popr)�
periodical�freer&r&r'�_find_xszSeqPer.__new__.<locals>._find_x�NNNr�rm�Invalid limits given: %sz/Both the start and end valuecannot be unboundedz6invalid period %s should be something like e.g (1, 2) rH)rrr$rrrorTrrr#�strrI�tuplerrr�r�r�__new__)�clsr��limitsr�rwr r5r&r&r'r�s0


�zSeqPer.__new__cCs
t|j�SrY)ror2r1r&r&r'�period,r^z
SeqPer.periodcC�|jSrY�r2r1r&r&r'r�0r�zSeqPer.periodicalcCsF|jtjur|j||j}n||j|j}|j|�|jd|�Sr�)r rrIr5r�r��subsr8)r,rD�idxr&r&r'rB4szSeqPer._eval_coeffc
Cs�t|t�rF|j|j}}|j|j}}t||�}g}t|�D]}|||}	|||}
|�|	|
�q|�|�\}}t||jd||f�SdS�zSee docstring of SeqBase._addrN�	rTr�r�r�rrcrqr.r8�
r,r-�per1�lper1�per2�lper2�
per_length�new_perrw�ele1�ele2r r5r&r&r'rN;�

�zSeqPer._addc
Cs�t|t�rF|j|j}}|j|j}}t||�}g}t|�D]}|||}	|||}
|�|	|
�q|�|�\}}t||jd||f�SdS�zSee docstring of SeqBase._mulrNr�r�r&r&r'rPLr�zSeqPer._mulcs,t����fdd�|jD�}t||jd�S)r�csg|]}|��qSr&r&�r;rw�rEr&r're`sz$SeqPer.coeff_mul.<locals>.<listcomp>rH)rr�r�r@)r,rE�perr&r�r'rQ]szSeqPer.coeff_mulrY)r�r�r�r�r�r�r�r�rBrNrPrQr&r&r&r'r��s
0(

r�c@sNeZdZdZddd�Zedd��Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)�
SeqFormulaaf
    Represents sequence based on a formula.

    Elements are generated using a formula.

    Examples
    ========

    >>> from sympy import SeqFormula, oo, Symbol
    >>> n = Symbol('n')
    >>> s = SeqFormula(n**2, (n, 0, 5))
    >>> s.formula
    n**2

    For value at a particular point

    >>> s.coeff(3)
    9

    supports slicing

    >>> s[:]
    [0, 1, 4, 9, 16, 25]

    iterable

    >>> list(s)
    [0, 1, 4, 9, 16, 25]

    sequence starts from negative infinity

    >>> SeqFormula(n**2, (-oo, 0))[0:6]
    [0, 1, 4, 9, 16, 25]

    See Also
    ========

    sympy.series.sequences.SeqPer
    NcCs�t|�}dd�}d\}}}|dur||�dtj}}}t|t�r;t|�dkr-|\}}}nt|�dkr;||�}|\}}t|ttf�rJ|dusJ|durRt	dt
|���|tjur`|tjur`t	d��t|||f�}t|d	|d�tj
urvtjSt�|||�S)
NcSs2|j}t|�dkr
|��S|std�Std|��)NrHr~z� specify dummy variables for %s. If the formula contains more than one free symbol, a dummy variable should be supplied explicitly e.g., SeqFormula(m*n**2, (n, 0, 5)))r9ror�rr#)�formular�r&r&r'r��s��z#SeqFormula.__new__.<locals>._find_xr�rr�rmr�z0Both the start and end value cannot be unboundedrH)rrr$rrrorTrrr#r�rIrr�r�rr�)r�r�r�r�rwr r5r&r&r'r��s&


zSeqFormula.__new__cCr�rYr�r1r&r&r'r��r�zSeqFormula.formulacCs|jd}|j�||�Sr�)r8r�r�)r,rDrur&r&r'rB�s
zSeqFormula._eval_coeffc	Cs`t|t�r.|j|jd}}|j|jd}}||�||�}|�|�\}}t||||f�SdSr��rTr�r�r8r�r.�	r,r-�form1�v1�form2�v2r�r r5r&r&r'rN��
�zSeqFormula._addc	Cs`t|t�r.|j|jd}}|j|jd}}||�||�}|�|�\}}t||||f�SdSr�r�r�r&r&r'rP�r�zSeqFormula._mulcCs"t|�}|j|}t||jd�S)r�rH)rr�r�r@)r,rEr�r&r&r'rQ�s
zSeqFormula.coeff_mulcOs$tt|jg|�Ri|��|jd�Sr�)r�rr�r@)r,r@�kwargsr&r&r'r�s$zSeqFormula.expandrY)r�r�r�r�r�r�r�rBrNrPrQrr&r&r&r'r�ds
('
		r�c@s�eZdZdZddd�Zedd��Zedd	��Zed
d��Zedd
��Z	edd��Z
edd��Zedd��Zedd��Z
edd��Zdd�Zdd�ZdS)�RecursiveSeqa�
    A finite degree recursive sequence.

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

    That is, a sequence a(n) that depends on a fixed, finite number of its
    previous values. The general form is

        a(n) = f(a(n - 1), a(n - 2), ..., a(n - d))

    for some fixed, positive integer d, where f is some function defined by a
    SymPy expression.

    Parameters
    ==========

    recurrence : SymPy expression defining recurrence
        This is *not* an equality, only the expression that the nth term is
        equal to. For example, if :code:`a(n) = f(a(n - 1), ..., a(n - d))`,
        then the expression should be :code:`f(a(n - 1), ..., a(n - d))`.

    yn : applied undefined function
        Represents the nth term of the sequence as e.g. :code:`y(n)` where
        :code:`y` is an undefined function and `n` is the sequence index.

    n : symbolic argument
        The name of the variable that the recurrence is in, e.g., :code:`n` if
        the recurrence function is :code:`y(n)`.

    initial : iterable with length equal to the degree of the recurrence
        The initial values of the recurrence.

    start : start value of sequence (inclusive)

    Examples
    ========

    >>> from sympy import Function, symbols
    >>> from sympy.series.sequences import RecursiveSeq
    >>> y = Function("y")
    >>> n = symbols("n")
    >>> fib = RecursiveSeq(y(n - 1) + y(n - 2), y(n), n, [0, 1])

    >>> fib.coeff(3) # Value at a particular point
    2

    >>> fib[:6] # supports slicing
    [0, 1, 1, 2, 3, 5]

    >>> fib.recurrence # inspect recurrence
    Eq(y(n), y(n - 2) + y(n - 1))

    >>> fib.degree # automatically determine degree
    2

    >>> for x in zip(range(10), fib): # supports iteration
    ...     print(x)
    (0, 0)
    (1, 1)
    (2, 1)
    (3, 2)
    (4, 3)
    (5, 5)
    (6, 8)
    (7, 13)
    (8, 21)
    (9, 34)

    See Also
    ========

    sympy.series.sequences.SeqFormula

    Nrcs\t|t�std�|���t|t�r|jstd�|���|j|fkr%td��|j�td|fd�}d}|�	��}|D]3}	t
|	j�dkrEtd��|	jd�||�|}
|
��r\|
j
r\|
dksctd	�|	���|
|krk|
}q8|swd
d�t|�D�}t
|�|kr�td��t|�}t���td
d�|D��}t�|||||��}��fdd�t|�D�|_||_|S)NzErecurrence sequence must be an applied undefined function, found `{}`z0recurrence variable must be a symbol, found `{}`z)recurrence sequence does not match symbolr~)�excluderrHz)Recurrence should be in a single variablezDRecurrence should have constant, negative, integer shifts (found {})cSsg|]	}td�|���qS)zc_{})r�format)r;r~r&r&r'reH�z(RecursiveSeq.__new__.<locals>.<listcomp>z)Number of initial terms must equal degreecss�|]}t|�VqdSrYrr�r&r&r'�	<genexpr>Ps�z'RecursiveSeq.__new__.<locals>.<genexpr>csi|]\}}��|�|�qSr&r&)r;r~�init�r r�r&r'�
<dictcomp>Tsz(RecursiveSeq.__new__.<locals>.<dictcomp>)rTr
rUr�r�	is_symbolr@rFr�findro�match�is_constant�
is_integerrcr#r
rrr��	enumerate�cache�degree)r��
recurrence�ynrtrJr r~r��prev_ys�prev_y�shift�seqr&r�r'r�$sH
��
�
�zRecursiveSeq.__new__cCr��zEquation defining recurrence.rr?r1r&r&r'�_recurrenceY�
zRecursiveSeq._recurrencecCst|j|jd�Sr�)rr�r@r1r&r&r'r�^szRecursiveSeq.recurrencecCr�)z*Applied function representing the nth termrHr?r1r&r&r'r�cr�zRecursiveSeq.yncCr�)z3Undefined function for the nth term of the sequence)r�rFr1r&r&r'r�hszRecursiveSeq.ycCr�)zSequence index symbolrmr?r1r&r&r'rtmr�zRecursiveSeq.ncCr�)z"The initial values of the sequencer�r?r1r&r&r'rJrr�zRecursiveSeq.initialcCr�)r4�r?r1r&r&r'r wr�zRecursiveSeq.startcCr�)z&The ending point of the sequence. (oo))rr$r1r&r&r'r5|szRecursiveSeq.stopcCs|jtjfS)z&Interval on which sequence is defined.)r rr$r1r&r&r'r)�r3zRecursiveSeq.intervalcCs�||jt|j�kr|j|�|�Stt|j�|d�D]}|j|}|j�|j|i�}|�|j�}||j|�|�<q|j|�|j|�Sr�)r ror�r�rcr��xreplacert)r,ri�current�	seq_index�current_recurrence�new_termr&r&r'rB�s
zRecursiveSeq._eval_coeffccs �|j}	|�|�V|d7}q)NTrH)r rB)r,rir&r&r'rd�s��zRecursiveSeq.__iter__r�)r�r�r�r�r�r�r�r�r�r�rtrJr r5r)rBrdr&r&r&r'r��s.
L5








r�NcCs&t|�}t|t�rt||�St||�S)a
    Returns appropriate sequence object.

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

    If ``seq`` is a sympy sequence, returns :class:`SeqPer` object
    otherwise returns :class:`SeqFormula` object.

    Examples
    ========

    >>> from sympy import sequence
    >>> from sympy.abc import n
    >>> sequence(n**2, (n, 0, 5))
    SeqFormula(n**2, (n, 0, 5))
    >>> sequence((1, 2, 3), (n, 0, 5))
    SeqPer((1, 2, 3), (n, 0, 5))

    See Also
    ========

    sympy.series.sequences.SeqPer
    sympy.series.sequences.SeqFormula
    )rrrr�r�)r�r�r&r&r'�sequence�s


r�c@r�)�	SeqExprOpa�
    Base class for operations on sequences.

    Examples
    ========

    >>> from sympy.series.sequences import SeqExprOp, sequence
    >>> from sympy.abc import n
    >>> s1 = sequence(n**2, (n, 0, 10))
    >>> s2 = sequence((1, 2, 3), (n, 5, 10))
    >>> s = SeqExprOp(s1, s2)
    >>> s.gen
    (n**2, (1, 2, 3))
    >>> s.interval
    Interval(5, 10)
    >>> s.length
    6

    See Also
    ========

    sympy.series.sequences.SeqAdd
    sympy.series.sequences.SeqMul
    cCstdd�|jD��S)zjGenerator for the sequence.

        returns a tuple of generators of all the argument sequences.
        cs��|]}|jVqdSrYr��r;�ar&r&r'r����z SeqExprOp.gen.<locals>.<genexpr>)r�r@r1r&r&r'r2�sz
SeqExprOp.gencCstdd�|jD��S)zeSequence is defined on the intersection
        of all the intervals of respective sequences
        csr�rY�r)r�r&r&r'r��r�z%SeqExprOp.interval.<locals>.<genexpr>)rr@r1r&r&r'r)�szSeqExprOp.intervalcCr�rYr�r1r&r&r'r �r[zSeqExprOp.startcCr�rYr�r1r&r&r'r5�r[zSeqExprOp.stopcCsttdd�|jD���S)z%Cumulative of all the bound variablescSsg|]}|j�qSr&)r8r�r&r&r're�sz'SeqExprOp.variables.<locals>.<listcomp>)r�rr@r1r&r&r'r8�szSeqExprOp.variablescCr�r�r�r1r&r&r'r6�r�zSeqExprOp.lengthN)r�r�r�r�r�r2r)r r5r8r6r&r&r&r'r��s




r�c@�,eZdZdZdd�Zedd��Zdd�ZdS)	rWa�Represents term-wise addition of sequences.

    Rules:
        * The interval on which sequence is defined is the intersection
          of respective intervals of sequences.
        * Anything + :class:`EmptySequence` remains unchanged.
        * Other rules are defined in ``_add`` methods of sequence classes.

    Examples
    ========

    >>> from sympy import EmptySequence, oo, SeqAdd, SeqPer, SeqFormula
    >>> from sympy.abc import n
    >>> SeqAdd(SeqPer((1, 2), (n, 0, oo)), EmptySequence)
    SeqPer((1, 2), (n, 0, oo))
    >>> SeqAdd(SeqPer((1, 2), (n, 0, 5)), SeqPer((1, 2), (n, 6, 10)))
    EmptySequence
    >>> SeqAdd(SeqPer((1, 2), (n, 0, oo)), SeqFormula(n**2, (n, 0, oo)))
    SeqAdd(SeqFormula(n**2, (n, 0, oo)), SeqPer((1, 2), (n, 0, oo)))
    >>> SeqAdd(SeqFormula(n**3), SeqFormula(n**2))
    SeqFormula(n**3 + n**2, (n, 0, oo))

    See Also
    ========

    sympy.series.sequences.SeqMul
    cs�|�dtj�}t|�}�fdd���|�}dd�|D�}|s!tjStdd�|D��tjur0tjS|r7t�	|�Stt
|tj��}t
j|g|�R�S)N�evaluatec�Lt|t�rt|t�rtt�|j�g�S|gSt|�r"tt�|�g�Std���Nz2Input must be Sequences or  iterables of Sequences)rTrrW�sum�mapr@rrU��arg��_flattenr&r'r�!�

z SeqAdd.__new__.<locals>._flattencSsg|]	}|tjur|�qSr&)rr�r�r&r&r're-r�z"SeqAdd.__new__.<locals>.<listcomp>csr�rYr�r�r&r&r'r�3r�z!SeqAdd.__new__.<locals>.<genexpr>)�getr	r��listrr�rr�rW�reducerrr(rr��r�r@r�r�r&r�r'r�s

zSeqAdd.__new__c�d}|r?t|�D]4\}�d}t|�D]#\}�||krq����}|dur5��fdd�|D�}|�|�nq|r<|}nq|st|�dkrI|��St|dd�S)aSimplify :class:`SeqAdd` using known rules.

        Iterates through all pairs and ask the constituent
        sequences if they can simplify themselves with any other constituent.

        Notes
        =====

        adapted from ``Union.reduce``

        TFNc�g|]
}|��fvr|�qSr&r&r���srlr&r'reVrfz!SeqAdd.reduce.<locals>.<listcomp>rH�r�)r�rNrqror�rW�r@�new_args�id1�id2�new_seqr&rr'r�>s*


���z
SeqAdd.reducecst�fdd�|jD��S)z9adds up the coefficients of all the sequences at point ptc3s�|]}|���VqdSrYr�r��rDr&r'r�ds�z%SeqAdd._eval_coeff.<locals>.<genexpr>)r�r@rCr&rr'rBbszSeqAdd._eval_coeffN�r�r�r�r�r�r�r�rBr&r&r&r'rW�s$
#rWc@r�)	r`a'Represents term-wise multiplication of sequences.

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

    Handles multiplication of sequences only. For multiplication
    with other objects see :func:`SeqBase.coeff_mul`.

    Rules:
        * The interval on which sequence is defined is the intersection
          of respective intervals of sequences.
        * Anything \* :class:`EmptySequence` returns :class:`EmptySequence`.
        * Other rules are defined in ``_mul`` methods of sequence classes.

    Examples
    ========

    >>> from sympy import EmptySequence, oo, SeqMul, SeqPer, SeqFormula
    >>> from sympy.abc import n
    >>> SeqMul(SeqPer((1, 2), (n, 0, oo)), EmptySequence)
    EmptySequence
    >>> SeqMul(SeqPer((1, 2), (n, 0, 5)), SeqPer((1, 2), (n, 6, 10)))
    EmptySequence
    >>> SeqMul(SeqPer((1, 2), (n, 0, oo)), SeqFormula(n**2))
    SeqMul(SeqFormula(n**2, (n, 0, oo)), SeqPer((1, 2), (n, 0, oo)))
    >>> SeqMul(SeqFormula(n**3), SeqFormula(n**2))
    SeqFormula(n**5, (n, 0, oo))

    See Also
    ========

    sympy.series.sequences.SeqAdd
    cs�|�dtj�}t|�}�fdd���|�}|stjStdd�|D��tjur)tjS|r0t�	|�Stt
|tj��}t
j|g|�R�S)Nr�cr�r�)rTrr`r�r�r@rrUr�r�r&r'r��r�z SeqMul.__new__.<locals>._flattencsr�rYr�r�r&r&r'r��r�z!SeqMul.__new__.<locals>.<genexpr>)r�r	r�r�rr�rr�r`r�rrr(rr�r�r&r�r'r��s

zSeqMul.__new__cr�)a.Simplify a :class:`SeqMul` using known rules.

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

        Iterates through all pairs and ask the constituent
        sequences if they can simplify themselves with any other constituent.

        Notes
        =====

        adapted from ``Union.reduce``

        TFNcr�r&r&r�rr&r're�rfz!SeqMul.reduce.<locals>.<listcomp>rHr)r�rPrqror�r`rr&rr'r��s*

���z
SeqMul.reducecCs"d}|jD]	}||�|�9}q|S)z<multiplies the coefficients of all the sequences at point ptrH)r@rE)r,rD�valr�r&r&r'rB�s
zSeqMul._eval_coeffNr	r&r&r&r'r`gs""
&r`rY)7�sympy.core.basicr�sympy.core.cacher�sympy.core.compatibilityrrr�sympy.core.containersr�sympy.core.decoratorsr�sympy.core.parametersr	�sympy.core.functionr
�sympy.core.mulr�sympy.core.numbersr
�sympy.core.relationalr�sympy.core.singletonrr�sympy.core.symbolrrr�sympy.core.sympifyr�sympy.polysrr�sympy.sets.setsrr�sympy.simplifyr�sympy.tensor.indexedr�sympy.utilities.iterablesr�sympyrrr�r�r�r�r�r�r�rWr`r&r&r&r'�<module>sBc%2s
F':j

Youez - 2016 - github.com/yon3zu
LinuXploit