U
    L?hV ã                   @  sô   d 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 dd	lmZmZmZ dd
lmZ ddlmZmZ ddlmZmZmZ G dd„ deƒZG dd„ deƒZG dd„ deƒZ eeƒddd„ƒZ!ddd„Z"eZ#dS )z
A MathML printer.
é    )Úannotations)ÚAny)ÚMul)ÚS)Údefault_sort_key)Úsympify)Úsplit_super_subÚrequires_partial)Úprecedence_traditionalÚ
PRECEDENCEÚPRECEDENCE_TRADITIONAL)Úgreek_unicode)ÚPrinterÚprint_function)Úprec_to_dpsÚrepr_dpsÚto_strc                   @  sN   e Zd ZU dZddddddddddddi d	d
œZded< ddd„Zdd„ ZdS )ÚMathMLPrinterBasez^Contains common code required for MathMLContentPrinter and
    MathMLPresentationPrinter.
    Nzutf-8FZabbreviatedú[ÚplainTú&#xB7;)ÚorderÚencodingÚfold_frac_powersZfold_func_bracketsÚfold_short_fracZinv_trig_styleÚln_notationZlong_frac_ratioÚ	mat_delimÚmat_symbol_styleÚ
mul_symbolÚroot_notationZsymbol_namesÚmul_symbol_mathml_numberszdict[str, Any]Ú_default_settingsc                   sN   t  ˆ|¡ ddlm}m} |ƒ ˆ_G dd„ d|ƒ‰ ‡ ‡fdd„}|ˆj_d S )Nr   )ÚDocumentÚTextc                   @  s   e Zd Zddd„ZdS )z+MathMLPrinterBase.__init__.<locals>.RawTextÚ c                 S  s    | j r| d || j |¡¡ d S )Nz{}{}{})ÚdataÚwriteÚformat)ÚselfÚwriterÚindentZ	addindentZnewl© r+   úG/var/www/html/venv/lib/python3.8/site-packages/sympy/printing/mathml.pyÚwritexml6   s    z4MathMLPrinterBase.__init__.<locals>.RawText.writexmlN)r$   r$   r$   )Ú__name__Ú
__module__Ú__qualname__r-   r+   r+   r+   r,   ÚRawText5   s   r1   c                   s   ˆ ƒ }| |_ ˆj|_|S ©N)r%   ÚdomZownerDocument)r%   Úr©r1   r(   r+   r,   ÚcreateRawTextNode:   s    z5MathMLPrinterBase.__init__.<locals>.createRawTextNode)r   Ú__init__Zxml.dom.minidomr"   r#   r3   ÚcreateTextNode)r(   Úsettingsr"   r#   r6   r+   r5   r,   r7   +   s    zMathMLPrinterBase.__init__c                 C  s,   t  | |¡}| ¡ }| dd¡}| ¡ }|S )z2
        Prints the expression as MathML.
        ÚasciiÚxmlcharrefreplace)r   Ú_printZtoxmlÚencodeÚdecode)r(   ÚexprZmathMLZunistrZxmlbstrÚresr+   r+   r,   ÚdoprintB   s
    zMathMLPrinterBase.doprint)N)r.   r/   r0   Ú__doc__r!   Ú__annotations__r7   rA   r+   r+   r+   r,   r      s$   
ò
r   c                   @  sB  e Zd ZdZdZdd„ Zdd„ ZdJd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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d,d-„ ZeZeZd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Z d8d9„ Z!d:d;„ Z"d<d=„ Z#d>d?„ Z$d@dA„ Z%e"Z&e"Z'e"Z(dBdC„ Z)dDdE„ Z*dFdG„ Z+dHdI„ Z,dS )KÚMathMLContentPrinterz}Prints an expression to the Content MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter4.html
    Z_mathml_contentc              6   C  s¨   dddddddddd	d
dddddddddddddddddddddddd d!d"d!d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2œ5}|j jD ]}|j}||krx||   S qx|j j}| ¡ S )3ú)Returns the MathML tag for an expression.ÚplusÚtimesÚdiffÚcnÚpowerÚmaxÚminÚabsÚandÚorÚxorÚnotZimpliesÚciÚintÚsumÚsinÚcosÚtanÚcotÚcscÚsecÚsinhÚcoshÚtanhÚcothÚcschÚsechÚarcsinÚarcsinhÚarccosÚarccoshÚarctanÚarctanhÚarccotZarccothZarcsecZarcsechZarccscZarccschÚlnÚeqZneqZgeqZleqÚgtÚltÚunionZ	intersect)5ÚAddr   Ú
DerivativeÚNumberrS   ÚPowZMaxZMinZAbsÚAndÚOrZXorÚNotZImpliesÚSymbolÚMatrixSymbolZRandomSymbolÚIntegralÚSumrU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ÚasinÚasinhÚacosÚacoshÚatanÚatanhÚatan2ÚacotZacothZasecZasechZacscZacschÚlogÚEqualityÚ
UnequalityÚGreaterThanÚLessThanÚStrictGreaterThanÚStrictLessThanÚUnionÚIntersection©Ú	__class__Ú__mro__r.   Úlower)r(   ÚeÚ	translateÚclsÚnr+   r+   r,   Ú
mathml_tagT   sx    Ë8zMathMLContentPrinter.mathml_tagc           	      C  s@  |  ¡ r<| j d¡}| | j d¡¡ | |  | ¡¡ |S ddlm} ||ƒ\}}|tjk	r | j d¡}| | j d¡¡ | |  	|¡¡ | |  	|¡¡ |S | 
¡ \}}|tjkrÐt|ƒdkrÐ|  	|d ¡S | jdkrèt |¡ ¡ }| j d¡}| | j d¡¡ |dkr | |  	|¡¡ |D ]}| |  	|¡¡ q$|S )	NÚapplyÚminusr   ©ÚfractionÚdivideé   ÚoldrG   )Úcould_extract_minus_signr3   ÚcreateElementÚappendChildÚ
_print_MulÚsympy.simplifyr•   r   ÚOner<   Úas_coeff_mulÚlenr   r   Ú
_from_argsÚas_ordered_factors)	r(   r?   Úxr•   ÚnumerÚdenomÚcoeffÚtermsÚtermr+   r+   r,   rœ   –   s2    


zMathMLContentPrinter._print_MulNc                 C  s
  | j ||d}|  |d ¡}g }|dd … D ]’}| ¡ rŽ| j d¡}| | j d¡¡ | |¡ | |  | ¡¡ |}||d kr¾| |¡ q,| |¡ |  |¡}||d kr,| |  |¡¡ q,t|ƒdkrÐ|S | j d¡}| | j d¡¡ |r| | d¡¡ qî|S )N©r   r   r—   r’   r“   éÿÿÿÿrF   )	Ú_as_ordered_termsr<   r™   r3   rš   r›   Úappendr    Úpop)r(   r?   r   ÚargsZlastProcessedZ	plusNodesÚargr£   r+   r+   r,   Ú
_print_Add¹   s.    


zMathMLContentPrinter._print_Addc                 C  s®   |j d jdkrtdƒ‚| j d¡}t|j ƒD ]z\}\}}|t|j ƒd krr|dkrr| j d¡}| |  |¡¡ n,| j d¡}| |  |¡¡ | |  |¡¡ | |¡ q.|S )Nrª   Tz¼All Piecewise expressions must contain an (expr, True) statement to be used as a default condition. Without one, the generated expression may not evaluate to anything under some condition.Z	piecewiser—   Z	otherwiseÚpiece)	r®   ZcondÚ
ValueErrorr3   rš   Ú	enumerater    r›   r<   )r(   r?   ÚrootÚir   Úcr±   r+   r+   r,   Ú_print_PiecewiseÕ   s    z%MathMLContentPrinter._print_Piecewisec              	   C  s^   | j  d¡}t|jƒD ]B}| j  d¡}t|jƒD ]}| |  |||f ¡¡ q0| |¡ q|S )NÚmatrixZ	matrixrow)r3   rš   ÚrangeÚrowsÚcolsr›   r<   )r(   Úmr£   rµ   Zx_rÚjr+   r+   r,   Ú_print_MatrixBaseê   s    z&MathMLContentPrinter._print_MatrixBasec                 C  s°   |j dkr2| j d¡}| | j t|jƒ¡¡ |S | j d¡}| | j d¡¡ | j d¡}| | j t|jƒ¡¡ | j d¡}| | j t|j ƒ¡¡ | |¡ | |¡ |S )Nr—   rI   r’   r–   )Úqr3   rš   r›   r8   ÚstrÚp)r(   r   r£   ÚxnumZxdenomr+   r+   r,   Ú_print_Rationaló   s    


z$MathMLContentPrinter._print_Rationalc                 C  s–   | j  d¡}| | j  |  |¡¡¡ | j  d¡}| j  d¡}| |  |jd ¡¡ | |  |jd ¡¡ | |¡ | |¡ | |  |jd ¡¡ |S )Nr’   ÚbvarÚlowlimitr—   é   r   )r3   rš   r›   r‘   r<   r®   )r(   r   r£   Úx_1Úx_2r+   r+   r,   Ú_print_Limit  s    

z!MathMLContentPrinter._print_Limitc                 C  s   | j  d¡S )NZ
imaginaryi©r3   rš   ©r(   r   r+   r+   r,   Ú_print_ImaginaryUnit  s    z)MathMLContentPrinter._print_ImaginaryUnitc                 C  s   | j  d¡S )NZ
eulergammarÊ   rË   r+   r+   r,   Ú_print_EulerGamma  s    z&MathMLContentPrinter._print_EulerGammac                 C  s"   | j  d¡}| | j  d¡¡ |S )zwWe use unicode #x3c6 for Greek letter phi as defined here
        https://www.w3.org/2003/entities/2007doc/isogrk1.htmlrI   u   Ï†©r3   rš   r›   r8   ©r(   r   r£   r+   r+   r,   Ú_print_GoldenRatio  s    z'MathMLContentPrinter._print_GoldenRatioc                 C  s   | j  d¡S )NZexponentialerÊ   rË   r+   r+   r,   Ú_print_Exp1   s    z MathMLContentPrinter._print_Exp1c                 C  s   | j  d¡S )NÚpirÊ   rË   r+   r+   r,   Ú	_print_Pi#  s    zMathMLContentPrinter._print_Pic                 C  s   | j  d¡S )NÚinfinityrÊ   rË   r+   r+   r,   Ú_print_Infinity&  s    z$MathMLContentPrinter._print_Infinityc                 C  s   | j  d¡S )NZ
