o
    ôjZ+ ã                   @  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-8FÚabbreviatedÚ[ÚplainTú&#xB7;)ÚorderÚencodingÚfold_frac_powersÚfold_func_bracketsÚfold_short_fracÚinv_trig_styleÚln_notationÚlong_frac_ratioÚ	mat_delimÚmat_symbol_styleÚ
mul_symbolÚroot_notationÚ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 d S )Nz{}{}{})ÚdataÚwriteÚformat)ÚselfÚwriterÚindentÚ	addindentÚnewl© r3   úf/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/sympy/printing/mathml.pyÚwritexml7   s   ÿz4MathMLPrinterBase.__init__.<locals>.RawText.writexmlN)r*   r*   r*   )Ú__name__Ú
__module__Ú__qualname__r5   r3   r3   r3   r4   ÚRawText6   s    r9   c                   s   ˆ ƒ }| |_ ˆj|_|S ©N)r+   ÚdomÚownerDocument)r+   Úr©r9   r.   r3   r4   ÚcreateRawTextNode;   s   z5MathMLPrinterBase.__init__.<locals>.createRawTextNode)r   Ú__init__Zxml.dom.minidomr(   r)   r;   ÚcreateTextNode)r.   Úsettingsr(   r)   r?   r3   r>   r4   r@   ,   s   zMathMLPrinterBase.__init__c                 C  s,   t  | |¡}| ¡ }| dd¡}| ¡ }|S )z2
        Prints the expression as MathML.
        ÚasciiÚxmlcharrefreplace)r   Ú_printÚtoxmlÚencodeÚdecode)r.   ÚexprZmathMLZunistrZxmlbstrÚresr3   r3   r4   ÚdoprintC   s
   zMathMLPrinterBase.doprintc                 C  s   | j d r
|g g fS t|ƒS )Nr&   )Ú	_settingsr   )r.   Únamer3   r3   r4   Ú_split_super_subM   s   

z"MathMLPrinterBase._split_super_subr:   )	r6   r7   r8   Ú__doc__r'   Ú__annotations__r@   rK   rN   r3   r3   r3   r4   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                 C  s€  i 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“i 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/d0“d1d2“d3d4“¥i d5d6“d7d8“d9d:“d;d8“d<d=“d>d?“d@dA“dBdC“dDdE“dFdG“dHdI“dJdK“dLdM“dNdO“dPdQ“dRdS“dTdU“¥dVdWdXœ¥}|j jD ]}|j}||v r·||   S q¨|j j}| ¡ S )Yú)Returns the MathML tag for an expression.ÚAddÚplusr   ÚtimesÚ
DerivativeÚdiffÚNumberÚcnÚintÚPowÚpowerÚMaxÚmaxÚMinÚminÚAbsÚabsÚAndÚandÚOrÚorÚXorÚxorÚNotÚnotÚImpliesZimpliesÚSymbolÚciÚMatrixSymbolZRandomSymbolÚIntegralÚSumÚsumÚsinÚcosÚtanÚcotÚcscÚsecÚsinhÚcoshÚtanhÚcothÚcschÚsechÚasinÚarcsinÚasinhÚarcsinhÚacosÚarccosÚacoshÚarccoshÚatanÚarctanÚatanhÚarctanhÚatan2ÚacotÚarccotÚacothZarccothÚasecZarcsecÚasechZarcsechÚacscZarccscÚacschZarccschÚlogÚlnÚEqualityÚeqÚ
UnequalityZneqÚGreaterThanZgeqÚLessThanZleqÚStrictGreaterThanÚgtÚStrictLessThanÚltÚunionZ	intersect)ÚUnionÚIntersection©Ú	__class__Ú__mro__r6   Úlower)r.   ÚeÚ	translateÚclsÚnr3   r3   r4   Ú
mathml_tag[   sâ   ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ý$Ü%Û&Ú'Ù(Ø)×*Ö+Õ,Ô-Ó.Ò/Ñ0Ð1Ï2Î3Í4Ë8ÿzMathMLContentPrinter.mathml_tagc           	      C  s<  |  ¡ r| j d¡}| | j d¡¡ | |  | ¡¡ |S ddlm} ||ƒ\}}|tjurP| j d¡}| | j d¡¡ | |  	|¡¡ | |  	|¡¡ |S | 
¡ \}}|tju rht|ƒdkrh|  	|d ¡S | jdkrtt |¡ ¡ }| j d¡}| | j d¡¡ |dkr�| |  	|¡¡ |D ]
}| |  	|¡¡ q‘|S )	NÚapplyÚminusr   ©ÚfractionÚdivideé   ÚoldrU   )Úcould_extract_minus_signr;   ÚcreateElementÚappendChildÚ
_print_MulÚsympy.simplifyr¬   r   ÚOnerE   Úas_coeff_mulÚlenr   r   Ú
_from_argsÚas_ordered_factors)	r.   rI   Úxr¬   ÚnumerÚdenomÚcoeffÚtermsÚtermr3   r3   r4   r³   �   s2   

zMathMLContentPrinter._print_MulNc                 C  s
  | j ||d�}|  |d ¡}g }|dd … D ]I}| ¡ rG| j d¡}| | j d¡¡ | |¡ | |  | ¡¡ |}||d krF| |¡ q| |¡ |  |¡}||d kr_| |  |¡¡ qt|ƒdkrh|S | j d¡}| | j d¡¡ |rƒ| | d¡¡ |sy|S )N©r   r   r®   r©   rª   éÿÿÿÿrT   )	Ú_as_ordered_termsrE   r°   r;   r±   r²   Úappendr·   Úpop)r.   rI   r   ÚargsZlastProcessedZ	plusNodesÚargrº   r3   r3   r4   Ú
_print_AddÀ   s4   

€

€ÿzMathMLContentPrinter._print_Addc                 C  s®   |j d jdkrtdƒ‚| j d¡}t|j ƒD ]=\}\}}|t|j ƒd kr9|dkr9| 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.Ú	piecewiser®   Ú	otherwiseÚpiece)	rÅ   ÚcondÚ
ValueErrorr;   r±   Ú	enumerater·   r²   rE   )r.   rI   ÚrootÚir¤   ÚcrÊ   r3   r3   r4   Ú_print_PiecewiseÜ   s   z%MathMLContentPrinter._print_Piecewisec              	   C  s^   | j  d¡}t|jƒD ]!}| j  d¡}t|jƒD ]}| |  |||f ¡¡ q| |¡ q|S )NÚmatrixZ	matrixrow)r;   r±   ÚrangeÚrowsÚcolsr²   rE   )r.   Úmrº   rÏ   Zx_rÚjr3   r3   r4   Ú_print_MatrixBaseñ   s   z&MathMLContentPrinter._print_MatrixBasec                 C  s°   |j dkr| j d¡}| | j t|jƒ¡¡ |S | j d¡}| | j d¡¡ | j d¡}| | j t|jƒ¡¡ | j d¡}| | j t|j ƒ¡¡ | |¡ | |¡ |S )Nr®   rY   r©   r­   )Úqr;   r±   r²   rA   ÚstrÚp)r.   r¤   rº   ÚxnumZxdenomr3   r3   r4   Ú_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   )r;   r±   r²   r¨   rE   rÅ   )r.   r¤   rº   Úx_1Úx_2r3   r3   r4   Ú_print_Limit  s   

z!MathMLContentPrinter._print_Limitc                 C  ó   | j  d¡S )NZ
imaginaryi©r;   r±   ©r.   r¤   r3   r3   r4   Ú_print_ImaginaryUnit  ó   z)MathMLContentPrinter._print_ImaginaryUnitc                 C  rä   )NZ
eulergammarå   ræ   r3   r3   r4   Ú_print_EulerGamma  rè   z&MathMLContentPrinter._print_EulerGammac                 C  ó"   | j  d¡}| | j  d¡¡ |S )zwWe use unicode #x3c6 for Greek letter phi as defined here
        https://www.w3.org/2003/entities/2007doc/isogrk1.htmlrY   u   Ï†©r;   r±   r²   rA   ©r.   r¤   rº   r3   r3   r4   Ú_print_GoldenRatio   s   z'MathMLContentPrinter._print_GoldenRatioc                 C  rä   )NZexponentialerå   ræ   r3   r3   r4   Ú_print_Exp1'  rè   z MathMLContentPrinter._print_Exp1c                 C  rä   )NÚpirå   ræ   r3   r3   r4   Ú	_print_Pi*  rè   zMathMLContentPrinter._print_Pic                 C  rä   )NÚinfinityrå   ræ   r3   r3   r4   Ú_print_Infinity-  rè   z$MathMLContentPrinter._print_Infinityc                 C  rä   )NZ
