a
    kº”hZ+ ã                   @  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                   @  sX   e Zd ZU dZddddddddddddi d	dd
œZded< ddd„Z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_numbersÚdisable_split_super_subz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,   úC/var/www/auris/lib/python3.9/site-packages/sympy/printing/mathml.pyÚwritexml7   s    z4MathMLPrinterBase.__init__.<locals>.RawText.writexmlN)r%   r%   r%   )Ú__name__Ú
__module__Ú__qualname__r.   r,   r,   r,   r-   ÚRawText6   s   r2   c                   s   ˆ ƒ }| |_ ˆj|_|S ©N)r&   ÚdomZownerDocument)r&   Úr©r2   r)   r,   r-   ÚcreateRawTextNode;   s    z5MathMLPrinterBase.__init__.<locals>.createRawTextNode)r   Ú__init__Zxml.dom.minidomr#   r$   r4   ÚcreateTextNode)r)   Úsettingsr#   r$   r7   r,   r6   r-   r8   ,   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-   ÚdoprintC   s
    zMathMLPrinterBase.doprintc                 C  s    | j d r|g g fS t|ƒS d S )Nr!   )Ú	_settingsr   )r)   Únamer,   r,   r-   Ú_split_super_subM   s    

z"MathMLPrinterBase._split_super_sub)N)	r/   r0   r1   Ú__doc__r"   Ú__annotations__r8   rB   rE   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}||v 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ÚNumberrW   ÚPowZMaxZMinZAbsÚAndÚOrZXorÚNotZImpliesÚSymbolÚMatrixSymbolZRandomSymbolÚIntegralÚSumrY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   Ú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_tag[   sx    Ë8zMathMLContentPrinter.mathml_tagc           	      C  s@  |  ¡ r<| j d¡}| | j d¡¡ | |  | ¡¡ |S ddlm} ||ƒ\}}|tjur | j d¡}| | j d¡¡ | |  	|¡¡ | |  	|¡¡ |S | 
¡ \}}|tju 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é   ÚoldrK   )Úcould_extract_minus_signr4   Ú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—   éÿÿÿÿrJ   )	Ú_as_ordered_termsr=   r   r4   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Ú
ValueErrorr4   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 )NZmatrixZ	matrixrow)r4   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›   rM   r–   rš   )Úqr4   rž   rŸ   r9   Ú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   )r4   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©r4   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.htmlrM   u   Ï†©r4   rž   rŸ   r9   ©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_NaN0  s    zMathMLContentPrinter._print_NaNc                 C  s   | j  d¡S )NZemptysetrÍ   rÎ   r,   r,   r-   Ú_print_EmptySet3  s    z$MathMLContentPrinter._print_EmptySetc                 C  s   | j  d¡S )NÚtruerÍ   rÎ   r,   r,   r-   Ú_print_BooleanTrue6  s    z'MathMLContentPrinter._print_BooleanTruec                 C  s   | j  d¡S )NÚfalserÍ   rÎ   r,   r,   r-   Ú_print_BooleanFalse9  s    z(MathMLContentPrinter._print_BooleanFalsec                 C  s4   | j  d¡}| | j  d¡¡ | | j  d¡¡ |S )Nr–   r—   r×   )r4   rž   rŸ   rÒ   r,   r,   r-   Ú_print_NegativeInfinity<  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É   )r4   rž   rŸ   r•   r=   r¤   Úfunction)Úlimitsr§   Z	bvar_elemÚlow_elemÚup_elem©r‘   Ú
lime_recurr)   r,   r-   ræ   C  s(    



z8MathMLContentPrinter._print_Integral.<locals>.lime_recur)Úlistrâ   Úreverse)r)   r‘   râ   r,   rå   r-   Ú_print_IntegralB  s    
z$MathMLContentPrinter._print_Integralc                 C  s
   |   |¡S r3   )ré   rÎ   r,   r,   r-   Ú