notanumberrÊ   rË   r+   r+   r,   Ú
_print_NaN)  s    zMathMLContentPrinter._print_NaNc                 C  s   | j  d¡S )NZemptysetrÊ   rË   r+   r+   r,   Ú_print_EmptySet,  s    z$MathMLContentPrinter._print_EmptySetc                 C  s   | j  d¡S )NÚtruerÊ   rË   r+   r+   r,   Ú_print_BooleanTrue/  s    z'MathMLContentPrinter._print_BooleanTruec                 C  s   | j  d¡S )NÚfalserÊ   rË   r+   r+   r,   Ú_print_BooleanFalse2  s    z(MathMLContentPrinter._print_BooleanFalsec                 C  s4   | j  d¡}| | j  d¡¡ | | j  d¡¡ |S )Nr’   r“   rÔ   )r3   rš   r›   rÏ   r+   r+   r,   Ú_print_NegativeInfinity5  s    z,MathMLContentPrinter._print_NegativeInfinityc                   s*   ‡ ‡‡fdd„‰t ˆ jƒ}| ¡  ˆ|ƒS )Nc                   s8  ˆj  d¡}| ˆj  ˆ ˆ ¡¡¡ ˆj  d¡}| ˆ | d d ¡¡ | |¡ t| d ƒdkr¾ˆj  d¡}| ˆ | d d ¡¡ | |¡ ˆj  d¡}| ˆ | d d ¡¡ | |¡ t| d ƒdkrüˆj  d¡}| ˆ | d d ¡¡ | |¡ t| ƒdkr| ˆ ˆ j¡¡ n| ˆ| dd … ƒ¡ |S )	Nr’   rÄ   r   é   rÅ   r—   ZuplimitrÆ   )r3   rš   r›   r‘   r<   r    Úfunction)Úlimitsr£   Z	bvar_elemÚlow_elemÚup_elem©r   Ú
lime_recurr(   r+   r,   rã   <  s(    



z8MathMLContentPrinter._print_Integral.<locals>.lime_recur)Úlistrß   Úreverse)r(   r   rß   r+   râ   r,   Ú_print_Integral;  s    
z$MathMLContentPrinter._print_Integralc                 C  s
   |   |¡S r2   )ræ   rË   r+   r+   r,   Ú
_print_SumX  s    zMathMLContentPrinter._print_Sumc                   sB  ˆ j  ˆ  |¡¡}‡ fdd„}dd„ ‰t|jƒ\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j  d¡}| ˆ j  |¡¡ |sÌ|sœ| ˆ j  |¡¡ n.ˆ j  d	¡}| |¡ | ||ƒ¡ | |¡ nr|sˆ j  d
¡}	|	 |¡ |	 ||ƒ¡ | |	¡ n<ˆ j  d¡}
|
 |¡ |
 ||ƒ¡ |
 ||ƒ¡ | |
¡ |S )Nc                   s°   t | ƒdkr†ˆ j d¡}t| ƒD ]`\}}|dkrXˆ j d¡}| ˆ j d¡¡ | |¡ ˆ j d¡}| ˆ j |¡¡ | |¡ q |S ˆ j d¡}| ˆ j | d ¡¡ |S d S )Nr—   zmml:mrowr   zmml:moú úmml:mi©r    r3   rš   r³   r›   r8   ©ÚitemsÚmrowrµ   ÚitemÚmoÚmi©r(   r+   r,   Újoin`  s    
z0MathMLContentPrinter._print_Symbol.<locals>.joinc                 S  s   | t krt  | ¡S | S d S r2   ©r   Úget©Úsr+   r+   r,   rŽ   r  s    
z5MathMLContentPrinter._print_Symbol.<locals>.translatec                   s   g | ]}ˆ |ƒ‘qS r+   r+   ©Ú.0Úsup©rŽ   r+   r,   Ú
<listcomp>z  s     z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>c                   s   g | ]}ˆ |ƒ‘qS r+   r+   ©rø   Úsubrú   r+   r,   rû   {  s     ré   zmml:msubzmml:msupzmml:msubsup)r3   rš   r‘   r   Únamer›   r8   )r(   ÚsymrR   rò   rþ   ÚsupersÚsubsÚmnameÚmsubÚmsupÚmsubsupr+   ©r(   rŽ   r,   Ú_print_Symbol]  s6    



z"MathMLContentPrinter._print_Symbolc                 C  sô   | j d r¤|jjr¤|jjdkr¤| j d¡}| | j d¡¡ |jjdkrŽ| j d¡}| j d¡}| | j t	|jjƒ¡¡ | |¡ | |¡ | |  
|j¡¡ |S | j d¡}| j |  |¡¡}| |¡ | |  
|j¡¡ | |  
|j¡¡ |S )Nr   r—   r’   r´   rÆ   ÚdegreerI   )Ú	_settingsÚexpÚis_RationalrÁ   r3   rš   r›   r¿   r8   rÀ   r<   Úbaser‘   )r(   r   r£   ZxmldegZxmlcnrÇ   r+   r+   r,   Ú
_print_Pow˜  s&    
ÿ


zMathMLContentPrinter._print_Powc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r2   ©r3   rš   r‘   r›   r8   rÀ   rÏ   r+   r+   r,   Ú_print_Number¯  s    z"MathMLContentPrinter._print_Numberc                 C  s:   | j  |  |¡¡}t|jt|jƒƒ}| | j  |¡¡ |S r2   )	r3   rš   r‘   Úmlib_to_strÚ_mpf_r   Ú_precr›   r8   )r(   r   r£   Zrepr_er+   r+   r,   Ú_print_Float´  s    z!MathMLContentPrinter._print_Floatc                 C  s¸   | j  d¡}|  |¡}t|jƒr$d}| | j  |¡¡ | j  d¡}t|jƒD ]J\}}| |  |¡¡ |dkrL| j  d¡}| |  t	|ƒ¡¡ | |¡ qL| |¡ | |  |j¡¡ |S )Nr’   ZpartialdiffrÄ   r—   r  )
r3   rš   r‘   r	   r?   r›   ÚreversedÚvariable_countr<   r   )r(   r   r£   Zdiff_symbolrÇ   rÿ   rG   r  r+   r+   r,   Ú_print_Derivativeº  s    


z&MathMLContentPrinter._print_Derivativec                 C  sD   | j  d¡}| | j  |  |¡¡¡ |jD ]}| |  |¡¡ q*|S ©Nr’   )r3   rš   r›   r‘   r®   r<   ©r(   r   r£   r¯   r+   r+   r,   Ú_print_FunctionÍ  s
    
z$MathMLContentPrinter._print_Functionc                 C  s2   | j  |  |¡¡}|jD ]}| |  |¡¡ q|S r2   )r3   rš   r‘   r®   r›   r<   r  r+   r+   r,   Ú_print_BasicÔ  s    
z!MathMLContentPrinter._print_Basicc                 C  sH   | j  d¡}| j  |  |¡¡}| |¡ |jD ]}| |  |¡¡ q.|S r  )r3   rš   r‘   r›   r®   r<   )r(   r   r£   rÇ   r¯   r+   r+   r,   Ú_print_AssocOpÚ  s    

z#MathMLContentPrinter._print_AssocOpc                 C  sL   | j  d¡}| | j  |  |¡¡¡ | |  |j¡¡ | |  |j¡¡ |S r  )r3   rš   r›   r‘   r<   ÚlhsÚrhsrÏ   r+   r+   r,   Ú_print_Relationalâ  s
    z&MathMLContentPrinter._print_Relationalc                 C  s*   | j  d¡}|D ]}| |  |¡¡ q|S )zgMathML reference for the <list> element:
        https://www.w3.org/TR/MathML2/chapter4.html#contm.listrä   ©r3   rš   r›   r<   )r(   ÚseqÚdom_elementrî   r+   r+   r,   Ú_print_listé  s    z MathMLContentPrinter._print_listc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r2   r  ©r(   rÁ   r!  r+   r+   r,   Ú
