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/integrals/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

�8VaV��@sXdZddlmZmZddlmZmZddlm	Z	ddl
mZddlZddl
mZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZmZmZmZddlm Z m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ej(j)Z*�ddd�Z+e+dd�Z,e+dd�Z-e+dd�Z.e+dd�Z/e+dd�Z0e+d d!�Z1e+d"d#�Z2e+d$d%�Z3e+d&d�Z4e+d'd(�Z5e+d)�Z6e+d*d(�Z7e+d+d,�Z8e+d-�Z9e+d.�Z:e+d/d0�Z;e+d1d2�Z<e+d3d4�Z=e+d5d6�Z>e+d7d8�Z?e+d9d8�Z@e+d:d8�ZAe+d;d<�ZBe+d=d>�ZCe+d?d@�ZDe+dAd@�ZEe+dBd@�ZFe+dCd@�ZGe+dDd@�ZHe+dEd>�ZIe+dFdG�ZJe+dHdG�ZKe+dIdG�ZLe+dJdG�ZMe+dKdG�ZNe+dLd8�ZOe+dMd8�ZPe+dNd8�ZQe+dOdG�ZRe+dPdG�ZSe+dQdR�ZTe+dSdT�ZUe+dUdT�ZVedVdW�ZWiZXdXdY�ZYdZd[�ZZd\d]�Z[d^d_�Z\ej]ej^ej_ej`ejaejbfZcd`da�Zddbdc�Zeddde�Zfdfdg�Zgdhd,�Zhdidj�Zidkdl�Zjdmdn�Zkdodp�Zldqdr�Zmdsdt�Zndudv�Zodwdx�Zpdydz�Zqd{d|�Zrd}d~�Zsdd��Ztd�d��Zud�d��Zvejwd�d���Zxejwd�d���Zyejwd�d���Zzejwd�d���Z{ejwd�d���Z|d�d��Z}d�d��Z~e}d�d���Ze~d�d���Z�e}d�d���Z�e~d�d���Z�e}d�d���Z�e~d�d���Z�e}d�d���Z�e~d�d���Z�e}d�d���Z�e~d�d���Z�e}d�d���Z�e~d�d���Z�e}d�d���Z�e~d�d���Z�e}d�d���Z�e~d�d���Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�eed�d��d�d���Z�eed�d��d�d���Z�eed�d��d�d���Z�eed�d��d�d���Z�d�d��Z�d�d��Z�d�d��Z�iZ�ee��Z�e��d¡Z�d�dĄZ�eYe,�d�dƄ�Z�eYe-�d�dȄ�Z�eYe.�d�dʄ�Z�eYe4�d�d̄�Z�eYe/�d�d΄�Z�eYe0�d�dЄ�Z�eYe1�d�d҄�Z�eYe2�d�dԄ�Z�eYe3�d�dք�Z�eYe?�d�d؄�Z�eYe@�d�dڄ�Z�eYeA�d�d܄�Z�eYe5�d�dބ�Z�eYe6�d�d��Z�eYe7�d�d��Z�eYe8�d�d��Z�eYe;�d�d��Z�eYe<�d�d��Z�eYe>�d�d��Z�eYe:�d�d��Z�eYe=�d�d��Z�eYeB�d�d��Z�eYeC�d�d��Z�eYeD�d�d��Z�eYeE�d�d���Z�eYeF�d�d���Z�eYeG�d�d���Z�eYeH�d�d���Z�eYeI�d�d���Z�eYeJ�d��d��Z�eYeK��d�d��Z�eYeL��d�d��Z�eYeM��d�d��Z�eYeN��d�d��Z�eYeO��d	�d
��Z�eYeP��d�d��Z�eYeQ��d
�d��Z�eYeR��d�d��Z�eYeS��d�d��Z�eYeT��d�d��Z�eYeU��d�d��Z�eYeV��d�d��Z�eYe9��d�d��Zΐd�d�Zϐd�d�Z�dS( a�Integration method that emulates by-hand techniques.

This module also provides functionality to get the steps used to evaluate a
particular integral, in the ``integral_steps`` function. This will return
nested namedtuples representing the integration rules used. The
``manualintegrate`` function computes the integral using those steps given
an integrand; given the steps, ``_manualintegrate`` will evaluate them.

The integrator can be extended with new heuristics and evaluation
techniques. To do so, write a function that accepts an ``IntegralInfo``
object and returns either a namedtuple representing a rule or
``None``. Then, write another function that accepts the namedtuple's fields
and returns the antiderivative, and decorate it with
``@evaluates(namedtuple_type)``.  If the new technique requires a new
match, add the key and call to the antiderivative function to integral_steps.
To enable simple substitutions, add the match to find_substitutions.

�)�Dict�Optional)�
namedtuple�defaultdict)�Mapping)�reduceN)�iterable)r)�Expr)�	fuzzy_not)�TrigonometricFunction)�OrthogonalPolynomial)�	Piecewise)�switch�do_one�	null_safe�	condition)�Eq�Ne��degree)�divisors)�debug�cs2dd���fdd�}t||d�}�|_||_|S)NcSs|j|jkot�||�S�N)�	__class__�tuple�__eq__��self�other�r �A/usr/lib/python3/dist-packages/sympy/integrals/manualintegrate.pyr,szRule.<locals>.__eq__cs�||�Srr r�rr r!�<lambda>.�zRule.<locals>.<lambda>z context symbol)rr�__ne__)�name�props�__neq__�clsr r"r!�Rule*sr*�ConstantRule�constant�ConstantTimesRulezconstant other substep�	PowerRulezbase exp�AddRule�substeps�URulezu_var u_func constant substep�	PartsRulezu dv v_step second_step�CyclicPartsRulezparts_rules coefficient�TrigRulezfunc arg�ExpRule�ReciprocalRule�func�
ArcsinRule�InverseHyperbolicRule�AlternativeRule�alternatives�DontKnowRule�DerivativeRule�RewriteRulezrewritten substep�
PiecewiseRule�subfunctions�
HeavisideRulezharg ibnd substep�TrigSubstitutionRulez(theta func rewritten substep restriction�
ArctanRuleza b c�ArccothRule�ArctanhRule�
JacobiRulezn a b�GegenbauerRulezn a�ChebyshevTRule�n�ChebyshevURule�LegendreRule�HermiteRule�LaguerreRule�AssocLaguerreRule�CiRuleza b�ChiRule�EiRule�SiRule�ShiRule�ErfRule�FresnelCRule�FresnelSRule�LiRule�PolylogRule�UpperGammaRuleza e�
EllipticFRuleza d�
EllipticERule�IntegralInfozintegrand symbolc��fdd�}|S)Ncs�|_|t�<|Sr)�rule�
evaluators�r7�r^r r!�
_evaluateseszevaluates.<locals>._evaluatesr )r^rbr rar!�	evaluatesdsrccCsXt|t�rdS|D] }t|t�rt|�rdSq	t|t�r)tdd�|D��r)dSq	dS)NTcss�|]}t|�VqdSr��contains_dont_know��.0�ir r r!�	<genexpr>ts�z%contains_dont_know.<locals>.<genexpr>F)�
isinstancer<rre�list�any)r^�valr r r!reks