notanumberrå   ræ   r3   r3   r4   Ú
_print_NaN0  rè   zMathMLContentPrinter._print_NaNc                 C  rä   )NZemptysetrå   ræ   r3   r3   r4   Ú_print_EmptySet3  rè   z$MathMLContentPrinter._print_EmptySetc                 C  rä   )NÚtruerå   ræ   r3   r3   r4   Ú_print_BooleanTrue6  rè   z'MathMLContentPrinter._print_BooleanTruec                 C  rä   )NÚfalserå   ræ   r3   r3   r4   Ú_print_BooleanFalse9  rè   z(MathMLContentPrinter._print_BooleanFalsec                 C  s4   | j  d¡}| | j  d¡¡ | | j  d¡¡ |S )Nr©   rª   rñ   )r;   r±   r²   rì   r3   r3   r4   Ú_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¡¡ |S | ˆ| dd … ƒ¡ |S )	Nr©   rÞ   r   é   rß   r®   Zuplimitrà   )r;   r±   r²   r¨   rE   r·   Úfunction)Úlimitsrº   Z	bvar_elemÚlow_elemÚup_elem©r¤   Ú
lime_recurr.   r3   r4   r   C  s*   



ÿz8MathMLContentPrinter._print_Integral.<locals>.lime_recur)Úlistrü   Úreverse)r.   r¤   rü   r3   rÿ   r4   Ú_print_IntegralB  s   
z$MathMLContentPrinter._print_Integralc                 C  s
   |   |¡S r:   )r  ræ   r3   r3   r4   Ú
_print_Sum_  s   
zMathMLContentPrinter._print_Sumc                   sH  ˆ j  ˆ  |¡¡}‡ fdd„}dd„ ‰ˆ  |j¡\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j  d¡}| ˆ j  |¡¡ |si|sP| ˆ j  |¡¡ |S ˆ j  d	¡}| |¡ | ||ƒ¡ | |¡ |S |s„ˆ j  d
¡}	|	 |¡ |	 ||ƒ¡ | |	¡ |S ˆ j  d¡}
|
 |¡ |
 ||ƒ¡ |
 ||ƒ¡ | |
¡ |S )Nc                   ó¬   t | ƒdkrCˆ j d¡}t| ƒD ]0\}}|dkr,ˆ j d¡}| ˆ j d¡¡ | |¡ ˆ j d¡}| ˆ j |¡¡ | |¡ q|S ˆ j d¡}| ˆ j | d ¡¡ |S )Nr®   zmml:mrowr   zmml:moú úmml:mi©r·   r;   r±   rÍ   r²   rA   ©ÚitemsÚmrowrÏ   ÚitemÚmoÚmi©r.   r3   r4   Újoing  ó   
z0MathMLContentPrinter._print_Symbol.<locals>.joinc                 S  ó   | t v r	t  | ¡S | S r:   ©r   Úget©Úsr3   r3   r4   r¥   y  ó   
z5MathMLContentPrinter._print_Symbol.<locals>.translatec                   ó   g | ]}ˆ |ƒ‘qS r3   r3   ©Ú.0Úsup©r¥   r3   r4   Ú
<listcomp>�  ó    z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>c                   r  r3   r3   ©r  Úsubr  r3   r4   r  ‚  r  r  zmml:msubzmml:msupzmml:msubsup)r;   r±   r¨   rN   rM   r²   rA   )r.   Úsymrm   r  rM   ÚsupersÚsubsÚmnameÚmsubÚmsupÚmsubsupr3   ©r.   r¥   r4   Ú_print_Symbold  s<   ð

õ

û

z"MathMLContentPrinter._print_Symbolc                 C  sô   | j d rR|jjrR|jjdkrR| j d¡}| | j d¡¡ |jjdkrG| j d¡}| j d¡}| | j t	|jjƒ¡¡ | |¡ | |¡ | |  
|j¡¡ |S | j d¡}| j |  |¡¡}| |¡ | |  
|j¡¡ | |  
|j¡¡ |S )Nr#   r®   r©   rÎ   rà   ÚdegreerY   )rL   ÚexpÚis_RationalrÛ   r;   r±   r²   rÙ   rA   rÚ   rE   Úbaser¨   )r.   r¤   rº   ZxmldegZxmlcnrá   r3   r3   r4   Ú
_print_PowŸ  s$   


zMathMLContentPrinter._print_Powc                 C  ó,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r:   ©r;   r±   r¨   r²   rA   rÚ   rì   r3   r3   r4   Ú_print_Number¶  ó   z"MathMLContentPrinter._print_Numberc                 C  s:   | j  |  |¡¡}t|jt|jƒƒ}| | j  |¡¡ |S r:   )	r;   r±   r¨   Úmlib_to_strÚ_mpf_r   Ú_precr²   rA   )r.   r¤   rº   Zrepr_er3   r3   r4   Ú_print_Float»  s   z!MathMLContentPrinter._print_Floatc                 C  s¸   | j  d¡}|  |¡}t|jƒrd}| | j  |¡¡ | j  d¡}t|jƒD ]%\}}| |  |¡¡ |dkrK| j  d¡}| |  t	|ƒ¡¡ | |¡ q&| |¡ | |  |j¡¡ |S )Nr©   ZpartialdiffrÞ   r®   r*  )
r;   r±   r¨   r	   rI   r²   ÚreversedÚvariable_countrE   r   )r.   r¤   rº   Údiff_symbolrá   r!  rU   r*  r3   r3   r4   Ú_print_DerivativeÁ  s    


€
z&MathMLContentPrinter._print_Derivativec                 C  sD   | j  d¡}| | j  |  |¡¡¡ |jD ]
}| |  |¡¡ q|S ©Nr©   )r;   r±   r²   r¨   rÅ   rE   ©r.   r¤   rº   rÆ   r3   r3   r4   Ú_print_FunctionÔ  s
   
z$MathMLContentPrinter._print_Functionc                 C  s2   | j  |  |¡¡}|jD ]
}| |  |¡¡ q|S r:   )r;   r±   r¨   rÅ   r²   rE   r<  r3   r3   r4   Ú_print_BasicÛ  s   
z!MathMLContentPrinter._print_Basicc                 C  sH   | j  d¡}| j  |  |¡¡}| |¡ |jD ]
}| |  |¡¡ q|S r;  )r;   r±   r¨   r²   rÅ   rE   )r.   r¤   rº   rá   rÆ   r3   r3   r4   Ú_print_AssocOpá  s   

z#MathMLContentPrinter._print_AssocOpc                 C  sL   | j  d¡}| | j  |  |¡¡¡ | |  |j¡¡ | |  |j¡¡ |S r;  )r;   r±   r²   r¨   rE   ÚlhsÚrhsrì   r3   r3   r4   Ú_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  )r;   r±   r²   rE   )r.   ÚseqÚdom_elementr  r3   r3   r4   Ú_print_listð  s   z MathMLContentPrinter._print_listc                 C  r/  r:   r0  ©r.   rÛ   rD  r3   r3   r4   Ú
_print_intø  r2  zMathMLContentPrinter._print_intc                 C  s,   | j  d¡}|jD ]
}| |  |¡¡ q	|S )NÚset)r;   r±   rÅ   r²   rE   r<  r3   r3   r4   Ú_print_FiniteSet  s   
z%MathMLContentPrinter._print_FiniteSetc                 C  ó>   | j  d¡}| | j  d¡¡ |jD ]
}| |  |¡¡ q|S )Nr©   Zsetdiff©r;   r±   r²   rÅ   rE   r<  r3   r3   r4   Ú_print_Complement  ó
   