_print_intñ  s    zMathMLContentPrinter._print_intc                 C  s,   | j  d¡}|jD ]}| |  |¡¡ q|S )NÚset©r3   rš   r®   r›   r<   r  r+   r+   r,   Ú_print_FiniteSetú  s    
z%MathMLContentPrinter._print_FiniteSetc                 C  s>   | j  d¡}| | j  d¡¡ |jD ]}| |  |¡¡ q$|S )Nr’   Zsetdiff©r3   rš   r›   r®   r<   r  r+   r+   r,   Ú_print_Complement   s
    
z&MathMLContentPrinter._print_Complementc                 C  s>   | j  d¡}| | j  d¡¡ |jD ]}| |  |¡¡ q$|S )Nr’   Zcartesianproductr(  r  r+   r+   r,   Ú_print_ProductSet  s
    
z&MathMLContentPrinter._print_ProductSetc                 C  sZ   | j  |  |¡¡}|jD ]*}| j  d¡}| |  |¡¡ | |¡ q| |  |j¡¡ |S )NrÄ   )r3   rš   r‘   Ú	signaturer›   r<   r?   )r(   r   r£   r¯   rÇ   r+   r+   r,   Ú_print_Lambda  s    
z"MathMLContentPrinter._print_Lambda)N)-r.   r/   r0   rB   Úprintmethodr‘   rœ   r°   r·   r¾   rÃ   rÉ   rÌ   rÍ   rÐ   rÑ   rÓ   rÕ   rÖ   r×   rÙ   rÛ   rÜ   ræ   rç   r  Ú_print_MatrixSymbolÚ_print_RandomSymbolr  r  r  r  r  r  r  r  r"  r$  Ú_print_ImpliesÚ
_print_NotÚ
_print_Xorr'  r)  r*  r,  r+   r+   r+   r,   rD   M   sT   B#
	8rD   c                   @  sD  e Zd ZdZdZdd„ Zddd„Zdd	„ Zddd„Zdd„ Z	d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d!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zdd6d7„Zd8d9„ ZeZd:d;„ Z d<d=„ Z!d>d?„ Z"d@dA„ Z#dBdC„ Z$dDdE„ Z%dFdG„ Z&dHdI„ Z'dJdK„ Z(dLdM„ Z)dNdO„ Z*dPdQ„ Z+dRdS„ Z,dTdU„ Z-dVdW„ Z.ddXdY„Z/e/Z0dZd[„ Z1dd\d]„Z2dd^d_„Z3d`da„ Z4dbdc„ Z5ddde„ Z6dfdg„ Z7dhdi„ Z8djdk„ Z9dldm„ Z:dndo„ Z;dpdq„ Z<e<Z=drds„ Z>dtdu„ Z?dvdw„ Z@dxdy„ ZAdzd{„ ZBd|d}„ ZCd~d„ ZDd€d„ ZEd‚dƒ„ ZFeFZGeFZHd„d…„ ZId†d‡„ ZJdˆd‰„ ZKeK ZLZMdŠd‹„ ZNdŒd„ ZOdŽd„ ZPdd‘„ ZQd’d“„ ZRd”d•„ ZSd–d—„ ZTd˜d™„ ZUdšd›„ ZVdœd„ ZWdždŸ„ ZXd d¡„ ZYd¢d£„ ZZd¤d¥„ Z[d¦d§„ Z\d¨d©„ Z]dªd«„ Z^d¬d­„ Z_d®d¯„ Z`d°d±„ Zad²d³„ ZbebZcd´dµ„ Zdd¶d·„ Zed¸d¹„ Zfdºd»„ Zgd¼d½„ Zhd¾d¿„ ZidÀdÁ„ ZjdÂdÃ„ ZkdÄdÅ„ ZldÆdÇ„ ZmdÈdÉ„ ZndÊdË„ ZodÌdÍ„ ZpdÎdÏ„ ZqdÐdÑ„ ZrdÒdÓ„ ZsdÔdÕ„ ZtdÖd×„ ZudØdÙ„ ZvdÚdÛ„ ZwdÜdÝ„ ZxdÞdß„ Zydàdá„ Zzdâdã„ Z{dädå„ Z|dædç„ Z}dèdé„ Z~dêdë„ Zdìdí„ Z€dîdï„ Zdð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Šd
S (	  ÚMathMLPresentationPrinterz‚Prints an expression to the Presentation MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter3.html
    Z_mathml_presentationc              1     s¼   dddddddddd	d
dddddddddddddddddddddddd d!d"d#d$d%d&d'd(d"d#d)d*d+d,œ0}‡ fd-d.„}|j jD ]}|j}||krz||   S qz|j jd/kr¬|ƒ S |j j}| ¡ S )0rE   Úmnz&#x2192;ú&dd;rð   z&int;z&#x2211;rU   rV   rW   rX   ra   rb   rc   rd   re   rf   rg   ú=z&#x2260;z&#x2265;z&#x2264;ú>ú<ú&#x3A6;z&#x3B6;z&#x3B7;z&#x39A;ú&#x3B3;z&#x393;z&#x3D5;z&#x3BB;z&#x3BD;z&#x3A9;r   ÚCÚWz&#x398;ÚTrueÚFalseÚNonez	S&#x2032;z	C&#x2032;Úlambda)0ro   ZLimitrn   rS   rt   rv   rw   rU   rV   rW   rX   rx   ry   rz   r{   r|   r}   r   r~   r   r‚   rƒ   r„   r…   r†   ZlerchphiÚzetaZdirichlet_etaZ
elliptic_kZ
lowergammaZ
uppergammaÚgammaZtotientZreduced_totientZprimenuZ
primeomegaZfresnelsZfresnelcZLambertWZ	HeavisideZBooleanTrueZBooleanFalseZNoneTypeZmathieusZmathieucZmathieusprimeZmathieucprimeÚLambdac                     sz   ˆ j d d ksˆ j d dkr dS ˆ j d dkr2dS ˆ j d dkrDdS ˆ j d dkrVd	S tˆ j d tƒslt‚n
ˆ j d S d S )
Nr   r?  ú&InvisibleTimes;rG   ú&#xD7;Údotr   Zldotz&#x2024;)r	  Ú
isinstancerÀ   Ú	TypeErrorr+   rñ   r+   r,   Úmul_symbol_selectionX  s    ÿzBMathMLPresentationPrinter.mathml_tag.<locals>.mul_symbol_selectionr   r‰   )r(   r   rŽ   rI  r   r   r+   rñ   r,   r‘   #  st    Ð3z$MathMLPresentationPrinter.mathml_tagFc                 C  sJ   t |ƒ}||k s|s<||kr<| j d¡}| |  |¡¡ |S |  |¡S d S ©NÚmfenced)r
   r3   rš   r›   r<   )r(   rî   ÚlevelÚstrictZprec_valÚbracr+   r+   r,   Úparenthesizep  s    z&MathMLPresentationPrinter.parenthesizec                   sd   ‡ fdd„}ˆ j  d¡}| ¡ rVˆ j  d¡}| ˆ j  d¡¡ | |¡ || |ƒ}n