_print_Sum_  s    zMathMLContentPrinter._print_Sumc                   sD  ˆ j  ˆ  |¡¡}‡ fdd„}dd„ ‰ˆ  |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¤   r4   rž   r·   rŸ   r9   ©ÚitemsÚmrowr¹   ÚitemÚmoÚmi©r)   r,   r-   Újoing  s    
z0MathMLContentPrinter._print_Symbol.<locals>.joinc                 S  s   | t v rt  | ¡S | S d S r3   ©r   Úget©Úsr,   r,   r-   r’   y  s    
z5MathMLContentPrinter._print_Symbol.<locals>.translatec                   s   g | ]}ˆ |ƒ‘qS r,   r,   ©Ú.0Úsup©r’   r,   r-   Ú
<listcomp>  ó    z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>c                   s   g | ]}ˆ |ƒ‘qS r,   r,   ©rû   Úsubrý   r,   r-   rþ   ‚  rÿ   rì   zmml:msubzmml:msupzmml:msubsup)r4   rž   r•   rE   rD   rŸ   r9   )r)   ÚsymrV   rõ   rD   ÚsupersÚsubsÚmnameÚmsubÚmsupÚmsubsupr,   ©r)   r’   r-   Ú_print_Symbold  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É   ÚdegreerM   )rC   ÚexpÚis_RationalrÄ   r4   rž   rŸ   rÂ   r9   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 r3   ©r4   rž   r•   rŸ   r9   rÃ   rÒ   r,   r,   r-   Ú_print_Number¶  s    z"MathMLContentPrinter._print_Numberc                 C  s:   | j  |  |¡¡}t|jt|jƒƒ}| | j  |¡¡ |S r3   )	r4   rž   r•   Úmlib_to_strÚ_mpf_r   Ú_precrŸ   r9   )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  )
r4   rž   r•   r	   r@   rŸ   ÚreversedÚvariable_countr=   r   )r)   r‘   r§   Zdiff_symbolrÊ   r  rK   r  r,   r,   r-   Ú_print_DerivativeÁ  s    


z&MathMLContentPrinter._print_Derivativec                 C  sD   | j  d¡}| | j  |  |¡¡¡ |jD ]}| |  |¡¡ q*|S ©Nr–   )r4   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 r3   )r4   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  )r4   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  )r4   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ç   )r4   rž   rŸ   r=   )r)   ÚseqÚdom_elementrñ   r,   r,   r-   Ú_print_listð  s    z MathMLContentPrinter._print_listc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r3   r  ©r)   rÄ   r"  r,   r,   r-   Ú
_print_intø  s    zMathMLContentPrinter._print_intc                 C  s,   | j  d¡}|jD ]}| |  |¡¡ q|S )NÚset)r4   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©r4   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Ç   )r4   rž   r•   Ú	signaturerŸ   r=   r@   )r)   r‘   r§   r³   rÊ   r,   r,   r-   Ú_print_Lambda  s    
z"MathMLContentPrinter._print_Lambda)N)-r/   r0   r1   rF   Ú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-   rH   T   sT   B#
	8rH   c                   @  s°  e Zd ZdZ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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/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ Zd9d:„ Zd;d<„ Z d=d>„ Z!d?d@„ Z"dAdB„ Z#dCdD„ Z$dEdF„ Z%ddHdI„Z&dJdK„ Z'e&Z(dLdM„ Z)dNdO„ Z*dPdQ„ Z+dRdS„ Z,dTdU„ Z-dVdW„ Z.dXdY„ Z/dZd[„ Z0d\d]„ Z1d^d_„ Z2d`da„ Z3dbdc„ Z4ddde„ Z5dfdg„ Z6dhdi„ Z7ddjdk„Z8e8Z9dldm„ Z:ddndo„Z;ddpdq„Z<drds„ Z=dtdu„ Z>dvdw„ Z?dxdy„ Z@dzd{„ ZAd|d}„ ZBd~d„ ZCd€d„ ZDd‚dƒ„ ZEeEZFd„d…„ ZGd†d‡„ ZHdˆd‰„ ZIdŠd‹„ ZJdŒd„ ZKdŽd„ ZLdd‘„ ZMd’d“„ ZNd”d•„ ZOeOZPeOZQd–d—„ ZRd˜d™„ ZSdšd›„ ZTeT ZUZVdœ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³„ Zbd´dµ„ Zcd¶d·„ Zdd¸d¹„ Zedºd»„ Zfd¼d½„ Zgd¾d¿„ ZhdÀdÁ„ ZidÂdÃ„ ZjdÄdÅ„ ZkekZldÆ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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}||v rz||   S qz|j jd/kr¬|ƒ S |j j}| ¡ S )0rI   Úmnz&#x2192;ú&dd;ró   z&int;z&#x2211;rY   rZ   r[   r\   re   rf   rg   rh   ri   rj   rk   ú=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)0rs   ZLimitrr   rW   rx   rz   r{   rY   rZ   r[   r\   r|   r}   r~   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 u 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;rK   ú&#xD7;Údotr   Zldotz&#x2024;)rC   Ú