z&MathMLContentPrinter._print_Complementc                 C  rJ  )Nr©   ZcartesianproductrK  r<  r3   r3   r4   Ú_print_ProductSet  rM  z&MathMLContentPrinter._print_ProductSetc                 C  sZ   | j  |  |¡¡}|jD ]}| j  d¡}| |  |¡¡ | |¡ q| |  |j¡¡ |S )NrÞ   )r;   r±   r¨   Ú	signaturer²   rE   rI   )r.   r¤   rº   rÆ   rá   r3   r3   r4   Ú_print_Lambda  s   
z"MathMLContentPrinter._print_Lambdar:   )-r6   r7   r8   rO   Ú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.  r1  r6  r:  r=  r>  r?  rB  rE  rG  Ú_print_ImpliesÚ
_print_NotÚ
_print_XorrI  rL  rN  rP  r3   r3   r3   r4   rQ   T   sV    B
#	8rQ   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�„ ZLd�d‘„ 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ï„ 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“dS (  ÚMathMLPresentationPrinterz‚Prints an expression to the Presentation MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter3.html
    Z_mathml_presentationc                   sL  i 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“i dd“d d“d!d"“d#d$“d%d&“d'd(“d)d*“d+d,“d-d.“d/d0“d1d2“d3d4“d5d6“d7d8“d9d8“d:d;“d<d=“¥d>d?d@dAdBdCdDdEdFd@dAdGdHdIdJœ¥}‡ fdKdL„}|j jD ]}|j}||v r”||   S q…|j jdMkrž|ƒ S |j j}| ¡ S )NrR   rX   ÚmnÚLimitz&#x2192;rV   ú&dd;rZ   rl   r  ro   z&int;rp   z&#x2211;rr   rs   rt   ru   r~   r   r€   r�   r‚   rƒ   r„   r…   r†   r‡   rˆ   r‰   r‹   rŒ   rŠ   r”   ú=r–   z&#x2260;r—   z&#x2265;r˜   z&#x2264;r™   ú>r›   ú<Úlerchphiú&#x3A6;Úzetaz&#x3B6;Údirichlet_etaz&#x3B7;Ú
