| 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 : |
o
�8Va� � @ s� d dl mZ d dlmZmZmZ d dlmZ d dlm Z m
Z
mZmZm
Z
d dlmZmZ d dlmZmZ d dlmZ dd � 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)�debugc C sZ t | ��� \}}z
t||gddd�\}}W n
ty" || Y S w t|� 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
r r )�expr�f�g�Q�r� r �8/usr/lib/python3/dist-packages/sympy/simplify/ratsimp.py�ratsimp s
�r TF)�quick�
polynomialc s� ddl m� td| � t| ��� \}}zt||g� g|�R i |��\}�W n ty1 | Y S w �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 ||j S )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 %sc s g | ]}|� � j��qS r )�LM�order)�.0r ��optr r �
<listcomp>S s z#ratsimpmodprime.<locals>.<listcomp>� Nc s� | dkrdgS g }t tt�j��| �D ]'}dgt�j� � |D ]
}� | d7 <