�
�recs$|jr�|jd}t|tj�r|���t�|�dSt|tj�r-|���t�|�dSt|tj�rB|���t�|�t�|�St|tj�rX|���t�|�t�|�St|tj�rjt	�fdd�|jD��St|tj
�r�t|j�dkr�t|jdtj�r�|jdt
|jd��S|���S)aDerivative of f in form expected by find_substitutions

    SymPy's derivatives for some trig functions (like cot) aren't in a form
    that works well with finding substitutions; this replaces the
    derivatives for those particular forms with something that works better.

    r�c�g|]}t|���qSr )�manual_diff�rg�arg��symbolr r!�
<listcomp>��zmanual_diff.<locals>.<listcomp>�)�argsrj�sympy�tan�diff�sec�cot�csc�Add�sum�Mul�len�Numberrp)�frtrrr rsr!rpxs 
  
rpcs�t|�dkr|d}t|ttf�r|��}nt|�std��nt|�dkr)|g}ntd��g}|D]'\}�t|tj�rX|j	d�|�
�fdd��fdd��}|��t���f�q1|�
t|�|�S)	zn
    A wrapper for `expr.subs(*args)` with additional logic for substitution
    of invertible functions.
    rwrz(Expected an iterable of (old, new) pairsrnz$subs accepts either 1 or 2 argumentscs|jo|j�kSr)�is_Pow�base��x)�x0r r!r#��zmanual_subs.<locals>.<lambda>cst�|j��Sr)ry�expr�)�newr r!r#�r�)r�rjrr�itemsr�
ValueErrorry�logrx�replace�appendr��subsrk)�exprrx�sequence�new_subs�oldr )r�r�r!�manual_subs�s(
�

��r�c
s�g}���fdd�}��fdd�����D]0}|�krqt|��}|||�}|durE|\}}|�����kr7q|||f}	|	|vrE|�|	�q|S)Ncsj|dkrdS�|}�|jvrdStd�||���t||����}�|jvrX����rQ|���rQt�fdd����D��}t�fdd�|��D��}||krQdS|j�dd�St	|t
j�r�d|jj
r�t
�|j�dkr�t
jd	�gd
�}t
jd�gd
�}|j�|�|���r��fdd�||fD�\}}|dkr�|dkr�|���d|j||�}|j�dd�SdS)
NrFz!substituted: {}, u: {}, u_var: {}cror r�rg�trsr r!ru�rvz<find_substitutions.<locals>.test_subterm.<locals>.<listcomp>cror rr�)�u_varr r!ru�rv)�as_Addrw�a��exclude�bc�g|]}��|t��qSr ��get�ZEROrf��matchr r!ru��)�free_symbolsr�formatr��cancel�is_rational_function�max�as_numer_denom�as_independentrjry�Powr��
is_Integer�Abs�Wildr�r�r�)�u�u_diff�substituted�
deg_before�	deg_afterr�r�)�	integrandrtr�r�r!�test_subterm�s6

�z(find_substitutions.<locals>.test_subtermcs�t�tgt�tj�tj�tj�R�r�jdgSt�tjtj	tj
tjtjf�r-�jdgSt�tj
tjf�r<�jdgSt�tj�rH�jdgSt�tj�rdg}�jD]}|�|�|��|��qS|St�tj�r�g}�jd���r}|��jd�n�jd���r�|��jd��jdjr�|��fdd�t�jd�D���jdjr�|�dd���jd�D��|St�tj�r�g}�jD]}|�|�|��|��q�|SgS)Nrrwrn�cs<g|]}d|krt�jd�krnn�jd|�qS)rwr)�absrx)rg�d��termr r!ru�s"�zAfind_substitutions.<locals>.possible_subterms.<locals>.<listcomp>cSsg|]}|jr|�qSr )r�r�r r r!ru�s
�)rjr�inverse_trig_functionsryr�r��	Heavisiderx�
chebyshevt�
chebyshevu�legendre�hermite�laguerre�
gegenbauer�assoc_laguerre�jacobir�r��extendr��is_constantr�r�is_Addr)r��rr�rr)�possible_subtermsrtr�r!r��sT�����

"

z-find_substitutions.<locals>.possible_subtermsF)rpr�r�)
r�rtr��resultsr�r�r��
new_integrandr,�substitutionr )r�r�rtr�r!�find_substitutions�s""'