|||ƒ}|S )Nc                   sŠ  ddl m} || ƒ\}}|tjk	rŠˆ j d¡}ˆ jd rTtt| ƒƒdk rT| 	dd¡ ˆ  
|¡}ˆ  
|¡}| |¡ | |¡ | |¡ |S |  ¡ \}}	|tjkrÄt|	ƒdkrÄ| ˆ  
|	d ¡¡ |S ˆ jd	krÜt |	¡ ¡ }	|dkr(ˆ  
|¡}
ˆ j d
¡}| ˆ j ˆ  | ¡¡¡ | |
¡ | |¡ |	D ]X}| ˆ  |td ¡¡ ||	d ks,ˆ j d
¡}| ˆ j ˆ  | ¡¡¡ | |¡ q,|S )Nr   r”   Úmfracr   é   ÚbevelledrØ   r—   r˜   rï   r   rª   )r   r•   r   rž   r3   rš   r	  r    rÀ   ÚsetAttributer<   r›   rŸ   r   r   r¡   r¢   r8   r‘   rO  r   )r?   rí   r•   r¤   r¥   ÚfracrÂ   Zxdenr¦   r§   r£   Úyr¨   rñ   r+   r,   Úmultiply{  s>    










z6MathMLPresentationPrinter._print_Mul.<locals>.multiplyrí   rï   ú-)r3   rš   r™   r›   r8   )r(   r?   rV  rí   r£   r+   rñ   r,   rœ   y  s    "

z$MathMLPresentationPrinter._print_MulNc                 C  s´   | j  d¡}| j||d}| |  |d ¡¡ |dd … D ]t}| ¡ rr| j  d¡}| | j  d¡¡ |  | ¡}n(| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ q:|S )Nrí   r©   r   r—   rï   rW  ú+)r3   rš   r«   r›   r<   r™   r8   )r(   r?   r   rí   r®   r¯   r£   rU  r+   r+   r,   r°   ¨  s    

z$MathMLPresentationPrinter._print_Addc              	   C  sÂ   | j  d¡}t|jƒD ]X}| j  d¡}t|jƒD ]2}| j  d¡}| |  |||f ¡¡ | |¡ q0| |¡ q| jd dkr‚|S | j  d¡}| jd dkr´| dd	¡ | d
d¡ | |¡ |S )NZmtableZmtrZmtdr   r$   rK  r   Úcloseú]Úopen)	r3   rš   r¹   rº   r»   r›   r<   r	  rS  )r(   r¼   Útablerµ   r£   r½   rU  rN  r+   r+   r,   r¾   ¼  s     
z+MathMLPresentationPrinter._print_MatrixBasec                 C  s¶   |j dk r|j  }n|j }| j d¡}|s4| jd r@| dd¡ | |  |¡¡ | |  |j¡¡ |j dk r®| j d¡}| j d¡}| | j d¡¡ | |¡ | |¡ |S |S d S )	Nr   rP  r   rR  rØ   rí   rï   rW  )	rÁ   r3   rš   r	  rS  r›   r<   r¿   r8   )r(   r   ÚfoldedrÁ   r£   rí   rï   r+   r+   r,   Ú_get_printed_RationalÎ  s     




z/MathMLPresentationPrinter._get_printed_Rationalc                 C  s(   |j dkr|  |j¡S |  || jd ¡S )Nr—   r   )r¿   r<   rÁ   r^  r	  rË   r+   r+   r,   rÃ   â  s    
z)MathMLPresentationPrinter._print_Rationalc           	      C  sÜ   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | j  d¡}|  |jd ¡}| j  d¡}| | j  |  |¡¡¡ |  |jd ¡}| |¡ | |¡ | |¡ | |¡ | |¡ | |¡ | |  |jd ¡¡ |S )	Nrí   Úmunderrð   Úlimr—   rï   rÆ   r   )r3   rš   r›   r8   r<   r®   r‘   )	r(   r   rí   r_  rð   r£   rÇ   ÚarrowrÈ   r+   r+   r,   rÉ   é  s"    





z&MathMLPresentationPrinter._print_Limitc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   z&ImaginaryI;rÎ   rÏ   r+   r+   r,   rÌ   ÿ  s    z.MathMLPresentationPrinter._print_ImaginaryUnitc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   r9  rÎ   rÏ   r+   r+   r,   rÐ     s    z,MathMLPresentationPrinter._print_GoldenRatioc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   z&ExponentialE;rÎ   rÏ   r+   r+   r,   rÑ   	  s    z%MathMLPresentationPrinter._print_Exp1c                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   z&pi;rÎ   rÏ   r+   r+   r,   rÓ     s    z#MathMLPresentationPrinter._print_Pic                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   ú&#x221E;rÎ   rÏ   r+   r+   r,   rÕ     s    z)MathMLPresentationPrinter._print_Infinityc                 C  sL   | j  d¡}| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ |S )Nrí   rï   rW  )r3   rš   r›   r8   rÕ   )r(   r   rí   rU  r£   r+   r+   r,   rÜ     s    


z1MathMLPresentationPrinter._print_NegativeInfinityc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   z&#x210F;rÎ   rÏ   r+   r+   r,   Ú_print_HBar!  s    z%MathMLPresentationPrinter._print_HBarc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   r:  rÎ   rÏ   r+   r+   r,   rÍ   &  s    z+MathMLPresentationPrinter._print_EulerGammac                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   ZTribonacciConstantrÎ   rÏ   r+   r+   r,   Ú_print_TribonacciConstant+  s    z3MathMLPresentationPrinter._print_TribonacciConstantc                 C  s8   | j  d¡}| |  |jd ¡¡ | | j  d¡¡ |S )Nr  r   ú&#x2020;©r3   rš   r›   r<   r®   r8   ©r(   r   r  r+   r+   r,   Ú_print_Dagger0  s    z'MathMLPresentationPrinter._print_Daggerc                 C  sd   | j  d¡}| |  |jd ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ |S )Nrí   r   rï   z&#x2208;r—   rf  )r(   r   rí   rï   r+   r+   r,   Ú_print_Contains6  s    
z)MathMLPresentationPrinter._print_Containsc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   z&#x210B;rÎ   rÏ   r+   r+   r,   Ú_print_HilbertSpace?  s    z-MathMLPresentationPrinter._print_HilbertSpacec                 C  s8   | j  d¡}| | j  d¡¡ | |  |jd ¡¡ |S )Nr  z	&#x1D49E;r   ©r3   rš   r›   r8   r<   r®   rg  r+   r+   r,   Ú_print_ComplexSpaceD  s    z-MathMLPresentationPrinter._print_ComplexSpacec                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   z&#x2131;rÎ   rÏ   r+   r+   r,   Ú_print_FockSpaceJ  s    z*MathMLPresentationPrinter._print_FockSpacec           	      C  s¸  ddddœ}| j  d¡}t|jƒdkrntdd„ |jD ƒƒrn| j  d	¡}| | j  |t|jƒ ¡¡ | |¡ nÜt|jƒD ]Ð}| j  d	¡}| | j  |d
 ¡¡ t|ƒd
kr´| |¡ t|ƒdkrô| j  d¡}| |¡ | |  |d
 ¡¡ | |¡ t|ƒdkrx| j  d¡}| |¡ | |  |d
 ¡¡ | |  |d ¡¡ | |¡ qx| | j	|j
td dd¡ t|jƒD ]B}| j  d	¡}| | j  d¡¡ | |¡ | |  |d ¡¡ qp|S )Nz&#x222B;z&#x222C;z&#x222D;)r—   rÆ   rÝ   rí   rÝ   c                 s  s   | ]}t |ƒd kV  qdS )r—   N)r    )rø   r`  r+   r+   r,   Ú	<genexpr>T  s     z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>rï   r—   rÆ   r  r  r   T©rM  r5  r   )r3   rš   r    rß   Úallr›   r8   r  r<   rO  rÞ   r   )	r(   r?   Z
intsymbolsrí   rï   r`  r  r  Údr+   r+   r,   ræ   P  s>    "



ÿ
z)MathMLPresentationPrinter._print_Integralc                 C  s@  t |jƒ}| j d¡}|  |d d ¡}|  |d d ¡}| j d¡}| | j |  |¡¡¡ | j d¡}|  |d d ¡}| j d¡}	|	 | j d¡¡ | |¡ | |	¡ | |¡ | |¡ | |¡ | |¡ | j d¡}
|
 |¡ tt	|j
ƒƒdkr|
 |  |j
¡¡ n(| j d¡}| |  |j
¡¡ |
 |¡ |
S )	NZ
munderoverr   r—   rÆ   rï   rí   r6  rK  )rä   rß   r3   rš   r<   r›   r8   r‘   r    rÀ   rÞ   )r(   r   rß   Zsubsuprà   rá   ZsummandÚlowÚvarÚequalrí   Zfencer+   r+   r,   rç   v  s0    








z$MathMLPresentationPrinter._print_Sumr   c           	        s0  ‡ fdd„}dd„ ‰t |jƒ\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j d¡}| ˆ j |¡¡ t|ƒd	kr²t|ƒd	krŒ|}n$ˆ j d
¡}| |¡ | ||ƒ¡ ndt|ƒd	kräˆ j d¡}| |¡ | ||ƒ¡ n2ˆ j d¡}| |¡ | ||ƒ¡ | ||ƒ¡ |dkr,| dd¡ |S )Nc                   s°   t | ƒdkr†ˆ j d¡}t| ƒD ]`\}}|dkrXˆ j d¡}| ˆ j d¡¡ | |¡ ˆ j d¡}| ˆ j |¡¡ | |¡ q |S ˆ j d¡}| ˆ j | d ¡¡ |S d S )Nr—   rí   r   rï   rè   rð   rê   rë   rñ   r+   r,   rò   –  s    
z5MathMLPresentationPrinter._print_Symbol.<locals>.joinc                 S  s   | t krt  | ¡S | S d S r2   ró   rõ   r+   r+   r,   rŽ   ¨  s    
z:MathMLPresentationPrinter._print_Symbol.<locals>.translatec                   s   g | ]}ˆ |ƒ‘qS r+   r+   r÷   rú   r+   r,   rû   °  s     z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>c                   s   g | ]}ˆ |ƒ‘qS r+   r+   rü   rú   r+   r,   rû   ±  s     rð   r   r  r  r  ÚboldÚmathvariant)r   rþ   r3   rš   r›   r8   r    rS  )	r(   rÿ   Ústylerò   rþ   r   r  r  r£   r+   r  r,   r  •  s2    



z'MathMLPresentationPrinter._print_Symbolc                 C  s   | j || jd dS )Nr   )rw  )r  r	  )r(   rÿ   r+   r+   r,   r.  Ë  s    ÿz-MathMLPresentationPrinter._print_MatrixSymbolc                 C  s2   | j  d¡}| dd¡ | |  |jd ¡¡ |S )NZmencloseÚnotationÚtopr   ©r3   rš   rS  r›   r<   r®   )r(   r?   Úencr+   r+   r,   Ú_print_conjugateÑ  s    z*MathMLPresentationPrinter._print_conjugatec                 C  sN   | j  d¡}| |  |td ¡¡ | j  d¡}| | j  |¡¡ | |¡ |S )Nrí   ZFuncrï   )r3   rš   r›   rO  r   r8   )r(   Úopr?   Úrowrï   r+   r+   r,   Ú_print_operator_after×  s    
z/MathMLPresentationPrinter._print_operator_afterc                 C  s   |   d|jd ¡S )Nú!r   ©r  r®   ©r(   r?   r+   r+   r,   Ú_print_factorialß  s    z*MathMLPresentationPrinter._print_factorialc                 C  s   |   d|jd ¡S )Nz!!r   r  r‚  r+   r+   r,   Ú_print_factorial2â  s    z+MathMLPresentationPrinter._print_factorial2c                 C  s^   | j  d¡}| j  d¡}| dd¡ | |  |jd ¡¡ | |  |jd ¡¡ | |¡ |S )NrK  rP  ZlinethicknessÚ0r   r—   rz  )r(   r?   rN  rT  r+   r+   r,   Ú_print_binomialå  s    
z)MathMLPresentationPrinter._print_binomialc                 C  sd  |j jrÐt|j jƒdkrÐ|j jdkrÐ| jd rÐ|j jdkrX| j d¡}| |  	|j
¡¡ |j jdkr–| j d¡}| |  	|j
¡¡ | |  	|j j¡¡ |j jdkrÌ| j d¡}| |  	d¡¡ | |¡ |S |S |j jrž|j jdkrž|j jr\| j d¡}| |  	d¡¡ | j d¡}| |  |j
td	 ¡¡ | |  |j  | jd
 ¡¡ | |¡ |S | j d¡}| |  |j
