403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.206
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/simplify/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

�8Va��@s�ddlmZddlmZmZmZddlmZddlm	Z	m
Z
mZmZm
Z
ddlmZmZddlmZmZddlmZdd	�Zd
dd�d
d�ZdS)�)�combinations_with_replacement)�symbols�Add�Dummy)�Rational)�cancel�ComputationFailed�parallel_poly_from_expr�reduced�Poly)�Monomial�monomial_div)�DomainError�PolificationFailed)�debugcCsZt|���\}}z
t||gddd�\}}Wn
ty"||YSwt|�t||�S)z�
    Put an expression over a common denominator, cancel and reduce.

    Examples
    ========

    >>> from sympy import ratsimp
    >>> from sympy.abc import x, y
    >>> ratsimp(1/x + 1/y)
    (x + y)/(x*y)
    TF)�field�expand)r�as_numer_denomr
rr)�expr�f�g�Q�r�r�8/usr/lib/python3/dist-packages/sympy/simplify/ratsimp.py�ratsimp	s
�rTF)�quick�
polynomialcs�ddlm�td|�t|���\}}zt||g�g|�Ri|��\}�Wnty1|YSw�j}	|	jr>|	�	��_nt
d|	���fdd�|dd�D��t�����fd	d
��d�������fdd�	�t|��j
�jd
�d}t|��j
�jd
�d}|r�||��S�t|�j
�jd�t|�j
�jd�g�\}
}}�s�|r�tdt|��g}
|D]\}}}}�||ddd�}|
�|�|�|�|�f�q�t|
dd�d�\}
}|	js�|
jdd�\}}
|jdd�\}}t||�}ntd�}|
|j||jS)a�
    Simplifies a rational expression ``expr`` modulo the prime ideal
    generated by ``G``.  ``G`` should be a Groebner basis of the
    ideal.

    Examples
    ========

    >>> from sympy.simplify.ratsimp import ratsimpmodprime
    >>> from sympy.abc import x, y
    >>> eq = (x + y**5 + y)/(x - y)
    >>> ratsimpmodprime(eq, [x*y**5 - x - y], x, y, order='lex')
    (-x**2 - x*y - x - y)/(-x**2 + x*y)

    If ``polynomial`` is ``False``, the algorithm computes a rational
    simplification which minimizes the sum of the total degrees of
    the numerator and the denominator.

    If ``polynomial`` is ``True``, this function just brings numerator and
    denominator into a canonical form. This is much faster, but has
    potentially worse results.

    References
    ==========

    .. [1] M. Monagan, R. Pearce, Rational Simplification Modulo a Polynomial
        Ideal, http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.163.6984
        (specifically, the second algorithm)
    r)�solve�ratsimpmodprimez-can't compute rational simplification over %scsg|]}|��j��qSr)�LM�order)�.0r��optrr�
<listcomp>Ssz#ratsimpmodprime.<locals>.<listcomp>�Ncs�|dkrdgSg}ttt�j��|�D]'}dgt�j��|D]
}�|d7<qt�fdd��D��r:|���q�fdd�|D��|d�S)z�
        Compute all monomials with degree less than ``n`` that are
        not divisible by any element of ``leading_monomials``.
        r�csg|]	}t�|�du�qS)N)r
)r"�lmg��mrrr%bsz6ratsimpmodprime.<locals>.staircase.<locals>.<listcomp>csg|]
}t|�j�j��qSr)r�as_expr�gens�r"�sr#rrr%f�)r�range�lenr,�all�append)�n�S�mi�i)�leading_monomialsr$�	staircaser)rr9Vs�
�z"ratsimpmodprime.<locals>.staircasec
s�||}}d}|��|��}�r|d}	n|}	|||	k�r2||f�
vr'�n�
�||f��	|���	|��td||��f�tdt��td��tdt��td����}
tt��fdd�tt���D���j	|
�}tt��fd	d�tt���D���j	|
�}t
||||��j	|
�jd
d�d}
t|
�j	d���}�|��d
d
d
�}|�r t
dd�|��D���s |�|�}|�|�}|�ttt��dgt��t������}|�ttt��dgt��t������}t|�j	�}t|�j	�}|dk�rtd��|�|||��f�|||k�r|dg}n|d7}|d7}|d7}|||	ks|dk�rQ�||||||�\}}}�||||||�\}}}|||fS)ak
        Computes a rational simplification of ``a/b`` which minimizes
        the sum of the total degrees of the numerator and the denominator.

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

        The algorithm proceeds by looking at ``a * d - b * c`` modulo
        the ideal generated by ``G`` for some ``c`` and ``d`` with degree
        less than ``a`` and ``b`` respectively.
        The coefficients of ``c`` and ``d`` are indeterminates and thus
        the coefficients of the normalform of ``a * d - b * c`` are
        linear polynomials in these indeterminates.
        If these linear polynomials, considered as system of
        equations, have a nontrivial solution, then `\frac{a}{b}
        \equiv \frac{c}{d}` modulo the ideal generated by ``G``. So,
        by construction, the degree of ``c`` and ``d`` is less than
        the degree of ``a`` and ``b``, so a simpler representation
        has been found.
        After a simpler representation has been found, the algorithm
        tries to reduce the degree of the numerator and denominator
        and returns the result afterwards.

        As an extension, if quick=False, we look at all possible degrees such
        that the total degree is less than *or equal to* the best current
        solution. We retain a list of all solutions of minimal degree, and try
        to find the best one at the end.
        rr'z%s / %s: %s, %szc:%d)�clszd:%dc�g|]
}�|�|�qSrr�r"r7)�Cs�M1rrr%�r/z=ratsimpmodprime.<locals>._ratsimpmodprime.<locals>.<listcomp>cr;rrr<)�Ds�M2rrr%�r/T)r!�polys)r,��
particularrcSsg|]}|dk�qS)rrr-rrrr%�szIdeal not prime?���)�total_degree�addrrr1rr�sumr0r,r
r!�coeffsr2�values�subs�dict�list�zip�
ValueErrorr3)�a�b�allsol�N�D�c�d�steps�maxdeg�bound�ng�c_hat�d_hatrr5�sol)�G�_ratsimpmodprimer$rrr9�tested)r=r?r>r@rr^hsd

&�&���

..

�
1
z)ratsimpmodprime.<locals>._ratsimpmodprime)r!r')�domainz*Looking for best minimal solution. Got: %sTFrBcSs t|d���t|d���S)Nrr')r1�terms)�xrrr�<lambda>�s z!ratsimpmodprime.<locals>.<lambda>)�key)�convert)rr)�sympyrrrrr	rr`�has_assoc_Field�	get_fieldr�setr
r,r!rr1r3rJ�min�is_Field�clear_denomsr�q�p)rr]rrr,�args�num�denomrAr`rTrUrQ�newsolrZr[r5rYr\�cn�dnrr)r]r^r8r$rrr9r_rrsL
&��^"
�rN)�	itertoolsr�
sympy.corerrr�sympy.core.numbersr�sympy.polysrrr	r
r�sympy.polys.monomialsrr
�sympy.polys.polyerrorsrr�sympy.utilities.miscrrrrrrr�<module>s

Youez - 2016 - github.com/yon3zu
LinuXploit