ó
    Š*£h×Š  ã                   óÊ  • S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
JrJr  S SKJr  S SKJr  S S	KJr  S S
KJrJr  S SKJr  S SKJrJrJr  S SKJr  S SKJr  S SK J!r!J"r"  S SK#J$r$J%r%  S SK&J'r'  S SK(J)r)J*r*J+r+   " S S\5      r, " S S\,\S9r- " S S\,5      r. " S S\.5      r/ " S S\.5      r0 " S S\,5      r1S(S! jr2 " S" S#\,5      r3 " S$ S%\35      r4 " S& S'\35      r5g ))é    )ÚBasic)Úcacheit)ÚTuple)Úcall_highest_priority)Úglobal_parameters)ÚAppliedUndefÚexpand©ÚMul)ÚInteger)ÚEq)ÚSÚ	Singleton)Úordered)ÚDummyÚSymbolÚWild©Úsympify)ÚMatrix)ÚlcmÚfactor)ÚIntervalÚIntersection)ÚIdx)ÚflattenÚis_sequenceÚiterablec                   óV  • \ rS rSrSrSrSr\S 5       rS r	\
S 5       r\
S 5       r\
S	 5       r\
S
 5       r\
S 5       r\
S 5       r\
S 5       r\S 5       rS rS rS rS rS rS r\" S5      S 5       rS r\" S5      S 5       rS rS r\" S5      S 5       r S r!S r"S#S! jr#S"r$g )$ÚSeqBaseé   zBase class for sequencesTé   c                 ób   •  U R                   nU$ ! [         a    [        R                  n U$ f = f)zKReturn start (if possible) else S.Infinity.

adapted from Set._infimum_key
)ÚstartÚNotImplementedErrorr   ÚInfinity)Úexprr$   s     ÚS/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/series/sequences.pyÚ
_start_keyÚSeqBase._start_key    s6   € ð	Ø—J‘JˆEð ˆøô #ó 	Ü—J‘J‰EØˆð	ús   ‚ �.­.c                 ór   • [        U R                  UR                  5      nUR                  UR                  4$ )zDReturns start and stop.