td	 ¡¡ | |  |j | jd
 ¡¡ |S |j jr*| j d¡}| |  	d¡¡ |j dkrä| |  	|j
¡¡ nB| j d¡}| |  |j
td	 ¡¡ | |  	|j  ¡¡ | |¡ |S | j d¡}| |  |j
td	 ¡¡ | |  	|j ¡¡ |S )Nr—   r   rÆ   ZmsqrtZmrootrª   rP  r  rp   r   )r
  r  rM   rÁ   r¿   r	  r3   rš   r›   r<   r  Zis_negativerO  r   r^  )r(   r   r£   rT  ry  r+   r+   r,   r  î  s^    $ÿ

ÿ
ÿ

z$MathMLPresentationPrinter._print_Powc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r2   r  rÏ   r+   r+   r,   r  $  s    z'MathMLPresentationPrinter._print_Numberc                 C  sL   | j  d¡}| dd¡ | dd¡ | |  |j¡¡ | |  |j¡¡ |S )NrK  rY  õ   âŸ©r[  õ   âŸ¨)r3   rš   rS  r›   r<   rL   rK   )r(   rµ   rN  r+   r+   r,   Ú_print_AccumulationBounds)  s    z3MathMLPresentationPrinter._print_AccumulationBoundsc                 C  s   t |jƒrd}n
|  |¡}| j d¡}d}t|jƒD ]š\}}||7 }|dkr’| j d¡}| j d¡}| | j |¡¡ | |¡ | |  	|¡¡ n| j d¡}| | j |¡¡ | |¡ |  	|¡}	| |	¡ q4| j d¡}
|dkr,| j d¡}| j d¡}| | j |¡¡ | |¡ | |  	|¡¡ n| j d¡}| | j |¡¡ |
 |¡ | j d¡}| j d¡}| |