�r�c���fdd�}|S)z$Strategy that rewrites an integrand.csh|\}}td�|�|���|�r,�|�}||kr.t||�}t|t�s0|r2t||||�SdSdSdSdS)Nz/Integral: {} is rewritten with {} on symbol: {})rr��integral_stepsrjr<r>)�integralr�rt�	rewritten�substep�r�rewriter r!�	_rewriters
��zrewriter.<locals>._rewriterr )rr�r�r r�r!�rewriter�r�cr�)zAStrategy that rewrites an integrand based on some other criteria.csd|\}}|\}}td�|�||��|t|�}�|�r.�|�}||kr0t|t||�||�SdSdS)Nz@Integral: {} is rewritten with {} on symbol: {} and criteria: {})rr�rkr>r�)�criteriar�r�rtrxr�r�r r!�_proxy_rewriter"s��z'proxy_rewriter.<locals>._proxy_rewriterr )rr�r�r r�r!�proxy_rewriter r�r�cr])z4Apply the rule that matches the condition, else Nonecs*���D]\}}||�r||�SqdSr)r�)r��keyr^��
conditionsr r!�multiplexer_rl2s
��z#multiplexer.<locals>.multiplexer_rlr )r�r�r r�r!�multiplexer0sr�cr])zHStrategy that makes an AlternativeRule out of multiple possible results.cs�g}d}td��D]&}|d}td�||��||�}|r0t|t�s0||kr0||vr0|�|�q
t|�dkr;|dS|rVdd�|D�}|rNt|g|�R�St|g|�R�SdS)NrzList of Alternative Rulesrw�Rule {}: {}cSsg|]}t|�s|�qSr rd)rgr^r r r!ruIr�z7alternatives.<locals>._alternatives.<locals>.<listcomp>)rr�rjr<r�r�r:)r��alts�countr^�result�doable��rulesr r!�
_alternatives:s&
��z#alternatives.<locals>._alternativesr )r�r�r r�r!r;8scCst|jg|�R�Sr)r+r��r�r r r!�
constant_rulePsr�cCs�|\}}|��\}}||jvr+t|tj�r+t�|d�dkr$t|||�St||||�S||jvrjt|tj�rlt||||�}t	t�
|�j�rG|St�
|�jrStdd|�St
|t�t�
|�d�ftdd|�dfg||�SdSdS)NrwrT)�as_base_expr�rjry�Symbol�simplifyr6r.r5r
r��is_zeror+r?r)r�r�rtr�r�r^r r r!�
power_ruleSs&���r�cCs4|\}}t|jdtj�rttj|jd||�SdS�Nr)rjrxryr�r5�E)r�r�rtr r r!�exp_rulehs�r�cs�tjttjttjttjttj	t
tjttj
ttjti}tjdtjdtjdi}|\}�|D]7}t||�rb|�|d�}|j|�urbt�fdd�|jd|�D��sb|jd|�|�f}|||�Sq+dS)Nr�rnrwc3s�|]}|���VqdSr��has)rg�vrsr r!ri���z'orthogonal_poly_rule.<locals>.<genexpr>)ryr�rFr�rGr�rHr�rJr�rKr�rLr�rMr�rNrjr�rxrl)r��orthogonal_poly_classes�orthogonal_poly_var_indexr��klass�	var_indexrxr rsr!�orthogonal_poly_rulens0��
���r�c
s�|\}}tjd|gdd�gd�}tjd|gd�}tjd|gd�}tjd|gd	d�gd�}tjd
|gdd�gd�}|||||f}tjt�|||�|dtftjt�|||�|dtftjt�|||�|dtftjt�	|||�|dt
ftjt�|||�|dtftj
dt�|||�dtftjt�||d
|||�dtftj	t�	||d
|||�dtftjt�||d
|||�dtftj||t�||�dtftjt�|||�|dtftj
dt�||t�	|�d
�dd�tftj
t�||t�	|�d
�dd�tff
}	|	D]<}
t||
d��rX|�|
d����rXt�fdd�|D��}|
d
du�sJ|
d
|��rX|||f}|
d|�S�qdS)Nr�cS�|jSr�r�r�r r r!r#��z'special_function_rule.<locals>.<lambda>�r��
propertiesr�r��cr�cSr�rr�r�r r r!r#�r�ecSs|jo|jSr)�is_nonnegative�
is_integerr�r r r!r#��rwrncS�||kSrr �r�r�r r r!r#�rcSrrr r	r r r!r#�rrc3s(�|]}��|�dur��|�VqdSr)r�)rg�wr�r r!ri�s���z(special_function_rule.<locals>.<genexpr>r�)ryr�r�r�rQ�cosrO�coshrP�sinrR�sinhrSr�r�rWrTrVrUrY�polylogrX�sqrtrZr[rjr�r)
r�r�rtr�r�rr�r�wilds�patterns�p�	wild_valsrxr r�r!�special_function_rule�sJ
�&&&"�����rc	
s�|\�����\�}tjd�gd�}tjd�gd�}��||�d���s)dSdd�}dd�}d	d
�}���fdd���fd
d�||fD�\}}g}t�d|d�dkr�|�t||d|dt�|dk|dk�f�|�|||d|dt�|dk|dk�f�|�|||d|dt�|dk|dk�f�dd�|D�}|jr�|jr�dd�|D�}t	|�dkr��|ddd��SdS|r�t
�fdd�|D����SdS)Nr�r�r�rncSs|jp|��Sr)�is_negative�could_extract_minus_signr�r r r!�negative��z#inverse_trig_rule.<locals>.negativecS�ttj||�Sr)r9ry�asinh�r�rtr r r!�ArcsinhRule�rz&inverse_trig_rule.<locals>.ArcsinhRulecSrr)r9ry�acoshrr r r!�ArccoshRule�rz&inverse_trig_rule.<locals>.ArccoshRulecst�d�}�}�}d}	}
}}�}
|dkr+||}	|||||d}||}
||dkrKt�||��}
t�||�}|}|||d}||||�}|
duru|dkrl|durlt|||||||��}t||
|||
��}|	dur�|dur�t|	|
|���}|S)Nr�rwrn)ry�Dummyrr-r1)�	RuleClass�base_expr��sign_ar��sign_br��current_base�current_symbolr,�u_func�
u_constantr��factored)r�r�rtr r!�make_inverse_trig�s2

�z,inverse_trig_rule.<locals>.make_inverse_trigcr�r r�rfr�r r!ru�r�z%inverse_trig_rule.<locals>.<listcomp>rwr���cSsg|]}|dtjur|�qS�r+)ry�false�rgrr r r!ru��cSsg|]}|dtjur|�qSr,)ry�truer.r r r!ru�r/cs$g|]}�|dd��|df�qS�Nr+r r.)r*r r!ru�s$)r�ryr�r�r�r�r8�And�	is_numberr�r?)	r�r�r�r�rrr�
possibilities�possibilityr )r�r�r*r�rtr!�inverse_trig_rule�s:*(*���r6cs6|\}��fdd�|��D�}d|vrdSt||��S)Ncror )r�)rg�grsr r!ru�s�zadd_rule.<locals>.<listcomp>)�as_ordered_termsr/)r�r�r�r rsr!�add_rule�s