elliptic_kz&#x39A;Ú
lowergammaú&#x3B3;Ú
uppergammaz&#x393;ÚgammaÚtotientz&#x3D5;Úreduced_totientz&#x3BB;z&#x3BD;z&#x3A9;r   ÚCÚWz&#x398;ÚTrueÚFalseÚNonez	S&#x2032;z	C&#x2032;Úlambda)ÚprimenuÚ
primeomegaÚfresnelsÚfresnelcÚLambertWÚ	HeavisideÚBooleanTrueÚBooleanFalseÚNoneTypeÚmathieusÚmathieucÚmathieusprimeÚmathieucprimeÚLambdac                     st   ˆ j d d u sˆ j d dkrdS ˆ j d dkrdS ˆ j d dkr"dS ˆ j d dkr+d	S tˆ j d tƒs5t‚ˆ j d S )
Nr"   rm  ú&InvisibleTimes;rU   ú&#xD7;Údotr   Úldotz&#x2024;)rL   Ú
isinstancerÚ   Ú	TypeErrorr3   r  r3   r4   Úmul_symbol_selection_  s   
zBMathMLPresentationPrinter.mathml_tag.<locals>.mul_symbol_selectionr   r    )r.   r¤   r¥   rƒ  r¦   r§   r3   r  r4   r¨   *  s¼   ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ð3ÿz$MathMLPresentationPrinter.mathml_tagc                 C  ó"   | j  d¡}| | j  d¡¡ |S )Nr  ú(rë   ©r.   r  r3   r3   r4   Ú_l_parenw  ó   z"MathMLPresentationPrinter._l_parenc                 C  r„  )Nr  ú)rë   r†  r3   r3   r4   Ú_r_paren|  rˆ  z"MathMLPresentationPrinter._r_parenc                 C  r„  )Nr  Ú{rë   r†  r3   r3   r4   Ú_l_brace�  rˆ  z"MathMLPresentationPrinter._l_bracec                 C  r„  )Nr  Ú}rë   r†  r3   r3   r4   Ú_r_brace†  rˆ  z"MathMLPresentationPrinter._r_bracec                 C  r„  )Nr  ú,rë   r†  r3   r3   r4   Ú_comma‹  rˆ  z MathMLPresentationPrinter._commac                 C  r„  )Nr  ú|rë   r†  r3   r3   r4   Ú_bar�  rˆ  zMathMLPresentationPrinter._barc                 C  r„  )Nr  ú;rë   r†  r3   r3   r4   Ú
_semicolon•  rˆ  z$MathMLPresentationPrinter._semicolonc                 G  ó`   | j  d¡}| |  ¡ ¡ t|ƒD ]\}}|r| |  ¡ ¡ | |  |¡¡ q| |  ¡ ¡ |S ©Nr  )r;   r±   r²   r‡  rÍ   r�  rE   rŠ  ©r.   rÅ   r  rÏ   rÆ   r3   r3   r4   Ú_paren_comma_separatedš  ó   z0MathMLPresentationPrinter._paren_comma_separatedc                 G  r•  r–  )r;   r±   r²   r‡  rÍ   r’  rE   rŠ  r—  r3   r3   r4   Ú_paren_bar_separated¤  r™  z.MathMLPresentationPrinter._paren_bar_separatedFc                 C  sb   t |ƒ}||k s|s,||kr,| j d¡}| |  ¡ ¡ | |  |¡¡ | |  ¡ ¡ |S |  |¡S r–  )r
   r;   r±   r²   r‡  rE   rŠ  )r.   r  ÚlevelÚstrictÚprec_valr  r3   r3   r4   Úparenthesize®  s   
z&MathMLPresentationPrinter.parenthesizec                   sf   ‡ fdd„}ˆ j  d¡}| ¡ r,ˆ j  d¡}| ˆ j  d¡¡ | |¡ || |ƒ}|S |||ƒ}|S )Nc                   s„  ddl m} || ƒ\}}|tjurEˆ j d¡}ˆ jd r*tt| ƒƒdk r*| 	dd¡ ˆ  
|¡}ˆ  
|¡}| |¡ | |¡ | |¡ |S |  ¡ \}}	|tju rbt|	ƒdkrb| ˆ  
|	d ¡¡ |S ˆ jd	krnt |	¡ ¡ }	|dkr“ˆ  
|¡}
ˆ j d
¡}| ˆ j ˆ  | ¡¡¡ | |
¡ | |¡ |	D ]*}| ˆ  |td ¡¡ ||	d ks¿ˆ j d
¡}| ˆ j ˆ  | ¡¡¡ | |¡ q•|S )Nr   r«   Úmfracr   é   Úbevelledrõ   r®   r¯   r  r   rÁ   )r´   r¬   r   rµ   r;   r±   rL   r·   rÚ   ÚsetAttributerE   r²   r¶   r   r   r¸   r¹   rA   r¨   rž  r   )rI   r  r¬   r»   r¼   ÚfracrÜ   Zxdenr½   r¾   rº   Úyr¿   r  r3   r4   Úmultiplyº  s@   










€z6MathMLPresentationPrinter._print_Mul.<locals>.multiplyr  r  ú-)r;   r±   r°   r²   rA   )r.   rI   r¥  r  rº   r3   r  r4   r³   ¸  s   "

þz$MathMLPresentationPrinter._print_MulNc                 C  s´   | j  d¡}| j||d�}| |  |d ¡¡ |dd … D ]:}| ¡ r9| j  d¡}| | j  d¡¡ |  | ¡}n| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ q|S )Nr  rÀ   r   r®   r  r¦  ú+)r;   r±   rÂ   r²   rE   r°   rA   )r.   rI   r   r  rÅ   rÆ   rº   r¤  r3   r3   r4   rÇ   ç  s   

z$MathMLPresentationPrinter._print_Addc              	   C  s  | j  d¡}t|jƒD ],}| j  d¡}t|jƒD ]}| j  d¡}| |  |||f ¡¡ | |¡ q| |¡ q| jd }|dkrC|S | j  d¡}| j  d¡}	|dkrf| | j  d¡¡ |	 | j  d¡¡ n| | j  d	¡¡ |	 | j  d
¡¡ | j  d¡}
|
 |¡ |
 |¡ |
 |	¡ |
S )NZmtableZmtrZmtdr    r*   r  r   Ú]r…  r‰  r  )	r;   r±   rÓ   rÔ   rÕ   r²   rE   rL   rA   )r.   rÖ   ÚtablerÏ   rº   r×   r¤  r    ÚleftÚrightr  r3   r3   r4   rØ   û  s.   



z+MathMLPresentationPrinter._print_MatrixBasec                 C  s²   |j dk r
|j  }n|j }| j d¡}|s| jd r | dd¡ | |  |¡¡ | |  |j¡¡ |j dk rW| j d¡}| j d¡}| | j d¡¡ | |¡ | |¡ |S |S )	Nr   rŸ  r   r¡  rõ   r  r  r¦  )	rÛ   r;   r±   rL   r¢  r²   rE   rÙ   rA   )r.   r¤   ÚfoldedrÛ   rº   r  r  r3   r3   r4   Ú_get_printed_Rational  s    




z/MathMLPresentationPrinter._get_printed_Rationalc                 C  s(   |j dkr|  |j¡S |  || jd ¡S )Nr®   r   )rÙ   rE   rÛ   r­  rL   ræ   r3   r3   r4   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   )r;   r±   r²   rA   rE   rÅ   r¨   )	r.   r¤   r  r®  r  rº   rá   Úarrowrâ   r3   r3   r4   rã   0  s"   





z&MathMLPresentationPrinter._print_Limitc                 C  rê   )Nr  z&ImaginaryI;rë   rì   r3   r3   r4   rç   F  rˆ  z.MathMLPresentationPrinter._print_ImaginaryUnitc                 C  rê   )Nr  r_  rë   rì   r3   r3   r4   rí   K  rˆ  z,MathMLPresentationPrinter._print_GoldenRatioc                 C  rê   )Nr  z&ExponentialE;rë   rì   r3   r3   r4   rî   P  rˆ  z%MathMLPresentationPrinter._print_Exp1c                 C  rê   )Nr  z&pi;rë   rì   r3   r3   r4   rð   U  rˆ  z#MathMLPresentationPrinter._print_Pic                 C  rê   )Nr  ú&#x221E;rë   rì   r3   r3   r4   rò   Z  rˆ  z)MathMLPresentationPrinter._print_Infinityc                 C  sL   | j  d¡}| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ |S )Nr  r  r¦  )r;   r±   r²   rA   rò   )r.   r¤   r  r¤  rº   r3   r3   r4   rù   _  s   


z1MathMLPresentationPrinter._print_NegativeInfinityc                 C  rê   )Nr  z&#x210F;rë   rì   r3   r3   r4   Ú_print_HBarh  rˆ  z%MathMLPresentationPrinter._print_HBarc                 C  rê   )Nr  rd  rë   rì   r3   r3   r4   ré   m  rˆ  z+MathMLPresentationPrinter._print_EulerGammac                 C  rê   )Nr  ÚTribonacciConstantrë   rì   r3   r3   r4   Ú_print_TribonacciConstantr  rˆ  z3MathMLPresentationPrinter._print_TribonacciConstantc                 C  s8   | j  d¡}| |  |jd ¡¡ | | j  d¡¡ |S )Nr&  r   ú&#x2020;©r;   r±   r²   rE   rÅ   rA   ©r.   r¤   r&  r3   r3   r4   Ú_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®   r¶  )r.   r¤   r  r  r3   r3   r4   Ú_print_Contains}  s   
z)MathMLPresentationPrinter._print_Containsc                 C  rê   )Nr  z&#x210B;rë   rì   r3   r3   r4   Ú_print_HilbertSpace†  rˆ  z-MathMLPresentationPrinter._print_HilbertSpacec                 C  s8   | j  d¡}| | j  d¡¡ | |  |jd ¡¡ |S )Nr&  z	&#x1D49E;r   ©r;   r±   r²   rA   rE   rÅ   r·  r3   r3   r4   Ú_print_ComplexSpace‹  s   z-MathMLPresentationPrinter._print_ComplexSpacec                 C  rê   )Nr  z&#x2131;rë   rì   r3   r3   r4   Ú_print_FockSpace‘  rˆ  z*MathMLPresentationPrinter._print_FockSpacec           	      C  s¶  ddddœ}| j  d¡}t|jƒdkr7tdd„ |jD ƒƒr7| j  d	¡}| | j  |t|jƒ ¡¡ | |¡ nnt|jƒD ]h}| j  d	¡}| | j  |d
 ¡¡ t|ƒd
krZ| |¡ t|ƒdkrz| j  d¡}| |¡ | |  |d
 ¡¡ | |¡ t|ƒdkr¤| j  d¡}| |¡ | |  |d
 ¡¡ | |  |d ¡¡ | |¡ q<| | j	|j
td dd�¡ t|jƒD ] }| j  d	¡}| | j  d¡¡ | |¡ | |  |d ¡¡ q¸|S )Nz&#x222B;z&#x222C;z&#x222D;)r®   rà   rú   r  rú   c                 s  s   � | ]	}t |ƒd kV  qdS )r®   N)r·   )r  r¯  r3   r3   r4   Ú	<genexpr>›  s   € z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>r  r®   rà   r&  r'  r   T©rœ  rZ  r   )r;   r±   r·   rü   Úallr²   rA   r7  rE   rž  rû   r   )	r.   rI   Z
intsymbolsr  r  r¯  r&  r'  Údr3   r3   r4   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  r[  )r  rü   r;   r±   rE   r²   rA   r¨   rž  rû   r
   )r.   r¤   rü   Zsubsuprý   rþ   ÚsummandÚlowÚvarÚequalr  r3   r3   r4   r  ½  s(   







z$MathMLPresentationPrinter._print_Sumr   c           	        s0  ‡ fdd„}dd„ ‰ˆ   |j¡\}}}ˆ|ƒ}‡fdd„|D ƒ}‡fdd„|D ƒ}ˆ j d¡}| ˆ j |¡¡ t|ƒd	krZt|ƒd	krG|}nEˆ j d
¡}| |¡ | ||ƒ¡ n2t|ƒd	krsˆ j d¡}| |¡ | ||ƒ¡ nˆ j d¡}| |¡ | ||ƒ¡ | ||ƒ¡ |dkr–| dd¡ |S )Nc                   r  )Nr®   r  r   r  r  r  r  r	  r  r3   r4   r  ×  r  z5MathMLPresentationPrinter._print_Symbol.<locals>.joinc                 S  r  r:   r  r  r3   r3   r4   r¥   é  r  z:MathMLPresentationPrinter._print_Symbol.<locals>.translatec                   r  r3   r3   r  r  r3   r4   r  ñ  r  z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>c                   r  r3   r3   r  r  r3   r4   r  ò  r  r  r   r%  r&  r'  ÚboldÚmathvariant)rN   rM   r;   r±   r²   rA   r·   r¢  )	r.   r!  Ústyler  rM   r"  r#  r$  rº   r3   r(  r4   r)  Ö  s2   


z'MathMLPresentationPrinter._print_Symbolc                 C  s   | j || jd d�S )Nr!   )rÈ  )r)  rL   )r.   r!  r3   r3   r4   rR    s   ÿz-MathMLPresentationPrinter._print_MatrixSymbolc                 C  s2   | j  d¡}| dd¡ | |  |jd ¡¡ |S )NZmencloseÚnotationÚtopr   )r;   r±   r¢  r²   rE   rÅ   )r.   rI   Úencr3   r3   r4   Ú_print_conjugate  s   z*MathMLPresentationPrinter._print_conjugatec                 C  sN   | j  d¡}| |  |td ¡¡ | j  d¡}| | j  |¡¡ | |¡ |S )Nr  ÚFuncr  )r;   r±   r²   rž  r   rA   )r.   ÚoprI   Úrowr  r3   r3   r4   Ú_print_operator_after  s   
z/MathMLPresentationPrinter._print_operator_afterc                 C  ó   |   d|jd ¡S )Nú!r   ©rÐ  rÅ   ©r.   rI   r3   r3   r4   Ú_print_factorial   ó   z*MathMLPresentationPrinter._print_factorialc                 C  rÑ  )Nz!!r   rÓ  rÔ  r3   r3   r4   Ú_print_factorial2#  rÖ  z+MathMLPresentationPrinter._print_factorial2c                 C  sz   | j  d¡}| dd¡ | |  |jd ¡¡ | |  |jd ¡¡ | j  d¡}| |  ¡ ¡ | |¡ | |  ¡ ¡ |S )NrŸ  ZlinethicknessÚ0r   r®   r  )r;   r±   r¢  r²   rE   rÅ   r‡  rŠ  )r.   rI   r£  Úbracr3   r3   r4   Ú_print_binomial&  s   
z)MathMLPresentationPrinter._print_binomialc                 C  s^  |j jrht|j jƒdkrh|j jdkrh| jd rh|j jdkr,| j d¡}| |  	|j
¡¡ |j jdkrK| j d¡}| |  	|j
¡¡ | |  	|j j¡¡ |j jdkrf| 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
¡¡ |S | j d¡}| |  |j
td	 ¡¡ | |  	|j  ¡¡ | |¡ |S | j d¡}| |  |j
td	 ¡¡ | |  	|j ¡¡ |S )Nr®   r#   rà   ZmsqrtZmrootrÁ   rŸ  r&  r[   r   )r+  r,  rb   rÛ   rÙ   rL   r;   r±   r²   rE   r-  Úis_negativerž  r   r­  )r.   r¤   rº   r£  rÊ  r3   r3   r4   r.  1  s`   $ÿ
ÿ
ÿ