isinstancerÃ   Ú	TypeErrorr,   rô   r,   r-   Úmul_symbol_selection_  s    ÿzBMathMLPresentationPrinter.mathml_tag.<locals>.mul_symbol_selectionr   r   )r)   r‘   r’   rI  r“   r”   r,   rô   r-   r•   *  st    Ð3z$MathMLPresentationPrinter.mathml_tagc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrò   ú(rÑ   ©r)   rò   r,   r,   r-   Ú_l_parenw  s    z"MathMLPresentationPrinter._l_parenc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrò   ú)rÑ   rK  r,   r,   r-   Ú_r_paren|  s    z"MathMLPresentationPrinter._r_parenc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrò   Ú{rÑ   rK  r,   r,   r-   Ú_l_brace  s    z"MathMLPresentationPrinter._l_bracec                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrò   Ú}rÑ   rK  r,   r,   r-   Ú_r_brace†  s    z"MathMLPresentationPrinter._r_bracec                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrò   ú,rÑ   rK  r,   r,   r-   Ú_comma‹  s    z MathMLPresentationPrinter._commac                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrò   ú|rÑ   rK  r,   r,   r-   Ú_bar  s    zMathMLPresentationPrinter._barc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nrò   ú;rÑ   rK  r,   r,   r-   Ú
_semicolon•  s    z$MathMLPresentationPrinter._semicolonc                 G  s`   | j  d¡}| |  ¡ ¡ t|ƒD ]*\}}|r<| |  ¡ ¡ | |  |¡¡ q"| |  ¡ ¡ |S ©Nrð   )r4   rž   rŸ   rL  r·   rT  r=   rN  ©r)   r²   rð   r¹   r³   r,   r,   r-   Ú_paren_comma_separatedš  s    z0MathMLPresentationPrinter._paren_comma_separatedc                 G  s`   | j  d¡}| |  ¡ ¡ t|ƒD ]*\}}|r<| |  ¡ ¡ | |  |¡¡ q"| |  ¡ ¡ |S rY  )r4   rž   rŸ   rL  r·   rV  r=   rN  rZ  r,   r,   r-   Ú_paren_bar_separated¤  s    z.MathMLPresentationPrinter._paren_bar_separatedFc                 C  sb   t |ƒ}||k s|sX||krX| j d¡}| |  ¡ ¡ | |  |¡¡ | |  ¡ ¡ |S |  |¡S rY  )r
   r4   rž   rŸ   rL  r=   rN  )r)   rñ   ÚlevelÚstrictZprec_valrð   r,   r,   r-   Úparenthesize®  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urŠˆ j d¡}ˆ jd rTtt| ƒƒdk rT| 	dd¡ ˆ  
|¡}ˆ  
|¡}| |¡ | |¡ | |¡ |S |  ¡ \}}	|tju 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¢   r4   rž   rC   r¤   rÃ   ÚsetAttributer=   rŸ   r£   r   r   r¥   r¦   r9   r•   r_  r   )r@   rð   r™   r¨   r©   ÚfracrÅ   Zxdenrª   r«   r§   Úyr¬   rô   r,   r-   Úmultiplyº  s>    










z6MathMLPresentationPrinter._print_Mul.<locals>.multiplyrð   rò   ú-)r4   rž   r   rŸ   r9   )r)   r@   rf  rð   r§   r,   rô   r-   r    ¸  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ò   rg  ú+)r4   rž   r¯   rŸ   r=   r   r9   )r)   r@   r   rð   r²   r³   r§   re  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Ì| | j  d¡¡ |	 | j  d¡¡ n$| | j  d	¡¡ |	 | j  d
¡¡ | j  d¡}
|
 |¡ |
 |¡ |
 |	¡ |