�r9cCsH|\}}|�|�\}}t||�}|dkr |dur"t|||||�SdSdS�Nrw)r�r�r-)r�r�rt�coeffr��	next_stepr r r!�mul_rule�s
��r=cs�fdd�}dd�}|tj�|t�||tjtj�|tj�g}t�d�}t|tjgt�R�r1||}t|�D]�\}}||�}|�r|\}	}
�|	j	vrQ|	�
|�sQdS|	�|d�}	|
�|d�}
||kri|	���sidSt|	tj�r�d|
}|���r�t
|��dkr�dS||kr�t|
t�r�t|
��}t|�r�dS|	���}
t|�}|	|
||
|fSd}|dkr�d	}n4||kr�|
jr�td
d�|
jD��r�d	}n ||dd�D]}||�}|r�|d�|d��|
�r�d	}nq�|�r|	���}
tt�|
���}t|��st|�}|	|
||
|fSq5dS)
NcsV|����}t|tj�rgn	�fdd�|jD�}|r)tj|�}||��}||fSdS)Ncsg|]	}|���r|�qSr )�is_algebraic_exprrqrsr r!rusz;_parts_rule.<locals>.pull_out_algebraic.<locals>.<listcomp>)r��togetherrjryr
rxr�)r��	algebraicr��dvrsr r!�pull_out_algebraics�
�z'_parts_rule.<locals>.pull_out_algebraiccr])NcsTt�fdd��D��r&�fdd��jD�}|r(tdd�|�}�|}||fSdSdS)Ncsg|]}��|��qSr r��rgr��r�r r!rurvzJ_parts_rule.<locals>.pull_out_u.<locals>.pull_out_u_rl.<locals>.<listcomp>cs&g|]�t�fdd��D��r��qS)c3s�|]}t�|�VqdSr)rj)rgr)�rrr r!rir�zT_parts_rule.<locals>.pull_out_u.<locals>.pull_out_u_rl.<locals>.<listcomp>.<genexpr>)rl)rg��	functionsrEr!rus
�cSs||Srr )r�r�r r r!r#rzH_parts_rule.<locals>.pull_out_u.<locals>.pull_out_u_rl.<locals>.<lambda>)rlrxr)r�rxr�rArFrDr!�
pull_out_u_rls�z6_parts_rule.<locals>.pull_out_u.<locals>.pull_out_u_rlr )rGrHr rFr!�
pull_out_us	z_parts_rule.<locals>.pull_out_u�	temporaryrwFrnTcss&�|]}t|tjtjtjf�VqdSr)rjryr
rr��rgr�r r r!riMs��z_parts_rule.<locals>.<genexpr>r)ryr�r�r
rr�r rj�	enumerater�r�r��
is_polynomialrrr�rer{�_manualintegraterx�all�equalsr�)r�rtrBrI�liate_rules�dummy�indexr^r�r�rA�rec_dv�v_step�dur��acceptr�r rsr!�_parts_rulesl
�



���

��rXcs|\}�|��\}}t|��}g}|r�|\}}}}}	td�|||||	��|�|�t|tj�r2dSt|tjtj	tj
tjtjf�rX|�
�ti�}
t|
dkrPdSt|
d7<td�D]n}td�||||��|||��}|dkrvnU�|jvr�tdd�|D�dt|�||��}
|dkr�|
r�t|||
||��}
|
S||��\}}t|��}|r�|\}}}}}	||9}||9}|�|||||	f�q\��fd	d
��|�r|d\}}}}}	t|||	�|dd�||�|��}
|dk�r|
�rt|||
||��}
|
SdS)Nz,u : {}, dv : {}, v : {}, du : {}, v_step: {}rnrw�z7Cyclic integration {} with v: {}, du: {}, integrand: {}c	Ss(g|]\}}}}}t|||ddd��qSr)r2)rgr�rAr�rVrUr r r!ru}s�zparts_rule.<locals>.<listcomp>r+csV|r|d\}}}}}t|||�|dd�||�|��St|��}|r&|St|��S)Nrrw)r2r�r<)�stepsr�r�rAr�rVrU��make_second_steprtr r!r\�s�

z$parts_rule.<locals>.make_second_stepr)�as_coeff_MulrXrr�r�rjry�Integralr
rr�rr�xreplace�_cache_dummy�_parts_u_cache�ranger�r�r3r�r-r2)r�r�r,r�rZr�rAr�rVrU�cachekey�_�coefficientr^�
next_constant�next_integrandr r[r!�
parts_rule_sl


���

���rhcCs�|\}}t|tj�st|tj�r/|jd}t|tj�sdSt|tj�r&d}nd}t||||�S|t�|�dkr?td|||�S|t�|�dkrOtd|||�St|tj	�rbtj|j�tj|j�}nct|tj
�rutj|j�tj|j�}nPt|tj�r�|jd}t�|�dt�	|�t�|�t�|�t�	|�}n)t|tj�r�|jd}t�|�dt�
|�t�|�t�|�t�
|�}ndSt|t||�||�S)Nrr
rrn�sec**2�csc**2)
rjryr
rrxr�r4r|r~rzr}r>r�)r�r�rtrrr7r�r r r!�	trig_rule�sB

 �
 ��rkcCs�|\}}t�|�t�|�}||}||jvr.td|||�}|dkr,|r,t|||||�}|St�|�t�|�}||}||jvrYtd|||�}|dkrW|rWt|||||�}|SdS)N�sec*tanrw�csc*cot)ryr|rzr�r4r-r~r})r�r�rt�sectan�qr^�csccotr r r!�trig_product_rule�s 