¡ | |¡ | |¡ | |  	|j¡¡ |S )Nz&#x2202;rí   r   rÆ   r  rï   rP  )
r	   r?   r‘   r3   rš   r  r  r›   r8   r<   )r(   r   rq  r¼   Údimrÿ   Únumr£   ZxxrU  Zmnumrí   rT  r+   r+   r,   r  1  sF    










z+MathMLPresentationPrinter._print_Derivativec                 C  sœ   | j  d¡}| j  d¡}|  |¡dkrD| jd rD| | j  d¡¡ n| | j  |  |¡¡¡ | j  d¡}|jD ]}| |  |¡¡ qn| |¡ | |¡ |S )Nrí   rð   r€   r   rh   rK  )r3   rš   r‘   r	  r›   r8   r®   r<   )r(   r   rí   r£   rU  r¯   r+   r+   r,   r  a  s    


z)MathMLPresentationPrinter._print_Functionc                 C  sh  t |jƒ}t|j|dd}| jd }| j d¡}d|kr| d¡\}}|d dkr`|dd … }| j d	¡}| | j 	|¡¡ | |¡ | j d
¡}	|	 | j 	|¡¡ | |	¡ | j d¡}
| j d	¡}| | j 	d¡¡ |
 |¡ | j d	¡}| | j 	|¡¡ |
 |¡ | |
¡ |S |dkr.|  
d ¡S |dkrB|  d ¡S | j d	¡}| | j 	|¡¡ |S d S )NT)Zstrip_zerosr    rí   r   r   rX  r—   r4  rï   r  Ú10z+infz-inf)r   r  r  r  r	  r3   rš   Úsplitr›   r8   rÕ   rÜ   )r(   r?   ZdpsZstr_realÚ	separatorrí   Zmantr
  r4  rï   r  r+   r+   r,   r  o  s<    











z&MathMLPresentationPrinter._print_Floatc                 C  s   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | j  d¡}| |  |jd ¡¡ | |¡ |S )Nrí   r  rð   ZLir   rK  r—   rk  )r(   r?   rí   r¼   rð   rN  r+   r+   r,   Ú_print_polylog–  s    


z(MathMLPresentationPrinter._print_polylogc                 C  sp   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ | j  d¡}|jD ]}| |  |¡¡ qL| |¡ |S )Nrí   rð   rK  ©r3   rš   r›   r8   r‘   r®   r<   )r(   r   rí   rð   rN  r¯   r+   r+   r,   r  ¤  s    


z&MathMLPresentationPrinter._print_Basicc                 C  sB   | j  d¡}| j  d¡}|jD ]}| |  |¡¡ q| |¡ |S )Nrí   rK  r&  )r(   r   rí   r£   r¯   r+   r+   r,   Ú_print_Tuple¯  s    

z&MathMLPresentationPrinter._print_Tuplec                 C  sÂ   | j  d¡}| j  d¡}|j|jkrP| dd¡ | dd¡ | |  |j¡¡ nd|jrd| dd¡ n| dd¡ |jr„| dd	¡ n| dd
¡ | |  |j¡¡ | |  |j¡¡ | |¡ |S )Nrí   rK  rY  Ú}r[  Ú{ú)rZ  ú(r   )	r3   rš   ÚstartÚendrS  r›   r<   Z
right_openZ	left_open)r(   rµ   rí   rN  r+   r+   r,   Ú_print_Interval·  s     
z)MathMLPresentationPrinter._print_Intervalc                 C  sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nrí   rK  rY  ú|r[  r   rz  )r(   r?   r
  rí   r£   r+   r+   r,   Ú
_print_AbsÏ  s    
z$MathMLPresentationPrinter._print_Absc                 C  sj   | j  d¡}| j  d¡}| dd¡ | | j  |¡¡ | |¡ | j  d¡}| |  |¡¡ | |¡ |S )Nrí   rð   rv  ZfrakturrK  )r3   rš   rS  r›   r8   r<   )r(   r¶   r?   rí   rð   rN  r+   r+   r,   Ú_print_re_imÚ  s    

z&MathMLPresentationPrinter._print_re_imc                 C  s   |   d|jd ¡S )NÚRr   ©r›  r®   ©r(   r?   r
  r+   r+   r,   Ú	_print_reå  s    z#MathMLPresentationPrinter._print_rec                 C  s   |   d|jd ¡S )NÚIr   r  rž  r+   r+   r,   Ú	_print_imè  s    z#MathMLPresentationPrinter._print_imc                 C  sZ   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ |jD ]}| |  |¡¡ q@|S )Nrí   rð   r  )r(   r   rí   rð   r¯   r+   r+   r,   r  ë  s    

z(MathMLPresentationPrinter._print_AssocOpc                 C  sz   | j  d¡}| |  |jd |¡¡ |jdd … D ]B}| j  d¡}| | j  |¡¡ |  ||¡}| |¡ | |¡ q2|S )Nrí   r   r—   rï   )r3   rš   r›   rO  r®   r8   )r(   r?   ÚsymbolÚprecrí   r¯   r£   rU  r+   r+   r,   Ú_print_SetOpô  s    
z&MathMLPresentationPrinter._print_SetOpc                 C  s   t d }|  |d|¡S )Nr‡   z&#x222A;©r   r¤  ©r(   r?   r£  r+   r+   r,   Ú_print_Unionÿ  s    z&MathMLPresentationPrinter._print_Unionc                 C  s   t d }|  |d|¡S )Nrˆ   z&#x2229;r¥  r¦  r+   r+   r,   Ú_print_Intersection  s    z-MathMLPresentationPrinter._print_Intersectionc                 C  s   t d }|  |d|¡S )NZ
Complementz&#x2216;r¥  r¦  r+   r+   r,   r)    s    z+MathMLPresentationPrinter._print_Complementc                 C  s   t d }|  |d|¡S )NZSymmetricDifferenceú&#x2206;r¥  r¦  r+   r+   r,   Ú_print_SymmetricDifference  s    z4MathMLPresentationPrinter._print_SymmetricDifferencec                 C  s   t d }|  |d|¡S )NZ
ProductSetz&#x00d7;r¥  r¦  r+   r+   r,   r*    s    z+MathMLPresentationPrinter._print_ProductSetc                 C  s   |   |j¡S r2   )Ú
_print_setr®   )r(   rö   r+   r+   r,   r'    s    z*MathMLPresentationPrinter._print_FiniteSetc                 C  sN   t |td}| j d¡}| dd¡ | dd¡ |D ]}| |  |¡¡ q4|S )N©ÚkeyrK  rY  r’  r[  r“  )Úsortedr   r3   rš   rS  r›   r<   )r(   rö   rì   rN  rî   r+   r+   r,   r«    s    z$MathMLPresentationPrinter._print_setc                 C  sÜ   | j  d¡}|d jrL|d jsL| j  d¡}| |  |d ¡¡ | |¡ n| |  |d ¡¡ |dd … D ]j}| j  d¡}| | j  |¡¡ |jr¸|js¸| j  d¡}| |  |¡¡ n
|  |¡}| |¡ | |¡ ql|S )Nrí   r   rK  r—   rï   )r3   rš   Ú
is_BooleanZis_Notr›   r<   r8   )r(   r®   r¢  rí   rN  r¯   r£   rU  r+   r+   r,   Ú_print_LogOp!  s     

z&MathMLPresentationPrinter._print_LogOpc                 C  s°  ddl m} ||jkr"|  |j¡S t||ƒr:| ¡  ¡ }n
d|fg}| j d¡}|D ]T\}}t	|j
 ¡ ƒ}|jdd„ d t|ƒD ]"\}\}	}
|
dkrØ|rÆ| j d¡}| | j d	¡¡ | |¡ | |  |	¡¡ q„|
d
kr| j d¡}| | j d¡¡ | |¡ | |  |	¡¡ q„|rJ| j d¡}| | j d	¡¡ | |¡ | j d¡}| |  |
¡¡ | |¡ | j d¡}| | j d¡¡ | |¡ | |  |	¡¡ q„qT|S )Nr   )ÚVectorrí   c                 S  s   | d   ¡ S )Nr   )Ú__str__)r£   r+   r+   r,   Ú<lambda>C  ó    zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>r¬  r—   rï   rX  rª   rW  rK  rD  )Zsympy.vectorr±  Úzeror<   rG  Zseparaterì   r3   rš   rä   Ú
componentsÚsortr³   r›   r8   )r(   r?   r±  rì   rí   ÚsystemZvectZ
inneritemsrµ   ÚkÚvrï   Zmbracr+   r+   r,   Ú_print_BasisDependent5  sD    








z/MathMLPresentationPrinter._print_BasisDependentc                 C  s   t |jtd}|  |d¡S )Nr¬  z&#x2227;©r®  r®   r   r°  ©r(   r?   r®   r+   r+   r,   Ú
_print_And_  s    z$MathMLPresentationPrinter._print_Andc                 C  s   t |jtd}|  |d¡S )Nr¬  z&#x2228;r¼  r½  r+   r+   r,   Ú	_print_Orc  s    z#MathMLPresentationPrinter._print_Orc                 C  s   t |jtd}|  |d¡S )Nr¬  z&#x22BB;r¼  r½  r+   r+   r,   r2  g  s    z$MathMLPresentationPrinter._print_Xorc                 C  s   |   |jd¡S )Nz&#x21D2;)r°  r®   r‚  r+   r+   r,   r0  k  s    z(MathMLPresentationPrinter._print_Impliesc                 C  s   t |jtd}|  |d¡S )Nr¬  z&#x21D4;r¼  r½  r+   r+   r,   Ú_print_Equivalentn  s    z+MathMLPresentationPrinter._print_Equivalentc                 C  s‚   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ |jd jrd| j  d¡}| |  |jd ¡¡ n|  |jd ¡}| |¡ |S )Nrí   rï   z&#xAC;r   rK  )r3   rš   r›   r8   r®   r¯  r<   )r(   r   rí   rï   r£   r+   r+   r,   r1  r  s    

z$MathMLPresentationPrinter._print_Notc                 C  s(   | j  d¡}| | j  |  |¡¡¡ |S ©Nrð   ©r3   rš   r›   r8   r‘   ©r(   r   rð   r+   r+   r,   Ú_print_bool  s    z%MathMLPresentationPrinter._print_boolc                 C  s(   | j  d¡}| | j  |  |¡¡¡ |S rÁ  rÂ  rÃ  r+   r+   r,   Ú_print_NoneType‡  s    z)MathMLPresentationPrinter._print_NoneTypec                 C  s.  d}| j  d¡}| dd¡ | dd¡ |jjr`|jjr`|jjrP|ddd	|f}qÜ|d	dd|f}n||jjr‚||d |j |d f}nZ|jjr¦t|ƒ}t	|ƒt	|ƒ|f}n6t
|ƒd
krÔt|ƒ}t	|ƒt	|ƒ||d f}nt|ƒ}|D ]H}||kr| j  d¡}| | j  |¡¡ | |¡ qà| |  |¡¡ qà|S )Nu   â€¦rK  rY  r’  r[  r“  rª   r   r—   é   rð   )r3   rš   rS  r–  Úis_infiniteÚstopÚstepZis_positiveÚiterÚnextr    Útupler›   r8   r<   )r(   rö   ÚdotsrN  ZprintsetÚitÚelrð   r+   r+   r,   Ú_print_RangeŒ  s0    
z&MathMLPresentationPrinter._print_Rangec                 C  s€   t |jtd}| j d¡}| j d¡}| | j t|jƒ 	¡ ¡¡ | |¡ | j d¡}|D ]}| |  
|¡¡ q\| |¡ |S )Nr¬  rí   rï   rK  )r®  r®   r   r3   rš   r›   r8   rÀ   ÚfuncrŒ   r<   )r(   r?   r®   rí   rï   rN  r¢  r+   r+   r,   Ú_hprint_variadic_function¬  s    

z3MathMLPresentationPrinter._hprint_variadic_functionc                 C  s6   | j  d¡}| |  d ¡¡ | |  |jd ¡¡ |S )Nr  r   )r3   rš   r›   rÑ   r<   r®   )r(   r?   r  r+   r+   r,   Ú
_print_expº  s    z$MathMLPresentationPrinter._print_expc                 C  sb   | j  d¡}| |  |j¡¡ | j  d¡}| | j  |  |¡¡¡ | |¡ | |  |j¡¡ |S )Nrí   rï   )r3   rš   r›   r<   r  r8   r‘   r  ©r(   r   rí   r£   r+   r+   r,   r  À  s    
z+MathMLPresentationPrinter._print_Relationalc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r2   r  r#  r+   r+   r,   r$  É  s    z$MathMLPresentationPrinter._print_intc                 C  sŠ   | j  d¡}|j\}}| j  d¡}| dd¡ | | j  |j| ¡¡ | |¡ | j  d¡}| dd¡ | | j  |j¡¡ | |¡ |S )Nr  rð   rv  ru  )r3   rš   Ú_idrS  r›   r8   Z_variable_namesÚ_name)r(   r   r  Úindexr¸  rð   r+   r+   r,   Ú_print_BaseScalarÎ  s    


z+MathMLPresentationPrinter._print_BaseScalarc                 C  sÈ   | j  d¡}|j\}}| j  d¡}| j  d¡}| dd¡ | | j  |j| ¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |¡ | j  d¡}| dd¡ | | j  |j¡¡ | |¡ |S )Nr  Úmoverrð   rv  ru  rï   ú^)r3   rš   rÕ  rS  r›   r8   Z_vector_namesrÖ  )r(   r   r  r×  r¸  rÙ  rð   rï   r+   r+   r,   Ú_print_BaseVectorÛ  s     




z+MathMLPresentationPrinter._print_BaseVectorc                 C  sl   | j  d¡}| j  d¡}| dd¡ | | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ |S )NrÙ  rð   rv  ru  r…  rï   rÚ  ©r3   rš   rS  r›   r8   )r(   r   rÙ  rð   rï   r+   r+   r,   Ú_print_VectorZeroí  s    

z+MathMLPresentationPrinter._print_VectorZeroc                 C  sp   | j  d¡}|j}|j}| |  |td ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |td ¡¡ |S )Nrí   r   rï   rE  ©r3   rš   Z_expr1Z_expr2r›   rO  r   r8   ©r(   r?   rí   Zvec1Zvec2rï   r+   r+   r,   Ú_print_Crossø  s    
z&MathMLPresentationPrinter._print_Crossc                 C  sx   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nrí   rï   ú&#x2207;rE  r   ©r3   rš   r›   r8   rO  Z_exprr   ©r(   r?   rí   rï   r+   r+   r,   Ú_print_Curl  s    

z%MathMLPresentationPrinter._print_Curlc                 C  sx   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nrí   rï   rá  r   r   râ  rã  r+   r+   r,   Ú_print_Divergence  s    

z+MathMLPresentationPrinter._print_Divergencec                 C  sp   | j  d¡}|j}|j}| |  |td ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |td ¡¡ |S )Nrí   r   rï   r   rÞ  rß  r+   r+   r,   Ú
_print_Dot  s    
z$MathMLPresentationPrinter._print_Dotc                 C  sP   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nrí   rï   rá  r   râ  rã  r+   r+   r,   Ú_print_Gradient$  s    
z)MathMLPresentationPrinter._print_Gradientc                 C  sP   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nrí   rï   r©  r   râ  rã  r+   r+   r,   Ú_print_Laplacian,  s    
z*MathMLPresentationPrinter._print_Laplacianc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nrð   rv  Únormalz&#x2124;rÜ  rÏ   r+   r+   r,   Ú_print_Integers4  s    z)MathMLPresentationPrinter._print_Integersc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nrð   rv  ré  z&#x2102;rÜ  rÏ   r+   r+   r,   Ú_print_Complexes:  s    z*MathMLPresentationPrinter._print_Complexesc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nrð   rv  ré  z&#x211D;rÜ  rÏ   r+   r+   r,   Ú_print_Reals@  s    z&MathMLPresentationPrinter._print_Realsc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nrð   rv  ré  ú&#x2115;rÜ  rÏ   r+   r+   r,   Ú_print_NaturalsF  s    z)MathMLPresentationPrinter._print_Naturalsc                 C  sV   | j  d¡}| j  d¡}| dd¡ | | j  d¡¡ | |¡ | |  tj¡¡ |S )Nr  rð   rv  ré  rí  )r3   rš   rS  r›   r8   r<   r   ZZero)r(   r   rý   r£   r+   r+   r,   Ú_print_Naturals0L  s    
z*MathMLPresentationPrinter._print_Naturals0c                 C  s|   |j d |j d  }|j d }| j d¡}| j d¡}| dd¡ | dd	¡ | |  |¡¡ | |¡ | |  |¡¡ |S )
Nr   r—   rÆ   r  rK  rY  r‡  r[  rˆ  )r®   r3   rš   rS  r›   r<   )r(   r?   ÚshiftrJ   rù   rN  r+   r+   r,   Ú_print_SingularityFunctionU  s    

z4MathMLPresentationPrinter._print_SingularityFunctionc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   ÚNaNrÎ   rÏ   r+   r+   r,   rÖ   a  s    z$MathMLPresentationPrinter._print_NaNc                 C  s°   | j  d¡}| j  d¡}| | j  |¡¡ | |¡ | |  |jd ¡¡ t|jƒdkr\|S | j  d¡}| j  d¡}|jdd … D ]}| |  |¡¡ q‚| |¡ | |¡ |S )Nr  rð   r   r—   rí   rK  )r3   rš   r›   r8   r<   r®   r    )r(   r   rþ   rý   rð   rí   rU  r¯   r+   r+   r,   Ú_print_number_functionf  s    


z0MathMLPresentationPrinter._print_number_functionc                 C  s   |   |d¡S )NÚB©ró  rË   r+   r+   r,   Ú_print_bernoulliy  s    z*MathMLPresentationPrinter._print_bernoullic                 C  s   |   |d¡S )Nr;  rõ  rË   r+   r+   r,   Ú_print_catalan~  s    z(MathMLPresentationPrinter._print_catalanc                 C  s   |   |d¡S )NÚErõ  rË   r+   r+   r,   Ú_print_euler  s    z&MathMLPresentationPrinter._print_eulerc                 C  s   |   |d¡S )NÚFrõ  rË   r+   r+   r,   Ú_print_fibonacci„  s    z*MathMLPresentationPrinter._print_fibonaccic                 C  s   |   |d¡S )NÚLrõ  rË   r+   r+   r,   Ú_print_lucas‡  s    z&MathMLPresentationPrinter._print_lucasc                 C  s   |   |d¡S )Nz&#x03B3;rõ  rË   r+   r+   r,   Ú_print_stieltjesŠ  s    z*MathMLPresentationPrinter._print_stieltjesc                 C  s   |   |d¡S )NÚTrõ  rË   r+   r+   r,   Ú_print_tribonacci  s    z+MathMLPresentationPrinter._print_tribonaccic                 C  s`   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ |S )NrÙ  rï   rb  ú~rÎ   )r(   r   r£   rï   r+   r+   r,   Ú_print_ComplexInfinity  s    

z0MathMLPresentationPrinter._print_ComplexInfinityc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrï   z&#x2205;rÎ   rÏ   r+   r+   r,   r×   š  s    z)MathMLPresentationPrinter._print_EmptySetc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrï   z	&#x1D54C;rÎ   rÏ   r+   r+   r,   Ú_print_UniversalSetŸ  s    z-MathMLPresentationPrinter._print_UniversalSetc                 C  sŒ   ddl m} |j}| j d¡}t||ƒsP| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | j d¡}| | j d¡¡ | |¡ |S )Nr   ©ru   r  rK  rï   re  ©	Úsympy.matricesru   r¯   r3   rš   rG  r›   r<   r8   ©r(   r?   ru   Úmatrù   rN  rï   r+   r+   r,   Ú_print_Adjoint¤  s    

z(MathMLPresentationPrinter._print_Adjointc                 C  sŒ   ddl m} |j}| j d¡}t||ƒsP| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | j d¡}| | j d¡¡ | |¡ |S )Nr   r  r  rK  rï   rÿ  r  r  r+   r+   r,   Ú_print_Transpose³  s    