S )NZmtableZmtrZmtdr   r%   rò   r   ú]rJ  rM  rð   )	r4   rž   r¼   r½   r¾   rŸ   r=   rC   r9   )r)   r¿   Útabler¹   r§   rÀ   re  r   ÚleftÚrightrð   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   r`  r   rb  rÛ   rð   rò   rg  )	rÄ   r4   rž   rC   rc  rŸ   r=   rÂ   r9   )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Ä   rn  rC   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   )r4   rž   rŸ   r9   r=   r²   r•   )	r)   r‘   rð   ro  ró   r§   rÊ   ZarrowrË   r,   r,   r-   rÌ   0  s"    





z&MathMLPresentationPrinter._print_Limitc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   z&ImaginaryI;rÑ   rÒ   r,   r,   r-   rÏ   F  s    z.MathMLPresentationPrinter._print_ImaginaryUnitc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   r9  rÑ   rÒ   r,   r,   r-   rÓ   K  s    z,MathMLPresentationPrinter._print_GoldenRatioc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   z&ExponentialE;rÑ   rÒ   r,   r,   r-   rÔ   P  s    z%MathMLPresentationPrinter._print_Exp1c                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   z&pi;rÑ   rÒ   r,   r,   r-   rÖ   U  s    z#MathMLPresentationPrinter._print_Pic                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   ú&#x221E;rÑ   rÒ   r,   r,   r-   rØ   Z  s    z)MathMLPresentationPrinter._print_Infinityc                 C  sL   | j  d¡}| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ |S )Nrð   rò   rg  )r4   rž   rŸ   r9   rØ   )r)   r‘   rð   re  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_HBarh  s    z%MathMLPresentationPrinter._print_HBarc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   r:  rÑ   rÒ   r,   r,   r-   rÐ   m  s    z+MathMLPresentationPrinter._print_EulerGammac                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   ZTribonacciConstantrÑ   rÒ   r,   r,   r-   Ú_print_TribonacciConstantr  s    z3MathMLPresentationPrinter._print_TribonacciConstantc                 C  s8   | j  d¡}| |  |jd ¡¡ | | j  d¡¡ |S )Nr  r   ú&#x2020;©r4   rž   rŸ   r=   r²   r9   ©r)   r‘   r  r,   r,   r-   Ú_print_Daggerw  s    z'MathMLPresentationPrinter._print_Daggerc                 C  sd   | j  d¡}| |  |jd ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ |S )Nrð   r   rò   z&#x2208;r›   ru  )r)   r‘   rð   rò   r,   r,   r-   Ú_print_Contains}  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   ©r4   rž   rŸ   r9   r=   r²   rv  r,   r,   r-   Ú_print_ComplexSpace‹  s    z-MathMLPresentationPrinter._print_ComplexSpacec                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   z&#x2131;rÑ   rÒ   r,   r,   r-   Ú_print_FockSpace‘  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û   rp  r,   r,   r-   Ú	<genexpr>›  rÿ   z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>rò   r›   rÉ   r  r  r   T©r^  r5  r   )r4   rž   r¤   râ   ÚallrŸ   r9   r  r=   r_  rá   r   )	r)   r@   Z
intsymbolsrð   rò   rp  r  r  Údr,   r,   r-   ré   —  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¡}
|
 |¡ |
 |  |j	t
|ƒ¡¡ |
S )NZ
munderoverr   r›   rÉ   rò   rð   r6  )rç   râ   r4   rž   r=   rŸ   r9   r•   r_  rá   r
   )r)   r‘   râ   Zsubsuprã   rä   ZsummandÚlowÚvarÚequalrð   r,   r,   r-   rê   ½  s(    







z$MathMLPresentationPrinter._print_Sumr   c           	        s2  ‡ fdd„}dd„ ‰ˆ   |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 v rt  | ¡S | S d S r3   rö   rø   r,   r,   r-   r’   é  s    
z:MathMLPresentationPrinter._print_Symbol.<locals>.translatec                   s   g | ]}ˆ |ƒ‘qS r,   r,   rú   rý   r,   r-   rþ   ñ  rÿ   z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>c                   s   g | ]}ˆ |ƒ‘qS r,   r,   r   rý   r,   r-   rþ   ò  rÿ   ró   r   r  r  r  ÚboldÚmathvariant)rE   rD   r4   rž   rŸ   r9   r¤   rc  )	r)   r  Ústylerõ   rD   r  r  r  r§   r,   r	  r-   r
  Ö  s2    



z'MathMLPresentationPrinter._print_Symbolc                 C  s   | j || jd dS )Nr   )r†  )r
  rC   )r)   r  r,   r,   r-   r.    s    ÿz-MathMLPresentationPrinter._print_MatrixSymbolc                 C  s2   | j  d¡}| dd¡ | |  |jd ¡¡ |S )NZmencloseÚnotationÚtopr   )r4   rž   rc  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ò   )r4   rž   rŸ   r_  r   r9   )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  sz   | j  d¡}| dd¡ | |  |jd ¡¡ | |  |jd ¡¡ | j  d¡}| |  ¡ ¡ | |¡ | |  ¡ ¡ |S )Nr`  ZlinethicknessÚ0r   r›   rð   )r4   rž   rc  rŸ   r=   r²   rL  rN  )r)   r@   rd  Úbracr,   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®   r`  r  rt   r   )r  r  rQ   rÄ   rÂ   rC   r4   rž   rŸ   r=   r  Zis_negativer_  r   rn  )r)   r‘   r§   rd  rˆ  r,   r,   r-   r  1  s^    $ÿ

ÿ
ÿ

z$MathMLPresentationPrinter._print_Powc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r3   r  rÒ   r,   r,   r-   r  g  s    z'MathMLPresentationPrinter._print_Numberc                 C  s’   | j  d¡}| | j  d¡¡ | j  d¡}| | j  d¡¡ | j  d¡}| |¡ | |  |j¡¡ | |  ¡ ¡ | |  |j¡¡ | |¡ |S )Nrò   õ   âŸ¨õ   âŸ©rð   )r4   rž   rŸ   r9   r=   rP   rT  rO   )r)   r¹   rk  rl  r”  r,   r,   r-   Ú_print_AccumulationBoundsl  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ò   r`  )
r	   r@   r•   r4   rž   r  r  rŸ   r9   r=   )r)   r‘   r€  r¿   Zdimr  Únumr§   Úxxre  Zmnumrð   rd  r,   r,   r-   r  y  sF    