�rqcCs&|\}}tjd|gd�}tjd|gd�}tjd|gd�}|�|||d|�}|r�||||||}}}|jr�|jr�tt|||||�t�||d�ft|||||�t�t�|d||�t�	||d��ft
|||||�t�t�	|d||�t�	||d��fg||�St|||||�Stjd|gd�}|�|||d|||�}|r�||||}}|jr�dSt�d�}	||d|}
|�
||	|d|�}t||	�}|r�t|	|
d|||�SdStjd	|gd�}
|�|||||d|||
�}|�r�||||||||||
f\}}}}}
|j�r$dS||d|||
}|d|}d|||}|||}t�d�}	t|	||t|	d
|	�||�}|dk�rkt||||||||�}|j�rq|St|||�}t||g||�}|||||}t||||�SdS)Nr�r�r�rrnrr�r�rr+rw)ryr�r��is_extended_realr?rC�GtrDr2�LtrEr�r r�r�r1r-r/r>)r�r�rtr�r�rr�r��match2r�r'�
integrand2r<r�match3�denominator�const�numer1�numer2�step1�step2r0�rewritenr r r!�quadratic_denom_rule�sx 88��"

*,
�

�rcCs4|\}}tjd|gd�}tjd|gd�}t�d�}|�t�|||�|�}|s+dS||||||}}}tjd|gd�}tjd|gd�}t�d�}	|�t�|||�|	�}
|
r`dSt�d�}t�|||�}|�||�}|�||d	||�}|d	||}t||�}
|
r�t||d|
||�SdS)
Nr�r�r�rr�rr�r�rn)ryr�r�rr r�r�r1)r�r�rtr�r�rr�r�rr��recursion_testr�r'r<r r r!�
root_mul_rule+s.



�r�cCs\tjd|gd�}tjd|gd�}tjd|gdd�gd�}tjd|gd	d�gd�}||||fS)
Nr�r�r��mcS�t|tj�Sr�rjry�Integer�rIr r r!r#Jr$zmake_wilds.<locals>.<lambda>rrIcSr�rr�r�r r r!r#Kr$)ryr�)rtr�r�r�rIr r r!�
make_wildsFs
r�cC�Bt|�\}}}}t�||�|t�||�|}|||||fSr)r�ryr
r�rtr�r�r�rI�patternr r r!�sincos_patternO�$r�cCr�r)r�ryrzr|r�r r r!�tansec_patternVr�r�cCr�r)r�ryr}r~r�r r r!�cotcsc_pattern]r�r�cCsLtjd|gd�}tjd|gd�}t�d�}t�|||�|}||||fS)Nr�r�r�r7)ryr�r�)rtr�r�r7r�r r r!�heaviside_patternds

r�cr])Ncs�|�Srr �rxr`r r!�
uncurry_rln�zuncurry.<locals>.uncurry_rlr )r7r�r r`r!�uncurrymsr�cr])NcsB|\}}}}}}�||||||�}||krt|t||�||�SdSr)r>r�)rxr�r�r�rIr�rtr��r�r r!�trig_rewriter_rlss��z'trig_rewriter.<locals>.trig_rewriter_rlr )r�r�r r�r!�
trig_rewriterrsr�cCs|jo|jo|jo|jSr)�is_evenr�r�r�r�rIrh�sr r r!r#~s�r#cCsDdt�d||�d|ddt�d||�d|dS�Nrwrn)ryr�r�r�r�rIrhrtr r r!r#�s  �cCs|jo|dkS�Nr���is_oddr�r r r!r#�rcCsBdt�||�d|ddt�||�t�||�|Sr�)ryrr
r�r r r!r#��
 ��cC�|jo|dkSr�r�r�r r r!r#�rcCsBdt�||�d|ddt�||�t�||�|Sr�)ryr
rr�r r r!r#�r�cCr��NrY�r�r�r r r!r#�rcC�Fdt�||�d|ddt�||�dt�||�|Sr�)ryrzr|r�r r r!r#��
 ��cC�|jSrr�r�r r r!r#��cC�Bt�||�dd|ddt�||�t�||�|S�Nrnrw)ryr|rzr�r r r!r#�r�cCs|dko|dkS)Nrnrr r�r r r!r#�r�cCst�||�ddSr�)ryr|r�r r r!r#�rvcCr�r�r�r�r r r!r#�rcCr�r�)ryr}r~r�r r r!r#�r�cCr�rr�r�r r r!r#�r�cCr�r�)ryr~r}r�r r r!r#�r�cs�|\�}t�fdd�tjtjfD��rBt|�\}}}}}��|���s%dStttt	t
tti�t
�fdd�||||fD��|g��SdS)Nc3��|]}��|�VqdSrr�rCrDr r!ri�r�z#trig_sincos_rule.<locals>.<genexpr>cr�r r�rfr�r r!ru�r�z$trig_sincos_rule.<locals>.<listcomp>)rlryr
rr�r�r��sincos_botheven_condition�sincos_botheven�sincos_sinodd_condition�
sincos_sinodd�sincos_cosodd_condition�
sincos_cosoddr�r�rtr�r�r�r�rIr �r�r�r!�trig_sincos_rule�s$
�����r�cs�|\�}��dt�|�t�|�i��t�fdd�tjtjfD��rQt|�\}}}}}��|���s4dStt	t
ttt
ti�t�fdd�||||fD��|g��SdS)Nrwc3r�rr�rCrDr r!ri�r�z#trig_tansec_rule.<locals>.<genexpr>cr�r r�rfr�r r!ru�r�z$trig_tansec_rule.<locals>.<listcomp>)r�ryrr|rlrzr�r�r��tansec_tanodd_condition�
tansec_tanodd�tansec_seceven_condition�tansec_seceven�tan_tansquared_condition�tan_tansquaredrr�r r�r!�trig_tansec_rule�s*�
�����r�c
s�|\�}��dt�|�t�|�dt�|�t�|�t�|�t�|�t�|�i��t�fdd�tjtjfD��rft|�\}}}}}��	|���sKdSt
ttt
ti�t�fdd�||||fD��|g��SdS)Nrwc3r�rr�rCrDr r!ri�r�z#trig_cotcsc_rule.<locals>.<genexpr>cr�r r�rfr�r r!ru�r�z$trig_cotcsc_rule.<locals>.<listcomp>)r�ryr
r~rzr}rrlr�r�r��cotcsc_cotodd_condition�
cotcsc_cotodd�cotcsc_csceven_condition�cotcsc_cscevenrr�r r�r!�trig_cotcsc_rule�s,�
�����r�cCsv|\}}tjdt�d|�gd�}|�t�d|�|�}|r9dt�|�t�|�t�d|�}t|||�SdS)Nr�rnr�)ryr�r
r�rr�)r�r�rtr�r��
sin_doubler r r!�trig_sindouble_rule�s&�r�cCs"ttt�tt�tt�tt��|�Sr)rrr�r�r�r�r�r r r!�trig_powers_products_rule�s��r�c	Cs�|\}}tjdd|gd�}tjdd|gd�}t�d�}|||d}|�|�}|D�]}|�|�}	|	�|t�}
|	�|t�}|
jrE|
dkpG|
j}|jrO|dkpQ|j}
|
jrY|
dkp[|
j	}|jrc|dkpe|j	}d}|r~|
r~t�
|
�t�
|�t�|�}d}nC|r�|r�t�
|
�t�
|�}|t�|�}t�
||k||k�}n!|r�|
r�t�
|
�t�
|�}|t�|�}t�
||k||k�}|�rCi}tjtjtjtjtjtjfD]}||�|t�
||�d�<d||�|t�
||�d	�<q�|�||���}t||�}|�|��sC|t||�9}|��}|�dt�|��}|�r-|�dt�|�t�|�i�}t||�}t|��sCt|||||||�Sq*dS)
Nr�rr�r��thetarnTrw���)ryr�r �findr�r�r�r3�is_positiverrrzr
r2r|rr~r}r��trigsimpr�r�rpr_r�rerB)r�r�rt�A�Br��target_pattern�matchesr�r�r�r��
a_positive�
b_positive�
a_negative�
b_negative�x_func�restrictionr,�
substitutionsr��replaced�secantsr�r r r!�trig_substitution_rule�sf



� 
�


���r�c
Cs�|\}}t|�\}}}}|�|�}|r<d||kr>t|||�}t|�}	||||}}t||||||	||�SdSdSr�)r�r�r�rNrA)
r�r�rtr�r�r�r7r�rUr�r r r!�heaviside_rule5s
�r�c
Cs�|\}}t�d�}t|||�}d}|r�td�g}|D]�\}}}	t|	|�}
|d}td�||
��t|
�r6qt�|d�dkr�|��\}}|
rOt	||	|
|	|�}
|j
r�g}
g}t|tj�r`|j
}n|�|�|D]}t|j�s�tt||d�|�}|r�|
�|t�|d�f�qg|
�|
df�t|
|	|�}
|�t||||
||��qt|�dkr�t|||�S|r�|dSdS|�tj�r�t�|�}d}||�|�}	|	�||�}	||	j
vr�t|||t|	|�||�SdSdS)Nr�rzList of Substitution Rulesrwr�T)ryr r�rr�r�rer�r�r-r�rjr�rxr�r
r�r�rr?r1r�r:r�r�r{r�)r�r�rtr�r�r��waysr'rr��subrulerd�denom�	piecewise�
could_be_zeror�r�r r r!�substitution_rule@sn