z*MathMLPresentationPrinter._print_Transposec                 C  st   ddl m} |j}| j d¡}t||ƒsP| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | |  d¡¡ |S )Nr   r  r  rK  rª   )r  ru   r¯   r3   rš   rG  r›   r<   )r(   r?   ru   r  rù   rN  r+   r+   r,   Ú_print_InverseÂ  s    
z(MathMLPresentationPrinter._print_Inversec                 C  s&  ddl m} | j d¡}|j}t|d tƒrJ|d  ¡ t|dd … ƒ }nt|ƒ}t||ƒr´| 	¡ r´|d dkr~|dd … }n|d  |d< | j d¡}| 
| j d¡¡ | 
|¡ |d d… D ]D}| 
|  |t|ƒd¡¡ | j d¡}| 
| j d	¡¡ | 
|¡ qÀ| 
|  |d t|ƒd¡¡ |S )
Nr   )ÚMatMulrí   r—   rª   rï   rW  FrD  )Z!sympy.matrices.expressions.matmulr  r3   rš   r®   rG  r   r¢   rä   r™   r›   r8   rO  r
   )r(   r?   r  r£   r®   rï   r¯   r+   r+   r,   Ú_print_MatMulÏ  s0    
ÿÿz'MathMLPresentationPrinter._print_MatMulc                 C  s|   ddl m} |j|j }}| j d¡}t||ƒsX| j d¡}| |  |¡¡ | |¡ n| |  |¡¡ | |  |¡¡ |S )Nr   r  r  rK  )	r  ru   r  r
  r3   rš   rG  r›   r<   )r(   r?   ru   r  r
  rù   rN  r+   r+   r,   Ú_print_MatPowì  s    
z'MathMLPresentationPrinter._print_MatPowc                 C  s„   | j  d¡}|j}|d d… D ]D}| |  |t|ƒd¡¡ | j  d¡}| | j  d¡¡ | |¡ q| |  |d t|ƒd¡¡ |S )Nrí   rª   Frï   z&#x2218;)r3   rš   r®   r›   rO  r
   r8   )r(   r?   r£   r®   r¯   rï   r+   r+   r,   Ú_print_HadamardProductù  s    ÿÿz0MathMLPresentationPrinter._print_HadamardProductc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr4  z&#x1D7D8rÎ   ©r(   ÚZr£   r+   r+   r,   Ú_print_ZeroMatrix  s    z+MathMLPresentationPrinter._print_ZeroMatrixc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr4  z&#x1D7D9rÎ   r  r+   r+   r,   Ú_print_OneMatrix  s    z*MathMLPresentationPrinter._print_OneMatrixc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrð   z	&#x1D540;rÎ   )r(   r   r£   r+   r+   r,   Ú_print_Identity  s    z)MathMLPresentationPrinter._print_Identityc                 C  sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nrí   rK  rY  u   âŒ‹r[  u   âŒŠr   rz  rÔ  r+   r+   r,   Ú_print_floor  s    
z&MathMLPresentationPrinter._print_floorc                 C  sT   | j  d¡}| j  d¡}| dd¡ | dd¡ | |  |jd ¡¡ | |¡ |S )Nrí   rK  rY  u   âŒ‰r[  u   âŒˆr   rz  rÔ  r+   r+   r,   Ú_print_ceiling  s    
z(MathMLPresentationPrinter._print_ceilingc                 C  sž   | j  d¡}| j  d¡}|jd }t|ƒdkr>|  |d ¡}n
|  |¡}| |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ |S )NrK  rí   r   r—   rï   z&#x21A6;)r3   rš   r®   r    r<   r›   r8   )r(   r   r£   rí   Úsymbolsrï   r+   r+   r,   r,  '  s    