ü
z$MathMLPresentationPrinter._print_Powc                 C  r/  r:   r0  rì   r3   r3   r4   r1  g  r2  z'MathMLPresentationPrinter._print_Numberc                 C  s’   | j  d¡}| | j  d¡¡ | j  d¡}| | j  d¡¡ | j  d¡}| |¡ | |  |j¡¡ | |  ¡ ¡ | |  |j¡¡ | |¡ |S )Nr  õ   âŸ¨õ   âŸ©r  )r;   r±   r²   rA   rE   r`   r�  r^   )r.   rÏ   rª  r«  rÙ  r3   r3   r4   Ú_print_AccumulationBoundsl  s   

z3MathMLPresentationPrinter._print_AccumulationBoundsc                 C  sž  t |jƒrd}n|  |¡}| j d¡}d}t|jƒD ]M\}}||7 }|dkrI| j d¡}| j d¡}| | j |¡¡ | |¡ | |  	|¡¡ n| j d¡}| | j |¡¡ | |¡ |  	|¡}	| |	¡ q| 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	   rI   r¨   r;   r±   r7  r8  r²   rA   rE   )r.   r¤   rÁ  rÖ   Údimr!  Únumrº   Úxxr¤  Zmnumr  r£  r3   r3   r4   r:  y  sF   









z+MathMLPresentationPrinter._print_Derivativec                 C  s|   | j  d¡}|  |¡dkr| jd r| | j  d¡¡ n| | j  |  |¡¡¡ | j  d¡}| |¡ | | j|jŽ ¡ |S )Nr  r’   r   r“   r  )r;   r±   r¨   rL   r²   rA   r˜  rÅ   )r.   r¤   rº   r  r3   r3   r4   r=  ©  s   
z)MathMLPresentationPrinter._print_Functionc                 C  s^  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rž|  d ¡S | j d	¡}| | j 	|¡¡ |S )NT)Ústrip_zerosr%   r  r¤   r   r§  r®   rX  r  r&  Ú10z+infz-inf)r   r5  r3  r4  rL   r;   r±   Úsplitr²   rA   rò   rù   )r.   rI   ÚdpsÚstr_realÚ	separatorr  Úmantr+  rX  r  r&  r3   r3   r4   r6  ´  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  ÚLir   r®   )r;   r±   r²   rA   rE   rÅ   r‡  rŠ  )r.   rI   r  rÖ   r  rÙ  r3   r3   r4   Ú_print_polylogÛ  s   


z(MathMLPresentationPrinter._print_polylogc                 C  sP   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ | | j|jŽ ¡ |S ©Nr  r  )r;   r±   r²   rA   r¨   r˜  rÅ   )r.   r¤   r  r  r3   r3   r4   r>  ë  s   
z&MathMLPresentationPrinter._print_Basicc                 C  s   | j |jŽ S r:   )r˜  rÅ   ræ   r3   r3   r4   Ú_print_Tupleó  rè   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  r‰  r¨  r…  r   r  )
r;   r±   Ú
right_openr²   rA   Ú	left_openrE   Ústartr�  Úend)r.   rÏ   r«  rª  r  r3   r3   r4   Ú_print_Intervalö  s   

z)MathMLPresentationPrinter._print_Intervalc                 C  sB   | j  d¡}| |  ¡ ¡ | |  |jd ¡¡ | |  ¡ ¡ |S )Nr  r   )r;   r±   r²   r’  rE   rÅ   )r.   rI   r+  r  r3   r3   r4   Ú
_print_Abs	  s
   z$MathMLPresentationPrinter._print_Absc                 C  sz   | j  d¡}| |  ¡ ¡ | |  |¡¡ | |  ¡ ¡ | j  d¡}| | j  |¡¡ | j  d¡}| |¡ | |¡ |S rë  )r;   r±   r²   r‡  rE   rŠ  rA   )r.   rÐ   rI   rÙ  r  r  r3   r3   r4   Ú_print_re_im  s   

z&MathMLPresentationPrinter._print_re_imc                 C  rÑ  )Nu   â„œr   ©ró  rÅ   ©r.   rI   r+  r3   r3   r4   Ú	_print_re  rÖ  z#MathMLPresentationPrinter._print_rec                 C  rÑ  )Nu   â„‘r   rô  rõ  r3   r3   r4   Ú	_print_im!  rÖ  z#MathMLPresentationPrinter._print_imc                 C  sZ   | j  d¡}| j  d¡}| | j  |  |¡¡¡ | |¡ |jD ]
}| |  |¡¡ q |S rë  )r;   r±   r²   rA   r¨   rÅ   rE   )r.   r¤   r  r  rÆ   r3   r3   r4   r?  $  s   

z(MathMLPresentationPrinter._print_AssocOpc                 C  sz   | j  d¡}| |  |jd |¡¡ |jdd … D ]!}| j  d¡}| | j  |¡¡ |  ||¡}| |¡ | |¡ q|S ©Nr  r   r®   r  )r;   r±   r²   rž  rÅ   rA   )r.   rI   ÚsymbolÚprecr  rÆ   rº   r¤  r3   r3   r4   Ú_print_SetOp-  s   
z&MathMLPresentationPrinter._print_SetOpc                 C  ó   t d }|  |d|¡S )Nrž   z&#x222A;©r   rû  ©r.   rI   rú  r3   r3   r4   Ú_print_Union8  ó   z&MathMLPresentationPrinter._print_Unionc                 C  rü  )NrŸ   z&#x2229;rý  rþ  r3   r3   r4   Ú_print_Intersection<  r   z-MathMLPresentationPrinter._print_Intersectionc                 C  rü  )NÚ
Complementz&#x2216;rý  rþ  r3   r3   r4   rL  @  r   z+MathMLPresentationPrinter._print_Complementc                 C  rü  )NÚSymmetricDifferenceú&#x2206;rý  rþ  r3   r3   r4   Ú_print_SymmetricDifferenceD  r   z4MathMLPresentationPrinter._print_SymmetricDifferencec                 C  rü  )NÚ
ProductSetz&#x00d7;rý  rþ  r3   r3   r4   rN  H  r   z+MathMLPresentationPrinter._print_ProductSetc                 C  ó   |   |j¡S r:   )Ú
_print_setrÅ   )r.   r  r3   r3   r4   rI  L  rè   z*MathMLPresentationPrinter._print_FiniteSetc                 C  sl   t |td�}| j d¡}| |  ¡ ¡ t|ƒD ]\}}|r$| |  ¡ ¡ | |  |¡¡ q| |  	¡ ¡ |S )N©Úkeyr  )
Úsortedr   r;   r±   r²   rŒ  rÍ   r�  rE   rŽ  )r.   r  r
  rÙ  rÏ   r  r3   r3   r4   r  O  s   z$MathMLPresentationPrinter._print_setc                 C  s  | j  d¡}|d jr4|d js4| j  d¡}| |  ¡ ¡ | |  |d ¡¡ | |  ¡ ¡ | |¡ n
