a
    <b                     @   sD
  d Z ddlmZmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZmZ ddlmZ ddlm Z m!Z!m"Z"m#Z# ddl$m%Z% ddl&m'Z'm(Z(m)Z) ddl*m+Z+ ddl,m-Z-m.Z. ddl/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZG ddlHmIZI ddlJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZT ddlUmVZV ddlWmXZXmYZY ddlZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZc ddldmeZe ddlfmgZg dd lhmiZi dd!ljmkZk dd"llmmZm dd#lnmoZo dd$lpmqZq dd%lrmsZs dd&ltmuZumvZvmwZwmxZx dd'lymzZz dd(l{m|Z| d6d*d+Z}e}d,d-Z~e}d.d/Ze}d0d1Ze}d2d3Ze}d4d5Ze}d6d7Ze}d8d9Ze}d:d;Ze}d<d1Ze}d=d>Ze}d?Ze}d@d>Ze}dAdBZe}dCZe}dDZe}dEdFZe}dGdHZe}dIdJZe}dKdLZe}dMdNZe}dOdNZe}dPdNZe}dQdRZe}dSdTZe}dUdVZe}dWdVZe}dXdVZe}dYdVZe}dZdVZe}d[dTZe}d\d]Ze}d^d]Ze}d_d]Ze}d`d]Ze}dad]Ze}dbdNZe}dcdNZe}dddNZe}ded]Ze}dfd]Ze}dgdhZe}didjZe}dkdjZedldmZi Zdndo Zdpdq Zdrds Zdtdu ZeDeCeBeEeFeGfZdvdw Zdxdy Zdzd{ Zd|d} Zd~dB Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zedd Zedd Zedd Zedd Zedd Zdd Zdd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zdd Zdd Zdd Zdd ZddÄ Zddń ZddǄ ZddɄ Zedd dd Zedd dd Zedd dd Zedd dd Zddӄ ZddՄ Zddׄ Zi ZeeZe'd؃Zddڄ Zee~dd܄ Zeeddބ Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd Zeedd  Z eedd Zeedd Zeedd Zeedd Zeed	d
 Zeedd Zeedd Zeedd Zeedd Z	eedd Z
eedd Zeedd Zeedd Zeedd Zeedd Zeedd  Zeed!d" Zeed#d$ Zeed%d& Zeed'd( Zeed)d* Zeed+d, Zeed-d. Zeed/d0 Zd1d2 Zd3d4 Zd5S (7  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)reduce)Add)cacheit)r   )Expr)
Derivative)	fuzzy_not)Mul)IntegerNumberE)Pow)EqNeGtLt)S)DummySymbolWild)Abs)explog)coshsinhacoshasinhacothatanh)sqrt	Piecewise)TrigonometricFunctioncossintancotcscsecacosasinatanacotacscasec)	Heaviside)
erferfifresnelcfresnelsCiChiSiShiEili
uppergamma)
elliptic_e
elliptic_f)	
chebyshevt
chebyshevulegendrehermitelaguerreassoc_laguerre
gegenbauerjacobiOrthogonalPolynomialpolylog   Integral)And)divisorsdegree)fraction)simplify)solve)switchdo_one	null_safe	condition)iterable)debug c                    s2   dd   fdd}t | |d } |_||_|S )Nc                 S   s   | j |j kot| |S N)	__class__tuple__eq__selfother re   o/Users/vegardjervell/Documents/master/model/venv/lib/python3.9/site-packages/sympy/integrals/manualintegrate.pyra   D   s    zRule.<locals>.__eq__c                    s    | | S r^   re   rb   ra   re   rf   <lambda>F       zRule.<locals>.<lambda>z context symbol)r   ra   __ne__)namepropsZ__neq__clsre   rg   rf   RuleB   s    rn   ConstantRuleconstantConstantTimesRulezconstant other substep	PowerRulezbase expAddRulesubstepsURulezu_var u_func constant substep	PartsRulezu dv v_step second_stepCyclicPartsRulezparts_rules coefficientTrigRulezfunc argExpRuleReciprocalRulefunc
ArcsinRuleInverseHyperbolicRuleAlternativeRulealternativesDontKnowRuleDerivativeRuleRewriteRulezrewritten substepPiecewiseRuleZsubfunctionsHeavisideRulezharg ibnd substepTrigSubstitutionRulez(theta func rewritten substep restriction
ArctanRuleza b cArccothRuleArctanhRule
JacobiRulezn a bGegenbauerRulezn aChebyshevTRulenChebyshevURuleLegendreRuleHermiteRuleLaguerreRuleAssocLaguerreRuleCiRuleza bChiRuleEiRuleSiRuleShiRuleErfRuleFresnelCRuleFresnelSRuleLiRulePolylogRuleUpperGammaRuleza eEllipticFRuleza dEllipticERuleIntegralInfozintegrand symbolc                    s    fdd}|S )Nc                    s    | _ | t < | S r^   )rule
evaluatorsr{   r   re   rf   
_evaluates}   s    zevaluates.<locals>._evaluatesre   )r   r   re   r   rf   	evaluates|   s    r   c                 C   sX   t | trdS | D ]@}t |tr0t|rR dS qt |trtdd |D r dS qdS )NTc                 s   s   | ]}t |V  qd S r^   contains_dont_know.0ire   re   rf   	<genexpr>   ri   z%contains_dont_know.<locals>.<genexpr>F)
isinstancer   r`   r   listany)r   valre   re   rf   r      s    


r   c                    s  | j r| j d }t| tr2| t|d  S t| trT|  t|d  S t| trx| t| t| S t| tr|  t| t| S t| trt fdd| j D S t| t	rt
| j dkrt| j d tr| j d t| j d   S |  S )a  Derivative 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                    s   g | ]}t | qS re   )manual_diffr   argsymbolre   rf   
<listcomp>   ri   zmanual_diff.<locals>.<listcomp>rM   )argsr   r)   diffr,   r*   r+   r   sumr   lenr   r   )fr   r   re   r   rf   r      s     





"r   c                    s   t |dkr>|d }t|ttfr,| }qZt|sZtdnt |dkrR|g}ntdg }|D ]J\} t|trb|jd | 	fdd fdd} |
t f qb| t|| S )	zn
    A wrapper for `expr.subs(*args)` with additional logic for substitution
    of invertible functions.
    rM   r   z(Expected an iterable of (old, new) pairsr   z$subs accepts either 1 or 2 argumentsc                    s   | j o| j kS r^   )is_Powbasex)x0re   rf   rh      ri   zmanual_subs.<locals>.<lambda>c                    s   t | j   S r^   )r   r   )newre   rf   rh      ri   )r   r   r   r   itemsr[   
ValueErrorr   r   replaceappendr   subsr   )exprr   sequenceZnew_subsoldre   )r   r   rf   manual_subs   s$    




r   c           
         s   g } fdd}fdd D ]`}|kr8q*t |}|||}|dur*|\}}| krnq*|||f}	|	|vr*||	 q*|S )Nc                    sn  |dkrdS | }|j vr"dS td||  t||  }|j vrr|rtfdd D }tfdd| D }||krdS |jddS t	| t