����

��r�cC�|��Sr)r�rr r r!r#�rcCs
|�|�Sr)�apartrr r r!r#�s
cCsdS)NTr rr r r!r#�scCr�r)r�rr r r!r#�rcs0t�fdd�|jD��pt|tj�pt|tj�S)Nc3s �|]}|jp|���VqdSr)r�rMrqrsr r!ri�s�z<lambda>.<locals>.<genexpr>)rOrxrjryr�r�rr rsr!r#�s
�cCr�r��expandrr r r!r#�rcCstdd�|�t�D��dkS)NcSsh|]}|jd�qS)rr�rKr r r!�	<setcomp>�rvz<lambda>.<locals>.<setcomp>rw)r��atomsrrr r r!r#�scCs|jdd�S)NT)�trigr�rr r r!r#�r$cCsT|d}|j}|j}|j}|j|vr!|j|vrt|�St||j�St|jg|�R�Sr�)�	variablesr�r�rtr=r<r+r�)r�r��diff_variables�undifferentiated_function�integrand_variablesr r r!�derivative_rule�s

r�cCsP|\}}|�dt�|��r&|�dt�|�t�|��}t|t||�||�SdSr:)r�ryrr�r|r>r�)r�r�rtr�r r r!�
rewrites_rule�s
�r�cCst|�Sr)r<r�r r r!�
fallback_rule�r�r��zcsn|��ti�}|tvr t|durt|��St|�t���fSdt|<t|��}�fdd���fdd�}ttt�tt�t	j
ttt�tt�tt
��t	jtt	jtt	jtt	jttt�tt�tt�tt
�tt��t	jtttt	jtttt	jt i
��ttt�tt!t"t#t$|t	jt	j
�t%�t$|t	jt	j
�t&�t$|t	jt	j'gt(�R�t)�t$|t	jt	j
�t*�t+t,��tt-��t.�|�}t|=|S)a�Returns the steps needed to compute an integral.

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

    This function attempts to mirror what a student would do by hand as
    closely as possible.

    SymPy Gamma uses this to provide a step-by-step explanation of an
    integral. The code it uses to format the results of this function can be
    found at
    https://github.com/sympy/sympy_gamma/blob/master/app/logic/intsteps.py.

    Examples
    ========

    >>> from sympy import exp, sin
    >>> from sympy.integrals.manualintegrate import integral_steps
    >>> from sympy.abc import x
    >>> print(repr(integral_steps(exp(x) / (1 + exp(2 * x)), x)))     # doctest: +NORMALIZE_WHITESPACE
    URule(u_var=_u, u_func=exp(x), constant=1,
    substep=PiecewiseRule(subfunctions=[(ArctanRule(a=1, b=1, c=1, context=1/(_u**2 + 1), symbol=_u), True),
        (ArccothRule(a=1, b=1, c=1, context=1/(_u**2 + 1), symbol=_u), False),
        (ArctanhRule(a=1, b=1, c=1, context=1/(_u**2 + 1), symbol=_u), False)],
    context=1/(_u**2 + 1), symbol=_u), context=exp(x)/(exp(2*x) + 1), symbol=x)
    >>> print(repr(integral_steps(sin(x), x)))     # doctest: +NORMALIZE_WHITESPACE
    TrigRule(func='sin', arg=x, context=sin(x), symbol=x)
    >>> print(repr(integral_steps((x**2 + 3)**2 , x)))     # doctest: +NORMALIZE_WHITESPACE
    RewriteRule(rewritten=x**4 + 6*x**2 + 9,
    substep=AddRule(substeps=[PowerRule(base=x, exp=4, context=x**4, symbol=x),
        ConstantTimesRule(constant=6, other=x**2,
            substep=PowerRule(base=x, exp=2, context=x**2, symbol=x),
                context=6*x**2, symbol=x),
        ConstantRule(constant=9, context=9, symbol=x)],
    context=x**4 + 6*x**2 + 9, symbol=x), context=(x**2 + 3)**2, symbol=x)


    Returns
    =======

    rule : namedtuple
        The first step; most rules have substeps that must also be
        considered. These substeps can be evaluated using ``manualintegrate``
        to obtain a result.

    Ncs~|j}t|t�r