z+MathMLPresentationPrinter._print_Derivativec                 C  s|   | j  d¡}|  |¡dkr8| jd r8| | j  d¡¡ n| | j  |  |¡¡¡ | j  d¡}| |¡ | | j|jŽ ¡ |S )Nró   r„   r   rl   rð   )r4   rž   r•   rC   rŸ   r9   r[  r²   )r)   r‘   r§   rð   r,   r,   r-   r  ©  s    
z)MathMLPresentationPrinter._print_Functionc                 C  sh  t |jƒ}t|j|dd}| jd }| j d¡}d|v 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   rh  r›   r4  rò   r  Ú10z+infz-inf)r   r  r  r  rC   r4   rž   ÚsplitrŸ   r9   rØ   rß   )r)   r@   ZdpsZstr_realÚ	separatorrð   Zmantr  r4  rò   r  r,   r,   r-   r  ´  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   r›   )r4   rž   rŸ   r9   r=   r²   rL  rN  )r)   r@   rð   r¿   ró   r”  r,   r,   r-   Ú_print_polylogÛ  s    


z(MathMLPresentationPrinter._print_polylogc                 C  sP   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ | | j|jŽ ¡ |S ©Nrð   ró   )r4   rž   rŸ   r9   r•   r[  r²   )r)   r‘   rð   ró   r,   r,   r-   r  ë  s    
z&MathMLPresentationPrinter._print_Basicc                 C  s   | j |jŽ S r3   )r[  r²   rÎ   r,   r,   r-   Ú_print_Tupleó  s    z&MathMLPresentationPrinter._print_Tuplec                 C  sÆ   | j  d¡}|jr&| | j  d¡¡ n| | j  d¡¡ | j  d¡}|jr^| | j  d¡¡ n| | j  d¡¡ | j  d¡}| |¡ | |  |j¡¡ | |  ¡ ¡ | |  |j	¡¡ | |¡ |S )Nrò   rM  ri  rJ  r   rð   )
r4   rž   Z
right_openrŸ   r9   Z	left_openr=   ÚstartrT  Úend)r)   r¹   rl  rk  rð   r,   r,   r-   Ú_print_Intervalö  s    

z)MathMLPresentationPrinter._print_Intervalc                 C  sB   | j  d¡}| |  ¡ ¡ | |  |jd ¡¡ | |  ¡ ¡ |S )Nrð   r   )r4   rž   rŸ   rV  r=   r²   )r)   r@   r  rð   r,   r,   r-   Ú
_print_Abs	  s
    z$MathMLPresentationPrinter._print_Absc                 C  sz   | j  d¡}| |  ¡ ¡ | |  |¡¡ | |  ¡ ¡ | j  d¡}| | j  |¡¡ | j  d¡}| |¡ | |¡ |S rŸ  )r4   rž   rŸ   rL  r=   rN  r9   )r)   rº   r@   r”  ró   rð   r,   r,   r-   Ú_print_re_im  s    