rjd| j jrjt| jdk rjtd	gd
}tdgd
}| j| |   rj fdd||fD \}}|dkrj|dkrj|d| j  | | }|jddS dS )Nr   Fz!substituted: {}, u: {}, u_var: {}c                    s   g | ]}t | qS re   rR   r   tr   re   rf   r      ri   z<find_substitutions.<locals>.test_subterm.<locals>.<listcomp>c                    s   g | ]}t | qS re   rR   r   )u_varre   rf   r      ri   )Zas_AddrM   aexcludebc                    s   g | ]}  |tjqS re   getr   Zeror   matchre   rf   r      ri   )free_symbolsr\   formatr   cancelis_rational_functionmaxas_numer_denomas_independentr   r   r   
is_Integerr   r   r   r   r   )uu_diffsubstitutedZ
deg_beforeZ	deg_afterr   r   )	integrandr   r   r   rf   test_subterm   s8    

z(find_substitutions.<locals>.test_subtermc                    s  t  tgttttR r* jd gS t  ttt	t
tfrJ jd gS t  ttfrd jd gS t  trz jd gS t  trg } jD ]}|| || q|S t  trdg } jd r| jd  n" jd r| jd   jd jr`| fddt jd D   jd jr`|dd  jd D  |S t  trg } jD ]}|| || qz|S g S )Nr   rM   r      c                    s<   g | ]4}d |  k r&t  jd  k rn q jd | qS )rM   r   )absr   )r   dtermre   rf   r     s   "zAfind_substitutions.<locals>.possible_subterms.<locals>.<listcomp>c                 S   s   g | ]}|j r|qS re   )r   r   re   re   rf   r     s   )r   r&   inverse_trig_functionsr   r   r3   r   rB   rC   rD   rE   rF   rH   rG   rI   r   r   extendr   is_constantr   rQ   Zis_Addr   )r   rr   r   )possible_subtermsr   r   rf   r      sT    



"

z-find_substitutions.<locals>.possible_subtermsF)r   r   r   )
r   r   r   resultsr   r   r   Znew_integrandrp   substitutionre   )r   r   r   r   rf   find_substitutions   s     "'