| |  |d ¡¡ |dd … D ]C}| j  d¡}| | j  |¡¡ |jrx|jsx| j  d¡}| |  ¡ ¡ | |  |¡¡ | |  ¡ ¡ n|  |¡}| |¡ | |¡ qD|S rø  )	r;   r±   Ú
is_BooleanÚis_Notr²   r‡  rE   rŠ  rA   )r.   rÅ   rù  r  rÙ  rÆ   rº   r¤  r3   r3   r4   Ú_print_LogOp\  s(   

z&MathMLPresentationPrinter._print_LogOpc                 C  sÄ  ddl m} ||jkr|  |j¡S t||ƒr| ¡  ¡ }nd|fg}| j d¡}|D ]µ\}}t	|j
 ¡ ƒ}|jdd„ d� t|ƒD ]�\}\}	}
|
dkrj|ra| j d¡}| | j d	¡¡ | |¡ | |  |	¡¡ qA|
d
kr‹| j d¡}| | j d¡¡ | |¡ | |  |	¡¡ qA|r¡| j d¡}| | j d	¡¡ | |¡ | j d¡}| |  ¡ ¡ | |  |
¡¡ | |  ¡ ¡ | |¡ | j d¡}| | j d¡¡ | |¡ | |  |	¡¡ qAq*|S )Nr   )ÚVectorr  c                 S  s   | d   ¡ S )Nr   )Ú__str__)rº   r3   r3   r4   Ú<lambda>‚  s    zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>r	  r®   r  r§  rÁ   r¦  r}  )Úsympy.vectorr  ÚzerorE   r�  Úseparater
  r;   r±   r  Ú
componentsÚsortrÍ   r²   rA   r‡  rŠ  )r.   rI   r  r
  r  ÚsystemÚvectÚ
inneritemsrÏ   ÚkÚvr  Zmbracr3   r3   r4   Ú_print_BasisDependentt  sJ   







çz/MathMLPresentationPrinter._print_BasisDependentc                 C  ó   t |jtd�}|  |d¡S )Nr	  z&#x2227;©r  rÅ   r   r  ©r.   rI   rÅ   r3   r3   r4   Ú
_print_And   ó   z$MathMLPresentationPrinter._print_Andc                 C  r  )Nr	  z&#x2228;r  r  r3   r3   r4   Ú	_print_Or¤  r!  z#MathMLPresentationPrinter._print_Orc                 C  r  )Nr	  z&#x22BB;r  r  r3   r3   r4   rV  ¨  r!  z$MathMLPresentationPrinter._print_Xorc                 C  s   |   |jd¡S )Nz&#x21D2;)r  rÅ   rÔ  r3   r3   r4   rT  ¬  s   z(MathMLPresentationPrinter._print_Impliesc                 C  r  )Nr	  z&#x21D4;r  r  r3   r3   r4   Ú_print_Equivalent¯  r!  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   )	r;   r±   r²   rA   rÅ   r  r‡  rE   rŠ  )r.   r¤   r  r  rº   r3   r3   r4   rU  ³  s   

z$MathMLPresentationPrinter._print_Notc                 C  ó(   | j  d¡}| | j  |  |¡¡¡ |S ©Nr  ©r;   r±   r²   rA   r¨   ©r.   r¤   r  r3   r3   r4   Ú_print_boolÂ  ó   z%MathMLPresentationPrinter._print_boolc                 C  r$  r%  r&  r'  r3   r3   r4   Ú_print_NoneTypeÊ  r)  z)MathMLPresentationPrinter._print_NoneTypec           	      C  sJ  d}|j jr|jjr|jjr|ddd|f}nF|ddd|f}n>|j jr/||d |j |d f}n-|jjrAt|ƒ}t|ƒt|ƒ|f}nt|ƒdkrXt|ƒ}t|ƒt|ƒ||d f}nt|ƒ}| j	 
d¡}| |  ¡ ¡ t|ƒD ].\}}|rz| |  ¡ ¡ ||kr“| j	 
d¡}| | j	 |¡¡ | |¡ qm| |  |¡¡ qm| |  ¡ ¡ |S )Nu   â€¦rÁ   r   r®   é   r  r  )rï  Úis_infiniteÚstopÚstepÚis_positiveÚiterÚnextr·   Útupler;   r±   r²   rŒ  rÍ   r�  rA   rE   rŽ  )	r.   r  ÚdotsÚprintsetÚitrÙ  rÏ   Úelr  r3   r3   r4   Ú_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   r;   r±   r²   rA   rÚ   Úfuncr£   r˜  )r.   rI   rÅ   r  r  r3   r3   r4   Ú_hprint_variadic_functionî  s   
z3MathMLPresentationPrinter._hprint_variadic_functionc                 C  s6   | j  d¡}| |  d ¡¡ | |  |jd ¡¡ |S )Nr&  r   )r;   r±   r²   rî   rE   rÅ   )r.   rI   r&  r3   r3   r4   Ú
_print_expù  s   z$MathMLPresentationPrinter._print_expc                 C  sb   | j  d¡}| |  |j¡¡ | j  d¡}| | j  |  |¡¡¡ | |¡ | |  |j¡¡ |S )Nr  r  )r;   r±   r²   rE   r@  rA   r¨   rA  )r.   r¤   r  rº   r3   r3   r4   rB  ÿ  s   
z+MathMLPresentationPrinter._print_Relationalc                 C  r/  r:   r0  rF  r3   r3   r4   rG    r2  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Æ  )r;   r±   Ú_idr¢  r²   rA   Z_variable_namesÚ_name)r.   r¤   r%  Úindexr  r  r3   r3   r4   Ú_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  ú^)r;   r±   r;  r¢  r²   rA   Z_vector_namesr<  )r.   r¤   r%  r=  r  r?  r  r  r3   r3   r4   Ú_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@  ©r;   r±   r¢  r²   rA   )r.   r¤   r?  r  r  r3   r3   r4   Ú_print_VectorZero,  s   

z+MathMLPresentationPrinter._print_VectorZeroc                 C  óp   | j  d¡}|j}|j}| |  |td ¡¡ | j  d¡}| | j  d¡¡ | |¡ | |  |td ¡¡ |S )Nr  r   r  r~  ©r;   r±   Ú_expr1Ú_expr2r²   rž  r   rA   ©r.   rI   r  Úvec1Úvec2r  r3   r3   r4   Ú_print_Cross7  ó   
z&MathMLPresentationPrinter._print_Crossc                 C  óx   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nr  r  ú&#x2207;r~  r   ©r;   r±   r²   rA   rž  Ú_exprr   ©r.   rI   r  r  r3   r3   r4   Ú_print_CurlB  ó   