Takes intersection over the two intervals.
)r   ÚintervalÚinfÚsup)ÚselfÚotherr,   s      r(   Ú_intersect_intervalÚSeqBase._intersect_interval,   s+   € ô
   §¡¨u¯~©~Ó>ˆØ�|‰|˜XŸ\™\Ð)Ð)ó    c                 ó   • [        SU -  5      e)z&Returns the generator for the sequencez(%s).gen©r%   ©r/   s    r(   ÚgenÚSeqBase.gen4   s   € ô " *¨tÑ"3Ó4Ð4r3   c                 ó   • [        SU -  5      e)z-The interval on which the sequence is definedz(%s).intervalr5   r6   s    r(   r,   ÚSeqBase.interval9   s   € ô " /°DÑ"8Ó9Ð9r3   c                 ó   • [        SU -  5      e)ú:The starting point of the sequence. This point is includedz
(%s).startr5   r6   s    r(   r$   ÚSeqBase.start>   s   € ô " ,°Ñ"5Ó6Ð6r3   c                 ó   • [        SU -  5      e)z8The ending point of the sequence. This point is includedz	(%s).stopr5   r6   s    r(   ÚstopÚSeqBase.stopC   s   € ô " +°Ñ"4Ó5Ð5r3   c                 ó   • [        SU -  5      e)zLength of the sequencez(%s).lengthr5   r6   s    r(   ÚlengthÚSeqBase.lengthH   s   € ô " -°$Ñ"6Ó7Ð7r3   c                 ó   • g)z-Returns a tuple of variables that are bounded© rE   r6   s    r(   Ú	variablesÚSeqBase.variablesM   s   € ð r3   c                 ó¢   • U R                    VVs1 s H0  oR                  R                  U R                  5        H  o"iM     M2     snn$ s  snnf )zÿ
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}
)ÚargsÚfree_symbolsÚ
differencerF   )r/   ÚiÚjs      r(   rJ   ÚSeqBase.free_symbolsR   sH   € ð !ŸIšIô 0šI�q¯~©~ß‘J˜tŸ~™~Ó.ó0/¨!’ñ 0/‘™Iò 0ð 	1ùó 0s   �7Ac                 óš   • XR                   :  d  XR                  :”  a  [        SU< SU R                  < 35      eU R	                  U5      $ )z#Returns the coefficient at point ptzIndex z out of bounds )r$   r?   Ú
IndexErrorr,   Ú_eval_coeff©r/   Úpts     r(   ÚcoeffÚSeqBase.coeffc   s:   € ð —
‘
‹?˜b§9¡9›nÝ»BÀÇÃÐNÓOÐOØ×Ñ Ó#Ð#r3   c                 ó2   • [        SU R                  -  5      e)NzhThe _eval_coeff method should be added to%s to return coefficient so it is availablewhen coeff calls it.)r%   ÚfuncrR   s     r(   rQ   ÚSeqBase._eval_coeffj   s"   € Ü!ð #9ð %)§I¡Iñ#.ó /ð 	/r3   c                 óÀ   • U R                   [        R                  L a  U R                  nOU R                   nU R                   [        R                  L a  SnOSnX!U-  -   $ )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   ÚNegativeInfinityr?   )r/   rL   ÚinitialÚsteps       r(   Ú
_ith_pointÚSeqBase._ith_pointp   sR   € ð@ �:‰:œ×+Ñ+Ò+Ø—i‘i‰Gà—j‘jˆGà�:‰:œ×+Ñ+Ò+Ø‰DàˆDà˜4™ÑÐr3   c                 ó   • g)a	  
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.
NrE   ©r/   r0   s     r(   Ú_addÚSeqBase._addœ   ó   € ð r3   c                 ó   • g)a  
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.
NrE   rb   s     r(   Ú_mulÚSeqBase._mul¬   re   r3   c                 ó   • [        X5      $ )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.
r
   rb   s     r(   Ú	coeff_mulÚSeqBase.coeff_mul¼   s   € ô$ �4ÓÐr3   c                 óp   • [        U[        5      (       d  [        S[        U5      -  5      e[	        X5      $ )zôReturns 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))
zcannot add sequence and %s©Ú
isinstancer    Ú	TypeErrorÚtypeÚSeqAddrb   s     r(   Ú__add__ÚSeqBase.__add__Ð   s1   € ô ˜%¤×)Ñ)ÜÐ8¼4À»;ÑFÓGÐGÜ�dÓ"Ð"r3   rr   c                 ó
   • X-   $ ©NrE   rb   s     r(   Ú__radd__ÚSeqBase.__radd__á   ó
   € à‰|Ðr3   c                 ór   • [        U[        5      (       d  [        S[        U5      -  5      e[	        X* 5      $ )z÷Returns 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))
zcannot subtract sequence and %srm   rb   s     r(   Ú__sub__ÚSeqBase.__sub__å   s3   € ô ˜%¤×)Ñ)ÜÐ=ÄÀUÃÑKÓLÐLÜ�d˜FÓ#Ð#r3   rz   c                 ó   • U * U-   $ ru   rE   rb   s     r(   Ú__rsub__ÚSeqBase.__rsub__ö   s   € à�˜‰Ðr3   c                 ó$   • U R                  S5      $ )z›Negates the sequence.

Examples
========

>>> from sympy import SeqFormula
>>> from sympy.abc import n
>>> -SeqFormula(n**2)
SeqFormula(-n**2, (n, 0, oo))
rZ   )rj   r6   s    r(   Ú__neg__ÚSeqBase.__neg__ú   s   € ð �~‰~˜bÓ!Ð!r3   c                 óp   • [        U[        5      (       d  [        S[        U5      -  5      e[	        X5      $ )a3  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))
zcannot multiply sequence and %s)rn   r    ro   rp   ÚSeqMulrb   s     r(   Ú__mul__ÚSeqBase.__mul__  s1   € ô ˜%¤×)Ñ)ÜÐ=ÄÀUÃÑKÓLÐLÜ�dÓ"Ð"r3   r„   c                 ó
   • X-  $ ru   rE   rb   s     r(   Ú__rmul__ÚSeqBase.__rmul__  rx   r3   c              #   óŒ   #   • [        U R                  5       H'  nU R                  U5      nU R                  U5      v •  M)     g 7fru   )ÚrangerB   r_   rT   )r/   rL   rS   s      r(   Ú__iter__ÚSeqBase.__iter__  s4   é € Ü�t—{‘{Ö#ˆAØ—‘ Ó#ˆBØ—*‘*˜R“.Ô ò $ùs   ‚AAc                 ó–  • [        U[        5      (       a"  U R                  U5      nU R                  U5      $ [        U[        5      (       ax  UR
                  UR                  p2Uc  SnUc  U R                  n[        X#UR                  =(       d    S5       Vs/ s H"  o@R                  U R                  U5      5      PM$     sn$ g s  snf )Nr   r[   )
rn   Úintr_   rT   Úslicer$   r?   rB   rŠ   r^   )r/   Úindexr$   r?   rL   s        r(   Ú__getitem__ÚSeqBase.__getitem__"  s©   € Ü�eœS×!Ñ!Ø—O‘O EÓ*ˆEØ—:‘:˜eÓ$Ð$Ü˜œu×%Ñ%ØŸ+™+ u§z¡z�4Ø‰}Ø�Ø‰|Ø—{‘{�ä˜% u§z¡z§°QÔ7ó9Ú7ð 89—J‘J˜tŸ™¨qÓ1Ö2Ù7ñ9ð 9ð &ùò9s   Â)CNc           
      ó  • SSK Jn  U SU  Vs/ s H  oT" [        U5      5      PM     nn[        U5      nUc  US-  nO[	        X'S-  5      n/ n	[        SUS-   5       Hé  n
SU
-  n/ n[        U
5       H  nUR                  XmXÚ-    5        M     [        U5      nUR                  5       S:w  d  MR  U" UR                  [        XjU 5      5      5      nX{:X  a  [        USSS2   5      n	  Oa/ n[        X§U
-
  5       H  nUR                  XmXÚ-    5        M     [        U5      nXï-  [        XkS 5      :X  d  MØ  [        USSS2   5      n	  O   Uc  U	$ [        U	5      n
U
S:X  a  / S4$ XjS-
     X:S-
  -  -  SXšS-
     X:-  -  -
  p![        U
S-
  5       HQ  nXU   UU-  -  -  n[        U
U-
  S-
  5       H  nXU   UU   -  UUU-   S-   -  -  -  nM     X)U   UUS-   -  -  -  nMS     X”" [        U5      [        U5      -  5      4$ s  snf )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   )ÚsimplifyNé   r[   rZ   )Úsympy.simplifyr”   r	   ÚlenÚminrŠ   Úappendr   ÚdetÚLUsolver   r   )r/   ÚnÚdÚgfvarr”   ÚtÚxÚlxÚrÚcoeffsÚlÚl2ÚmlistÚkÚmÚyrL   rM   s                     r(   Úfind_linear_recurrenceÚSeqBase.find_linear_recurrence/  s(  € õD 	,Ø*.¨r°©(Ó3ª( QˆX”f˜Q“iÖ ©(ˆÐ3Ü�‹VˆØ‰9Ø�A‘‰Aä�A˜!‘e“ˆAØˆÜ�q˜!˜A™#–ˆAØ�1‘ˆBØˆEÜ˜1–X�Ø—‘˜Q ¡˜XÖ&ñ ä�u“ˆAØ�u‰u‹w˜!�|Ù˜QŸY™Y¤v¨a°"¨g£Ó7Ó8�Ø“8Ü$ Q¡t¨ t¡WÓ-�FÙØ�Ü˜q A¡ž�AØ—L‘L  Q¡S Ö*ñ 'ä˜5“M�Ø‘3œ&  3 ›.Õ(Ü$ Q¡t¨ t¡WÓ-�FÙñ# ð$ ‰=ØˆMä�F“ˆAØ�A‹vØ˜4�x�à˜1™‘v˜e¨¡c™lÑ*¨A°¸±s±¸E¹HÑ0DÑ,D�1Ü˜q ™sž�AØ˜1™˜e Q™h™Ñ&�AÜ" 1 Q¡3 q¡5ž\˜Ø A™Y q¨¡t™^¨E°A°a±C¸±E©NÑ:Ñ:šñ *à ™ 5¨1¨Q©3¡<Ñ/Ñ/’Añ	 $ð
 ˜x¬¨q«	´&¸³)Ñ(;Ó<Ð<Ð<ùòM 4s   ŽHrE   )NN)%Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úis_commutativeÚ_op_priorityÚstaticmethodr)   r1   Úpropertyr7   r,   r$   r?   rB   rF   rJ   r   rT   rQ   r_   rc   rg   rj   rr   r   rv   rz   r}   r€   r„   r‡   r‹   r‘   rª   Ú__static_attributes__rE   r3   r(   r    r       sO  † Ù"à€NØ€Làñ	ó ð	ò*ð ñ5ó ð5ð ñ:ó ð:ð ñ7ó ð7ð ñ6ó ð6ð ñ8ó ð8ð ñó ðð ñ1ó ð1ð  ñ$ó ð$ò/ò* òXò ò  ò(#ñ" ˜9Ó%ñó &ðò$ñ" ˜9Ó%ñó &ðò"ò#ñ$ ˜9Ó%ñó &ðò!ò
9÷I=r3   r    c                   óD   • \ rS rSrSr\S 5       r\S 5       rS rS r	Sr
g)	ÚEmptySequenceiz  a�  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
c                 ó"   • [         R                  $ ru   )r   ÚEmptySetr6   s    r(   r,   ÚEmptySequence.interval�  s   € ä�z‰zÐr3   c                 ó"   • [         R                  $ ru   )r   ÚZeror6   s    r(   rB   ÚEmptySequence.length“  s   € ä�v‰vˆr3   c                 ó   • U $ )ú"See docstring of SeqBase.coeff_mulrE   )r/   rT   s     r(   rj   ÚEmptySequence.coeff_mul—  s   € àˆr3   c                 ó   • [        / 5      $ ru   )Úiterr6   s    r(   r‹   ÚEmptySequence.__iter__›  s   € Ü�B‹xˆr3   rE   N)r¬   r­   r®   r¯   r°   r´   r,   rB   rj   r‹   rµ   rE   r3   r(   r·   r·   z  s9   † ñð( ñó ðð ñó ðòõr3   r·   )Ú	metaclassc                   óx   • \ rS rSrSr\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       rS	rg
)ÚSeqExpriŸ  a‘  Sequence expression class.

Various sequences should inherit from this class.

Examples
========

>>> from sympy.series.sequences import SeqExpr
>>> from sympy.abc import x
>>> from sympy import Tuple
>>> s = SeqExpr(Tuple(1, 2, 3), Tuple(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
c                 ó    • U R                   S   $ ©Nr   ©rI   r6   s    r(   r7   ÚSeqExpr.gen¹  s   € à�y‰y˜‰|Ðr3   c                 óZ   • [        U R                  S   S   U R                  S   S   5      $ )Nr[   r•   )r   rI   r6   s    r(   r,   ÚSeqExpr.interval½  s'   € ä˜Ÿ	™	 !™ Q™¨¯©°1©°a©Ó9Ð9r3   c                 ó.   • U R                   R                  $ ru   ©r,   r-   r6   s    r(   r$   ÚSeqExpr.startÁ  ó   € à�}‰}× Ñ Ð r3   c                 ó.   • U R                   R                  $ ru   ©r,   r.   r6   s    r(   r?   ÚSeqExpr.stopÅ  rÐ   r3   c                 ó:   • U R                   U R                  -
  S-   $ ©Nr[   ©r?   r$   r6   s    r(   rB   ÚSeqExpr.lengthÉ  ó   € à�y‰y˜4Ÿ:™:Ñ%¨Ñ)Ð)r3   c                 ó(   • U R                   S   S   4$ )Nr[   r   rÉ   r6   s    r(   rF   ÚSeqExpr.variablesÍ  s   € à—	‘	˜!‘˜Q‘Ð!Ð!r3   rE   N)r¬   r­   r®   r¯   r°   r´   r7   r,   r$   r?   rB   rF   rµ   rE   r3   r(   rÆ   rÆ   Ÿ  s   † ñð2 ñó ðð ñ:ó ð:ð ñ!ó ð!ð ñ!ó ð!ð ñ*ó ð*ð ñ"ó ó"r3   rÆ   c                   óZ   • \ rS rSrSrSS jr\S 5       r\S 5       rS r	S r
S	 rS
 rSrg)ÚSeqPeriÒ  aj  
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
Nc                 óì  • [        U5      nS nSu  pEnUc  U" U5      S[        R                  pen[        U[        5      (       a0  [        U5      S:X  a  Uu  pEnO[        U5      S:X  a  U" U5      nUu  pV[        U[        [        45      (       a  Ub  Uc  [        S[        U5      -  5      eU[        R                  L a  U[        R                  L a  [        S5      e[        XEU45      n[        U[        5      (       a  [        [        [        U5      5      5      nO[        SU-  5      e[        US	   US   5      [        R                  L a  [        R                   $ ["        R$                  " XU5      $ )
Nc                 ó‚   • U R                   n[        U R                   5      S:X  a  UR                  5       $ [        S5      $ )Nr[   r§   )rJ   r—   Úpopr   )Ú
periodicalÚfrees     r(   Ú_find_xÚSeqPer.__new__.<locals>._find_x  s6   € Ø×*Ñ*ˆDÜ�:×*Ñ*Ó+¨qÓ0Ø—x‘x“zÐ!ä˜S“zÐ!r3   ©NNNr   é   r•   úInvalid limits given: %sz/Both the start and end valuecannot be unboundedz6invalid period %s should be something like e.g (1, 2) r[   )r   r   r&   r   r   r—   rn   r   r   Ú
ValueErrorÚstrr\   Útupler   r   r¹   r·   r   Ú__new__)Úclsrà   Úlimitsrâ   r    r$   r?   s          r(   rê   ÚSeqPer.__new__  sQ  € Ü˜ZÓ(ˆ
ò	"ð *‰ˆ�$Ø‰>Ù$ ZÓ0°!´Q·Z±Z�dˆAÜ�vœu×%Ñ%Ü�6‹{˜aÓØ!'‘�™$Ü�V“ Ó!Ù˜JÓ'�Ø$‘�ä˜!œf¤c˜]×+Ñ+¨u©}ÀÁÜÐ7¼#¸f»+ÑEÓFÐFà”A×&Ñ&Ò&¨4´1·:±:Ò+=Ü ð "7ó 8ð 8ô ˜! DÐ)Ó*ˆä�z¤5×)Ñ)Ü ¤¤w¨zÓ':Ó!;Ó<‰Jäð 0Ø2<ñ=ó >ð >ô �F˜1‘I˜v a™yÓ)¬Q¯Z©ZÒ7Ü—?‘?Ð"ä�}Š}˜S¨fÓ5Ð5r3   c                 ó,   • [        U R                  5      $ ru   )r—   r7   r6   s    r(   ÚperiodÚSeqPer.period+  s   € ä�4—8‘8‹}Ðr3   c                 ó   • U R                   $ ru   ©r7   r6   s    r(   rà   ÚSeqPer.periodical/  ó   € à�x‰xˆr3   c                 ó  • U R                   [        R                  L a  U R                  U-
  U R                  -  nOXR                   -
  U R                  -  nU R
                  U   R                  U R                  S   U5      $ rÈ   )r$   r   r\   r?   rï   rà   ÚsubsrF   )r/   rS   Úidxs      r(   rQ   ÚSeqPer._eval_coeff3  sc   € Ø�:‰:œ×+Ñ+Ò+Ø—9‘9˜r‘> T§[¡[Ñ0‰CàŸ
™
‘? d§k¡kÑ1ˆCØ�‰˜sÑ#×(Ñ(¨¯©¸Ñ):¸BÓ?Ð?r3   c                 ód  • [        U[        5      (       a›  U R                  U R                  p2UR                  UR                  pT[	        X55      n/ n[        U5       H$  nX(U-     n	XHU-     n
UR                  Xš-   5        M&     U R                  U5      u  p¼[        XpR                  S   X¼45      $ g©zSee docstring of SeqBase._addr   N©	rn   rÜ   rà   rï   r   rŠ   r™   r1   rF   ©r/   r0   Úper1Úlper1Úper2Úlper2Ú
per_lengthÚnew_perr    Úele1Úele2r$   r?   s                r(   rc   ÚSeqPer._add:  ó£   € ä�eœV×$Ñ$ØŸ/™/¨4¯;©;�%Ø×*Ñ*¨E¯L©L�%ä˜UÓ*ˆJàˆGÜ˜:Ö&�Ø ™I‘�Ø ™I‘�Ø—‘˜t™{Ö+ñ 'ð
 ×2Ñ2°5Ó9‰KˆEÜ˜'§N¡N°1Ñ$5°uÐ#CÓDÐDð %r3   c                 ód  • [        U[        5      (       a›  U R                  U R                  p2UR                  UR                  pT[	        X55      n/ n[        U5       H$  nX(U-     n	XHU-     n
UR                  Xš-  5        M&     U R                  U5      u  p¼[        XpR                  S   X¼45      $ g©zSee docstring of SeqBase._mulr   Nrû   rü   s                r(   rg   ÚSeqPer._mulK  r  r3   c                 óŽ   • [        U5      nU R                   Vs/ s H  o"U-  PM	     nn[        X0R                  S   5      $ s  snf ©r¿   r[   )r   rà   rÜ   rI   )r/   rT   r    Úpers       r(   rj   ÚSeqPer.coeff_mul\  s=   € ä˜“ˆØ"&§/¢/Ó2¢/˜Q�5Œy¡/ˆÐ2Ü�cŸ9™9 Q™<Ó(Ð(ùò 3s   šArE   ru   )r¬   r­   r®   r¯   r°   rê   r´   rï   rà   rQ   rc   rg   rj   rµ   rE   r3   r(   rÜ   rÜ   Ò  sM   † ñ.ô`&6ðP ñó ðð ñó ðò@òEò"Eõ")r3   rÜ   c                   óP   • \ rS rSrSrSS jr\S 5       rS rS r	S r
S	 rS
 rSrg)Ú
SeqFormulaic  a  
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
Nc                 ój  • [        U5      nS nSu  pEnUc  U" U5      S[        R                  pen[        U[        5      (       a0  [        U5      S:X  a  Uu  pEnO[        U5      S:X  a  U" U5      nUu  pV[        U[        [        45      (       a  Ub  Uc  [        S[        U5      -  5      eU[        R                  L a  U[        R                  L a  [        S5      e[        XEU45      n[        US   US   5      [        R                  L a  [        R                  $ [        R                   " XU5      $ )	Nc                 ó˜   • U R                   n[        U5      S:X  a  UR                  5       $ U(       d  [        S5      $ [	        SU -  5      e)Nr[   r§   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)))rJ   r—   rß   r   rç   )Úformulará   s     r(   râ   Ú#SeqFormula.__new__.<locals>._find_x�  sN   € Ø×'Ñ'ˆDÜ�4‹y˜A‹~Ø—x‘x“zÐ!ÞÜ˜S“zÐ!ä ðOð ñóð r3   rä   r   rå   r•   ræ   z0Both the start and end value cannot be unboundedr[   )r   r   r&   r   r   r—   rn   r   r   rç   rè   r\   r   r¹   r·   r   rê   )rë   r  rì   râ   r    r$   r?   s          r(   rê   ÚSeqFormula.__new__Œ  s  € Ü˜'Ó"ˆò	ð *‰ˆ�$Ø‰>Ù$ WÓ-¨q´!·*±*�dˆAÜ�vœu×%Ñ%Ü�6‹{˜aÓØ!'‘�™$Ü�V“ Ó!Ù˜GÓ$�Ø$‘�ä˜!œf¤c˜]×+Ñ+¨u©}ÀÁÜÐ7¼#¸f»+ÑEÓFÐFà”A×&Ñ&Ò&¨4´1·:±:Ò+=Ü ð "7ó 8ð 8ä˜! DÐ)Ó*ˆä�F˜1‘I˜v a™yÓ)¬Q¯Z©ZÒ7Ü—?‘?Ð"ä�}Š}˜S¨6Ó2Ð2r3   c                 ó   • U R                   $ ru   rò   r6   s    r(   r  ÚSeqFormula.formula³  rô   r3   c                 óV   • U R                   S   nU R                  R                  X!5      $ rÈ   )rF   r  rö   )r/   rS   r�   s      r(   rQ   ÚSeqFormula._eval_coeff·  s%   € Ø�N‰N˜1ÑˆØ�|‰|× Ñ  Ó'Ð'r3   c                 óü   • [        U[        5      (       ag  U R                  U R                  S   p2UR                  UR                  S   pTX$R	                  XS5      -   nU R                  U5      u  px[        XcXx45      $ grú   ©rn   r  r  rF   rö   r1   ©	r/   r0   Úform1Úv1Úform2Úv2r  r$   r?   s	            r(   rc   ÚSeqFormula._add»  óo   € ä�eœZ×(Ñ(ØŸ™ d§n¡n°QÑ&7�2ØŸ™ u§¡°qÑ'9�2ØŸj™j¨Ó0Ñ0ˆGØ×2Ñ2°5Ó9‰KˆEÜ˜g¨EÐ'8Ó9Ð9ð )r3   c                 óü   • [        U[        5      (       ag  U R                  U R                  S   p2UR                  UR                  S   pTX$R	                  XS5      -  nU R                  U5      u  px[        XcXx45      $ gr  r  r  s	            r(   rg   ÚSeqFormula._mulÄ  r!  r3   c                 óf   • [        U5      nU R                  U-  n[        X R                  S   5      $ r  )r   r  r  rI   )r/   rT   r  s      r(   rj   ÚSeqFormula.coeff_mulÍ  s,   € ä˜“ˆØ—,‘, Ñ&ˆÜ˜'§9¡9¨Q¡<Ó0Ð0r3   c                 ób   • [        [        U R                  /UQ70 UD6U R                  S   5      $ rÕ   )r  r	   r  rI   )r/   rI   Úkwargss      r(   r	   ÚSeqFormula.expandÓ  s*   € Üœ& §¡Ð?°Ò?¸Ñ?ÀÇÁÈ1ÁÓNÐNr3   rE   ru   )r¬   r­   r®   r¯   r°   rê   r´   r  rQ   rc   rg   rj   r	   rµ   rE   r3   r(   r  r  c  s<   † ñ&ôP%3ðN ñó ðò(ò:ò:ò1õOr3   r  c                   ó¾   • \ rS rSrSrSS jr\S 5       r\S 5       r\S 5       r	\S 5       r
\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       rS rS rSrg)ÚRecursiveSeqiÖ  a´  
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

Nc                 óT  • [        U[        5      (       d  [        SR                  U5      5      e[        U[        5      (       a  UR
                  (       d  [        SR                  U5      5      eUR                  U4:w  a  [        S5      eUR                  n[        SU4S9nSnUR                  U5      n	U	 Hœ  n
[        U
R                  5      S:w  a  [        S5      eU
R                  S   R                  X7-   5      U   nUR                  5       (       a  UR                  (       a  US:  d  [        S	R                  U
5      5      eU* U:”  d  M™  U* nMž     U(       d3  [        U5       Vs/ s H  n[        S
R                  U5      5      PM     nn[        U5      U:w  a  [!        S5      e[#        U5      n[%        U5      n['        S U 5       6 n[        R(                  " XX#XE5      n[+        U5       VVs0 s H  u  p}U" XW-   5      U_M     snnUl        XŒl        U$ s  snf s  snnf )NzErecurrence sequence must be an applied undefined function, found `{}`z0recurrence variable must be a symbol, found `{}`z)recurrence sequence does not match symbolr§   )Úexcluder   r[   z)Recurrence should be in a single variablezDRecurrence should have constant, negative, integer shifts (found {})zc_{}z)Number of initial terms must equal degreec              3   ó8   #   • U  H  n[        U5      v •  M     g 7fru   r   )Ú.0r    s     r(   Ú	<genexpr>Ú'RecursiveSeq.__new__.<locals>.<genexpr>O  s   é € Ð6ªg¨œ' !Ÿ*˜*ªgùó   ‚)rn   r   ro   Úformatr   Ú	is_symbolrI   rW   r   Úfindr—   ÚmatchÚis_constantÚ
is_integerrŠ   r   rç   r   r   r   rê   Ú	enumerateÚcacheÚdegree)rë   Ú
recurrenceÚynrœ   r]   r$   r©   r§   r:  Úprev_ysÚprev_yÚshiftÚseqÚinits                 r(   rê   ÚRecursiveSeq.__new__#  sè  € Ü˜"œl×+Ñ+Üð +ß+1©6°"«:ó7ð 7ô ˜!œU×#Ñ#¨1¯;¯;Üð +ß+1©6°!«9ó6ð 6ð �7‰7�q�d‹?ÜÐGÓHÐHà�G‰Gˆä�˜q˜dÑ#ˆØˆð —/‘/ !Ó$ˆÛˆFÜ�6—;‘;Ó 1Ó$ÜÐ KÓLÐLà—K‘K ‘N×(Ñ(¨©Ó/°Ñ2ˆEØ×%Ñ%×'Ñ'¨E×,<×,<ÀÈÃÜð !.ç.4©f°V«nó>ð >ð ˆv˜�Ø˜’ñ ö Ü8=¸f¼ÓFº°1”u˜VŸ]™]¨1Ó-Ö.¹ˆGÐFäˆw‹<˜6Ó!ÜÐHÓIÐIä˜“ˆÜ˜“ˆäÑ6©gÓ6Ð7ˆä�mŠm˜C¨R°GÓCˆä7@ÀÔ7IÔJÒ7I©G¨A‘Q�u‘y“\ 4Ò'Ñ7IÒJˆŒ	ØŒ
àˆ
ùò Gùó Ks   Å,$HÇ7H$c                 ó    • U R                   S   $ ©zEquation defining recurrence.r   rÉ   r6   s    r(   Ú_recurrenceÚRecursiveSeq._recurrenceX  ó   € ð �y‰y˜‰|Ðr3   c                 óH   • [        U R                  U R                  S   5      $ rD  )r   r<  rI   r6   s    r(   r;  ÚRecursiveSeq.recurrence]  s   € ô �$—'‘'˜4Ÿ9™9 Q™<Ó(Ð(r3   c                 ó    • U R                   S   $ )z*Applied function representing the nth termr[   rÉ   r6   s    r(   r<  ÚRecursiveSeq.ynb  rG  r3   c                 ó.   • U R                   R                  $ )z3Undefined function for the nth term of the sequence)r<  rW   r6   s    r(   r©   ÚRecursiveSeq.yg  s   € ð �w‰w�|‰|Ðr3   c                 ó    • U R                   S   $ )zSequence index symbolr•   rÉ   r6   s    r(   rœ   ÚRecursiveSeq.nl  rG  r3   c                 ó    • U R                   S   $ )z"The initial values of the sequencerå   rÉ   r6   s    r(   r]   ÚRecursiveSeq.initialq  rG  r3   c                 ó    • U R                   S   $ )r<   é   rÉ   r6   s    r(   r$   ÚRecursiveSeq.startv  rG  r3   c                 ó"   • [         R                  $ )z&The ending point of the sequence. (oo))r   r&   r6   s    r(   r?   ÚRecursiveSeq.stop{  s   € ô �z‰zÐr3   c                 ó:   • U R                   [        R                  4$ )z&Interval on which sequence is defined.)r$   r   r&   r6   s    r(   r,   ÚRecursiveSeq.interval€  s   € ð —
‘
œAŸJ™JÐ'Ð'r3   c                 ó  • XR                   -
  [        U R                  5      :  a  U R                  U R                  U5         $ [	        [        U R                  5      US-   5       Hq  nU R                   U-   nU R
                  R                  U R                  U05      nUR                  U R                  5      nXPR                  U R                  U5      '   Ms     U R                  U R                  U R                   W-   5         $ rÕ   )r$   r—   r9  r©   rŠ   rE  Úxreplacerœ   )r/   r�   ÚcurrentÚ	seq_indexÚcurrent_recurrenceÚnew_terms         r(   rQ   ÚRecursiveSeq._eval_coeff…  sÉ   € Ø—:‘:Ñ¤ D§J¡J£Ó/Ø—:‘:˜dŸf™f U›mÑ,Ð,äœS §¡›_¨e°a©iÖ8ˆGð Ÿ
™
 WÑ,ˆIØ!%×!1Ñ!1×!:Ñ!:¸D¿F¹FÀIÐ;NÓ!OÐØ)×2Ñ2°4·:±:Ó>ˆHà,4�J‰J�t—v‘v˜iÓ(Ó)ñ 9ð �z‰z˜$Ÿ&™& §¡¨gÑ!5Ó6Ñ7Ð7r3   c              #   óX   #   • U R                   n U R                  U5      v •  US-  nM  7frÕ   )r$   rQ   )r/   r�   s     r(   r‹   ÚRecursiveSeq.__iter__”  s0   é € Ø—
‘
ˆØØ×"Ñ" 5Ó)Ò)Ø�Q‰JˆEñ ùs   ‚(*rE   rÈ   )r¬   r­   r®   r¯   r°   rê   r´   rE  r;  r<  r©   rœ   r]   r$   r?   r,   rQ   r‹   rµ   rE   r3   r(   r*  r*  Ö  sÍ   † ñJôX3ðj ñó ðð ñ)ó ð)ð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñó ðð ñ(ó ð(ò8õr3   r*  Nc                 ón   • [        U 5      n [        U [        5      (       a  [        X5      $ [	        X5      $ )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
)r   r   r   rÜ   r  )r@  rì   s     r(   Úsequencerc  ›  s0   € ô4 �#‹,€Cä�3œ×ÑÜ�cÓ"Ð"ä˜#Ó&Ð&r3   c                   óx   • \ rS rSrSr\S 5       r\S 5       r\S 5       r\S 5       r	\S 5       r
\S 5       rS	rg
)Ú	SeqExprOpiÂ  a•  
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
c                 ó:   • [        S U R                   5       5      $ )zZGenerator for the sequence.

returns a tuple of generators of all the argument sequences.
c              3   ó8   #   • U  H  oR                   v •  M     g 7fru   rò   ©r.  Úas     r(   r/  Ú SeqExprOp.gen.<locals>.<genexpr>á  s   é € Ð.¢I˜q—U–U¢Iùr1  )ré   rI   r6   s    r(   r7   ÚSeqExprOp.genÛ  s   € ô Ñ. D§I¢IÓ.Ó.Ð.r3   c                 ó4   • [        S U R                   5       6 $ )zUSequence is defined on the intersection
of all the intervals of respective sequences
c              3   ó8   #   • U  H  oR                   v •  M     g 7fru   ©r,   rh  s     r(   r/  Ú%SeqExprOp.interval.<locals>.<genexpr>è  s   é € Ð<²)¨QŸjžj²)ùr1  )r   rI   r6   s    r(   r,   ÚSeqExprOp.intervalã  s   € ô
 Ñ<°$·)²)Ó<Ð=Ð=r3   c                 ó.   • U R                   R                  $ ru   rÎ   r6   s    r(   r$   ÚSeqExprOp.startê  rÐ   r3   c                 ó.   • U R                   R                  $ ru   rÒ   r6   s    r(   r?   ÚSeqExprOp.stopî  rÐ   r3   c                 ó|   • [        [        U R                   Vs/ s H  oR                  PM     sn5      5      $ s  snf )z%Cumulative of all the bound variables)ré   r   rI   rF   )r/   ri  s     r(   rF   ÚSeqExprOp.variablesò  s,   € ô ”W°4·9²9Ó=²9¨aŸkœk±9Ñ=Ó>Ó?Ð?ùÒ=s   ™9c                 ó:   • U R                   U R                  -
  S-   $ rÕ   rÖ   r6   s    r(   rB   ÚSeqExprOp.length÷  rØ   r3   rE   N)r¬   r­   r®   r¯   r°   r´   r7   r,   r$   r?   rF   rB   rµ   rE   r3   r(   re  re  Â  s�   † ñð0 ñ/ó ð/ð ñ>ó ð>ð ñ!ó ð!ð ñ!ó ð!ð ñ@ó ð@ð ñ*ó ó*r3   re  c                   ó4   • \ rS rSrSrS r\S 5       rS rSr	g)rq   iü  aF  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
c                 ó  ^• UR                  S[        R                  5      n[        U5      nU4S jmT" U5      nU Vs/ s H  oD[        R
                  Ld  M  UPM     nnU(       d  [        R
                  $ [        S U 5       6 [        R                  L a  [        R
                  $ U(       a  [        R                  U5      $ [        [        U[        R                  5      5      n[        R                  " U /UQ76 $ s  snf )NÚevaluatec                 ó   >• [        U [        5      (       a8  [        U [        5      (       a   [        [	        TU R
                  5      / 5      $ U /$ [        U 5      (       a  [        [	        TU 5      / 5      $ [        S5      e©Nz2Input must be Sequences or  iterables of Sequences)rn   r    rq   ÚsumÚmaprI   r   ro   ©ÚargÚ_flattens    €r(   r‚  Ú SeqAdd.__new__.<locals>._flatten   sk   ø€ Ü˜#œw×'Ñ'Ü˜c¤6×*Ñ*Üœs 8¨S¯X©XÓ6¸Ó;Ð;à˜5�LÜ˜�}‰}Üœ3˜x¨Ó-¨rÓ2Ð2Üð 6ó 7ð 7r3   c              3   ó8   #   • U  H  oR                   v •  M     g 7fru   rn  rh  s     r(   r/  Ú!SeqAdd.__new__.<locals>.<genexpr>2  ó   é € Ð3ªd¨Ÿ*ž*ªdùr1  )Úgetr   r{  Úlistr   r·   r   r¹   rq   Úreducer   r    r)   r   rê   )rë   rI   r'  r{  ri  r‚  s        @r(   rê   ÚSeqAdd.__new__  sÆ   ø€ Ø—:‘:˜jÔ*;×*DÑ*DÓEˆô �D‹zˆõ		7ñ ˜‹~ˆáÓ<š4�a¬A¯O©OÐ#;—™4ˆÐ<ö Ü—?‘?Ð"äÑ3©dÓ3Ð4¼¿
¹
ÒBÜ—?‘?Ð"ö Ü—=‘= Ó&Ð&ä”G˜D¤'×"4Ñ"4Ó5Ó6ˆä�}Š}˜SÐ( 4Ò(Ð(ùò =s   ¿C>ÁC>c                 ó|  • SnU(       a†  [        U 5       Hn  u  p#Sn[        U 5       HM  u  pEX$:X  a  M  UR                  U5      nUc  M"  U  Vs/ s H  owX54;  d  M  UPM     nnUR                  U5          O   U(       d  Ml  Un   O   U(       a  M†  [        U 5      S:X  a  U R	                  5       $ [        U SS9$ s  snf )zÓSimplify :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``

TFr[   ©r{  )r8  rc   r™   r—   rß   rq   ©rI   Únew_argsÚid1ÚsÚid2rŸ   Únew_seqri  s           r(   r‰  ÚSeqAdd.reduce=  s¹   € ð ˆÞÜ# Dž/‘�Ø �Ü'¨žo‘F�CØ“zÙ ØŸf™f Q›i�Gð Ó*Ù/3Ó#Gªt¨!ÀÀ±§A©t˜Ð#GØ Ÿ™¨Ô0Ùñ .÷ �8Ø#�DÙñ *÷ ˆhô" ˆt‹9˜‹>Ø—8‘8“:Ðä˜$¨Ñ/Ð/ùò $Hó   Á
B9ÁB9c                 óB   ^• [        U4S jU R                   5       5      $ )z9adds up the coefficients of all the sequences at point ptc              3   óD   >#   • U  H  oR                  T5      v •  M     g 7fru   )rT   )r.  ri  rS   s     €r(   r/  Ú%SeqAdd._eval_coeff.<locals>.<genexpr>c  s   øé € Ð2ª	 1—7‘7˜2—;�;ª	ùs   ƒ )r~  rI   rR   s    `r(   rQ   ÚSeqAdd._eval_coeffa  s   ø€ äÔ2¨¯	ª	Ó2Ó2Ð2r3   rE   N©
r¬   r­   r®   r¯   r°   rê   r³   r‰  rQ   rµ   rE   r3   r(   rq   rq   ü  s'   † ñò8")ðH ñ!0ó ð!0õF3r3   rq   c                   ó4   • \ rS rSrSrS r\S 5       rS rSr	g)rƒ   if  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
c                 ó°  ^• UR                  S[        R                  5      n[        U5      nU4S jmT" U5      nU(       d  [        R
                  $ [        S U 5       6 [        R                  L a  [        R
                  $ U(       a  [        R                  U5      $ [        [        U[        R                  5      5      n[        R                  " U /UQ76 $ )Nr{  c                 ó   >• [        U [        5      (       a8  [        U [        5      (       a   [        [	        TU R
                  5      / 5      $ U /$ [        U 5      (       a  [        [	        TU 5      / 5      $ [        S5      er}  )rn   r    rƒ   r~  r  rI   r   ro   r€  s    €r(   r‚  Ú SeqMul.__new__.<locals>._flatten�  sk   ø€ Ü˜#œw×'Ñ'Ü˜c¤6×*Ñ*Üœs 8¨S¯X©XÓ6¸Ó;Ð;à˜5�LÜ˜#—‘Üœ3˜x¨Ó-¨rÓ2Ð2Üð 6ó 7ð 7r3   c              3   ó8   #   • U  H  oR                   v •  M     g 7fru   rn  rh  s     r(   r/  Ú!SeqMul.__new__.<locals>.<genexpr>   r†  r1  )r‡  r   r{  rˆ  r   r·   r   r¹   rƒ   r‰  r   r    r)   r   rê   )rë   rI   r'  r{  r‚  s       @r(   rê   ÚSeqMul.__new__‰  s¤   ø€ Ø—:‘:˜jÔ*;×*DÑ*DÓEˆô �D‹zˆõ		7ñ ˜‹~ˆö Ü—?‘?Ð"äÑ3©dÓ3Ð4¼¿
¹
ÒBÜ—?‘?Ð"ö Ü—=‘= Ó&Ð&ä”G˜D¤'×"4Ñ"4Ó5Ó6ˆä�}Š}˜SÐ( 4Ò(Ð(r3   c                 ó|  • SnU(       a†  [        U 5       Hn  u  p#Sn[        U 5       HM  u  pEX$:X  a  M  UR                  U5      nUc  M"  U  Vs/ s H  owX54;  d  M  UPM     nnUR                  U5          O   U(       d  Ml  Un   O   U(       a  M†  [        U 5      S:X  a  U R	                  5       $ [        U SS9$ s  snf )zî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``

TFr[   rŒ  )r8  rg   r™   r—   rß   rƒ   r�  s           r(   r‰  ÚSeqMul.reduce«  s¹   € ð  ˆÞÜ# Dž/‘�Ø �Ü'¨žo‘F�CØ“zÙ ØŸf™f Q›i�Gð Ó*Ù/3Ó#Gªt¨!ÀÀ±§A©t˜Ð#GØ Ÿ™¨Ô0Ùñ .÷ �8Ø#�DÙñ *÷ ˆhô" ˆt‹9˜‹>Ø—8‘8“:Ðä˜$¨Ñ/Ð/ùò $Hr”  c                 óV   • SnU R                    H  nX#R                  U5      -  nM     U$ )z<multiplies the coefficients of all the sequences at point ptr[   )rI   rT   )r/   rS   Úvalri  s       r(   rQ   ÚSeqMul._eval_coeffÒ  s*   € àˆØ—”ˆAØ—7‘7˜2“;ÑŠCñ àˆ
r3   rE   Nr™  rE   r3   r(   rƒ   rƒ   f  s(   † ñ òD )ðD ñ$0ó ð$0õLr3   rƒ   ru   )6Úsympy.core.basicr   Úsympy.core.cacher   Úsympy.core.containersr   Úsympy.core.decoratorsr   Úsympy.core.parametersr   Úsympy.core.functionr   r	   Úsympy.core.mulr   Úsympy.core.numbersr   Úsympy.core.relationalr   Úsympy.core.singletonr   r   Úsympy.core.sortingr   Úsympy.core.symbolr   r   r   Úsympy.core.sympifyr   Úsympy.matricesr   Úsympy.polysr   r   Úsympy.sets.setsr   r   Úsympy.tensor.indexedr   Úsympy.utilities.iterablesr   r   r   r    r·   rÆ   rÜ   r  r*  rc  re  rq   rƒ   rE   r3   r(   Ú<module>r¸     sË   ðÝ "Ý $Ý 'Ý 7Ý 3ß 4Ý Ý &Ý $ß -Ý &ß 1Ñ 1Ý &Ý !ß #ß 2Ý $ß DÑ Dô^=ˆeô ^=ô@"�G yò "ôJ0"ˆgô 0"ôfN)ˆWô N)ôbqO�ô qOôfB�7ô BôJ'ôN7*�ô 7*ôtg3ˆYô g3ôTqˆYõ qr3   