z'MathMLPresentationPrinter._print_Lambdac                 C  s*   | j  d¡}|D ]}| |  |¡¡ q|S rJ  r  )r(   r   r£   rµ   r+   r+   r,   Ú_print_tuple7  s    z&MathMLPresentationPrinter._print_tuplec                 C  s   |   |j¡S r2   )r<   ÚlabelrË   r+   r+   r,   Ú_print_IndexedBase=  s    z,MathMLPresentationPrinter._print_IndexedBasec                 C  s\   | j  d¡}| |  |j¡¡ t|jƒdkrF| |  |jd ¡¡ |S | |  |j¡¡ |S )Nr  r—   r   )r3   rš   r›   r<   r  r    ÚindicesrÏ   r+   r+   r,   Ú_print_Indexed@  s    z(MathMLPresentationPrinter._print_Indexedc                 C  sv   | j  d¡}| | j|jtd dd¡ | j  d¡}| dd¡ | dd¡ |jD ]}| |  |¡¡ qR| |¡ |S )	Nr  ZAtomTro  rK  rY  r$   r[  )	r3   rš   r›   rO  Úparentr   rS  r  r<   )r(   r   r£   rN  rµ   r+   r+   r,   Ú_print_MatrixElementI  s    

z.MathMLPresentationPrinter._print_MatrixElementc                 C  sv   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| dd¡ |jD ]}| |  |¡¡ qR| |¡ |S )Nrí   rð   z	&#x1d5a5;rK  Ú
separatorsr™  ©r3   rš   r›   r8   rS  r®   r<   ©r(   r   r£   rð   rU  rµ   r+   r+   r,   Ú_print_elliptic_fT  s    


z+MathMLPresentationPrinter._print_elliptic_fc                 C  sv   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| dd¡ |jD ]}| |  |¡¡ qR| |¡ |S )Nrí   rð   z	&#x1d5a4;rK  r  r™  r   r!  r+   r+   r,   Ú_print_elliptic_e`  s    


z+MathMLPresentationPrinter._print_elliptic_ec                 C  s’   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}t|jƒdkr\| dd¡ n| dd¡ |jD ]}| |  |¡¡ qn| |¡ |S )	Nrí   rð   z	&#x1d6f1;rK  rÆ   r  r™  z;|)r3   rš   r›   r8   r    r®   rS  r<   r!  r+   r+   r,   Ú_print_elliptic_pil  s    


z,MathMLPresentationPrinter._print_elliptic_pic                 C  sJ   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |j¡¡ |S )Nrí   rð   ZEirk  )r(   r   r£   rð   r+   r+   r,   Ú	_print_Ei{  s    
z#MathMLPresentationPrinter._print_Eic                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrí   r  rï   rø  r   r—   rk  ©r(   r   r£   rU  rï   r+   r+   r,   Ú_print_expintƒ  s    

z'MathMLPresentationPrinter._print_expintc                 C  s˜   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  |jdd… ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrí   r  rï   ÚPr   r—   rÝ   rk  r&  r+   r+   r,   Ú_print_jacobiŽ  s    

z'MathMLPresentationPrinter._print_jacobic                 C  s˜   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  |jdd… ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrí   r  rï   r;  r   r—   rÆ   rk  r&  r+   r+   r,   Ú_print_gegenbauerš  s    

z+MathMLPresentationPrinter._print_gegenbauerc                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrí   r  rï   rÿ  r   r—   rk  r&  r+   r+   r,   Ú_print_chebyshevt¦  s    

z+MathMLPresentationPrinter._print_chebyshevtc                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrí   r  rï   ÚUr   r—   rk  r&  r+   r+   r,   Ú_print_chebyshevu±  s    

z+MathMLPresentationPrinter._print_chebyshevuc                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrí   r  rï   r(  r   r—   rk  r&  r+   r+   r,   Ú_print_legendre¼  s    

z)MathMLPresentationPrinter._print_legendrec                 C  s˜   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  |jdd… ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrí   r  rï   r(  r   r—   rÆ   rk  r&  r+   r+   r,   Ú_print_assoc_legendreÇ  s    

z/MathMLPresentationPrinter._print_assoc_legendrec                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrí   r  rï   rü  r   r—   rk  r&  r+   r+   r,   Ú_print_laguerreÓ  s    

z)MathMLPresentationPrinter._print_laguerrec                 C  s˜   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  |jdd… ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrí   r  rï   rü  r   r—   rÆ   rk  r&  r+   r+   r,   Ú_print_assoc_laguerreÞ  s    

z/MathMLPresentationPrinter._print_assoc_laguerrec                 C  s~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrí   r  rï   ÚHr   r—   rk  r&  r+   r+   r,   Ú_print_hermiteê  s    

z(MathMLPresentationPrinter._print_hermite)F)N)N)r   )N)N)N)‹r.   r/   r0   rB   r-  r‘   rO  rœ   r°   r¾   r^  rÃ   rÉ   rÌ   rÐ   rÑ   rÓ   rÕ   rÜ   rc  rÍ   rd  rh  ri  rj  rl  rm  ræ   rç   r  r.  r/  r|  r  rƒ  r„  r†  r  r  r‰  r  r  r  r  r  r‘  r˜  rš  Z_print_Determinantr›  rŸ  r¡  r  r¤  r§  r¨  r)  rª  r*  r'  r«  Z_print_frozensetr°  r»  r¾  r¿  r2  r0  rÀ  r1  rÄ  rÙ   rÛ   rÅ  rÐ  rÒ  Z
_print_MinZ
_print_MaxrÓ  r  r$  rØ  rÛ  rÝ  rà  rä  rå  ræ  rç  rè  rê  rë  rì  rî  rï  rñ  rÖ   ró  rö  Z_print_bellr÷  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/  r0  r1  r3  r+   r+   r+   r,   r3    s  M	/		&6	60'			* 		
			r3  Úcontentc                 K  s(   |dkrt |ƒ | ¡S t|ƒ | ¡S dS )zŠReturns the MathML representation of expr. If printer is presentation
    then prints Presentation MathML else prints content MathML.
    ÚpresentationN)r3  rA   rD   )r?   Úprinterr9   r+   r+   r,   Úmathmlö  s    r7  c                 K  s<   |dkrt |ƒ}nt|ƒ}| t| ƒ¡}| ¡ }t|ƒ dS )a  
    Prints a pretty representation of the MathML code for expr. If printer is
    presentation then prints Presentation MathML else prints content MathML.

    Examples
    ========

    >>> ##
    >>> from sympy import print_mathml
    >>> from sympy.abc import x
    >>> print_mathml(x+1) #doctest: +NORMALIZE_WHITESPACE
    <apply>
        <plus/>
        <ci>x</ci>
        <cn>1</cn>
    </apply>
    >>> print_mathml(x+1, printer='presentation')
    <mrow>
        <mi>x</mi>
        <mo>+</mo>
        <mn>1</mn>
    </mrow>

    r5  N)r3  rD   r<   r   ZtoprettyxmlÚprint)r?   r6  r9   rö   ÚxmlZ
pretty_xmlr+   r+   r,   Úprint_mathml  s    
r:  N)r4  )r4  )$rB   Ú
__future__r   Útypingr   Zsympy.core.mulr   Zsympy.core.singletonr   Zsympy.core.sortingr   Zsympy.core.sympifyr   Zsympy.printing.conventionsr   r	   Zsympy.printing.precedencer
   r   r   Z&sympy.printing.pretty.pretty_symbologyr   Zsympy.printing.printerr   r   Zmpmath.libmpr   r   r   r  r   rD   r3  r7  r:  ZMathMLPrinterr+   r+   r+   r,   Ú<module>   s@   8   R           e

$