a
    rÀ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,   úQ/var/www/html/assistant/venv/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 )NÚ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’   rJ  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Ò   rL  r,   r,   r-   Ú_r_paren|  s    z"MathMLPresentationPrinter._r_parenc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   Ú{rÒ   rL  r,   r,   r-   Ú_l_brace  s    z"MathMLPresentationPrinter._l_bracec                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   Ú}rÒ   rL  r,   r,   r-   Ú_r_brace†  s    z"MathMLPresentationPrinter._r_bracec                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   ú,rÒ   rL  r,   r,   r-   Ú_comma‹  s    z MathMLPresentationPrinter._commac                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   ú|rÒ   rL  r,   r,   r-   Ú_bar  s    zMathMLPresentationPrinter._barc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nró   ú;rÒ   rL  r,   r,   r-   Ú
_semicolon•  s    z$MathMLPresentationPrinter._semicolonc                 G  s`   | j  d¡}| |  ¡ ¡ t|ƒD ]*\}}|r<| |  ¡ ¡ | |  |¡¡ q"| |  ¡ ¡ |S ©Nrñ   )r4   rž   rŸ   rM  r·   rU  r=   rO  ©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 rZ  )r4   rž   rŸ   rM  r·   rW  r=   rO  r[  r,   r,   r-   Ú_paren_bar_separated¤  s    z.MathMLPresentationPrinter._paren_bar_separatedFc                 C  sb   t |ƒ}||k s|sX||krX| j d¡}| |  ¡ ¡ | |  |¡¡ | |  ¡ ¡ |S |  |¡S rZ  )r
   r4   rž   rŸ   rM  r=   rO  )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@   rg  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ó   rh  ú+)r4   rž   r¯   rŸ   r=   r   r9   )r)   r@   r   rñ   r²   r³   r§   rf  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   ú]rK  rN  rñ   )	r4   rž   r½   r¾   r¿   rŸ   r=   rC   r9   )r)   rÀ   Útabler¹   r§   rÁ   rf  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   ra  r   rc  rÜ   rñ   ró   rh  )	rÅ   r4   rž   rC   rd  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Å   ro  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ñ   rp  rô   r§   rË   Ú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ô   r:  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ó   rh  )r4   rž   rŸ   r9   rÙ   )r)   r‘   rñ   rf  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›   rw  )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²   rx  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ü   rq  r,   r,   r-   Ú	<genexpr>›  r   z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>ró   r›   rÊ   r  r	  r   T©r_  r6  r   )r4   rž   r¤   rã   ÚallrŸ   r9   r  r=   r`  râ   r   )	r)   r@   Z
intsymbolsrñ   ró   rq  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ñ   r7  )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¤   rd  )	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ž   rd  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 )Nra  ZlinethicknessÚ0r   r›   rñ   )r4   rž   rd  rŸ   r=   r²   rM  rO  )r)   r@   re  Ú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®   ra  r  rt   r   )r  r  rQ   rÅ   rÃ   rC   r4   rž   rŸ   r=   r  Zis_negativer`  r   ro  )r)   r‘   r§   re  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   rU  rO   )r)   r¹   rl  rm  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ó   ra  )
r	   r@   r•   r4   rž   r  r  rŸ   r9   r=   )r)   r‘   r‚  rÀ   Údimr  Únumr§   Úxxrf  Zmnumrñ   re  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   ri  r›   r5  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  r5  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²   rM  rO  )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ó   rN  rj  rK  r   rñ   )
r4   rž   Z
right_openrŸ   r9   Z	left_openr=   ÚstartrU  Úend)r)   r¹   rm  rl  rñ   r,   r,   r-   Ú_print_Intervalö  s    

z)MathMLPresentationPrinter._print_Intervalc                 C  sB   | j  d¡}| |  ¡ ¡ | |  |jd ¡¡ | |  ¡ ¡ |S )Nrñ   r   )r4   rž   rŸ   rW  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Ÿ   rM  r=   rO  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§   rf  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Ÿ   rQ  r·   rU  r=   rS  )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Ÿ   rM  r=   rO  r9   )r)   r²   r®  rñ   r–  r³   r§   rf  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ó   ri  r®   rh  rE  )Zsympy.vectorr½  Úzeror=   rH  Zseparaterð   r4   rž   rè   Ú
componentsÚsortr·   rŸ   r9   rM  rO  )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-   r3  ¨  s    z$MathMLPresentationPrinter._print_Xorc                 C  s   |   |jd¡S )Nz&#x21D2;)r¼  r²   r’  r,   r,   r-   r1  ¬  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»  rM  r=   rO  )r)   r‘   rñ   ró   r§   r,   r,   r-   r2  ³  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Ÿ   rQ  r·   rU  r9   r=   rS  )	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ž   Ú_idrd  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ß  rd  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ž   rd  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ó   rF  ©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;rF  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ž   rd  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   rl  rm  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ó   rs  ú~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ó   rv  ©Úsympy.matricesry   r³   r4   rž   rH  rŸ   rM  r=   rO  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ž   rH  rŸ   rM  r=   rO  )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ó   rh  FrE  )Z!sympy.matrices.expressions.matmulr  r4   rž   r²   rH  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ž   rH  rŸ   rM  r=   rO  )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 )Nr5  z&#x1D7D8rÒ   ©r)   ÚZr§   r,   r,   r-   Ú_print_ZeroMatrixM  s    z+MathMLPresentationPrinter._print_ZeroMatrixc                 C  s"   | j  d¡}| | j  d¡¡ |S )Nr5  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   r|  ©r)   r‘   rl  rm  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   r|  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Ÿ   rM  r9   rO  )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'  rU  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   rM  r¤   r²   r=   rW  rY  rO  )r)   r‘   r§   rô   rf  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Eir|  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›   r|  ©r)   r‘   r§   rf  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á   r|  r2  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Ê   r|  r2  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›   r|  r2  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›   r|  r2  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ó   r4  r   r›   r|  r2  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ó   r4  r   r›   rÊ   r|  r2  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›   r|  r2  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Ê   r|  r2  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›   r|  r2  r,   r,   r-   Ú_print_hermite2  s    

z(MathMLPresentationPrinter._print_hermite)F)N)N)r   )N)N)N)”r/   r0   r1   rF   r.  r•   rM  rO  rQ  rS  rU  rW  rY  r\  r]  r`  r    r´   rÂ   ro  rÇ   rÍ   rÐ   rÔ   rÕ   r×   rÙ   rà   rt  rÑ   ru  ry  rz  r{  r}  r~  rê   rë   r  r/  r0  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Ê  r3  r1  rË  r2  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.  r0  r1  r3  r5  r6  r7  r9  r:  r;  r<  r=  r?  r,   r,   r,   r-   r4  #  s   M


/		&660'	,			
	r4  Ú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)r4  rB   rH   )r@   Úprinterr:   r,   r,   r-   Úmathml>  s    rC  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>

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

$