r   c                    s    fdd}|S )z$Strategy that rewrites an integrand.c                    s\   | \}}t d||  |  rX|  }||krXt||}t|tsX|rXt||||S d S )Nz/Integral: {} is rewritten with {} on symbol: {})r\   r   integral_stepsr   r   r   )integralr   r   	rewrittensubsteprZ   rewritere   rf   	_rewriter*  s    
zrewriter.<locals>._rewriterre   )rZ   r   r   re   r   rf   rewriter(  s    r   c                    s    fdd}|S )zAStrategy that rewrites an integrand based on some other criteria.c                    s`   | \} }|\}}t d|||  | t| } | r\| }||kr\t|t||||S d S )Nz@Integral: {} is rewritten with {} on symbol: {} and criteria: {})r\   r   r   r   r   )criteriar   r   r   r   r   r   re   rf   _proxy_rewriter:  s    z'proxy_rewriter.<locals>._proxy_rewriterre   )rZ   r   r   re   r   rf   proxy_rewriter8  s    r   c                    s    fdd}|S )z4Apply the rule that matches the condition, else Nonec                    s*      D ]\}}|| r||   S qd S r^   )r   )r   keyr   
conditionsre   rf   multiplexer_rlJ  s    z#multiplexer.<locals>.multiplexer_rlre   )r   r   re   r   rf   multiplexerH  s    r   c                     s    fdd}|S )zHStrategy that makes an AlternativeRule out of multiple possible results.c                    s   g }d}t d  D ]L}|d }t d|| || }|rt|ts|| kr||vr|| qt|dkrv|d S |rdd |D }|rt|g| R  S t|g| R  S d S )Nr   zList of Alternative RulesrM   Rule {}: {}c                 S   s   g | ]}t |s|qS re   r   )r   r   re   re   rf   r   a  ri   z7alternatives.<locals>._alternatives.<locals>.<listcomp>)r\   r   r   r   r   r   r~   )r   Zaltscountr   resultZdoablerulesre   rf   _alternativesR  s(    z#alternatives.<locals>._alternativesre   )r  r  re   r  rf   r   P  s    c                 C   s   t | jg| R  S r^   )ro   r   r   re   re   rf   constant_ruleh  s    r  c                 C   s   | \}}|  \}}||jvrRt|trRt|d dkrDt|||S t||||S ||jvrt|trt||||}tt	|j
r|S t	|j
rtdd|S t|tt	|dftdd|dfg||S d S )NrM   r   T)as_base_expr   r   r   rU   rz   rr   ry   r   r   is_zeroro   r   r   )r   r   r   r   Zexptr   re   re   rf   
power_rulek  s$    
r  c                 C   s0   | \}}t |jd tr,tt|jd ||S d S Nr   )r   r   r   ry   r   )r   r   r   re   re   rf   exp_rule  s    r  c                    s   t ttttttttt	t
ttttti}t dtdtdi}| \} |D ]n}t||r@||d}|j|  u r@t fdd|jd | D s@|jd | | f }|| |   S q@d S )Nr   r   rM   c                 3   s   | ]}|  V  qd S r^   has)r   vr   re   rf   r     ri   z'orthogonal_poly_rule.<locals>.<genexpr>)rI   r   rH   r   rB   r   rC   r   rD   r   rE   r   rF   r   rG   r   r   r   r   r   )r   Zorthogonal_poly_classesZorthogonal_poly_var_indexr   klassZ	var_indexr   re   r   rf   orthogonal_poly_rule  s,    
r  c                    sv  | \}}t d|gdd gd}t d|gd}t d|gd}t d|gd	d gd}t d
|gdd gd}|||||f}tt|| | | d tftt|| | | d tftt|| | | d tftt|| | | d t	ftt
|| | | d tftdt|| |  d tftt||d  ||  | d tftt||d  ||  | d tftt||d  ||  | d tft|| t||  d tftt||| | d tftdt||t|d    dd tftt||t|d   dd tff}	|	D ]x}
t||
d r||
d   rt fdd|D }|
d d u sR|
d | r|||f }|
d |   S qd S )Nr   c                 S   s   | j  S r^   r
  r   re   re   rf   rh     ri   z'special_function_rule.<locals>.<lambda>r   Z
propertiesr   r   cr   c                 S   s   | j  S r^   r  r   re   re   rf   rh     ri   ec                 S   s   | j o
| j S r^   )is_nonnegative
is_integerr   re   re   rf   rh     ri   rM   r   c                 S   s   | |kS r^   re   r   r   re   re   rf   rh     ri   c                 S   s   | |kS r^   re   r  re   re   rf   rh     ri   r   c                 3   s&   | ]}  |d ur  |V  qd S r^   )r   )r   wr   re   rf   r     s   z(special_function_rule.<locals>.<genexpr>r   )r   r   r   r   r'   r   r   r   r(   r   r   r   r   r   r   r   r   r   r   rL   r   r#   r   r   r   r   r`   )r   r   r   r   r   r  r   r  ZwildspatternspZ	wild_valsr   re   r   rf   special_function_rule  sF    """r  c           	         s  | \  \ }tdgd}tdgd} ||d   sNd S dd }dd }d	d
 } fddfdd||fD \}}g }td| d dkr |t||d| dt|dk|dk f ||||d|dt|dk|dkf |||| d|dt|dk |dkf dd |D }|jrp|jrpdd |D }t|dkr|d d d  S n |rt	fdd|D S d S )Nr   r   r   r   c                 S   s   | j p|  S r^   )is_negativeZcould_extract_minus_signr   re   re   rf   negative  s    z#inverse_trig_rule.<locals>.negativec                 S   s   t t| |S r^   )r}   r    r   r   re   re   rf   ArcsinhRule  s    z&inverse_trig_rule.<locals>.ArcsinhRulec                 S   s   t t| |S r^   )r}   r   r   re   re   rf   ArccoshRule  s    z&inverse_trig_rule.<locals>.ArccoshRulec                    s  t d} }}d  }	 }
 }}}|dkrT|| }	||||  |d   }|| }|| dkrt||  }
t|| }|}|||d   }| || |}|
d ur|dkr|d urt||| ||||  }t||
|||}|	d ur|d urt|	||}|S )Nr   rM   r   )r   r#   rq   ru   )Z	RuleClassZbase_expr   Zsign_ar   Zsign_br   Zcurrent_baseZcurrent_symbolrp   u_funcZ
u_constantr   Zfactored)r   r   r   re   rf   make_inverse_trig  s2    
z,inverse_trig_rule.<locals>.make_inverse_trigc                    s   g | ]}  |tjqS re   r   r   r   re   rf   r     ri   z%inverse_trig_rule.<locals>.<listcomp>rM   r   c                 S   s   g | ]}|d  t jur|qS r%  )r   falser   r  re   re   rf   r     ri   c                 S   s   g | ]}|d  t ju r|qS r&  )r   truer(  re   re   rf   r     ri   c                    s$   g | ]} |d d  |d fqS Nr%  re   r(  )r$  re   rf   r     ri   )
r	  r   r   rU   r   r|   rP   	is_numberr   r   )	r   r   r   r   r  r!  r"  possibilitiesZpossibilityre   )r   r   r$  r   r   rf   inverse_trig_rule  s6    (&(r-  c                    s6   | \}  fdd|  D }d |v r*d S t|| S )Nc                    s   g | ]}t | qS re   )r   )r   gr   re   rf   r     s   zadd_rule.<locals>.<listcomp>)Zas_ordered_termsrs   )r   r   r   re   r   rf   add_rule	  s
    
r/  c                 C   sD   | \}}| |\}}t||}|dkr@|d ur@t|||||S d S NrM   )r   r   rq   )r   r   r   Zcoeffr   	next_stepre   re   rf   mul_rule  s    
r2  c                    s   fdd}dd }|t |t ||tt|tg}td}t| t gtR rV||  } t|D ]\}}|| }|r^|\}	}
 |	jvr|		|s d S |	
|d}	|

|d}
||kr|	 s d S t|	t rd|
 }| rt| dkr d S ||krJt|
trJt|
 }t|r& d S |	 }t|}|	|
|||f  S d}|dk r^d	}nv||kr|
jrtd
d |
jD rd	}nH||d d  D ]6}|| }|r|d 
|d|
rd	} qԐq|r^|	 }tt|
 }t|s^t|}|	|
|||f  S q^d S )Nc                    sR   |    } t| trg n fdd| jD }|rNt| }| |   }||fS d S )Nc                    s   g | ]}|  r|qS re   )Zis_algebraic_exprr   r   re   rf   r   #  ri   z;_parts_rule.<locals>.pull_out_algebraic.<locals>.<listcomp>)r   Ztogetherr   r%   r   r   )r   Z	algebraicr   dvr   re   rf   pull_out_algebraic  s    z'_parts_rule.<locals>.pull_out_algebraicc                     s    fdd}|S )Nc                    sP   t  fddD rLfdd jD }|rLtdd |} | }||fS d S )Nc                 3   s   | ]}  |V  qd S r^   r  r   r   r   re   rf   r   +  ri   zI_parts_rule.<locals>.pull_out_u.<locals>.pull_out_u_rl.<locals>.<genexpr>c                    s&   g | ] t  fd dD r qS )c                 3   s   | ]}t  |V  qd S r^   )r   )r   rm   r   re   rf   r   -  ri   zT_parts_rule.<locals>.pull_out_u.<locals>.pull_out_u_rl.<locals>.<listcomp>.<genexpr>)r   )r   	functionsr7  rf   r   ,  s   zJ_parts_rule.<locals>.pull_out_u.<locals>.pull_out_u_rl.<locals>.<listcomp>c                 S   s   | | S r^   re   )r   r   re   re   rf   rh   /  ri   zH_parts_rule.<locals>.pull_out_u.<locals>.pull_out_u_rl.<locals>.<lambda>)r   r   r   )r   r   r   r3  r8  r6  rf   pull_out_u_rl*  s    z6_parts_rule.<locals>.pull_out_u.<locals>.pull_out_u_rlre   )r9  r:  re   r8  rf   
pull_out_u)  s    	z_parts_rule.<locals>.pull_out_u	temporaryrM   Fr   Tc                 s   s   | ]}t |tttfV  qd S r^   )r   r(   r'   r   r   r   re   re   rf   r   e  s   z_parts_rule.<locals>.<genexpr>r   )r   r   r(   r'   r   r   r   	enumerater   r  r   is_polynomialrS   rJ   r   r   r   _manualintegrater   allequalsrU   )r   r   r4  r;  Zliate_rulesdummyindexr   r  r   r3  Zrec_dvv_stepdur  acceptZlruler   re   r   rf   _parts_rule  sh    









rH  c                    s  | \}|  \}}t|}g }|r|\}}}}}	td|||||	 || t|trdd S t|ttt	t
tfr|ti}
t|
 dkrd S t|
  d7  < tdD ]}td|||| || |  }|dkr q|jvr@tdd |D dt| | |}|dkr8|r8t||||| }|  S ||   \}}t|}|r|\}}}}}	||9 }||9 }||||||	f q qq fd	d
 |r|d \}}}}}	t|||	 |dd  || |}|dkr
|r
t||||| }|S d S )Nz,u : {}, dv : {}, v : {}, du : {}, v_step: {}r   rM      z7Cyclic integration {} with v: {}, du: {}, integrand: {}c              	   S   s(   g | ] \}}}}}t |||d d d qS r^   )rv   )r   r   r3  r  rF  rE  re   re   rf   r     s   zparts_rule.<locals>.<listcomp>r%  c                    sZ   | r:| d \}}}}}t ||| | dd  || |S t|} | rL| S t|S d S )Nr   rM   )rv   r   r   )stepsr   r   r3  r  rF  rE  make_second_stepr   re   rf   rL    s    
z$parts_rule.<locals>.make_second_stepr   )Zas_coeff_MulrH  r\   r   r   r   rO   r(   r'   r   r   r   xreplace_cache_dummy_parts_u_cacheranger   r   rw   r   rq   rv   )r   r   rp   r  rJ  r   r3  r  rF  rE  cachekey_coefficientr   Znext_constantZnext_integrandre   rK  rf   
parts_rulew  sj    



rT  c                 C   sl  | \}}t |ttfrP|jd }t |ts.d S t |tr>d}nd}t||||S |t|d krntd|||S |t|d krtd|||S t |trt|j t|j  }nt |t	rt|j t|j  }nt |tr|jd }t|d t|t|  t|t|  }nHt |trT|jd }t|d t	|t|  t|t	|  }nd S t
|t||||S )Nr   r(   r'   r   sec**2csc**2)r   r(   r'   r   r   rx   r,   r+   r)   r*   r   r   )r   r   r   r   r{   r   re   re   rf   	trig_rule  sB    






rW  c                 C   s   | \}}t |t| }|| }||jvrXtd|||}|dkrT|rTt|||||}|S t| t| }|| }||jvrtd|||}|dkr|rt|||||}|S d S )Nsec*tanrM   csc*cot)r,   r)   r   rx   rq   r+   r*   )r   r   r   Zsectanqr   Zcsccotre   re   rf   trig_product_rule  s    

r[  c              	   C   s  | \}}t d|gd}t d|gd}t d|gd}||||d  |  }|r|| || ||   }}}|jr
|jr
tt|||||t|| dft|||||tt|d | | t|| dft	|||||tt|d | | t|| dfg||S t|||||S t d|gd}||||d  ||  |  }|r|| ||  }}|j
rnd S td}	||d|   }
|||	|d|   }t||	}|rt|	|
d |||S d S t d	|gd}||| | ||d  ||  |  }|r|| || || || || f\}}}}}|j
r:d S ||d  ||  | }|d|  }d| | | }| | | }td}	t|	||t|	d
 |	||}|dkrt||| ||| | |}|j
r|S t|| |}t||g||}|| | ||  }t||||S d S )Nr   r   r   r  r   r   r   r   r  r%  rM   )r   r   is_extended_realr   r   r   r   rP   r   r   r
  r   r   r   ru   rq   rs   r   )r   r   r   r   r   r  r   r   Zmatch2r   r#  Z
integrand2r1  r  Zmatch3denominatorconstZnumer1Znumer2Zstep1Zstep2rt   Zrewritenre   re   rf   quadratic_denom_rule  sx    22"
*,

r_  c                 C   s"  | \}}t d|gd}t d|gd}t d}|t|| | | }|sNd S || || ||   }}}t d|gd}t d|gd}t d}	|t|| | |	 }
|
rd S td}t|| | }|||}|||d	 | | }|d	 | | }t||}|rt||d |||S d S )
Nr   r   r   r  r   r  r   r   r   )r   r   r#   r   r   r   ru   )r   r   r   r   r   r  r   r   r  r   Zrecursion_testr   r#  r1  re   re   rf   root_mul_ruleC  s,    
r`  c                 C   sT   t d| gd}t d| gd}t d| gdd gd}t d| gd	d gd}||||fS )
Nr   r   r   mc                 S   s
   t | tS r^   r   r   r   re   re   rf   rh   b  ri   zmake_wilds.<locals>.<lambda>r  r   c                 S   s
   t | tS r^   rb  rc  re   re   rf   rh   c  ri   )r   )r   r   r   ra  r   re   re   rf   
make_wilds^  s
    rd  c                 C   s>   t | \}}}}t||  | t||  |  }|||||fS r^   )rd  r(   r'   r   r   r   ra  r   patternre   re   rf   sincos_patterng  s     rg  c                 C   s>   t | \}}}}t||  | t||  |  }|||||fS r^   )rd  r)   r,   re  re   re   rf   tansec_patternn  s     rh  c                 C   s>   t | \}}}}t||  | t||  |  }|||||fS r^   )rd  r*   r+   re  re   re   rf   cotcsc_patternu  s     ri  c                 C   sD   t d| gd}t d| gd}t d}t||  | | }||||fS )Nra  r   r   r.  )r   r3   )r   ra  r   r.  rf  re   re   rf   heaviside_pattern|  s
    rj  c                    s    fdd}|S )Nc                    s    |  S r^   re   r   r   re   rf   
uncurry_rl  s    zuncurry.<locals>.uncurry_rlre   )r{   rl  re   r   rf   uncurry  s    rm  c                    s    fdd}|S )Nc                    sB   | \}}}}}} ||||||}||kr>t |t||||S d S r^   )r   r   )r   r   r   ra  r   r   r   r   r   re   rf   trig_rewriter_rl  s    z'trig_rewriter.<locals>.trig_rewriter_rlre   )r   ro  re   rn  rf   trig_rewriter  s    rp  c                 C   s   |j o|j o|jo|jS r^   )is_evenr  r   r   ra  r   r   sre   re   rf   rh     s   rh   c                 C   s@   dt d|  |  d |d  dt d| |  d |d   S NrM   r   )r'   r   r   ra  r   r   r   re   re   rf   rh     s   c                 C   s   |j o|dkS Nr   Zis_oddrr  re   re   rf   rh     ri   c                 C   s<   dt | | d  |d d  t| |  t || |  S rt  )r'   r(   ru  re   re   rf   rh     s   
c                 C   s   |j o|dkS rv  rw  rr  re   re   rf   rh     ri   c                 C   s<   dt || d  |d d  t||  t | | |  S rt  )r(   r'   ru  re   re   rf   rh     s   
c                 C   s   |j o|dkS NrI  rq  rr  re   re   rf   rh     ri   c                 C   s@   dt || d  |d d  t|| d  t | | |  S rt  )r)   r,   ru  re   re   rf   rh     s   c                 C   s   |j S r^   rw  rr  re   re   rf   rh     ri   c                 C   s<   t | | d d |d d  t| |  t || |  S Nr   rM   )r,   r)   ru  re   re   rf   rh     s   
c                 C   s   |dko|dkS )Nr   r   re   rr  re   re   rf   rh     ri   c                 C   s   t | | d d S rz  )r,   ru  re   re   rf   rh     ri   c                 C   s   |j o|dkS rx  ry  rr  re   re   rf   rh     ri   c                 C   s@   dt || d  |d d  t|| d  t | | |  S rt  )r*   r+   ru  re   re   rf   rh     s   c                 C   s   |j S r^   rw  rr  re   re   rf   rh     ri   c                 C   s<   t | | d d |d d  t| |  t || |  S rz  )r+   r*   ru  re   re   rf   rh     s   
c                    s   | \ }t  fddttfD rt|\}}}}} |sFd S ttttt	t
titfdd||||fD  |g S d S )Nc                 3   s   | ]}  |V  qd S r^   r  r5  r6  re   rf   r     ri   z#trig_sincos_rule.<locals>.<genexpr>c                    s   g | ]}  |tjqS re   r   r   r   re   rf   r     ri   z$trig_sincos_rule.<locals>.<listcomp>)r   r(   r'   rg  r   r   sincos_botheven_conditionsincos_bothevensincos_sinodd_conditionsincos_sinoddsincos_cosodd_conditionsincos_cosoddr`   r   r   rf  r   r   ra  r   re   r   r   rf   trig_sincos_rule  s"    
r  c                    s   | \ }  dt| t|i t fddttfD rt|\}}}}} |s`d S ttt	t
tttitfdd||||fD  |g S d S )NrM   c                 3   s   | ]}  |V  qd S r^   r  r5  r6  re   rf   r     ri   z#trig_tansec_rule.<locals>.<genexpr>c                    s   g | ]}  |tjqS re   r   r   r   re   rf   r     ri   z$trig_tansec_rule.<locals>.<listcomp>)r   r'   r,   r   r)   rh  r   r   tansec_tanodd_conditiontansec_tanoddtansec_seceven_conditiontansec_seceventan_tansquared_conditiontan_tansquaredr`   r  re   r  rf   trig_tansec_rule  s(    
r  c              	      s   | \ }  dt| t|dt| t|t|t| t|i t fddttfD rt|\}}}}} |sd S t	t
tttitfdd||||fD  |g S d S )NrM   c                 3   s   | ]}  |V  qd S r^   r  r5  r6  re   rf   r     ri   z#trig_cotcsc_rule.<locals>.<genexpr>c                    s   g | ]}  |tjqS re   r   r   r   re   rf   r     ri   z$trig_cotcsc_rule.<locals>.<listcomp>)r   r(   r+   r)   r*   r'   r   ri  r   r   cotcsc_cotodd_conditioncotcsc_cotoddcotcsc_csceven_conditioncotcsc_cscevenr`   r  re   r  rf   trig_cotcsc_rule  s*    
r  c                 C   sj   | \}}t dtd| gd}|td| | }|rfdt| t| td|  }t|| |S d S )Nr   r   r   )r   r(   r   r'   r   )r   r   r   r   r   Z
sin_doublere   re   rf   trig_sindouble_rule  s     r  c                 C   s"   t tttttttt| S r^   )rX   rY   r  r  r  r  r  re   re   rf   trig_powers_products_rule
  s    r  c              	   C   sb  | \}}t dd|gd}t dd|gd}td}|||d   }||}|D ]}||}	|	|tj}
|	|tj}|
jr|
dkp|
j}|jr|dkp|j}|
jr|
dk p|
j	}|jr|dk p|j	}d }|r|rt
|
t
| t| }d}n~|r4|r4t
|
t
|  }|t| }t|| k||k }n>|rr|rrt
|
 t
| }|t| }t|| k||k }|rNi }ttttttfD ]:}|||t
||d < d|| |t
||d	 < q||| }t||}||sN|t||9 }| }|dt| }|r2|dt| t|i}t||}t|sNt|||||||  S qNd S )
Nr   r   r   r   thetar   TrM   )r   r   findr   r   r   r   r+  Zis_positiver  r#   r)   r(   rP   r,   r'   r+   r*   r   trigsimpr   r  r   rM  r   r   r   )r   r   r   ABr  Ztarget_patternmatchesr   r   r   r   Z
a_positiveZ
b_positiveZ
a_negativeZ
b_negativeZx_funcrestrictionrp   substitutionsr   ZreplacedZsecantsr   re   re   rf   trig_substitution_rule  sb    


 



r  c           
      C   s|   | \}}t |\}}}}||}|rxd|| krxt|| |}t|}	|| ||  }}t|| | | | |	||S d S r  )rj  r   r   r@  r   )
r   r   r   rf  ra  r   r.  r   rE  r  re   re   rf   heaviside_ruleM  s    
r  c              
   C   s  | \}}t d}t|||}d}|rhtd g }|D ]\}}}	t|	|}
|d }td||
 t|
rnq6t|d dkr$| \}}|
rt||	|
|	|}
|j	r$g }g }t
|tr|j}n
|| |D ]8}t|jstt||d|}|r||t|df q||
df t||	|}
|t||||
|| q6t|dkrXt|||S |r|d S nV|trt|}d}||| }	|	||}	||	j	vrt|||t|	|||S d S )Nr   r   zList of Substitution RulesrM   r  T)r   r   r\   r   r   r   rU   r   rq   r   r   r   r   r   r   r
  r   r   r   ru   r   r~   r  r   r   r   )r   r   r   r   r  r  Zwaysr#  r  r   ZsubrulerR  denomZ	piecewiseZcould_be_zeror   r   re   re   rf   substitution_ruleX  sf    




r  c                 C   s   |   S r^   )r   r   re   re   rf   rh     ri   c                 C   s
   |  |S r^   )Zapartr   re   re   rf   rh     ri   c                 C   s   dS )NTre   r   re   re   rf   rh     ri   c                 C   s   |   S r^   )r   r   re   re   rf   rh     ri   c                    s,   t  fdd| jD p*t| tp*t| tS )Nc                 3   s   | ]}|j p| V  qd S r^   )r   r?  r   r   re   rf   r     ri   z<lambda>.<locals>.<genexpr>)rA  r   r   r   r   r   re   r   rf   rh     s    c                 C   s   |   S r^   expandr   re   re   rf   rh     ri   c                 C   s   t dd | tD dkS )Nc                 S   s   h | ]}|j d  qS )r   rk  r=  re   re   rf   	<setcomp>  ri   z<lambda>.<locals>.<setcomp>rM   )r   Zatomsr&   r   re   re   rf   rh     s    c                 C   s   | j ddS )NT)Ztrigr  r   re   re   rf   rh     ri   c                 C   sZ   | d }|j }|j}|j}| j|v rD| j|v r6t|  S t|| jS nt| jg| R  S d S r  )	variablesr   r   r   r   r   ro   r   )r   r   Zdiff_variablesZundifferentiated_functionZintegrand_variablesre   re   rf   derivative_rule  s    

r  c                 C   sJ   | \}}| dt| rF|dt| t|}t|t||||S d S r0  )r   r'   r   r,   r   r   )r   r   r   r   re   re   rf   rewrites_rule  s    r  c                 C   s   t |  S r^   )r   r  re   re   rf   fallback_rule  s    r  zc                    sP  |  ti}|tv rBt| du r,t| S t|  tfS ndt|< t| }fdd  fdd}ttttt t	ttt
tttttt
tttttttttttttttttttttttttti
ttttt t!t"t#|tt	t$t#|tt	t%t#|tt&gt'R  t(t#|tt	t)t*t+tt,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.

    Nc                    sj   | j } |jvrtS t|tr"tS t|tr0tS tttt	t
tgtttR D ]}t||rN|  S qNd S r^   )r   r   r   r   r&   r   r   r   r   r   r   r   r   r3   rJ   )r   r   rm   r   re   rf   r     s$    




zintegral_steps.<locals>.keyc                     s    fdd}|S )Nc                    s    | }|ot |S r^   )
issubclass)r   k)r   klassesre   rf   _integral_is_subclass   s    zKintegral_steps.<locals>.integral_is_subclass.<locals>._integral_is_subclassre   )r  r  )r   )r  rf   integral_is_subclass  s    z,integral_steps.<locals>.integral_is_subclass).rM  rN  _integral_cacher   r   rX   rY   r  rW   r   r  r-  r_  r   r   r  r   r/  r   r2  r[  r  r`  r   r  r&   rW  r3   rJ   r  r   r  r   r  r  rZ   partial_fractions_rulecancel_ruler   r   rT  distribute_expand_ruler  trig_expand_ruler  r  )r   r   optionsrQ  r   r  r  re   )r   r   rf   r     s    2

()r   c                 C   s   | | S r^   re   )rp   r   r   re   re   rf   eval_constantQ  s    r  c                 C   s   | t | S r^   r@  )rp   rd   r   r   r   re   re   rf   eval_constanttimesU  s    r  c                 C   s,   t | |d  |d  t|dft| dfS NrM   r%  T)r%   r   r   r   r   r   r   re   re   rf   
eval_powerY  s    
r  c                 C   s   |t |  S r^   r   r  re   re   rf   eval_exp`  s    r  c                 C   s   t tt| S r^   )r   mapr@  rt   r   r   re   re   rf   eval_addd  s    r  c                 C   s<   t |}|jr0|jdkr0|t| t|j }|| |S r*  )r@  r   r   r   r   r   )r   r#  rp   r   r   r   r  re   re   rf   eval_uh  s    r  c                 C   s   t |}| | t | S r^   r  )r   r3  rE  Zsecond_stepr   r   r  re   re   rf   
eval_partsp  s    r  c                 C   sH   d| }g }d}| D ]&}| ||j t|j  |d9 }qt| | S )NrM   r%  )r   r   r@  rE  r   )Zparts_rulesrS  r   r   r  signr   re   re   rf   eval_cyclicpartsv  s    
r  c                 C   sh   | dkrt | S | dkr"t|S | dkr2t|S | dkrBt|S | dkrRt|S | dkrdt| S d S )Nr(   r'   rX  rY  rU  rV  )r'   r(   r,   r+   r)   r*   )r{   r   r   r   re   re   rf   	eval_trig  s    
r  c                 C   s,   | | d t ||  t|t ||   S r0  )r#   r/   r   r   r  r   r   re   re   rf   eval_arctan  s    r  c                 C   s2   |  | d t | |  t|t | |   S r0  )r#   r!   r  re   re   rf   eval_arccoth  s    r  c                 C   s2   |  | d t | |  t|t | |   S r0  )r#   r"   r  re   re   rf   eval_arctanh  s    r  c                 C   s   t | S r^   r  r{   r   r   re   re   rf   eval_reciprocal  s    r  c                 C   s   t |S r^   )r.   r   re   re   rf   eval_arcsin  s    r  c                 C   s   | |S r^   re   r  re   re   rf   eval_inversehyperbolic  s    r  c                 C   s   t | d S r  r  )r   r   r   re   re   rf   eval_alternative  s    r  c                 C   s   t |S r^   r  )r   r   r   r   re   re   rf   eval_rewrite  s    r  c                 C   s   t dd | D  S )Nc                 S   s   g | ]\}}t ||fqS re   r  )r   r   condre   re   rf   r     s   z"eval_piecewise.<locals>.<listcomp>r$   r  re   re   rf   eval_piecewise  s    r  c                 C   s  | t| dt|  }| t| dt|  }| t| dt|  }t|t	}t
|dksfJ |d }t|| |}t
|dksJ t|d \}	}
t|tr|	}|
}t|
d |	d  }t|d }njt|tr|	}|
}t|
d |	d  }t|d }n4t|tr:|	}|
}t|
d |	d  }t|d }t| || ft| || ft| || f| |fg}tt| | |fS )NrM   r   r   )r   r,   r'   r+   r(   r*   r)   r   r  r&   r   rV   rT   r   r#   r.   r-   r/   r%   r@  r  )r  r{   r   r   r  r   r   Ztrig_functionZrelationZnumerr  oppositeZ
hypotenuseadjacentZinverser   re   re   rf   eval_trigsubstitution  s@    
r  c                 C   sN   t | j}t|D ](\}\}}||kr||d f||<  q<qt| jg|R  S r0  )r   variable_countr>  r   r   )r   r   r  r   varr  re   re   rf   eval_derivativerule  s    
r  c                 C   s   t | ||||  S r^   )r3   r   )ZhargZibndr   r   r   re   re   rf   eval_heaviside  s    r  c                 C   s|   t dt| d |d |d | | | |  t| | | df|t| df|| d |d  d || | d  t| dfS )Nr   rM   r   rI  )r%   rI   r   r   )r   r   r   r   r   re   re   rf   eval_jacobi  s
    :0r  c                 C   sT   t t| d |d |d|d   t|dft| d || d  t| dftjdfS )NrM   r   r%  T)r%   rH   r   rB   r   r   r   r   r   r   re   re   rf   eval_gegenbauer  s
    (r  c                 C   sP   t t| d || d  t| d || d   d tt| df|d d dfS )NrM   r   T)r%   rB   r   r   r   r   r   re   re   rf   eval_chebyshevt  s    r  c                 C   s,   t t| d || d  t| dftjdfS r  )r%   rB   r   r   r   r  re   re   rf   eval_chebyshevu  s    r  c                 C   s(   t | d |t | d | d|  d  S rt  )rD   r  re   re   rf   eval_legendre	  s    r  c                 C   s   t | d |d| d   S rt  )rE   r  re   re   rf   eval_hermite  s    r  c                 C   s   t | |t | d | S r0  )rF   r  re   re   rf   eval_laguerre  s    r  c                 C   s   t | d |d | S r0  )rG   r  re   re   rf   eval_assoclaguerre  s    r  c                 C   s(   t |t| |  t|t| |   S r^   )r'   r8   r(   r:   r   r   r   r   re   re   rf   eval_ci  s    r  c                 C   s(   t |t| |  t|t| |   S r^   )r   r9   r   r;   r  re   re   rf   eval_chi  s    r  c                 C   s   t |t| |  S r^   )r   r<   r  re   re   rf   eval_ei!  s    r  c                 C   s(   t |t| |  t|t| |   S r^   )r(   r8   r'   r:   r  re   re   rf   eval_si%  s    r  c                 C   s(   t |t| |  t|t| |   S r^   )r   r9   r   r;   r  re   re   rf   eval_shi)  s    r  c                 C   s   | j rtttj|   d t||d d|     td|  | | dt|     | dk fttj|  d t||d d|     td|  | | dt|    dfS ttj|  d t||d d|     td|  | | dt|    S d S )Nr   rI  r  r   T)r\  r%   r#   r   Pir   r4   r5   r  re   re   rf   eval_erf-  s     * ((r  c                 C   s   t tjd|   t|d d|   | td|  | | t d|  tj   t|d d|   | td|  | | t d|  tj     S Nr   rI  )r#   r   r  r'   r6   r(   r7   r  re   re   rf   eval_fresnelc9  s
    <<r  c                 C   s   t tjd|   t|d d|   | td|  | | t d|  tj   t|d d|   | td|  | | t d|  tj     S r  )r#   r   r  r'   r7   r(   r6   r  re   re   rf   eval_fresnels?  s
    <<r  c                 C   s   t | | | |  S r^   )r=   r  re   re   rf   eval_liE  s    r  c                 C   s   t |d | | S r0  rK   r  re   re   rf   eval_polylogI  s    r  c                 C   s0   || |  | |   t |d |  |  |  S r0  r>   )r   r  r   r   re   re   rf   eval_uppergammaM  s    r  c                 C   s   t |||  t|  S r^   )rA   r#   r   r   r   r   re   re   rf   eval_elliptic_fQ  s    r  c                 C   s   t |||  t|  S r^   )r@   r#   r  re   re   rf   eval_elliptic_eU  s    r  c                 C   s
   t | |S r^   rN   r   re   re   rf   eval_dontknowruleY  s    r  c                 C   s(   t | j}|s tdt|  ||  S )NzCannot evaluate rule %s)r   r   r_   r   repr)r   Z	evaluatorre   re   rf   r@  ]  s    r@  c                 C   s   t t| |}t  t|trt|jdkr|jd d }t|tr|jd d dkr|	|jd d t
|j f|jd d df}|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
    r   r   rM   T)r@  r   rO  clearr   r%   r   r   r   r{   r   )r   r  r  r  re   re   rf   manualintegrated  s    1r  N)r]   (  __doc__typingr   ZtDictr   collectionsr   r   collections.abcr   	functoolsr   Zsympy.core.addr   Zsympy.core.cacher	   Zsympy.core.containersZsympy.core.exprr
   Zsympy.core.functionr   Zsympy.core.logicr   Zsympy.core.mulr   Zsympy.core.numbersr   r   r   Zsympy.core.powerr   Zsympy.core.relationalr   r   r   r   Zsympy.core.singletonr   Zsympy.core.symbolr   r   r   Z$sympy.functions.elementary.complexesr   Z&sympy.functions.elementary.exponentialr   r   Z%sympy.functions.elementary.hyperbolicr   r   r   r    r!   r"   Z(sympy.functions.elementary.miscellaneousr#   Z$sympy.functions.elementary.piecewiser%   Z(sympy.functions.elementary.trigonometricr&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   Z'sympy.functions.special.delta_functionsr3   Z'sympy.functions.special.error_functionsr4   r5   r6   r7   r8   r9   r:   r;   r<   r=   Z'sympy.functions.special.gamma_functionsr?   Z*sympy.functions.special.elliptic_integralsr@   rA   Z#sympy.functions.special.polynomialsrB   rC   rD   rE   rF   rG   rH   rI   rJ   Z&sympy.functions.special.zeta_functionsrL   Z	integralsrO   Zsympy.logic.boolalgrP   Zsympy.ntheory.factor_rQ   Zsympy.polys.polytoolsrS   Zsympy.simplify.radsimprT   Zsympy.simplify.simplifyrU   Zsympy.solvers.solversrV   Zsympy.strategies.corerW   rX   rY   rZ   Zsympy.utilities.iterablesr[   Zsympy.utilities.miscr\   rn   ro   rq   rr   rs   ru   rv   rw   rx   ry   rz   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   r   r   r   r   r   r   r   r  r  r  r  r  r-  r/  r2  rH  rT  rW  r[  r_  r`  rd  rg  rh  ri  rj  rm  rp  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  intrO  rN  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  r  r  r  r  r  r  r@  r  re   re   re   rf   <module>   s(   <0,








































![(A[L)@




=? 

















&	