z%MathMLPresentationPrinter._print_Curlc                 C  rM  )Nr  r  rN  r   r   rO  rQ  r3   r3   r4   Ú_print_DivergenceM  rS  z+MathMLPresentationPrinter._print_Divergencec                 C  rD  )Nr  r   r  r   rE  rH  r3   r3   r4   Ú
_print_DotX  rL  z$MathMLPresentationPrinter._print_Dotc                 C  óP   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nr  r  rN  r   rO  rQ  r3   r3   r4   Ú_print_Gradientc  ó   
z)MathMLPresentationPrinter._print_Gradientc                 C  rV  )Nr  r  r  r   rO  rQ  r3   r3   r4   Ú_print_Laplaciank  rX  z*MathMLPresentationPrinter._print_Laplacianc                 C  ó.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nr  rÇ  Únormalz&#x2124;rB  rì   r3   r3   r4   Ú_print_Integerss  ó   z)MathMLPresentationPrinter._print_Integersc                 C  rZ  )Nr  rÇ  r[  z&#x2102;rB  rì   r3   r3   r4   Ú_print_Complexesy  r]  z*MathMLPresentationPrinter._print_Complexesc                 C  rZ  )Nr  rÇ  r[  z&#x211D;rB  rì   r3   r3   r4   Ú_print_Reals  r]  z&MathMLPresentationPrinter._print_Realsc                 C  rZ  )Nr  rÇ  r[  ú&#x2115;rB  rì   r3   r3   r4   Ú_print_Naturals…  r]  z)MathMLPresentationPrinter._print_Naturalsc                 C  sV   | j  d¡}| j  d¡}| dd¡ | | j  d¡¡ | |¡ | |  tj¡¡ |S )Nr%  r  rÇ  r[  r`  )r;   r±   r¢  r²   rA   rE   r   ÚZero)r.   r¤   r   rº   r3   r3   r4   Ú_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Å   r;   r±   r²   rA   rE   )r.   rI   Úshiftr\   rª  r«  rÙ  r  r3   r3   r4   Ú_print_SingularityFunction”  s   



z4MathMLPresentationPrinter._print_SingularityFunctionc                 C  rê   )Nr  ÚNaNrë   rì   r3   r3   r4   ró   ¤  rˆ  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  )r;   r±   r²   rA   rE   rÅ   r·   r˜  )r.   r¤   rM   r   r  r  r3   r3   r4   Ú_print_number_function©  s   

z0MathMLPresentationPrinter._print_number_functionc                 C  ó   |   |d¡S )NÚB©rg  ræ   r3   r3   r4   Ú_print_bernoulli¸  rè   z*MathMLPresentationPrinter._print_bernoullic                 C  rh  )Nri  rj  ræ   r3   r3   r4   Ú_print_catalan½  rè   z(MathMLPresentationPrinter._print_catalanc                 C  rh  )NÚErj  ræ   r3   r3   r4   Ú_print_eulerÀ  rè   z&MathMLPresentationPrinter._print_eulerc                 C  rh  )NÚFrj  ræ   r3   r3   r4   Ú_print_fibonacciÃ  rè   z*MathMLPresentationPrinter._print_fibonaccic                 C  rh  )NÚLrj  ræ   r3   r3   r4   Ú_print_lucasÆ  rè   z&MathMLPresentationPrinter._print_lucasc                 C  rh  )Nz&#x03B3;rj  ræ   r3   r3   r4   Ú_print_stieltjesÉ  rè   z*MathMLPresentationPrinter._print_stieltjesc                 C  rh  )NÚTrj  ræ   r3   r3   r4   Ú_print_tribonacciÌ  rè   z+MathMLPresentationPrinter._print_tribonaccic                 C  s`   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ |S )Nr?  r  r±  ú~rë   )r.   r¤   rº   r  r3   r3   r4   Ú_print_ComplexInfinityÏ  s   

z0MathMLPresentationPrinter._print_ComplexInfinityc                 C  rê   )Nr  z&#x2205;rë   rì   r3   r3   r4   rô   Ù  rˆ  z)MathMLPresentationPrinter._print_EmptySetc                 C  rê   )Nr  z	&#x1D54C;rë   rì   r3   r3   r4   Ú_print_UniversalSetÞ  rˆ  z-MathMLPresentationPrinter._print_UniversalSetc                 C  ó¨   ddl m} |j}| j d¡}t||ƒs6| j d¡}| |  ¡ ¡ | |  |¡¡ | |  	¡ ¡ | |¡ n| |  |¡¡ | j d¡}| | j 
d¡¡ | |¡ |S )Nr   ©rn   r&  r  r  rµ  ©Úsympy.matricesrn   rÆ   r;   r±   r�  r²   r‡  rE   rŠ  rA   ©r.   rI   rn   Úmatr  rÙ  r  r3   r3   r4   Ú_print_Adjointã  ó   