tSt|tj�rtjS�|jvrtjStjtjtj	tj
tjtjgt
�tj�t�RD]}t||�r<|Sq1dSr)r�rjrry�
Derivativer�r�r�r�r�r�rr�r�r�r)r�r�r)rsr r!r��s(

���
�
��zintegral_steps.<locals>.keycs��fdd�}|S)Ncs�|�}|o
t|��Sr)�
issubclass)r��k)r��klassesr r!�_integral_is_subclassszKintegral_steps.<locals>.integral_is_subclass.<locals>._integral_is_subclassr )r�r�)r�)r�r!�integral_is_subclasssz,integral_steps.<locals>.integral_is_subclass)/r_r`�_integral_cacher<r\rrrrryr�r�r6rr�r�r�rr9r�r=rqr�r�r�r�rrkr�rr�r�r�r;r�r�r�partial_fractions_rule�cancel_ruler�r�rh�distribute_expand_ruler��trig_expand_ruler�r�)r�rt�optionsrcr�r�r�r )r�rtr!r��s�2
�
�����������(�)r�cCs||Srr )r,r�rtr r r!�
eval_constant9�r�cCs|t|�Sr�rN)r,rr�r�rtr r r!�eval_constanttimes=�r�cCs2t�||d|dt�|d�ft�|�df�S�Nrwr+T)ryr
rr��r�r�r�rtr r r!�
eval_powerAs�r�cCs|t�|�Sr�ry�lnr�r r r!�eval_expH�rcCsttt|��Sr)r��maprN�r0r�rtr r r!�eval_addLrrcCs@t|�}|jr|jdkr|�t�|�t�|j��}|�||�Sr1)rNr�r�r�ryr�r�)r�r'r,r�r�rtr�r r r!�eval_uPsrcCst|�}||t|�Srr�)r�rArU�second_stepr�rtr�r r r!�
eval_partsXsrcCsJd|}g}d}|D]}|�||jt|j��|d9}q
tj|�|S)Nrwr+)r�r�rNrUryr)�parts_rulesrer�rtr��signr^r r r!�eval_cyclicparts^s
rcCst|dkr
t�|�S|dkrt�|�S|dkrt�|�S|dkr%t�|�S|dkr.t�|�S|dkr8t�|�SdS)Nr
rrlrmrirj)ryrr
r|r~rzr})r7rrr�rtr r r!�	eval_trigjs



�rcCs2||dt�||�t�|t�||��Sr:)ryr�atan�r�r�rr�rtr r r!�eval_arctany�2rcC�8||dt�||�t�|t�||��Sr:)ryr�acothrr r r!�eval_arccoth}�8rcCrr:)ryr�atanhrr r r!�eval_arctanh�rrcCs
t�|�Srr��r7r�rtr r r!�eval_reciprocal��
rcCs
t�|�Sr)ry�asinrr r r!�eval_arcsin�rrcCs||�Srr rr r r!�eval_inversehyperbolic�r�rcCst|d�Sr�r�)r;r�rtr r r!�eval_alternative�r�rcCst|�Srr�)r�r�r�rtr r r!�eval_rewrite�r�rcCstjdd�|D��S)NcSsg|]
\}}t|�|f�qSr r�)rgr��condr r r!ru�s�z"eval_piecewise.<locals>.<listcomp>)ryr
rr r r!�eval_piecewise�s
�r cCs�|�t�|�dt�|��}|�t�|�dt�|��}|�t�|�dt�|��}t|�	t
��}t|�dks9J�|d}t�|||�}t|�dksMJ�t�
|d�\}	}
t|tj�rs|	}|
}t�|
d|	d�}
t�|d�}n9t|tj�r�|	}
|
}t�|
d|	d�}t�|d�}nt|tj�r�|	}|
}
t�|
d|	d�}t�|d�}t�|�||ft�|�|
|ft�|�||
f||fg}t�t|��|���|f�S)Nrwrrn)r�ryr|rr~r
r}rzrkr�rr��solve�fractionrjrr�acosr
r
rNr�)r�r7r�r�r�r�rt�
trig_function�relation�numerr��opposite�
hypotenuse�adjacent�inverser�r r r!�eval_trigsubstitution�s@��r+cCsPt|j�}t|�D]\}\}}||kr||df||<nq	tj|jg|�R�Sr:)rk�variable_countrLryr�r�)r�rtr,rh�varr�r r r!�eval_derivativerule�s
�r.cCst�|�||�||�Sr)ryr�r�)�harg�ibndr�r�rtr r r!�eval_heaviside�sr1cCs~tdt�|d|d|d|�|||t|||d�f|t|d�f||d|dd|||dt|d�f�S)NrnrwrrY)r
ryr�rr)rIr�r�r�rtr r r!�eval_jacobi�s
<0�r2cCsZtt�|d|d|�d|dt|d�ft�|d|�|dt|d�ftjjdf�S)Nrwrnr+T)r
ryr�rr��S�Zero�rIr�r�rtr r r!�eval_gegenbauer�s
* 
�r6cCsVtt�|d|�|dt�|d|�|ddtt�|�d�f|dddf�S)NrwrnT)r
ryr�rr��rIr�rtr r r!�eval_chebyshevt�s����r8cCs0tt�|d|�|dt|d�ftjjdf�Sr�)r
ryr�rr3r4r7r r r!�eval_chebyshevu�s 
�r9cCs,t�|d|�t�|d|�d|dSr�)ryr�r7r r r!�
eval_legendre�s,r:cCst�|d|�d|dSr�)ryr�r7r r r!�eval_hermite��r;cCst�||�t�|d|�Sr:)ryr�r7r r r!�
eval_laguerre�r<r=cCst�|d|d|�Sr:)ryr�r5r r r!�eval_assoclaguerre��r>cCs0t�|�t�||�t�|�t�||�Sr)ryr�Cir
�Si�r�r�r�rtr r r!�eval_ci�0rCcC�0t�|�t�||�t�|�t�||�Sr)ryr�Chir�ShirBr r r!�eval_chirDrHcCst�|�t�||�Sr)ryr��EirBr r r!�eval_ei	r?rJcCrEr)ryr
r@rrArBr r r!�eval_si
rDrKcCrEr)ryrrFrrGrBr r r!�eval_shirDrLc
Cs|jr^tt�tj|�dt�||dd|�t�d|||dt�|��|dkft�tj|�dt�||dd|�t�d|||dt�|��df�St�tj|�dt�||dd|�t�d|||dt�|��S)NrnrYr�rT)rrr
ryr�pir��erf�erfirr r r!�eval_erfs .$��,"���,"�rPc
Cs�t�tjd|�t�|dd||�t�d|||t�d|tj��t�|dd||�t�d|||t�d|tj��S�NrnrY)ryrrMr�fresnelcr
�fresnelsrr r r!�
eval_fresnelc!�
BB��rTc
Cs�t�tjd|�t�|dd||�t�d|||t�d|tj��t�|dd||�t�d|||t�d|tj��SrQ)ryrrMrrSr
rRrr r r!�
eval_fresnels'rUrVcCst�|||�|Sr)ry�lirBr r r!�eval_li-srXcCst�|d||�Sr:)ryrrBr r r!�eval_polylog1srYcCs2|||||t�|d||�|Sr:)ry�
uppergamma)r�rr�rtr r r!�eval_uppergamma5rr[cCst�|||�t�|�Sr)ry�
elliptic_fr�r�r�r�rtr r r!�eval_elliptic_f9�r^cCst�|||�t�|�Sr)ry�
elliptic_err]r r r!�eval_elliptic_e=r_racCst�||�Sr)ryr^rr r r!�eval_dontknowruleAr�rbcCs(t�|j�}|stdt|���||�S)NzCannot evaluate rule %s)r_r�rr��repr)r^�	evaluatorr r r!rNEsrNcCs�tt||��}t��t|t�rDt|j�dkrD|jdd}t|t�rD|jdddkrD|�	|jddt
j|j�f|jdddf�}|S)a$manualintegrate(f, var)

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

    Compute indefinite integral of a single variable using an algorithm that
    resembles what a student would do by hand.

    Unlike :func:`~.integrate`, var can only be a single symbol.

    Examples
    ========

    >>> from sympy import sin, cos, tan, exp, log, integrate
    >>> from sympy.integrals.manualintegrate import manualintegrate
    >>> from sympy.abc import x
    >>> manualintegrate(1 / x, x)
    log(x)
    >>> integrate(1/x)
    log(x)
    >>> manualintegrate(log(x), x)
    x*log(x) - x
    >>> integrate(log(x))
    x*log(x) - x
    >>> manualintegrate(exp(x) / (1 + exp(2 * x)), x)
    atan(exp(x))
    >>> integrate(exp(x) / (1 + exp(2 * x)))
    RootSum(4*_z**2 + 1, Lambda(_i, _i*log(2*_i + exp(x))))
    >>> manualintegrate(cos(x)**4 * sin(x), x)
    -cos(x)**5/5
    >>> integrate(cos(x)**4 * sin(x), x)
    -cos(x)**5/5
    >>> manualintegrate(cos(x)**4 * sin(x)**3, x)
    cos(x)**7/7 - cos(x)**5/5
    >>> integrate(cos(x)**4 * sin(x)**3, x)
    cos(x)**7/7 - cos(x)**5/5
    >>> manualintegrate(tan(x), x)
    -log(cos(x))
    >>> integrate(tan(x), x)
    -log(cos(x))

    See Also
    ========

    sympy.integrals.integrals.integrate
    sympy.integrals.integrals.Integral.doit
    sympy.integrals.integrals.Integral
    rnrrwT)rNr�ra�clearrjr
r�rxrr7ryr)r�r-r�rr r r!�manualintegrateLs1�rf)r)��__doc__�typingr�tDictr�collectionsrr�collections.abcr�	functoolsrry�sympy.core.compatibilityr�sympy.core.containers�sympy.core.exprr	�sympy.core.logicr
�(sympy.functions.elementary.trigonometricr�#sympy.functions.special.polynomialsr�$sympy.functions.elementary.piecewiser
�sympy.strategies.corerrrr�sympy.core.relationalrr�sympy.polys.polytoolsr�sympy.ntheory.factor_r�sympy.utilities.miscrr3r4r�r*r+r-r.r/r1r2r3r4r5r6r8r9r:r<r=r>r?rArBrCrDrErFrGrHrJrKrLrMrNrOrPrQrRrSrTrUrVrWrXrYrZr[r\r_rcrerpr�r
rr#�acot�acsc�asecr�r�r�r�r�r;r�r�r�r�rr6r9r=rXrhrkrqrr��cacheitr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��intrar r`r�r�r�r�rrrrrrrrrrrrrrr r+r.r1r2r6r8r9r:r;r=r>rCrHrJrKrLrPrTrVrXrYr[r^rarbrNrfr r r r!�<module>s















�

























![(A
[L)@




���������=?����



















&
	










Youez - 2016 - github.com/yon3zu
LinuXploit