� ��g)����ddlmZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z mZmZddlmZdd lmZdd lmZmZdd lmZmZdd lmZdd lmZmZddlm Z m!Z!m"Z"ddl#m$Z$m%Z%m&Z&ddl'm(Z(m)Z)ddl*m+Z+m,Z,ddl-m.Z.m/Z/ddl0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7ddl8m9Z9Gd�de2e���Z:Gd�de2e���Z;Gd�de;��Z<Gd�de2e���Z=Gd�d e3e���Z>Gd!�d"e2��Z?Gd#�d$e2��Z@d%�e&eA<d&�ZBGd'�d(e2��ZCGd)�d*eC��ZDGd+�d,eC��ZEGd-�d.eDe���ZFd/S)0�)�reduce)�product)�Basic)�Tuple)�Expr)�Lambda)� fuzzy_not�fuzzy_or� fuzzy_and)�Mod)�igcd)�oo�Rational)�Eq�is_eq)� NumberKind)� Singleton�S)�Dummy�symbols�Symbol)�_sympify�sympify�_sympy_converter)�ceiling�floor)�sin�cos)�And�Or�)�tfn�Set�Interval�Union� FiniteSet� ProductSet�SetKind)� filldedentc�b�eZdZdZdZejZejZ dZ dZ d�Z d�Z ed���Zd�ZdS) � RationalsaS Represents the rational numbers. This set is also available as the singleton ``S.Rationals``. Examples ======== >>> from sympy import S >>> S.Half in S.Rationals True >>> iterable = iter(S.Rationals) >>> [next(iterable) for i in range(12)] [0, 1, -1, 1/2, 2, -1/2, -2, 1/3, 3, -1/3, -3, 2/3] TFc�h�t|t��s tjSt|jS�N)� isinstancerr�falser"� is_rational��self�others �d/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/sets/fancysets.py� _containszRationals._contains.s)���%��&�&� ��7�N��5�$�%�%�c#�LK�tjV�tjV�tjV�d} t |��D]`}t ||��dkrJt ||��V�t ||��V�t | |��V�t | |��V��a|dz }�v)N�Tr!)r�Zero�One� NegativeOne�ranger r)r2�d�ns r4�__iter__zRationals.__iter__3s������f� � � ��e� � � ��m���� �� ��1�X�X� *� *����1�:�:��?�?�"�1�a�.�.�(�(�(�"�1�a�.�.�(�(�(�"�A�2�q�/�/�)�)�)�"�A�2�q�/�/�)�)�)�� ��F�A� r6c��tjSr-)r�Reals�r2s r4� _boundaryzRationals._boundaryAs ���w�r6c�*�tt��Sr-�r(rrBs r4�_kindzRationals._kindE����z�"�"�"r6N)�__name__� __module__� __qualname__�__doc__� is_iterabler�NegativeInfinity�_inf�Infinity�_sup�is_empty� is_finite_setr5r?�propertyrCrF�r6r4r+r+s������� � ��K� � �D� �:�D��H��M�&�&�&� � � �����X��#�#�#�#�#r6r+)� metaclassc�t�eZdZdZdZejZejZ dZ dZ d�Z d�Z d�Zd�Zed���Zd �Zd �Zd S) �Naturalsak Represents the natural numbers (or counting numbers) which are all positive integers starting from 1. This set is also available as the singleton ``S.Naturals``. Examples ======== >>> from sympy import S, Interval, pprint >>> 5 in S.Naturals True >>> iterable = iter(S.Naturals) >>> next(iterable) 1 >>> next(iterable) 2 >>> next(iterable) 3 >>> pprint(S.Naturals.intersect(Interval(0, 10))) {1, 2, ..., 10} See Also ======== Naturals0 : non-negative integers (i.e. includes 0, too) Integers : also includes negative integers TFc��t|t��s tjS|jr|jr tjS|jdus |jdur tjSdS�NF)r.rrr/� is_positive� is_integer�truer1s r4r5zNaturals._containslsb���%��&�&� ��7�N� � � �5�#3� ��6�M� � �� &� &�%�*;�u�*D�*D��7�N�+E�*Dr6c�R�tdt���|��S�Nr!��Ranger� is_subsetr1s r4�_eval_is_subsetzNaturals._eval_is_subsetts���Q��|�|�%�%�e�,�,�,r6c�R�tdt���|��Sr^�r`r� is_supersetr1s r4�_eval_is_supersetzNaturals._eval_is_supersetws���Q��|�|�'�'��.�.�.r6c#�*K�|j} |V�|dz}� �NTr!)rN�r2�is r4r?zNaturals.__iter__zs)���� �I�� ��G�G�G��A��A� r6c��|Sr-rTrBs r4rCzNaturals._boundary����� r6c�~�ttt|��|��||jk|tk��Sr-)rrr�infr�r2�xs r4� as_relationalzNaturals.as_relational�s,���2�e�A�h�h��?�?�A���M�1�r�6�:�:�:r6c�*�tt��Sr-rErBs r4rFzNaturals._kind�rGr6N)rHrIrJrKrLrr:rNrOrPrQrRr5rbrfr?rSrCrqrFrTr6r4rWrWIs���������8�K� �5�D� �:�D��H��M����-�-�-�/�/�/���� ����X��;�;�;�#�#�#�#�#r6rWc�2�eZdZdZejZd�Zd�Zd�Z dS)� Naturals0z�Represents the whole numbers which are all the non-negative integers, inclusive of zero. See Also ======== Naturals : positive integers; does not include 0 Integers : also includes the negative integers c��t|t��s tjS|jr|jr tjS|jdus |jdur tjSdSrY)r.rrr/r[�is_nonnegativer\r1s r4r5zNaturals0._contains�sb���%��&�&� ��7�N� � � �%�"6� ��6�M� � �� &� &�%�*>�%�*G�*G��7�N�+H�*Gr6c�P�tt���|��Sr-r_r1s r4rbzNaturals0._eval_is_subset�s���R�y�y�"�"�5�)�)�)r6c�P�tt���|��Sr-rdr1s r4rfzNaturals0._eval_is_superset�s���R�y�y�$�$�U�+�+�+r6N) rHrIrJrKrr9rNr5rbrfrTr6r4rtrt�sT�������� �6�D����*�*�*�,�,�,�,�,r6rtc��eZdZdZdZdZdZd�Zd�Ze d���Z e d���Z e d���Z d �Z d �Zd �Zd �Zd S)�IntegersaH Represents all integers: positive, negative and zero. This set is also available as the singleton ``S.Integers``. Examples ======== >>> from sympy import S, Interval, pprint >>> 5 in S.Naturals True >>> iterable = iter(S.Integers) >>> next(iterable) 0 >>> next(iterable) 1 >>> next(iterable) -1 >>> next(iterable) 2 >>> pprint(S.Integers.intersect(Interval(-4, 4))) {-4, -3, ..., 4} See Also ======== Naturals0 : non-negative integers Integers : positive and negative integers and zero TFc�h�t|t��s tjSt|jSr-)r.rrr/r"r[r1s r4r5zIntegers._contains�s)���%��&�&� ��7�N��5�#�$�$r6c#�ZK�tjV�tj} |V�| V�|dz}�rh)rr9r:ris r4r?zIntegers.__iter__�s?�����f� � � � �E�� ��G�G�G��"�H�H�H��A��A� r6c��tjSr-�rrMrBs r4rNz Integers._inf�� ���!�!r6c��tjSr-�rrOrBs r4rPz Integers._sup�� ���z�r6c��|Sr-rTrBs r4rCzIntegers._boundary�rlr6c�*�tt��Sr-rErBs r4rFzIntegers._kind�rGr6c��ttt|��|��t |k|tk��Sr-)rrrrros r4rqzIntegers.as_relational�s,���2�e�A�h�h��?�?�R�C�!�G�Q��V�4�4�4r6c�^�tt t���|��Sr-r_r1s r4rbzIntegers._eval_is_subset�s ���b�S�"�~�~�'�'��.�.�.r6c�^�tt t���|��Sr-rdr1s r4rfzIntegers._eval_is_superset�s ���b�S�"�~�~�)�)�%�0�0�0r6N)rHrIrJrKrLrQrRr5r?rSrNrPrCrFrqrbrfrTr6r4rzrz�s���������<�K��H��M�%�%�%� ����"�"��X�"�����X������X��#�#�#�5�5�5�/�/�/�1�1�1�1�1r6rzc�v�eZdZdZed���Zed���Zed���Zed���Zd�Z d�Z dS) rAa� Represents all real numbers from negative infinity to positive infinity, including all integer, rational and irrational numbers. This set is also available as the singleton ``S.Reals``. Examples ======== >>> from sympy import S, Rational, pi, I >>> 5 in S.Reals True >>> Rational(-1, 2) in S.Reals True >>> pi in S.Reals True >>> 3*I in S.Reals False >>> S.Reals.contains(pi) True See Also ======== ComplexRegion c��tjSr-r~rBs r4�startz Reals.start rr6c��tjSr-r�rBs r4�endz Reals.endr�r6c��dS�NTrTrBs r4� left_openzReals.left_open����tr6c��dSr�rTrBs r4� right_openzReals.right_openr�r6c�R�|ttjtj��kSr-)r$rrMrOr1s r4�__eq__z Reals.__eq__s�����!3�Q�Z�@�@�@�@r6c�d�tttjtj����Sr-)�hashr$rrMrOrBs r4�__hash__zReals.__hash__s���H�Q�/���<�<�=�=�=r6N) rHrIrJrKrSr�r�r�r�r�r�rTr6r4rArA�s���������8�"�"��X�"�����X������X������X��A�A�A�>�>�>�>�>r6rAc��eZdZdZd�Zed���Zed���Zed���Zed���Z e d���Z d�Z d �Z d �Zed ���Zd �Zd �ZdS)�ImageSetaY Image of a set under a mathematical function. The transformation must be given as a Lambda function which has as many arguments as the elements of the set upon which it operates, e.g. 1 argument when acting on the set of integers or 2 arguments when acting on a complex region. This function is not normally called directly, but is called from ``imageset``. Examples ======== >>> from sympy import Symbol, S, pi, Dummy, Lambda >>> from sympy import FiniteSet, ImageSet, Interval >>> x = Symbol('x') >>> N = S.Naturals >>> squares = ImageSet(Lambda(x, x**2), N) # {x**2 for x in N} >>> 4 in squares True >>> 5 in squares False >>> FiniteSet(0, 1, 2, 3, 4, 5, 6, 7, 9, 10).intersect(squares) {1, 4, 9} >>> square_iterable = iter(squares) >>> for i in range(4): ... next(square_iterable) 1 4 9 16 If you want to get value for `x` = 2, 1/2 etc. (Please check whether the `x` value is in ``base_set`` or not before passing it as args) >>> squares.lamda(2) 4 >>> squares.lamda(S(1)/2) 1/4 >>> n = Dummy('n') >>> solutions = ImageSet(Lambda(n, n*pi), S.Integers) # solutions of sin(x) = 0 >>> dom = Interval(-1, 1) >>> dom.intersect(solutions) {0} See Also ======== sympy.sets.sets.imageset c����t|t��std���|j}t |��t |��krtd���d�|D��}t d�|D����st d���t �fd�t||��D����std|�d|�����|tj urt |��d kr|d St|j ��|j j zsEtd �|D����}|d kr tjS|d krt!|j ��St#j�|g|�R�S)NzFirst argument must be a Lambda�Incompatible signaturec�,�g|]}t|����SrT)r��.0�ss r4� <listcomp>z$ImageSet.__new__.<locals>.<listcomp>ds��*�*�*���� � �*�*�*r6c3�@K�|]}t|t��V��dSr-)r.r#r�s r4� <genexpr>z#ImageSet.__new__.<locals>.<genexpr>fs,����4�4�!�:�a��%�%�4�4�4�4�4�4r6z,Set arguments to ImageSet should of type Setc3�J�K�|]\}}��||��V��dSr-�� _check_sig)r��sg�st�clss �r4r�z#ImageSet.__new__.<locals>.<genexpr>is5�����M�M�f�b�"�3�>�>�"�b�)�)�M�M�M�M�M�Mr6z Signature z does not match sets r!rc3�$K�|] }|jV�� dSr-)rQr�s r4r�z#ImageSet.__new__.<locals>.<genexpr>ps$����9�9�q�� �9�9�9�9�9�9r6TF)r.r� ValueError� signature�len�all� TypeError�zipr�IdentityFunction�set� variables�expr� free_symbolsr �EmptySetr&r�__new__)r��flambda�setsr�rQs` r4r�zImageSet.__new__[s�����'�6�*�*� @��>�?�?� ?��%� � �y�>�>�S��Y�Y� &� &��5�6�6� 6�*�*�T�*�*�*���4�4�t�4�4�4�4�4� L��J�K�K� K��M�M�M�M��I�t�8L�8L�M�M�M�M�M� X��*�i�i�i�QU�QU�V�W�W� W� �a�(� (� (�S��Y�Y�!�^�^���7�N��7�$�%�%�� �(A�A� /��9�9�D�9�9�9�9�9�H��4����z�!��U�"�"� ���.�.�.��}�S�'�1�D�1�1�1�1r6c��|jdS�Nr��argsrBs r4�<lambda>zImageSet.<lambda>x� ��$�)�A�,�r6c� �|jdd�Sr^r�rBs r4r�zImageSet.<lambda>ys��d�i����m�r6c�|�|j}t|��dkr|dSt|����S)Nr!r)� base_setsr�r'�flatten)r2r�s r4�base_setzImageSet.base_set{s:���~�� �t�9�9��>�>���7�N��t�$�,�,�.�.� .r6c��t|j�Sr-)r'r�rBs r4� base_psetzImageSet.base_pset�s���4�>�*�*r6c����|jrdSt|t��rR|j}t |��t |��krdSt �fd�t ||��D����SdS)NTFc3�J�K�|]\}}��||��V��dSr-r�)r��ts�psr�s �r4r�z&ImageSet._check_sig.<locals>.<genexpr>�s5�����M�M�&�"�b�s�~�~�b�"�-�-�M�M�M�M�M�Mr6)� is_symbolr.r'r�r�r�r�)r��sig_i�set_ir�s` r4r�zImageSet._check_sig�s{��� �?� ��4� ��z� *� *� ��:�D��5�z�z�S��Y�Y�&�&��u��M�M�M�M�C��t�<L�<L�M�M�M�M�M� M��4r6c#�K�t��}|jD]*}|j|�}||vr�|�|��|V��+dSr-)r�r��lamda�add)r2� already_seenrj�vals r4r?zImageSet.__iter__�sd�����u�u� ��� � �A��$�*�a�.�C��l�"�"��� � ��%�%�%�� � � � �  � r6c�<�t|jj��dkSr^)r�r�r�rBs r4�_is_multivariatezImageSet._is_multivariate�s���4�:�'�(�(�1�,�,r6c��� ��ddlm}d�}d�}t|��}|jj}|jj}|jj}|j}d�|D��� � fd�|D��}|�� ��}|�� ��}g} |||��D])} | durtj cS| � | ���*|||�����dSd�| D��} t|��ttj| t����z}t|��}�fd �|D��}|| ||��} | �dSt t#| j��S) Nr)�_solveset_multic�4�tt||����}i}|D]u\}}|jr|||<�|jrZ|j}t |��t |��krt d���|�t||�����sdS|S)z,Attempt to get a map of symbols to base_setsr�N)�listr�r�� is_ProductSetr�r�r��extend)r�r��queue� symsetmap�sigr�r�s r4� get_symsetmapz)ImageSet._contains.<locals>.get_symsetmap�s�����Y� �2�2�3�3�E��I�!&� � � ��X��=�  �%-�I�c�N�N��+�  �#�=�D��3�x�x�3�t�9�9�,�,�(�)A�B�B�B��L�L��S�$���0�0�0�0� �4�4�� r6c3�2K�||fg}|D]�\}}t|t��st||��V��-t|t��r t|��t|��krdV�dS|�t ||������dS)z:Find the equations relating symbols in expr and candidate.FN)r.rrr�r�r�)r�� candidater��e�cs r4� get_equationsz)ImageSet._contains.<locals>.get_equations�s������I�&�'�E�� ,� ,���1�!�!�U�+�+�,��Q��(�(�N�N�N�N�#�A�u�-�-�,��Q���3�q�6�6�1A�1A��K�K�K��F�F��L�L��Q����+�+�+�+� ,� ,r6c�8�i|]}|t|j����SrT)r�name)r��vs r4� <dictcomp>z&ImageSet._contains.<locals>.<dictcomp>�s"��3�3�3�A�q�%���-�-�3�3�3r6c�:��g|]}|������SrT)�subs)r�r��reps �r4r�z&ImageSet._contains.<locals>.<listcomp>�s#���4�4�4�Q�Q�V�V�C�[�[�4�4�4r6Fc3�$K�|] }|jV�� dSr-)r�)r��eqs r4r�z%ImageSet._contains.<locals>.<genexpr>�s$����5�5�R���5�5�5�5�5�5r6c� ��g|] }�|�� SrTrT)r�r�r�s �r4r�z&ImageSet._contains.<locals>.<listcomp>�s���5�5�5�a�Y�q�\�5�5�5r6)�sympy.solvers.solvesetr�rr�r�r�r�r�r�rr/�appendr�r�union�tupler"r rQ)r2r3r�r�r�r�r�r�r�� equationsr��symss�solnsetr�r�s @@r4r5zImageSet._contains�s�����:�:�:�:�:�:� � � �( ,� ,� ,�������z����j�"���J�(� ��N� �4�3��3�3�3��4�4�4�4�)�4�4�4� ��h�h�s�m�m���y�y��~�~��� ��-��e�,�,� !� !�B��U�{�{��w���� � � �R� � � � �"�M�#�y�1�1� � � ��4�6�5�9�5�5�5��� �N�N�V�C�I�u�c�e�e�%D�%D�D� ��)�$�$� �5�5�5�5�9�5�5�5� �!�/�)�Y� �B�B�� �?��4��9�W�-�.�.�/�/r6c�>�td�|jD����S)Nc3�$K�|] }|jV�� dSr-)rLr�s r4r�z'ImageSet.is_iterable.<locals>.<genexpr>�s$����9�9�Q�1�=�9�9�9�9�9�9r6)r�r�rBs r4rLzImageSet.is_iterable�s!���9�9�$�.�9�9�9�9�9�9r6c ���ddlm}|j��j}t |��dkrW|djrJt �jt��r0|j d}||��� ���j Std�|j D����r!t�fd�t|j �D���S|S)Nr)�SetExprr!c3�$K�|] }|jV�� dSr-�� is_FiniteSetr�s r4r�z ImageSet.doit.<locals>.<genexpr>�s$����6�6�!�q�~�6�6�6�6�6�6r6c3�"�K�|] }�|�V�� dSr-rT)r��a�fs �r4r�z ImageSet.doit.<locals>.<genexpr>s)�����G�G��q�q�!�u�G�G�G�G�G�Gr6)�sympy.sets.setexprr�r�r�r�r�r.r�rr�� _eval_funcr�r�r&r)r2�hintsr�r�r�r�s @r4�doitz ImageSet.doit�s����.�.�.�.�.�.� �J���k�� �s�8�8�q�=�=�S��V�-�=�*�Q�V�T�2J�2J�=��~�a�(�H��7�8�$�$�/�/��2�2�6� 6� �6�6�t�~�6�6�6� 6� 6� I��G�G�G�G�g�t�~�.F�G�G�G�H� H�� r6c�>�t|jjj��Sr-)r(r�r��kindrBs r4rFzImageSet._kinds���t�z��+�,�,�,r6N)rHrIrJrKr�rSr�r�r�r�� classmethodr�r?r�r5rLrrFrTr6r4r�r�#s������6�6�n2�2�2�: �H�.�.� /� /�E���3�3�4�4�I� �/�/��X�/��+�+��X�+�����[��$���-�-�-�I0�I0�I0�V�:�:��X�:� � � �-�-�-�-�-r6r�c�:�eZdZdZd�Zed���Zed���Zed���Zed���Z d�Z d�Z d �Z ed ���Z d �Zed ���Zed ���Zed���Zd�Zd�Zed���Zed���Zed���Zd�ZdS)r`a� Represents a range of integers. Can be called as ``Range(stop)``, ``Range(start, stop)``, or ``Range(start, stop, step)``; when ``step`` is not given it defaults to 1. ``Range(stop)`` is the same as ``Range(0, stop, 1)`` and the stop value (just as for Python ranges) is not included in the Range values. >>> from sympy import Range >>> list(Range(3)) [0, 1, 2] The step can also be negative: >>> list(Range(10, 0, -2)) [10, 8, 6, 4, 2] The stop value is made canonical so equivalent ranges always have the same args: >>> Range(0, 10, 3) Range(0, 12, 3) Infinite ranges are allowed. ``oo`` and ``-oo`` are never included in the set (``Range`` is always a subset of ``Integers``). If the starting point is infinite, then the final value is ``stop - step``. To iterate such a range, it needs to be reversed: >>> from sympy import oo >>> r = Range(-oo, 1) >>> r[-1] 0 >>> next(iter(r)) Traceback (most recent call last): ... TypeError: Cannot iterate over Range with infinite start >>> next(iter(r.reversed)) 0 Although ``Range`` is a :class:`Set` (and supports the normal set operations) it maintains the order of the elements and can be used in contexts where ``range`` would be used. >>> from sympy import Interval >>> Range(0, 10, 2).intersect(Interval(3, 7)) Range(4, 8, 2) >>> list(_) [4, 6] Although slicing of a Range will always return a Range -- possibly empty -- an empty set will be returned from any intersection that is empty: >>> Range(3)[:0] Range(0, 0, 1) >>> Range(3).intersect(Interval(4, oo)) EmptySet >>> Range(3).intersect(Range(4, oo)) EmptySet Range will accept symbolic arguments but has very limited support for doing anything other than displaying the Range: >>> from sympy import Symbol, pprint >>> from sympy.abc import i, j, k >>> Range(i, j, k).start i >>> Range(i, j, k).inf Traceback (most recent call last): ... ValueError: invalid method for symbolic range Better success will be had when using integer symbols: >>> n = Symbol('n', integer=True) >>> r = Range(n, n + 20, 3) >>> r.inf n >>> pprint(r) {n, n + 3, ..., n + 18} c���t|��dkr3t|dt��rtd|dz���t |�}|jdkrt d���|jpd|j|jpd}}} g}|||fD]�}t|��}|tj tj fvs%|� t��r!|jdkr|�|���f|js|jrt d���t �|�|����n*#t $rt t'd�����wxYw|\}}}d}t)d�|||fD����ri||z } | |z } | jrK| dkrd }�n t-| ��} || |zz} | jr| |z jr| |z } n�| |z dz jr| |z } n�| jrd }n�|} n�|jrj|||z z} | tjus| dkrd }n�|jrA|jr:t5|��dkr't t'd |dkrdnd z�����|} na|j} | r|dkr tjn tj}t;||z |z ��} | dkrd }n| rtj}||z} n|| |zz} |rtjx}} tj}t?j ||| |��S) Nr!rz)use sympify(%s) to convert range to Rangezstep cannot be 0Fzinfinite symbols not allowedz� Finite arguments to Range must be integers; `imageset` can define other cases, e.g. use `imageset(i, i/10, Range(3))` to give [0, 1/10, 1/5].c3�JK�|]}|�t��V��dSr-)�hasr�r�rjs r4r�z Range.__new__.<locals>.<genexpr>|s,����:�:��q�u�u�V�}�}�:�:�:�:�:�:r6Tz7 Step size must be %s in this case.�����)!r�r.r<r��slice�stepr�r��stoprrrMrOrrr[r�� is_Integer� is_infiniter)�any� is_Rationalr� is_negative�is_extended_negative�NaN�absr:r;rr9rr�)r�r��slcr�r r �ok�w�null�difr>r��span�oosteps r4r�z Range.__new__Zs��� �t�9�9��>�>��$�q�'�5�)�)� K��?�$�q�'�I�K�K�K��T�l�� �8�q�=�=��/�0�0� 0��I�N��C�H�c�h�m�!�T�t�� ��B��T�4�(� !� !���A�J�J����+�Q�Z�8�8�8����f� � �9�*+�,�%�*?�*?��I�I�a�L�L�L�L���!��}�I�(�)G�H�H�H�$�$��I�I�a�L�L�L�L� !��� � � ��Z�)����� � ���� ���t�T��� �:�:�u�d�D�&9�:�:�:� :� :�' %���,�C��D��A��}� ��!�8�8��D�D��a���A��!�D�&�.�C���(��$�J�3�(��4�K�C����H�q�L�5�(��4�K�C���'� ������� � � %�����&�D��q�u�}�}��� � ������ �T�%5� �#�d�)�)�q�.�.� ��-:�BF��(�(�Q�Q�PR�-T�"U�"U�V�V�V�����%�F�� <� $�q���q�u�u�a�m������t�+�,�,�A��A�v�v����� %��u���d�l����a��f�n�� � ��&� �E�C��5�D��}�S�%��d�3�3�3s �B'D,�,'Ec��|jdSr�r�rBs r4r�zRange.<lambda>�r�r6c��|jdSr^r�rBs r4r�zRange.<lambda>�� ����1��r6c��|jdS)Nr8r�rBs r4r�zRange.<lambda>�rr6c�^�|�t��rK|j|jz |jz }|jrt d�|jD����std���|j|jkr|S|� |j|jz |j|jz |j ��S)z�Return an equivalent Range in the opposite order. Examples ======== >>> from sympy import Range >>> Range(10).reversed Range(9, -1, -1) c3�2K�|]}|jp|jV��dSr-�r[rr s r4r�z!Range.reversed.<locals>.<genexpr>��D����5F�5F�67�A�L�1�A�M�5F�5F�5F�5F�5F�5Fr6�!invalid method for symbolic range) rrr r�r �is_extended_positiver�r�r��func)r2r>s r4�reversedzRange.reversed�s��� �8�8�F� � � F���T�Z�'���2�A��)� F��5F�5F�;?�9�5F�5F�5F�2F�2F� F� �!D�E�E�E� �:��� "� "��K��y�y� �I�� � !�4�:�� �#9�D�I�:�G�G� Gr6c�*�tt��Sr-rErBs r4rFz Range._kind�rGr6c�>�|j|jkr tjS|jr tjS|jst |jS|�t��r?|j|jz |j z }|j rtd�|j D����sdSn|j }|jjr|j}n |jjr|j}n tjS|dkrt!||d��S||z |j z}|tjkrt|�t��r8t%d��}|�|���||��St+||jk||jk��S|jr tjSdS)Nc3�2K�|]}|jp|jV��dSr-r#r s r4r�z"Range._contains.<locals>.<genexpr>�r$r6r!rrj)r�r rr/rr[r"rrr r&r�r��size� is_finiter\rr9rrqr�rrn�supr)r2r3r>�ref�resr=s r4r5zRange._contains�s��� �:��� "� "��7�N� � � ��7�N��� )��u�'�(� (� �8�8�F� � � ���T�Z�'���2�A��)� ��5F�5F�;?�9�5F�5F�5F�2F�2F� ��� �� �A� �:� � ��*�C�C� �Y� � ��)�C�C��6�M� ��6�6��e�T�!�W�%�%� %��U�{�d�i�'�� �!�&�=�=��x�x���� <��#�J�J���)�)�!�,�,�1�1�!�U�;�;�;��u���(�%�4�8�*;�<�<� <� �^� ��7�N��4r6c#�K�|j}|�tj��s5|�tj��s|jst d���|jtjtjfvrt d���|j|jkr>|j}|j r |V�||j z }�t|��D]}|V�||j z }�dSdS)Nz"Cannot iterate over symbolic Rangez-Cannot iterate over Range with infinite start) r,rrrOrMrr�r�r rr r<)r2r>rj�_s r4r?zRange.__iter__�s����� �I�����a�j�!�!� B�Q�U�U�1�+=�%>�%>� B�!�,� B��@�A�A� A� �:�!�,�a�j�9� 9� 9��K�L�L� L� �Z�4�9� $� $�� �A��}� #�#��G�G�G����N�A�#��q���#�#�A��G�G�G����N�A�A�%� $�#�#r6c�V�|j|jz }||jz }|�tj��s(|�tj��s |jsdS|jtjtjfvrdS|jrtd�|j D����sdSdS)NFc3�$K�|] }|jV�� dSr-�r[r s r4r�z$Range.is_iterable.<locals>.<genexpr>s$����1R�1R�1�!�,�1R�1R�1R�1R�1R�1Rr6T) r r�r rrrOrMr�is_extended_nonnegativer�r��r2rr>s r4rLzRange.is_iterable�s����i�$�*�$�� �� �M�����a�j�!�!� �Q�U�U�1�+=�%>�%>� �!�,� ��5� �:�!�,�a�j�9� 9� 9��5��)� �c�1R�1R�� �1R�1R�1R�.R�.R� ��5��tr6c�h�|j}|tjurtd���t |��S)Nz0Use .size to get the length of an infinite Range)r,rrOr��int)r2�rvs r4�__len__z Range.__len__s0�� �Y�� ��� � ��O�P�P� P��2�w�w�r6c�2�|j|jkr tjS|j|jz }||jz }|jr tjS|jr:td�|j D����rtt|����Std���)Nc3�$K�|] }|jV�� dSr-r5r s r4r�zRange.size.<locals>.<genexpr>s$����-N�-N�q�a�l�-N�-N�-N�-N�-N�-Nr6�!Invalid method for symbolic Range) r�r rr9r rrOr6r�r�rrr�r7s r4r,z Range.size s��� �:��� "� "��6�M��i�$�*�$�� �� �M�� �=� ��:� � � %� !�#�-N�-N�D�I�-N�-N�-N�*N�*N� !��u�Q�x�x�=�=� ��<�=�=�=r6c�N�|jjr|jjrdS|jjSr�)r�r[r r,r-rBs r4rRzRange.is_finite_sets+�� �:� � �T�Y�%9� ��4��y�"�"r6c�>� |jjS#t$rYdSwxYwr-)r,�is_zeror�rBs r4rQzRange.is_emptys4�� ��9�$� $��� � � ��4�4� ���s � � �c�x�t|j|j��}|�td���t |�� S)Nz#cannot tell if Range is null or not)rr�r r��bool)r2�bs r4�__bool__zRange.__bool__#s9�� �$�*�d�i� (� (�� �9��B�C�C� C���7�7�{�r6c�� �d}d}d}d}t|t���ro|jjr�|j|jkrt d��S|�|j��\}}}t||z |z ��} | dkrt d��S|| |zz} | |z } ||j z} t |||| | z| ��S|j}|j}|j dkrt|���|j pd}||j z} |jj r|jj rt|���|jj r"|j |�|n| dz|�|n| |�j S|��|�9|dkrt |d|j| ��S|dkrt|���|S|dkr?|dkrt |d||| ��St |j||| ��S|dkr$|dkrt d��St|���|dkr$|dkrt|���t|���t|���|dkr�|�>|dkrt |||j| ��St |||j| ��S|dkrt ||||| ��S|dkr$|dkrt|���t d��S|dkrt|���dS|dkr�|�,|dkrt|���|dkrt|���|S|dkrF|dkrt|���|dkrt |j||| ��St d��St|���|dkrt|���dS|j|jkrtd���td �|jD����r|j|jz |j z jstd ���|dkr"|jj rt|���|jS|dkr*|jj rt|���|j|j z S|j} |dkr|jn|j||j zz} | j rt|���| |jz |j z }t#|j t%|j| |z jg��g��}|r| S|�td ���td���) Nz0cannot slice from the end with an infinite valuezslice step cannot be zeroz1slicing not possible on range with infinite startzBcannot unambiguously re-stride from the end with an infinite valuerr!r zRange index out of rangec3�2K�|]}|jp|jV��dSr-r#r s r4r�z$Range.__getitem__.<locals>.<genexpr>�s?����(�(��� �5�� �(�(�(�(�(�(r6r>)r.r r,r-r�r r`�indicesrr r�rr(� IndexErrorr�r�r&r r rv)r2rj�ooslice�zerostep�infinite� ambiguousr�r r r>�canonical_stopr��ssr:r��rels r4� __getitem__zRange.__getitem__,s~��D��.��F��%� � �a�� � �A 9��y�"�e .��:���*�*� ��8�8�O�$%�I�I�d�i�$8�$8�!��t�T��T�E�\�4�/�0�0����6�6� ��8�8�O�!&��4����$�t�+���$�)�^���T�%�[�$�s�)�b�.�"�=�=�=�����v���6�Q�;�;�$�X�.�.�.��v�{����$�)�^�� �:�)�/�d�i�.C�/�$�X�.�.�.� �9�(�'� �=� $� ���4�%�!�)�!&����U�F����'�'��=��|��!�8�8�#(��b��4�:�r�#B�#B�B�!�A�X�X�",�Y�"7�"7�7�#'�K������!�8�8�#(��b��4��:�r�#B�#B�B�#(���T�$�Z��#D�#D�D������!�8�8�#(��8�8�O�",�W�"5�"5�5������!�8�8�",�W�"5�"5�5�",�W�"5�"5�5�(��1�1�1��Q�Y�Y��|��!�8�8�#(��e��d�j�"�#E�#E�E�#(��e��d�i��#D�#D�D�����$�T�%�[�$�t�*�b�A�A�A������!�8�8�",�W�"5�"5�5�#(��8�8�O�����(��1�1�1�"���a�Z�Z��|��!�8�8�",�W�"5�"5�5�!�A�X�X�",�Y�"7�"7�7�#'�K������!�8�8�",�Y�"7�"7�7�!�Q�Y�Y�#(���T�$�Z��#D�#D�D�#(��8�8�O�(��1�1�1��Q�Y�Y�$�W�-�-�-��Y��z�T�Y�&�&� �!;�<�<�<��(�(�!�Y�(�(�(�(�(� F�.2�i�$�*�.D��I�.�3� F�!�!D�E�E�E��A�v�v��:�)�.�$�W�-�-�-��z�!��B�w�w��9�(�.�$�W�-�-�-��y�4�9�,�,�� �A� �1�u�u�$�)�)�$�*��$�)� �C�B��~� *� ��)�)�)��� �?�D�I�-�C��C�O�%�s�'9�A�c�E�;Q�&R�S�S�U�V�V�C�� �� ��{� �!D�E�E�E��7�8�8� 8r6c��|stjjS|�t��rxt d�|jD����rK|j|jz }|j j r|j r|jS|j j r|j r|j|j z Std���|j dkr|jS|j|j z S)Nc3�2K�|]}|jp|jV��dSr-r#r s r4r�zRange._inf.<locals>.<genexpr>��+����D�D�Q�1�<�0�1�=�D�D�D�D�D�Dr6r%r) rr�rnrrr�r�r r�r rZrr��r2rs r4rNz Range._inf�s���� "��:�>� !� �8�8�F� � � B��D�D�$�)�D�D�D�D�D� 1��i�$�*�,���9�(�1�S�_�1��:�%��Y�*�1�s��1��9�t�y�0�0��@�A�A� A� �9�q�=�=��:� ��9�t�y�(� (r6c��|stjjS|�t��rxt d�|jD����rK|j|jz }|j j r|j r|j|j z S|j j r|j r|jStd���|j dkr|j|j z S|jS)Nc3�2K�|]}|jp|jV��dSr-r#r s r4r�zRange._sup.<locals>.<genexpr>�rTr6r%r) rr�r.rrr�r�r r�r rZrr�rUs r4rPz Range._sup�s���� "��:�>� !� �8�8�F� � � B��D�D�$�)�D�D�D�D�D� &��i�$�*�,���9�(�&�S�_�&��9�t�y�0�0��Y�*�&�s��&��:�%��@�A�A� A� �9�q�=�=��9�t�y�(� (��:� r6c��|Sr-rTrBs r4rCzRange._boundary�rlr6c ��|jjr|jjrJ�|jj}n|j}|j}t t ||z |��d��}tt t |d��d��t t |d��d����}|j|jz |jz }|dkrtj � |��S|dkrtt ||��|��S |j |j }}n#t$rd}YnwxYw|�3t|jr||kn||k|jr||kn||k��}n�|j|j|jz }}tt|jdk|jr||kn||k|jr||kn||k��t|jdk|jr||kn||k|jr||kn||k����}t|||��S)z<Rewrite a Range in terms of equalities and logic operators. rr!Nr )r�rr r(r rr rrr�rqrnr.r�r ) r2rpr�r �in_seq�intsr>rD� range_conds r4rqzRange.as_relational�s�� �:� !� ��y�,� ,� ,�,�� �#�A�A�� �A��y���C��A��t�$�$�a�(�(���2�c�!�Q�i�i��#�#�R��D�!� � �a�%8�%8�9�9�� �Y��� #�T�Y� .�� ��6�6��:�+�+�A�.�.� .� ��6�6��r�!�Q�x�x��&�&� &� ��8�T�X�q�A�A��� � � ��A�A�A� ���� �=����2��A���A��F���2��A���A��F�4�4�J�J��:�t�y�4�9�4�q�A���D�I��N�Q�]�$F�A��E�E��Q����2��A���A��F�4�4��D�I��O�a�m�%G�Q��U�U��a����2��A���A��F�4�4�5�5�J� �6�4��,�,�,s�D� D�DN)rHrIrJrKr�rSr�r r r(rFr5r?rLr;r,rRrQrErQrNrPrCrqrTr6r4r`r`s�������P�P�dM4�M4�M4�^ �H�.�.� /� /�E� �8�-�-� .� .�D� �8�-�-� .� .�D� �G�G��X�G�(#�#�#����B#�#�#�"� � ��X� ���� � >� >��X� >��#�#��X�#� ����X�� ���J9�J9�J9�X�)�)��X�)� ����X�� ����X��-�-�-�-�-r6r`c�B�t|j|j|j��Sr-)r`r�r r )�rs r4r�r��s��E�!�'�1�6�1�6�$B�$B�r6c ��ddlm}|j�r�|j}|dtjzkr�|dtjzkru|jrn|jrg||j��}ttd|tjzdd��t|tjzdtjzdd����Stddtjzdd��S||j��||j ��}}|�|�td���|tjz}|tjz}||krQtttj |d|j��t|dtjz|jd����St|||j|j��S|jrNg}|D]@} || ��}|�td���|�|tjz���At!|�S|jrtd �|jD���S|�tj��rtd t+|��z���t-d |z���) a Normalize a Real Set `theta` in the interval `[0, 2\pi)`. It returns a normalized value of theta in the Set. For Interval, a maximum of one cycle $[0, 2\pi]$, is returned i.e. for theta equal to $[0, 10\pi]$, returned normalized value would be $[0, 2\pi)$. As of now intervals with end points as non-multiples of ``pi`` is not supported. Raises ====== NotImplementedError The algorithms for Normalizing theta Set are not yet implemented. ValueError The input is not valid, i.e. the input is not a real set. RuntimeError It is a bug, please report to the github issue tracker. Examples ======== >>> from sympy.sets.fancysets import normalize_theta_set >>> from sympy import Interval, FiniteSet, pi >>> normalize_theta_set(Interval(9*pi/2, 5*pi)) Interval(pi/2, pi) >>> normalize_theta_set(Interval(-3*pi/2, pi/2)) Interval.Ropen(0, 2*pi) >>> normalize_theta_set(Interval(-pi/2, pi/2)) Union(Interval(0, pi/2), Interval.Ropen(3*pi/2, 2*pi)) >>> normalize_theta_set(Interval(-4*pi, 3*pi)) Interval.Ropen(0, 2*pi) >>> normalize_theta_set(Interval(-3*pi/2, -pi/2)) Interval(pi/2, 3*pi/2) >>> normalize_theta_set(FiniteSet(0, pi, 3*pi)) {0, pi} r)� _pi_coeffr8FTNzBNormalizing theta without pi as coefficient is not yet implementedz@Normalizing theta without pi as coefficient, is not Implemented.c�,�g|]}t|����SrT)�normalize_theta_set)r��intervals r4r�z'normalize_theta_set.<locals>.<listcomp>Ms!��P�P�P��*�8�4�4�P�P�Pr6z;Normalizing theta when, it is of type %s is not implementedz %s is not a real set)�(sympy.functions.elementary.trigonometricr`� is_Interval�measurer�Pir�r�r�r%r$r��NotImplementedErrorr9r�r�r&�is_Unionr�rarA�typer�) �thetar`� interval_len�k�k_start�k_end� new_start�new_end� new_theta�elements r4rbrbsz��LC�B�B�B�B�B� ��*<��}� � �1�Q�T�6� !� !��q���v�%�%�%�/�%�e�>N�%��I�e�k�*�*���X�a��1�4����=�=� ��1�4���1�4���t�<�<�>�>�>��A�q���v�u�d�3�3� 3�"��5�;�/�/���5�9�1E�1E��� �?�e�m�%�':�;�;� ;��A�D�L� ����*�� �w� � ���!�&�'�5�%�:J�K�K�!�)�Q�q�t�V�U�_�d�K�K�M�M� M��I�w����AQ�R�R� R� � �<�� �� )� )�G�� �'�"�"�A��y�)�+M�N�N�N�� � ��1�4��(�(�(�(��)�$�$� ��<��P�P�U�Z�P�P�P�Q�Q� ����� !� !�<�!�#0�26�u�+�+�#>�?�?� ?��0�E�:�;�;�;r6c��eZdZdZdZdd�Zed���Zed���Zed���Z ed���Z ed ���Z d �Z e d ���Zd �Zd S)� ComplexRegionaA Represents the Set of all Complex Numbers. It can represent a region of Complex Plane in both the standard forms Polar and Rectangular coordinates. * Polar Form Input is in the form of the ProductSet or Union of ProductSets of the intervals of ``r`` and ``theta``, and use the flag ``polar=True``. .. math:: Z = \{z \in \mathbb{C} \mid z = r\times (\cos(\theta) + I\sin(\theta)), r \in [\texttt{r}], \theta \in [\texttt{theta}]\} * Rectangular Form Input is in the form of the ProductSet or Union of ProductSets of interval of x and y, the real and imaginary parts of the Complex numbers in a plane. Default input type is in rectangular form. .. math:: Z = \{z \in \mathbb{C} \mid z = x + Iy, x \in [\operatorname{re}(z)], y \in [\operatorname{im}(z)]\} Examples ======== >>> from sympy import ComplexRegion, Interval, S, I, Union >>> a = Interval(2, 3) >>> b = Interval(4, 6) >>> c1 = ComplexRegion(a*b) # Rectangular Form >>> c1 CartesianComplexRegion(ProductSet(Interval(2, 3), Interval(4, 6))) * c1 represents the rectangular region in complex plane surrounded by the coordinates (2, 4), (3, 4), (3, 6) and (2, 6), of the four vertices. >>> c = Interval(1, 8) >>> c2 = ComplexRegion(Union(a*b, b*c)) >>> c2 CartesianComplexRegion(Union(ProductSet(Interval(2, 3), Interval(4, 6)), ProductSet(Interval(4, 6), Interval(1, 8)))) * c2 represents the Union of two rectangular regions in complex plane. One of them surrounded by the coordinates of c1 and other surrounded by the coordinates (4, 1), (6, 1), (6, 8) and (4, 8). >>> 2.5 + 4.5*I in c1 True >>> 2.5 + 6.5*I in c1 False >>> r = Interval(0, 1) >>> theta = Interval(0, 2*S.Pi) >>> c2 = ComplexRegion(r*theta, polar=True) # Polar Form >>> c2 # unit Disk PolarComplexRegion(ProductSet(Interval(0, 1), Interval.Ropen(0, 2*pi))) * c2 represents the region in complex plane inside the Unit Disk centered at the origin. >>> 0.5 + 0.5*I in c2 True >>> 1 + 2*I in c2 False >>> unit_disk = ComplexRegion(Interval(0, 1)*Interval(0, 2*S.Pi), polar=True) >>> upper_half_unit_disk = ComplexRegion(Interval(0, 1)*Interval(0, S.Pi), polar=True) >>> intersection = unit_disk.intersect(upper_half_unit_disk) >>> intersection PolarComplexRegion(ProductSet(Interval(0, 1), Interval(0, pi))) >>> intersection == upper_half_unit_disk True See Also ======== CartesianComplexRegion PolarComplexRegion Complexes TFc�l�|durt|��S|durt|��Std���)NFTz$polar should be either True or False)�CartesianComplexRegion�PolarComplexRegionr�)r�r��polars r4r�zComplexRegion.__new__�s?�� �E�>�>�)�$�/�/� /� �d�]�]�%�d�+�+� +��C�D�D� Dr6c��|jdS)a Return raw input sets to the self. Examples ======== >>> from sympy import Interval, ComplexRegion, Union >>> a = Interval(2, 3) >>> b = Interval(4, 5) >>> c = Interval(1, 7) >>> C1 = ComplexRegion(a*b) >>> C1.sets ProductSet(Interval(2, 3), Interval(4, 5)) >>> C2 = ComplexRegion(Union(a*b, b*c)) >>> C2.sets Union(ProductSet(Interval(2, 3), Interval(4, 5)), ProductSet(Interval(4, 5), Interval(1, 7))) rr�rBs r4r�zComplexRegion.sets�s��(�y��|�r6c�R�|jjrd}||jfz}n |jj}|S)a Return a tuple of sets (ProductSets) input of the self. Examples ======== >>> from sympy import Interval, ComplexRegion, Union >>> a = Interval(2, 3) >>> b = Interval(4, 5) >>> c = Interval(1, 7) >>> C1 = ComplexRegion(a*b) >>> C1.psets (ProductSet(Interval(2, 3), Interval(4, 5)),) >>> C2 = ComplexRegion(Union(a*b, b*c)) >>> C2.psets (ProductSet(Interval(2, 3), Interval(4, 5)), ProductSet(Interval(4, 5), Interval(1, 7))) rT)r�r�r�)r2�psetss r4r|zComplexRegion.psets�s4��( �9� "� #��E��T�Y�M�)�E�E��I�N�E�� r6c�p�g}|jD]"}|�|jd���#t|�}|S)a2 Return the union of intervals of `x` when, self is in rectangular form, or the union of intervals of `r` when self is in polar form. Examples ======== >>> from sympy import Interval, ComplexRegion, Union >>> a = Interval(2, 3) >>> b = Interval(4, 5) >>> c = Interval(1, 7) >>> C1 = ComplexRegion(a*b) >>> C1.a_interval Interval(2, 3) >>> C2 = ComplexRegion(Union(a*b, b*c)) >>> C2.a_interval Union(Interval(2, 3), Interval(4, 5)) r�r|r�r�r%)r2� a_intervalrss r4rzComplexRegion.a_interval��G��,� ��z� /� /�G� � � �g�l�1�o� .� .� .� .��J�'� ��r6c�p�g}|jD]"}|�|jd���#t|�}|S)a Return the union of intervals of `y` when, self is in rectangular form, or the union of intervals of `theta` when self is in polar form. Examples ======== >>> from sympy import Interval, ComplexRegion, Union >>> a = Interval(2, 3) >>> b = Interval(4, 5) >>> c = Interval(1, 7) >>> C1 = ComplexRegion(a*b) >>> C1.b_interval Interval(4, 5) >>> C2 = ComplexRegion(Union(a*b, b*c)) >>> C2.b_interval Interval(1, 7) r!r~)r2� b_intervalrss r4r�zComplexRegion.b_interval�r�r6c��|jjS)ay The measure of self.sets. Examples ======== >>> from sympy import Interval, ComplexRegion, S >>> a, b = Interval(2, 5), Interval(4, 8) >>> c = Interval(0, 2*S.Pi) >>> c1 = ComplexRegion(a*b) >>> c1.measure 12 >>> c2 = ComplexRegion(a*c, polar=True) >>> c2.measure 6*pi )r��_measurerBs r4r�zComplexRegion._measures��&�y�!�!r6c�&�|jdjSr�)r�rrBs r4rFzComplexRegion._kind.s���y��|� � r6c��|�tj��std���t |t d��z��S)a2 Converts given subset of real numbers to a complex region. Examples ======== >>> from sympy import Interval, ComplexRegion >>> unit = Interval(0,1) >>> ComplexRegion.from_real(unit) CartesianComplexRegion(ProductSet(Interval(0, 1), {0})) z&sets must be a subset of the real liner)rarrAr�rwr&)r�r�s r4� from_realzComplexRegion.from_real1sC���~�~�a�g�&�&� G��E�F�F� F�%�d�Y�q�\�\�&9�:�:�:r6c�������ddlm}m}t|t��}|r"t |��dkrt d���t|ttf��s tj S|j sG|r|n|� ��\��tt��fd�|jD����S|j r�|jr)ttd�|jD����S|r|\��n||��||��c���jrG�jrB�dtjzz�tt��fd�|jD����SdSdSdS)Nr)�arg�Absr8zexpecting Tuple of length 2c3��K�|]Q}t|jd����|jd����g��V��RdS�rr!N�r r�r5)r��pset�im�res ��r4r�z*ComplexRegion._contains.<locals>.<genexpr>Rsv����� (� (��!*�� �!� �&�&�r�*�*�� �!� �&�&�r�*�*�+,�!-�!-� (� (� (� (� (� (r6c3�jK�|].}|jd�tj��V��/dS)rN)r�r5rr9)r�r�s r4r�z*ComplexRegion._contains.<locals>.<genexpr>[sL����$,�$,��%)�I�a�L�$:�$:�1�6�$B�$B�$,�$,�$,�$,�$,�$,r6c3��K�|]Q}t|jd����|jd����g��V��RdSr�r�)r�r�r^rks ��r4r�z*ComplexRegion._contains.<locals>.<genexpr>dsv�����$,�$,��%.��I�a�L�*�*�1�-�-��I�a�L�*�*�5�1�1�/3�%4�%4�$,�$,�$,�$,�$,�$,r6)�sympy.functionsr�r�r.rr�r�rrr/ry� as_real_imagr"r r|rA�is_real� is_numberrg) r2r3r�r��isTupler�r^r�rks @@@@r4r5zComplexRegion._containsDs�������,�,�,�,�,�,�,�,��U�E�*�*�� � <�s�5�z�z�Q����:�;�;� ;��%�$���/�/� ��7�N��z� -�%�?�U�U�5�+=�+=�+?�+?�F�B���x� (� (� (� (� (�!�J� (� (� (�(�(�)� )� �Z� -��}� -��8�$,�$,� $� �$,�$,�$,�,�,�-�-�� 2� ���5�5��3�u�:�:�s�s�5�z�z���5��}� -��� -���1�4�����8�$,�$,�$,�$,�$,�!%� �$,�$,�$,�,�,�-�-� -� -� -� -� -� -r6N)F)rHrIrJrK�is_ComplexRegionr�rSr�r|rr�r�rFrr�r5rTr6r4ruruVs������L�L�Z��E�E�E�E�����X��*����X��4����X��8����X��8�"�"��X�"�(!�!�!��;�;��[�;�$#-�#-�#-�#-�#-r6ruc�L�eZdZdZdZede���Zd�Ze d���Z dS)rwa� Set representing a square region of the complex plane. .. math:: Z = \{z \in \mathbb{C} \mid z = x + Iy, x \in [\operatorname{re}(z)], y \in [\operatorname{im}(z)]\} Examples ======== >>> from sympy import ComplexRegion, I, Interval >>> region = ComplexRegion(Interval(1, 3) * Interval(4, 6)) >>> 2 + 5*I in region True >>> 5*I in region False See also ======== ComplexRegion PolarComplexRegion Complexes Fzx, y�r�c��|tjtjzkr tjStd�|jD����rht |j��dkrPg}|jdD]7}|jdD]'}|�|tj|zz���(�8t|�Stj ||��S)Nc3�$K�|] }|jV�� dSr-r�)r��_as r4r�z1CartesianComplexRegion.__new__.<locals>.<genexpr>�s$����3�3�2�r��3�3�3�3�3�3r6r8rr!) rrA� Complexesr�r�r�r�� ImaginaryUnitr&r#r�)r�r�� complex_numrp�ys r4r�zCartesianComplexRegion.__new__�s��� �1�7�1�7�?� "� "��;� � �3�3���3�3�3� 3� 3� *��T�Y���1�9L�9L��K��Y�q�\� >� >����1��>�>�A��&�&�q�1�?�1�+<�'<�=�=�=�=�>��k�*� *��;�s�D�)�)� )r6c�:�|j\}}|tj|zzSr-)r�rr�)r2rpr�s r4r�zCartesianComplexRegion.expr�s���~���1��1�?�1�$�$�$r6N� rHrIrJrKryrrr�r�rSr�rTr6r4rwrwjsc��������. �E����E�*�*�*�I�*�*�*�*�%�%��X�%�%�%r6rwc�L�eZdZdZdZede���Zd�Ze d���Z dS)rxaX Set representing a polar region of the complex plane. .. math:: Z = \{z \in \mathbb{C} \mid z = r\times (\cos(\theta) + I\sin(\theta)), r \in [\texttt{r}], \theta \in [\texttt{theta}]\} Examples ======== >>> from sympy import ComplexRegion, Interval, oo, pi, I >>> rset = Interval(0, oo) >>> thetaset = Interval(0, pi) >>> upper_half_plane = ComplexRegion(rset * thetaset, polar=True) >>> 1 + I in upper_half_plane True >>> 1 - I in upper_half_plane False See also ======== ComplexRegion CartesianComplexRegion Complexes Tzr, thetar�c�P�g}|js |jD]}|�|���n|�|��t|��D];\}}t |jdt |jd����||<�<t |�}tj||��S)Nrr!) r�r�r�� enumerater'rbr%r#r�)r�r��new_setsrmr�s r4r�zPolarComplexRegion.__new__�s������!� "��Y� #� #������"�"�"�"� #� �O�O�D� !� !� !��h�'�'� E� E�D�A�q�$�Q�V�A�Y�%8�����%C�%C�E�E�H�Q�K�K��h����{�3��%�%�%r6c�t�|j\}}|t|��tjt |��zzzSr-)r�rrr�r)r2r^rks r4r�zPolarComplexRegion.expr�s0���>���5��#�e�*�*�q��s�5�z�z�9�9�:�:r6Nr�rTr6r4rxrx�sc��������4 �E��� ��.�.�.�I�&�&�&�"�;�;��X�;�;�;r6rxc�6�eZdZdZdZdZed���Zd�ZdS)r�z� The :class:`Set` of all complex numbers Examples ======== >>> from sympy import S, I >>> S.Complexes Complexes >>> 1 + I in S.Complexes True See also ======== Reals ComplexRegion Fc�J�ttjtj��Sr-)r'rrArBs r4r�zComplexes.sets�s���!�'�1�7�+�+�+r6c�*�tj|��Sr-)r#r�r�s r4r�zComplexes.__new__�s���{�3���r6N) rHrIrJrKrQrRrSr�r�rTr6r4r�r��sT��������(�H��M��,�,��X�,� � � � � r6r�N)G� functoolsr� itertoolsr�sympy.core.basicr�sympy.core.containersr�sympy.core.exprr�sympy.core.functionr�sympy.core.logicr r r �sympy.core.modr �sympy.core.intfuncr �sympy.core.numbersrr�sympy.core.relationalrr�sympy.core.kindr�sympy.core.singletonrr�sympy.core.symbolrrr�sympy.core.sympifyrrr�#sympy.functions.elementary.integersrrrdrr�sympy.logic.boolalgrr r�r"r#r$r%r&r'r(�sympy.utilities.miscr)r+rWrtrzrAr�r`r<rbrurwrxr�rTr6r4�<module>r�s#��������������"�"�"�"�"�"�'�'�'�'�'�'� � � � � � �&�&�&�&�&�&�;�;�;�;�;�;�;�;�;�;�������#�#�#�#�#�#�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�+�&�&�&�&�&�&�-�-�-�-�-�-�-�-�4�4�4�4�4�4�4�4�4�4�B�B�B�B�B�B�B�B�B�B�>�>�>�>�>�>�>�>�=�=�=�=�=�=�=�=�'�'�'�'�'�'�'�'�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�K�+�+�+�+�+�+�.#�.#�.#�.#�.#��y�.#�.#�.#�.#�b?#�?#�?#�?#�?#�s�i�?#�?#�?#�?#�D,�,�,�,�,��,�,�,�6F1�F1�F1�F1�F1�s�i�F1�F1�F1�F1�R1>�1>�1>�1>�1>�H� �1>�1>�1>�1>�ha-�a-�a-�a-�a-�s�a-�a-�a-�Hu-�u-�u-�u-�u-�C�u-�u-�u-�pC�B����R<�R<�R<�jQ-�Q-�Q-�Q-�Q-�C�Q-�Q-�Q-�h3%�3%�3%�3%�3%�]�3%�3%�3%�l2;�2;�2;�2;�2;��2;�2;�2;�j � � � � �&�)� � � � � � r6
Memory