z&MathMLPresentationPrinter._print_re_imc                 C  s   |   d|jd ¡S )Nu   â„œr   ©r¥  r²   ©r)   r@   r  r,   r,   r-   Ú	_print_re  s    z#MathMLPresentationPrinter._print_rec                 C  s   |   d|jd ¡S )Nu   â„‘r   r¦  r§  r,   r,   r-   Ú	_print_im!  s    z#MathMLPresentationPrinter._print_imc                 C  sZ   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ |jD ]}| |  |¡¡ q@|S rŸ  )r4   rž   rŸ   r9   r•   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ò   )r4   rž   rŸ   r_  r²   r9   )r)   r@   ÚsymbolÚprecrð   r³   r§   re  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_Union8  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_SymmetricDifferenceD  s    z4MathMLPresentationPrinter._print_SymmetricDifferencec                 C  s   t d }|  |d|¡S )NZ
ProductSetz&#x00d7;r®  r¯  r,   r,   r-   r*  H  s    z+MathMLPresentationPrinter._print_ProductSetc                 C  s   |   |j¡S r3   )Ú
_print_setr²   )r)   rù   r,   r,   r-   r'  L  s    z*MathMLPresentationPrinter._print_FiniteSetc                 C  sl   t |td}| j d¡}| |  ¡ ¡ t|ƒD ]*\}}|rH| |  ¡ ¡ | |  |¡¡ q.| |  	¡ ¡ |S )N©Úkeyrð   )
Úsortedr   r4   rž   rŸ   rP  r·   rT  r=   rR  )r)   rù   rï   r”  r¹   rñ   r,   r,   r-   r´  O  s    z$MathMLPresentationPrinter._print_setc                 C  s  | j  d¡}|d jrh|d jsh| j  d¡}| |  ¡ ¡ | |  |d ¡¡ | |  ¡ ¡ | |¡ n| |  |d ¡¡ |dd … D ]†}| j  d¡}| | j  |¡¡ |jrð|jsð| j  d¡}| |  ¡ ¡ | |  |¡¡ | |  ¡ ¡ n
|  |¡}| |¡ | |¡ qˆ|S rª  )	r4   rž   Ú
is_BooleanZis_NotrŸ   rL  r=   rN  r9   )r)   r²   r«  rð   r”  r³   r§   re  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 ]p\}}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>‚  rÿ   zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>rµ  r›   rò   rh  r®   rg  rD  )Zsympy.vectorrº  Zzeror=   rG  Zseparaterï   r4   rž   rç   Ú
componentsÚsortr·   rŸ   r9   rL  rN  )r)   r@   rº  rï   rð   ÚsystemZvectZ
inneritemsr¹   ÚkÚvrò   Zmbracr,   r,   r-   Ú_print_BasisDependentt  sH    








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_Or¤  s    z#MathMLPresentationPrinter._print_Orc                 C  s   t |jtd}|  |d¡S )Nrµ  z&#x22BB;rÃ  rÄ  r,   r,   r-   r2  ¨  s    z$MathMLPresentationPrinter._print_Xorc                 C  s   |   |jd¡S )Nz&#x21D2;)r¹  r²   r  r,   r,   r-   r0  ¬  s    z(MathMLPresentationPrinter._print_Impliesc                 C  s   t |jtd}|  |d¡S )Nrµ  z&#x21D4;rÃ  rÄ  r,   r,   r-   Ú_print_Equivalent¯  s    z+MathMLPresentationPrinter._print_Equivalentc                 C  sž   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ |jd jr€| j  d¡}| |  ¡ ¡ | |  |jd ¡¡ | |  ¡ ¡ n|  |jd ¡}| |¡ |S )Nrð   rò   z&#xAC;r   )	r4   rž   rŸ   r9   r²   r¸  rL  r=   rN  )r)   r‘   rð   rò   r§   r,   r,   r-   r1  ³  s    