z(MathMLPresentationPrinter._print_Adjointc                 C  ry  )Nr   rz  r&  r  r  rt  r{  r}  r3   r3   r4   Ú_print_Transposeô  r€  z*MathMLPresentationPrinter._print_Transposec                 C  s�   ddl m} |j}| j d¡}t||ƒs6| j d¡}| |  ¡ ¡ | |  |¡¡ | |  	¡ ¡ | |¡ n| |  |¡¡ | |  d¡¡ |S )Nr   rz  r&  r  rÁ   )
r|  rn   rÆ   r;   r±   r�  r²   r‡  rE   rŠ  )r.   rI   rn   r~  r  rÙ  r3   r3   r4   Ú_print_Inverse  s   
z(MathMLPresentationPrinter._print_Inversec                 C  s&  ddl m} | j d¡}|j}t|d tƒr%|d  ¡ t|dd … ƒ }nt|ƒ}t||ƒrZ| 	¡ rZ|d dkr?|dd … }n|d  |d< | j d¡}| 
| j d¡¡ | 
|¡ |d d… D ]"}| 
|  |t|ƒd¡¡ | j d¡}| 
| j d	¡¡ | 
|¡ q`| 
|  |d t|ƒd¡¡ |S )
Nr   )ÚMatMulr  r®   rÁ   r  r¦  Fr}  )Ú!sympy.matrices.expressions.matmulrƒ  r;   r±   rÅ   r�  r   r¹   r  r°   r²   rA   rž  r
   )r.   rI   rƒ  rº   rÅ   r  rÆ   r3   r3   r4   Ú_print_MatMul  s0   
ÿÿz'MathMLPresentationPrinter._print_MatMulc                 C  s˜   ddl m} |j|j}}| j d¡}t||ƒs:| j d¡}| |  ¡ ¡ | |  	|¡¡ | |  
¡ ¡ | |¡ n| |  	|¡¡ | |  	|¡¡ |S )Nr   rz  r&  r  )r|  rn   r-  r+  r;   r±   r�  r²   r‡  rE   rŠ  )r.   rI   rn   r-  r+  r  rÙ  r3   r3   r4   Ú_print_MatPow1  s   
z'MathMLPresentationPrinter._print_MatPowc                 C  s„   | j  d¡}|j}|d d… D ]"}| |  |t|ƒd¡¡ | j  d¡}| | j  d¡¡ | |¡ q| |  |d t|ƒd¡¡ |S )Nr  rÁ   Fr  z&#x2218;)r;   r±   rÅ   r²   rž  r
   rA   )r.   rI   rº   rÅ   rÆ   r  r3   r3   r4   Ú_print_HadamardProduct@  s   ÿÿz0MathMLPresentationPrinter._print_HadamardProductc                 C  rê   )NrX  z&#x1D7D8rë   ©r.   ÚZrº   r3   r3   r4   Ú_print_ZeroMatrixM  rˆ  z+MathMLPresentationPrinter._print_ZeroMatrixc                 C  rê   )NrX  z&#x1D7D9rë   rˆ  r3   r3   r4   Ú_print_OneMatrixR  rˆ  z*MathMLPresentationPrinter._print_OneMatrixc                 C  rê   )Nr  z	&#x1D540;rë   )r.   ÚIrº   r3   r3   r4   Ú_print_IdentityW  rˆ  z)MathMLPresentationPrinter._print_Identityc                 C  óv   | j  d¡}| | j  d¡¡ | j  d¡}| | j  d¡¡ | j  d¡}| |¡ | |  |jd ¡¡ | |¡ |S )Nr  u   âŒŠu   âŒ‹r  r   r»  ©r.   r¤   rª  r«  r  r3   r3   r4   Ú_print_floor\  ó   

z&MathMLPresentationPrinter._print_floorc                 C  rŽ  )Nr  u   âŒˆu   âŒ‰r  r   r»  r�  r3   r3   r4   Ú_print_ceilingg  r‘  z(MathMLPresentationPrinter._print_ceilingc                 C  s¤   | j  d¡}|jd }t|ƒdkr|  |d ¡}n|  |¡}| |  ¡ ¡ | |¡ | j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  ¡ ¡ |S )Nr  r   r®   r  z&#x21A6;)	r;   r±   rÅ   r·   rE   r²   r‡  rA   rŠ  )r.   r¤   r  Úsymbolsr  r3   r3   r4   rP  r  s   



z'MathMLPresentationPrinter._print_Lambdac                 C  s
   | j |Ž S r:   )r˜  ræ   r3   r3   r4   Ú_print_tuple‚  s   
z&MathMLPresentationPrinter._print_tuplec                 C  r  r:   )rE   Úlabelræ   r3   r3   r4   Ú_print_IndexedBase…  rè   z,MathMLPresentationPrinter._print_IndexedBasec                 C  s\   | j  d¡}| |  |j¡¡ t|jƒdkr#| |  |jd ¡¡ |S | |  |j¡¡ |S )Nr%  r®   r   )r;   r±   r²   rE   r-  r·   Úindicesrì   r3   r3   r4   Ú_print_Indexedˆ  s   z(MathMLPresentationPrinter._print_Indexedc                 C  sx   | j  d¡}| | j|jtd dd�¡ | j  d¡}t|jƒD ]\}}|r,| |  ¡ ¡ | |  	|¡¡ q| |¡ |S )Nr%  ÚAtomTr¿  r  )
r;   r±   r²   rž  Úparentr   rÍ   r—  r�  rE   )r.   r¤   rº   rÙ  rÏ   rÆ   r3   r3   r4   Ú_print_MatrixElement‘  s   
z.MathMLPresentationPrinter._print_MatrixElementc                 C  óJ   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | | j|jŽ ¡ |S )Nr  r  z	&#x1d5a5;©r;   r±   r²   rA   rš  rÅ   ©r.   r¤   rº   r  r3   r3   r4   Ú_print_elliptic_fœ  ó   
z+MathMLPresentationPrinter._print_elliptic_fc                 C  rœ  )Nr  r  z	&#x1d5a4;r�  rž  r3   r3   r4   Ú_print_elliptic_e¤  r   z+MathMLPresentationPrinter._print_elliptic_ec                 C  s
  | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | j  d¡}| |  ¡ ¡ t|jƒdkrK|j\}}| |  |¡¡ | |  ¡ ¡ | |  |¡¡ n,|j\}}}| |  |¡¡ | |  	¡ ¡ | |  |¡¡ | |  ¡ ¡ | |  |¡¡ | |  
¡ ¡ | |¡ |S )Nr  r  z	&#x1d6f1;rà   )r;   r±   r²   rA   r‡  r·   rÅ   rE   r’  r”  rŠ  )r.   r¤   rº   r  r¤  r§   rÖ   Úzr3   r3   r4   Ú_print_elliptic_pi¬  s(   


z,MathMLPresentationPrinter._print_elliptic_pic                 C  sJ   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |j¡¡ |S )Nr  r  ÚEir»  rž  r3   r3   r4   Ú	_print_EiÃ  r   z#MathMLPresentationPrinter._print_Eic                 C  ó~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r%  r  rm  r   r®   r»  ©r.   r¤   rº   r¤  r  r3   r3   r4   Ú_print_expintË  ó   

z'MathMLPresentationPrinter._print_expintc                 C  ó˜   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |  |jdd… ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nr  r'  r  ÚPr   r®   rú   r»  r§  r3   r3   r4   Ú_print_jacobiÖ  ó   

z'MathMLPresentationPrinter._print_jacobic                 C  rª  )Nr  r'  r  ri  r   r®   rà   r»  r§  r3   r3   r4   Ú_print_gegenbauerâ  r­  z+MathMLPresentationPrinter._print_gegenbauerc                 C  r¦  )Nr  r%  r  rt  r   r®   r»  r§  r3   r3   r4   Ú_print_chebyshevtî  r©  z+MathMLPresentationPrinter._print_chebyshevtc                 C  r¦  )Nr  r%  r  ÚUr   r®   r»  r§  r3   r3   r4   Ú_print_chebyshevuù  r©  z+MathMLPresentationPrinter._print_chebyshevuc                 C  r¦  )Nr  r%  r  r«  r   r®   r»  r§  r3   r3   r4   Ú_print_legendre  r©  z)MathMLPresentationPrinter._print_legendrec                 C  rª  )Nr  r'  r  r«  r   r®   rà   r»  r§  r3   r3   r4   Ú_print_assoc_legendre  r­  z/MathMLPresentationPrinter._print_assoc_legendrec                 C  r¦  )Nr  r%  r  rq  r   r®   r»  r§  r3   r3   r4   Ú_print_laguerre  r©  z)MathMLPresentationPrinter._print_laguerrec                 C  rª  )Nr  r'  r  rq  r   r®   rà   r»  r§  r3   r3   r4   Ú_print_assoc_laguerre&  r­  z/MathMLPresentationPrinter._print_assoc_laguerrec                 C  r¦  )Nr  r%  r  ÚHr   r®   r»  r§  r3   r3   r4   Ú_print_hermite2  r©  z(MathMLPresentationPrinter._print_hermite)Fr:   )r   )”r6   r7   r8   rO   rQ  r¨   r‡  rŠ  rŒ  rŽ  r�  r’  r”  r˜  rš  rž  r³   rÇ   rØ   r­  rÝ   rã   rç   rí   rî   rð   rò   rù   r²  ré   r´  r¸  r¹  rº  r¼  r½  r  r  r)  rR  rS  rÌ  rÐ  rÕ  r×  rÚ  r.  r1  rÞ  r:  r=  r6  rê  r>  rì  rñ  rò  Ú_print_Determinantró  rö  r÷  r?  rû  rÿ  r  rL  r  rN  rI  r  Ú_print_frozensetr  r  r   r"  rV  rT  r#  rU  r(  rö   rø   r*  r7  r9  Ú
_print_MinÚ
_print_Maxr:  rB  rG  r>  rA  rC  rK  rR  rT  rU  rW  rY  r\  r^  r_  ra  rc  re  ró   rg  rk  Ú_print_bellrl  rn  rp  rr  rs  ru  rw  rô   rx  r  r�  r‚  r…  r†  r‡  rŠ  r‹  r�  r�  r’  rP  r”  r–  r˜  r›  rŸ  r¡  r£  r¥  r¨  r¬  r®  r¯  r±  r²  r³  r´  rµ  r·  r3   r3   r3   r4   rW  #  s"   M


/		&660'	,			
	rW  Úcontentc                 K  s$   |dkrt |ƒ | ¡S t|ƒ | ¡S )zŠReturns the MathML representation of expr. If printer is presentation
    then prints Presentation MathML else prints content MathML.
    Úpresentation)rW  rK   rQ   )rI   ÚprinterrB   r3   r3   r4   Ú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)rW  rQ   rE   r   ÚtoprettyxmlÚprint)rI   r¿  rB   r  ÚxmlZ
pretty_xmlr3   r3   r4   Úprint_mathmlI  s   
rÄ  N)r½  )$rO   Ú
__future__r   Útypingr   Zsympy.core.mulr   Úsympy.core.singletonr   Úsympy.core.sortingr   Úsympy.core.sympifyr   Úsympy.printing.conventionsr   r	   Úsympy.printing.precedencer
   r   r   Z&sympy.printing.pretty.pretty_symbologyr   Úsympy.printing.printerr   r   Zmpmath.libmpr   r   r   r3  r   rQ   rW  rÀ  rÄ  ZMathMLPrinterr3   r3   r3   r4   Ú<module>   sD    ?   R            '

$