z$MathMLPresentationPrinter._print_Notc                 C  s(   | j  d¡}| | j  |  |¡¡¡ |S ©Nró   ©r4   rž   rŸ   r9   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  sL  d}|j jr<|jjr<|jjr,|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|ƒ}| j	 
d¡}| |  ¡ ¡ t|ƒD ]^\}}|rô| |  ¡ ¡ ||kr(| j	 
d¡}| | j	 |¡¡ | |¡ qÚ| |  |¡¡ qÚ| |  ¡ ¡ |S )Nu   â€¦r®   r   r›   é   rð   ró   )r¡  Úis_infiniteÚstopÚstepZis_positiveÚiterÚnextr¤   Útupler4   rž   rŸ   rP  r·   rT  r9   r=   rR  )	r)   rù   ÚdotsZprintsetÚitr”  r¹   Úelró   r,   r,   r-   Ú_print_RangeÏ  s4    
z&MathMLPresentationPrinter._print_Rangec                 C  s`   t |jtd}| j d¡}| j d¡}| | j t|jƒ 	¡ ¡¡ | |¡ | | j
|Ž ¡ |S )Nrµ  rð   rò   )r·  r²   r   r4   rž   rŸ   r9   rÃ   Úfuncr   r[  )r)   r@   r²   rð   rò   r,   r,   r-   Ú_hprint_variadic_functionî  s    
z3MathMLPresentationPrinter._hprint_variadic_functionc                 C  s6   | j  d¡}| |  d ¡¡ | |  |jd ¡¡ |S )Nr  r   )r4   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ò   )r4   rž   rŸ   r=   r  r9   r•   r  )r)   r‘   rð   r§   r,   r,   r-   r   ÿ  s    
z+MathMLPresentationPrinter._print_Relationalc                 C  s,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r3   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ó   r…  r„  )r4   rž   Ú_idrc  rŸ   r9   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ó   r…  r„  rò   ú^)r4   rž   rÛ  rc  rŸ   r9   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ó   r…  r„  r“  rò   rà  ©r4   rž   rc  rŸ   r9   )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  ©r4   rž   Z_expr1Z_expr2rŸ   r_  r   r9   ©r)   r@   rð   Zvec1Zvec2rò   r,   r,   r-   Ú_print_Cross7  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   ©r4   rž   rŸ   r9   r_  Z_exprr   ©r)   r@   rð   rò   r,   r,   r-   Ú_print_CurlB  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_DivergenceM  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_DotX  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_Gradientc  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_Laplaciank  s    
z*MathMLPresentationPrinter._print_Laplacianc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nró   r…  Únormalz&#x2124;râ  rÒ   r,   r,   r-   Ú_print_Integerss  s    z)MathMLPresentationPrinter._print_Integersc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nró   r…  rï  z&#x2102;râ  rÒ   r,   r,   r-   Ú_print_Complexesy  s    z*MathMLPresentationPrinter._print_Complexesc                 C  s.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nró   r…  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ó   r…  rï  ú&#x2115;râ  rÒ   r,   r,   r-   Ú_print_Naturals…  s    z)MathMLPresentationPrinter._print_Naturalsc                 C  sV   | j  d¡}| j  d¡}| dd¡ | | j  d¡¡ | |¡ | |  tj¡¡ |S )Nr  ró   r…  rï  ró  )r4   rž   rc  rŸ   r9   r=   r   ZZero)r)   r‘   r  r§   r,   r,   r-   Ú_print_Naturals0‹  s    
z*MathMLPresentationPrinter._print_Naturals0c                 C  s´   |j d |j d  }|j d }| j d¡}| | j d¡¡ | j d¡}| | j d¡¡ | j d¡}| |¡ | |  |¡¡ | |¡ | j d¡}| |¡ | |  |¡¡ |S )	Nr   r›   rÉ   rò   r–  r—  rð   r  )r²   r4   rž   rŸ   r9   r=   )r)   r@   ÚshiftrN   rk  rl  r”  rü   r,   r,   r-   Ú_print_SingularityFunction”  s    



z4MathMLPresentationPrinter._print_SingularityFunctionc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   ÚNaNrÑ   rÒ   r,   r,   r-   rÙ   ¤  s    z$MathMLPresentationPrinter._print_NaNc                 C  s   | j  d¡}| j  d¡}| | j  |¡¡ | |¡ | |  |jd ¡¡ t|jƒdkr\|S | j  d¡}| |¡ | | j|jdd … Ž ¡ |S )Nr  ró   r   r›   rð   )r4   rž   rŸ   r9   r=   r²   r¤   r[  )r)   r‘   rD   r  ró   rð   r,   r,   r-   Ú_print_number_function©  s    

z0MathMLPresentationPrinter._print_number_functionc                 C  s   |   |d¡S )NÚB©rù  rÎ   r,   r,   r-   Ú_print_bernoulli¸  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ò   rq  ú~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||ƒsl| j d¡}| |  ¡ ¡ | |  |¡¡ | |  	¡ ¡ | |¡ n| |  |¡¡ | j d¡}| | j 
d¡¡ | |¡ |S )Nr   ©ry   r  rð   rò   rt  ©Úsympy.matricesry   r³   r4   rž   rG  rŸ   rL  r=   rN  r9   ©r)   r@   ry   Úmatrü   r”  rò   r,   r,   r-   Ú_print_Adjointã  s    

z(MathMLPresentationPrinter._print_Adjointc                 C  s¨   ddl m} |j}| j d¡}t||ƒsl| j d¡}| |  ¡ ¡ | |  |¡¡ | |  	¡ ¡ | |¡ n| |  |¡¡ | j d¡}| | j 
d¡¡ | |¡ |S )Nr   r
  r  rð   rò   r  r  r  r,   r,   r-   Ú_print_Transposeô  s    

z*MathMLPresentationPrinter._print_Transposec                 C  s   ddl m} |j}| j d¡}t||ƒsl| j d¡}| |  ¡ ¡ | |  |¡¡ | |  	¡ ¡ | |¡ n| |  |¡¡ | |  d¡¡ |S )Nr   r
  r  rð   r®   )
r  ry   r³   r4   rž   rG  rŸ   rL  r=   rN  )r)   r@   ry   r  rü   r”  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ò   rg  FrD  )Z!sympy.matrices.expressions.matmulr  r4   rž   r²   rG  r   r¦   rç   r   rŸ   r9   r_  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||ƒst| j d¡}| |  ¡ ¡ | |  	|¡¡ | |  
¡ ¡ | |¡ n| |  	|¡¡ | |  	|¡¡ |S )Nr   r
  r  rð   )r  ry   r  r  r4   rž   rG  rŸ   rL  r=   rN  )r)   r@   ry   r  r  rü   r”  r,   r,   r-   Ú_print_MatPow1  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;)r4   rž   r²   rŸ   r_  r
   r9   )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_ZeroMatrixM  s    z+MathMLPresentationPrinter._print_ZeroMatrixc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr4  z&#x1D7D9rÑ   r  r,   r,   r-   Ú_print_OneMatrixR  s    z*MathMLPresentationPrinter._print_OneMatrixc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   z	&#x1D540;rÑ   )r)   ÚIr§   r,   r,   r-   Ú_print_IdentityW  s    z)MathMLPresentationPrinter._print_Identityc                 C  sv   | j  d¡}| | j  d¡¡ | j  d¡}| | j  d¡¡ | j  d¡}| |¡ | |  |jd ¡¡ | |¡ |S )Nrò   u   âŒŠu   âŒ‹rð   r   rz  ©r)   r‘   rk  rl  rð   r,   r,   r-   Ú_print_floor\  s    

z&MathMLPresentationPrinter._print_floorc                 C  sv   | j  d¡}| | j  d¡¡ | j  d¡}| | j  d¡¡ | j  d¡}| |¡ | |  |jd ¡¡ | |¡ |S )Nrò   u   âŒˆu   âŒ‰rð   r   rz  r  r,   r,   r-   Ú_print_ceilingg  s    

z(MathMLPresentationPrinter._print_ceilingc                 C  s¤   | j  d¡}|jd }t|ƒdkr2|  |d ¡}n
|  |¡}| |  ¡ ¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  ¡ ¡ |S )Nrð   r   r›   rò   z&#x21A6;)	r4   rž   r²   r¤   r=   rŸ   rL  r9   rN  )r)   r‘   rð   Úsymbolsrò   r,   r,   r-   r,  r  s    



z'MathMLPresentationPrinter._print_Lambdac                 C  s
   | j |Ž S r3   )r[  rÎ   r,   r,   r-   Ú_print_tuple‚  s    z&MathMLPresentationPrinter._print_tuplec                 C  s   |   |j¡S r3   )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   )r4   rž   rŸ   r=   r  r¤   ÚindicesrÒ   r,   r,   r-   Ú_print_Indexedˆ  s    z(MathMLPresentationPrinter._print_Indexedc                 C  sx   | j  d¡}| | j|jtd dd¡ | j  d¡}t|jƒD ]*\}}|rX| |  ¡ ¡ | |  	|¡¡ q>| |¡ |S )Nr  ZAtomTr~  rð   )
r4   rž   rŸ   r_  Úparentr   r·   r#  rT  r=   )r)   r‘   r§   r”  r¹   r³   r,   r,   r-   Ú_print_MatrixElement‘  s    
z.MathMLPresentationPrinter._print_MatrixElementc                 C  sJ   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | | j|jŽ ¡ |S )Nrð   ró   z	&#x1d5a5;©r4   rž   rŸ   r9   r\  r²   ©r)   r‘   r§   ró   r,   r,   r-   Ú_print_elliptic_fœ  s    
z+MathMLPresentationPrinter._print_elliptic_fc                 C  sJ   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | | j|jŽ ¡ |S )Nrð   ró   z	&#x1d5a4;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–|j\}}| |  |¡¡ | |  ¡ ¡ | |  |¡¡ nX|j\}}}| |  |¡¡ | |  	¡ ¡ | |  |¡¡ | |  ¡ ¡ | |  |¡¡ | |  
¡ ¡ | |¡ |S )Nrð   ró   z	&#x1d6f1;rÉ   )r4   rž   rŸ   r9   rL  r¤   r²   r=   rV  rX  rN  )r)   r‘   r§   ró   re  r”   r¿   Úzr,   r,   r-   Ú_print_elliptic_pi¬  s(    


z,MathMLPresentationPrinter._print_elliptic_pic                 C  sJ   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |j¡¡ |S )Nrð   ró   ZEirz  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›   rz  ©r)   r‘   r§   re  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à   rz  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É   rz  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›   rz  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›   rz  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ò   r0  r   r›   rz  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ò   r0  r   r›   rÉ   rz  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›   rz  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É   rz  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›   rz  r.  r,   r,   r-   Ú_print_hermite2  s    

z(MathMLPresentationPrinter._print_hermite)F)N)N)r   )N)N)N)”r/   r0   r1   rF   r-  r•   rL  rN  rP  rR  rT  rV  rX  r[  r\  r_  r    r´   rÁ   rn  rÆ   rÌ   rÏ   rÓ   rÔ   rÖ   rØ   rß   rr  rÐ   rs  rw  rx  ry  r{  r|  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/  r1  r2  r3  r5  r6  r7  r8  r9  r;  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  rB   rH   )r@   Úprinterr:   r,   r,   r-   Úmathml>  s    r?  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>

    r=  N)r3  rH   r=   r   ZtoprettyxmlÚprint)r@   r>  r:   rù   ÚxmlZ
pretty_xmlr,   r,   r-   Úprint_mathmlI  s    
rB  N)r<  )r<  )$rF   Ú
__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   rH   r3  r?  rB  ZMathMLPrinterr,   r,   r,   r-   Ú<module>   sB   ?   R            '

$