o
    GZŽ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 d S )Nz{}{}{})ÚdataÚwriteÚformat)ÚselfÚwriterÚindentZ	addindentZnewl© r,   úD/var/www/auris/lib/python3.10/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 )Nr!   )Ú	_settingsr   )r)   Únamer,   r,   r-   Ú_split_super_subM   s   

z"MathMLPrinterBase._split_super_subr3   )	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                 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ÚpowerZMaxÚmaxZMinÚminZAbsÚabsÚAndÚandÚOrÚorZXorÚxorÚNotÚnotZImpliesZimpliesÚSymbolÚciÚMatrixSymbolZRandomSymbolÚIntegralÚSumÚsumÚsinÚcosÚtanÚcotZcscÚsecÚsinhÚcoshÚtanhZcothZcschZsechÚasinÚarcsinÚasinhÚarcsinhÚacosÚarccosÚacoshÚarccoshÚatanÚarctanÚatanhÚarctanhÚatan2ÚacotÚarccotZacothZarccothZasecZarcsecZasechZarcsechZacscZarccscZacschZarccschÚlogÚlnÚEqualityÚeqÚ
UnequalityZneqÚGreaterThanZgeqÚLessThanZleqÚStrictGreaterThanÚgtÚStrictLessThanÚltÚunionZ	intersect)ÚUnionÚIntersection©Ú	__class__Ú__mro__r/   Úlower)r)   ÚeÚ	translateÚclsÚnr,   r,   r-   Ú
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é   ÚoldrL   )Ú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 ]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“   éÿÿÿÿrK   )	Ú_as_ordered_termsr=   r™   r4   rš   r›   Úappendr    Úpop)r)   r@   r   ÚargsZlastProcessedZ	plusNodesÚargr£   r,   r,   r-   Ú
_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.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 ]!}| j  d¡}t|jƒD ]}| |  |||f ¡¡ q| |¡ 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r| j d¡}| | j t|jƒ¡¡ |S | j d¡}| | j d¡¡ | j d¡}| | j t|jƒ¡¡ | j d¡}| | j t|j ƒ¡¡ | |¡ | |¡ |S )Nr—   rP   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  ó   | j  d¡S )NZ
imaginaryi©r4   rš   ©r)   r   r,   r,   r-   Ú_print_ImaginaryUnit  ó   z)MathMLContentPrinter._print_ImaginaryUnitc                 C  rÊ   )NZ
eulergammarË   rÌ   r,   r,   r-   Ú_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.htmlrP   u   Ï†©r4   rš   r›   r9   ©r)   r   r£   r,   r,   r-   Ú_print_GoldenRatio   s   z'MathMLContentPrinter._print_GoldenRatioc                 C  rÊ   )NZexponentialerË   rÌ   r,   r,   r-   Ú_print_Exp1'  rÎ   z MathMLContentPrinter._print_Exp1c                 C  rÊ   )NÚpirË   rÌ   r,   r,   r-   Ú	_print_Pi*  rÎ   zMathMLContentPrinter._print_Pic                 C  rÊ   )NÚinfinityrË   rÌ   r,   r,   r-   Ú_print_Infinity-  rÎ   z$MathMLContentPrinter._print_Infinityc                 C  rÊ   )NZ
notanumberrË   rÌ   r,   r,   r-   Ú
_print_NaN0  rÎ   zMathMLContentPrinter._print_NaNc                 C  rÊ   )NZemptysetrË   rÌ   r,   r,   r-   Ú_print_EmptySet3  rÎ   z$MathMLContentPrinter._print_EmptySetc                 C  rÊ   )NÚtruerË   rÌ   r,   r,   r-   Ú_print_BooleanTrue6  rÎ   z'MathMLContentPrinter._print_BooleanTruec                 C  rÊ   )NÚfalserË   rÌ   r,   r,   r-   Ú_print_BooleanFalse9  rÎ   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¡¡ |S | ˆ| 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                   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    r4   rš   r³   r›   r9   ©ÚitemsÚmrowrµ   ÚitemÚmoÚmi©r)   r,   r-   Újoing  ó   
z0MathMLContentPrinter._print_Symbol.<locals>.joinc                 S  ó   | t v r	t  | ¡S | S r3   ©r   Úget©Úsr,   r,   r-   rŽ   y  ó   
z5MathMLContentPrinter._print_Symbol.<locals>.translatec                   ó   g | ]}ˆ |ƒ‘qS r,   r,   ©Ú.0Úsup©rŽ   r,   r-   Ú
<listcomp>  ó    z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>c                   rþ   r,   r,   ©r   Úsubr  r,   r-   r  ‚  r  rí   zmml:msubzmml:msupzmml:msubsup)r4   rš   r‘   rE   rD   r›   r9   )r)   Úsymr_   rö   rD   ÚsupersÚsubsÚmnameÚmsubÚmsupÚmsubsupr,   ©r)   rŽ   r-   Ú_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Æ   ÚdegreerP   )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  ó,   | j  |  |¡¡}| | j  t|ƒ¡¡ |S r3   ©r4   rš   r‘   r›   r9   rÀ   rÒ   r,   r,   r-   Ú_print_Number¶  ó   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 ]%\}}| |  |¡¡ |dkrK| j  d¡}| |  t	|ƒ¡¡ | |¡ q&| |¡ | |  |j¡¡ |S )Nr’   ZpartialdiffrÄ   r—   r  )
r4   rš   r‘   r	   r@   r›   ÚreversedÚvariable_countr=   r   )r)   r   r£   Zdiff_symbolrÇ   r  rL   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  r  r3   r  ©r)   rÁ   r)  r,   r,   r-   Ú
_print_intø  r  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  ó>   | j  d¡}| | j  d¡¡ |jD ]
}| |  |¡¡ q|S )Nr’   Zsetdiff©r4   rš   r›   r®   r=   r!  r,   r,   r-   Ú_print_Complement  ó
   
z&MathMLContentPrinter._print_Complementc                 C  r/  )Nr’   Zcartesianproductr0  r!  r,   r,   r-   Ú_print_ProductSet  r2  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_Lambdar3   )-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.  r1  r3  r5  r,   r,   r,   r-   rH   T   sV    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                   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 )NrI   rO   ÚmnZLimitz&#x2192;rM   ú&dd;rQ   r^   rô   ra   z&int;rb   z&#x2211;rd   re   rf   rg   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   ry   rz   rx   r}   ú=r   z&#x2260;r€   z&#x2265;r   z&#x2264;r‚   ú>r„   ú<Zlerchphiú&#x3A6;Úzetaz&#x3B6;Zdirichlet_etaz&#x3B7;Z
elliptic_kz&#x39A;Z
lowergammaú&#x3B3;Z
uppergammaz&#x393;ÚgammaZtotientz&#x3D5;Zreduced_totientz&#x3BB;z&#x3BD;z&#x3A9;r   ÚCÚWz&#x398;ÚTrueÚFalseÚNonez	S&#x2032;z	C&#x2032;Úlambda)ZprimenuZ
primeomegaZfresnelsZfresnelcZLambertWZ	HeavisideZBooleanTrueZBooleanFalseÚNoneTypeZmathieusZmathieucZmathieusprimeZ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   rJ  ú&InvisibleTimes;rL   ú&#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Ž   rS  r   r   r,   rõ   r-   r‘   *  s¼   ÿþýüûúùø	÷
öõôóòñðïîíìëêéèçæåäãâá à!ß"Þ#Ð3ÿz$MathMLPresentationPrinter.mathml_tagc                 C  ó"   | j  d¡}| | j  d¡¡ |S )Nró   ú(rÑ   ©r)   ró   r,   r,   r-   Ú_l_parenw  ó   z"MathMLPresentationPrinter._l_parenc                 C  rT  )Nró   ú)rÑ   rV  r,   r,   r-   Ú_r_paren|  rX  z"MathMLPresentationPrinter._r_parenc                 C  rT  )Nró   Ú{rÑ   rV  r,   r,   r-   Ú_l_brace  rX  z"MathMLPresentationPrinter._l_bracec                 C  rT  )Nró   Ú}rÑ   rV  r,   r,   r-   Ú_r_brace†  rX  z"MathMLPresentationPrinter._r_bracec                 C  rT  )Nró   ú,rÑ   rV  r,   r,   r-   Ú_comma‹  rX  z MathMLPresentationPrinter._commac                 C  rT  )Nró   ú|rÑ   rV  r,   r,   r-   Ú_bar  rX  zMathMLPresentationPrinter._barc                 C  rT  )Nró   ú;rÑ   rV  r,   r,   r-   Ú
_semicolon•  rX  z$MathMLPresentationPrinter._semicolonc                 G  ó`   | j  d¡}| |  ¡ ¡ t|ƒD ]\}}|r| |  ¡ ¡ | |  |¡¡ q| |  ¡ ¡ |S ©Nrñ   )r4   rš   r›   rW  r³   r`  r=   rZ  ©r)   r®   rñ   rµ   r¯   r,   r,   r-   Ú_paren_comma_separatedš  ó   z0MathMLPresentationPrinter._paren_comma_separatedc                 G  re  rf  )r4   rš   r›   rW  r³   rb  r=   rZ  rg  r,   r,   r-   Ú_paren_bar_separated¤  ri  z.MathMLPresentationPrinter._paren_bar_separatedFc                 C  sb   t |ƒ}||k s|s,||kr,| j d¡}| |  ¡ ¡ | |  |¡¡ | |  ¡ ¡ |S |  |¡S rf  )r
   r4   rš   r›   rW  r=   rZ  )r)   rò   ÚlevelÚstrictZprec_valrñ   r,   r,   r-   Ú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ž   r4   rš   rC   r    rÀ   ÚsetAttributer=   r›   rŸ   r   r   r¡   r¢   r9   r‘   rm  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@   rt  rñ   r£   r,   rõ   r-   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ó   ru  ú+)r4   rš   r«   r›   r=   r™   r9   )r)   r@   r   rñ   r®   r¯   r£   rs  r,   r,   r-   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   ú]rU  rY  rñ   )	r4   rš   r¹   rº   r»   r›   r=   rC   r9   )r)   r¼   Útablerµ   r£   r½   rs  r   ÚleftÚrightrñ   r,   r,   r-   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   rn  r   rp  rÛ   rñ   ró   ru  )	rÁ   r4   rš   rC   rq  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Á   r|  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ñ   r}  rô   r£   rÇ   ÚarrowrÈ   r,   r,   r-   rÉ   0  s"   





z&MathMLPresentationPrinter._print_Limitc                 C  rÐ   )Nrô   z&ImaginaryI;rÑ   rÒ   r,   r,   r-   rÍ   F  rX  z.MathMLPresentationPrinter._print_ImaginaryUnitc                 C  rÐ   )Nrô   rB  rÑ   rÒ   r,   r,   r-   rÓ   K  rX  z,MathMLPresentationPrinter._print_GoldenRatioc                 C  rÐ   )Nrô   z&ExponentialE;rÑ   rÒ   r,   r,   r-   rÔ   P  rX  z%MathMLPresentationPrinter._print_Exp1c                 C  rÐ   )Nrô   z&pi;rÑ   rÒ   r,   r,   r-   rÖ   U  rX  z#MathMLPresentationPrinter._print_Pic                 C  rÐ   )Nrô   ú&#x221E;rÑ   rÒ   r,   r,   r-   rØ   Z  rX  z)MathMLPresentationPrinter._print_Infinityc                 C  sL   | j  d¡}| j  d¡}| | j  d¡¡ |  |¡}| |¡ | |¡ |S )Nrñ   ró   ru  )r4   rš   r›   r9   rØ   )r)   r   rñ   rs  r£   r,   r,   r-   rß   _  s   


z1MathMLPresentationPrinter._print_NegativeInfinityc                 C  rÐ   )Nrô   z&#x210F;rÑ   rÒ   r,   r,   r-   Ú_print_HBarh  rX  z%MathMLPresentationPrinter._print_HBarc                 C  rÐ   )Nrô   rD  rÑ   rÒ   r,   r,   r-   rÏ   m  rX  z+MathMLPresentationPrinter._print_EulerGammac                 C  rÐ   )Nrô   ZTribonacciConstantrÑ   rÒ   r,   r,   r-   Ú_print_TribonacciConstantr  rX  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—   r„  )r)   r   rñ   ró   r,   r,   r-   Ú_print_Contains}  s   
z)MathMLPresentationPrinter._print_Containsc                 C  rÐ   )Nrô   z&#x210B;rÑ   rÒ   r,   r,   r-   Ú_print_HilbertSpace†  rX  z-MathMLPresentationPrinter._print_HilbertSpacec                 C  s8   | j  d¡}| | j  d¡¡ | |  |jd ¡¡ |S )Nr  z	&#x1D49E;r   ©r4   rš   r›   r9   r=   r®   r…  r,   r,   r-   Ú_print_ComplexSpace‹  s   z-MathMLPresentationPrinter._print_ComplexSpacec                 C  rÐ   )Nrô   z&#x2131;rÑ   rÒ   r,   r,   r-   Ú_print_FockSpace‘  rX  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~  r,   r,   r-   Ú	<genexpr>›  s   € z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>ró   r—   rÆ   r  r  r   T©rl  r>  r   )r4   rš   r    râ   Úallr›   r9   r  r=   rm  rá   r   )	r)   r@   Z
intsymbolsrñ   ró   r~  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ñ   r?  )rç   râ   r4   rš   r=   r›   r9   r‘   rm  rá   r
   )r)   r   râ   Zsubsuprã   rä   ZsummandÚlowÚvarÚequalrñ   r,   r,   r-   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õ   r,   r-   rö   ×  r÷   z5MathMLPresentationPrinter._print_Symbol.<locals>.joinc                 S  rø   r3   rù   rû   r,   r,   r-   rŽ   é  rý   z:MathMLPresentationPrinter._print_Symbol.<locals>.translatec                   rþ   r,   r,   rÿ   r  r,   r-   r  ñ  r  z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>c                   rþ   r,   r,   r  r  r,   r-   r  ò  r  rô   r   r  r  r  ÚboldÚmathvariant)rE   rD   r4   rš   r›   r9   r    rq  )	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-   r7    s   ÿz-MathMLPresentationPrinter._print_MatrixSymbolc                 C  s2   | j  d¡}| dd¡ | |  |jd ¡¡ |S )NZmencloseÚnotationÚtopr   )r4   rš   rq  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›   rm  r   r9   )r)   Úopr@   Úrowró   r,   r,   r-   Ú_print_operator_after  s   
z/MathMLPresentationPrinter._print_operator_afterc                 C  ó   |   d|jd ¡S )Nú!r   ©rœ  r®   ©r)   r@   r,   r,   r-   Ú_print_factorial   ó   z*MathMLPresentationPrinter._print_factorialc                 C  r  )Nz!!r   rŸ  r   r,   r,   r-   Ú_print_factorial2#  r¢  z+MathMLPresentationPrinter._print_factorial2c                 C  sz   | j  d¡}| dd¡ | |  |jd ¡¡ | |  |jd ¡¡ | j  d¡}| |  ¡ ¡ | |¡ | |  ¡ ¡ |S )Nrn  ZlinethicknessÚ0r   r—   rñ   )r4   rš   rq  r›   r=   r®   rW  rZ  )r)   r@   rr  Úbracr,   r,   r-   Ú_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ª   rn  r  rR   r   )r  r  rV   rÁ   r¿   rC   r4   rš   r›   r=   r  Zis_negativerm  r   r|  )r)   r   r£   rr  r—  r,   r,   r-   r  1  s`   $ÿ
ÿ
ÿ

ü
z$MathMLPresentationPrinter._print_Powc                 C  r  r3   r  rÒ   r,   r,   r-   r  g  r  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=   rU   r`  rT   )r)   rµ   ry  rz  r¥  r,   r,   r-   Ú_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ó   rn  )
r	   r@   r‘   r4   rš   r  r  r›   r9   r=   )r)   r   r  r¼   Údimr  Únumr£   Úxxrs  Zmnumrñ   rr  r,   r,   r-   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ñ   )r4   rš   r‘   rC   r›   r9   rh  r®   )r)   r   r£   rñ   r,   r,   r-   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)Zstrip_zerosr    rñ   r   r   rv  r—   r=  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  r=  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®   rW  rZ  )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‘   rh  r®   )r)   r   rñ   rô   r,   r,   r-   r#  ë  s   
z&MathMLPresentationPrinter._print_Basicc                 C  s   | j |jŽ S r3   )rh  r®   rÌ   r,   r,   r-   Ú_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ó   rY  rw  rU  r   rñ   )
r4   rš   Z
right_openr›   r9   Z	left_openr=   Ústartr`  Úend)r)   rµ   rz  ry  rñ   r,   r,   r-   Ú_print_Intervalö  s   

z)MathMLPresentationPrinter._print_Intervalc                 C  sB   | j  d¡}| |  ¡ ¡ | |  |jd ¡¡ | |  ¡ ¡ |S )Nrñ   r   )r4   rš   r›   rb  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›   rW  r=   rZ  r9   )r)   r¶   r@   r¥  rô   rñ   r,   r,   r-   Ú_print_re_im  s   

z&MathMLPresentationPrinter._print_re_imc                 C  r  )Nu   â„œr   ©r·  r®   ©r)   r@   r  r,   r,   r-   Ú	_print_re  r¢  z#MathMLPresentationPrinter._print_rec                 C  r  )Nu   â„‘r   r¸  r¹  r,   r,   r-   Ú	_print_im!  r¢  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 ]!}| j  d¡}| | j  |¡¡ |  ||¡}| |¡ | |¡ q|S ©Nrñ   r   r—   ró   )r4   rš   r›   rm  r®   r9   )r)   r@   ÚsymbolÚprecrñ   r¯   r£   rs  r,   r,   r-   Ú_print_SetOp-  s   
z&MathMLPresentationPrinter._print_SetOpc                 C  ó   t d }|  |d|¡S )Nr‡   z&#x222A;©r   r¿  ©r)   r@   r¾  r,   r,   r-   Ú_print_Union8  ó   z&MathMLPresentationPrinter._print_Unionc                 C  rÀ  )Nrˆ   z&#x2229;rÁ  rÂ  r,   r,   r-   Ú_print_Intersection<  rÄ  z-MathMLPresentationPrinter._print_Intersectionc                 C  rÀ  )NZ
Complementz&#x2216;rÁ  rÂ  r,   r,   r-   r1  @  rÄ  z+MathMLPresentationPrinter._print_Complementc                 C  rÀ  )NZSymmetricDifferenceú&#x2206;rÁ  rÂ  r,   r,   r-   Ú_print_SymmetricDifferenceD  rÄ  z4MathMLPresentationPrinter._print_SymmetricDifferencec                 C  rÀ  )NZ
ProductSetz&#x00d7;rÁ  rÂ  r,   r,   r-   r3  H  rÄ  z+MathMLPresentationPrinter._print_ProductSetc                 C  ó   |   |j¡S r3   )Ú
_print_setr®   )r)   rü   r,   r,   r-   r.  L  rÎ   z*MathMLPresentationPrinter._print_FiniteSetc                 C  sl   t |td}| j d¡}| |  ¡ ¡ t|ƒD ]\}}|r$| |  ¡ ¡ | |  |¡¡ q| |  	¡ ¡ |S )N©Úkeyrñ   )
Úsortedr   r4   rš   r›   r\  r³   r`  r=   r^  )r)   rü   rð   r¥  rµ   rò   r,   r,   r-   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¼  )	r4   rš   Ú
is_BooleanZis_Notr›   rW  r=   rZ  r9   )r)   r®   r½  rñ   r¥  r¯   r£   rs  r,   r,   r-   Ú_print_LogOp\  s(   

z&MathMLPresentationPrinter._print_LogOpc                 C  sÄ  ddl m} ||jkr|  |j¡S t||ƒr| ¡  ¡ }nd|fg}| j d¡}|D ]µ\}}t	|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£   r,   r,   r-   Ú<lambda>‚  s    zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>rÊ  r—   ró   rv  rª   ru  rN  )Zsympy.vectorrÏ  Úzeror=   rQ  Zseparaterð   r4   rš   rç   Ú
componentsÚsortr³   r›   r9   rW  rZ  )r)   r@   rÏ  rð   rñ   ÚsystemZvectZ
inneritemsrµ   ÚkÚvró   Zmbracr,   r,   r-   Ú_print_BasisDependentt  sJ   







çz/MathMLPresentationPrinter._print_BasisDependentc                 C  ó   t |jtd}|  |d¡S )NrÊ  z&#x2227;©rÌ  r®   r   rÎ  ©r)   r@   r®   r,   r,   r-   Ú
_print_And   ó   z$MathMLPresentationPrinter._print_Andc                 C  rÙ  )NrÊ  z&#x2228;rÚ  rÛ  r,   r,   r-   Ú	_print_Or¤  rÝ  z#MathMLPresentationPrinter._print_Orc                 C  rÙ  )NrÊ  z&#x22BB;rÚ  rÛ  r,   r,   r-   r;  ¨  rÝ  z$MathMLPresentationPrinter._print_Xorc                 C  s   |   |jd¡S )Nz&#x21D2;)rÎ  r®   r   r,   r,   r-   r9  ¬  s   z(MathMLPresentationPrinter._print_Impliesc                 C  rÙ  )NrÊ  z&#x21D4;rÚ  rÛ  r,   r,   r-   Ú_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   )	r4   rš   r›   r9   r®   rÍ  rW  r=   rZ  )r)   r   rñ   ró   r£   r,   r,   r-   r:  ³  s   

z$MathMLPresentationPrinter._print_Notc                 C  ó(   | j  d¡}| | j  |  |¡¡¡ |S ©Nrô   ©r4   rš   r›   r9   r‘   ©r)   r   rô   r,   r,   r-   Ú_print_boolÂ  ó   z%MathMLPresentationPrinter._print_boolc                 C  rà  rá  râ  rã  r,   r,   r-   Ú_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ÚstepZis_positiveÚiterÚnextr    Útupler4   rš   r›   r\  r³   r`  r9   r=   r^  )	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Œ   rh  )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  r  r3   r  r+  r,   r,   r-   r,    r  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š   Ú_idrq  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õ  rq  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š   rq  r›   r9   )r)   r   rù  rô   ró   r,   r,   r-   Ú_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ó   rO  ©r4   rš   Z_expr1Z_expr2r›   rm  r   r9   ©r)   r@   rñ   Zvec1Zvec2ró   r,   r,   r-   Ú_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;rO  r   ©r4   rš   r›   r9   rm  Z_exprr   ©r)   r@   rñ   ró   r,   r,   r-   Ú_print_CurlB  ó   

z%MathMLPresentationPrinter._print_Curlc                 C  r  )Nrñ   ró   r  r   r   r  r  r,   r,   r-   Ú_print_DivergenceM  r  z+MathMLPresentationPrinter._print_Divergencec                 C  rþ  )Nrñ   r   ró   r   rÿ  r   r,   r,   r-   Ú
_print_DotX  r  z$MathMLPresentationPrinter._print_Dotc                 C  óP   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jtd ¡¡ |S )Nrñ   ró   r  r   r  r  r,   r,   r-   Ú_print_Gradientc  ó   
z)MathMLPresentationPrinter._print_Gradientc                 C  r  )Nrñ   ró   rÆ  r   r  r  r,   r,   r-   Ú_print_Laplaciank  r  z*MathMLPresentationPrinter._print_Laplacianc                 C  ó.   | j  d¡}| dd¡ | | j  d¡¡ |S )Nrô   r”  Únormalz&#x2124;rü  rÒ   r,   r,   r-   Ú_print_Integerss  ó   z)MathMLPresentationPrinter._print_Integersc                 C  r  )Nrô   r”  r  z&#x2102;rü  rÒ   r,   r,   r-   Ú_print_Complexesy  r  z*MathMLPresentationPrinter._print_Complexesc                 C  r  )Nrô   r”  r  z&#x211D;rü  rÒ   r,   r,   r-   Ú_print_Reals  r  z&MathMLPresentationPrinter._print_Realsc                 C  r  )Nrô   r”  r  ú&#x2115;rü  rÒ   r,   r,   r-   Ú_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  )r4   rš   rq  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@   ÚshiftrS   ry  rz  r¥  r  r,   r,   r-   Ú_print_SingularityFunction”  s   



z4MathMLPresentationPrinter._print_SingularityFunctionc                 C  rÐ   )Nrô   ÚNaNrÑ   rÒ   r,   r,   r-   rÙ   ¤  rX  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    rh  )r)   r   rD   r  rô   rñ   r,   r,   r-   Ú_print_number_function©  s   

z0MathMLPresentationPrinter._print_number_functionc                 C  ó   |   |d¡S )NÚB©r  rÌ   r,   r,   r-   Ú_print_bernoulli¸  rÎ   z*MathMLPresentationPrinter._print_bernoullic                 C  r  )NrF  r  rÌ   r,   r,   r-   Ú_print_catalan½  rÎ   z(MathMLPresentationPrinter._print_catalanc                 C  r  )NÚEr  rÌ   r,   r,   r-   Ú_print_eulerÀ  rÎ   z&MathMLPresentationPrinter._print_eulerc                 C  r  )NÚFr  rÌ   r,   r,   r-   Ú_print_fibonacciÃ  rÎ   z*MathMLPresentationPrinter._print_fibonaccic                 C  r  )NÚLr  rÌ   r,   r,   r-   Ú_print_lucasÆ  rÎ   z&MathMLPresentationPrinter._print_lucasc                 C  r  )Nz&#x03B3;r  rÌ   r,   r,   r-   Ú_print_stieltjesÉ  rÎ   z*MathMLPresentationPrinter._print_stieltjesc                 C  r  )NÚTr  rÌ   r,   r,   r-   Ú_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ó   r,   r,   r-   Ú_print_ComplexInfinityÏ  s   

z0MathMLPresentationPrinter._print_ComplexInfinityc                 C  rÐ   )Nró   z&#x2205;rÑ   rÒ   r,   r,   r-   rÚ   Ù  rX  z)MathMLPresentationPrinter._print_EmptySetc                 C  rÐ   )Nró   z	&#x1D54C;rÑ   rÒ   r,   r,   r-   Ú_print_UniversalSetÞ  rX  z-MathMLPresentationPrinter._print_UniversalSetc                 C  ó¨   ddl m} |j}| j d¡}t||ƒs6| j d¡}| |  ¡ ¡ | |  |¡¡ | |  	¡ ¡ | |¡ n| |  |¡¡ | j d¡}| | j 
d¡¡ | |¡ |S )Nr   ©r`   r  rñ   ró   rƒ  ©Úsympy.matricesr`   r¯   r4   rš   rQ  r›   rW  r=   rZ  r9   ©r)   r@   r`   Úmatr  r¥  ró   r,   r,   r-   Ú_print_Adjointã  ó   

z(MathMLPresentationPrinter._print_Adjointc                 C  r-  )Nr   r.  r  rñ   ró   r(  r/  r1  r,   r,   r-   Ú_print_Transposeô  r4  z*MathMLPresentationPrinter._print_Transposec                 C  s   ddl m} |j}| j d¡}t||ƒs6| j d¡}| |  ¡ ¡ | |  |¡¡ | |  	¡ ¡ | |¡ n| |  |¡¡ | |  d¡¡ |S )Nr   r.  r  rñ   rª   )
r0  r`   r¯   r4   rš   rQ  r›   rW  r=   rZ  )r)   r@   r`   r2  r  r¥  r,   r,   r-   Ú_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ó   ru  FrN  )Z!sympy.matrices.expressions.matmulr7  r4   rš   r®   rQ  r   r¢   rç   r™   r›   r9   rm  r
   )r)   r@   r7  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||ƒs:| j d¡}| |  ¡ ¡ | |  	|¡¡ | |  
¡ ¡ | |¡ n| |  	|¡¡ | |  	|¡¡ |S )Nr   r.  r  rñ   )r0  r`   r  r  r4   rš   rQ  r›   rW  r=   rZ  )r)   r@   r`   r  r  r  r¥  r,   r,   r-   Ú_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;)r4   rš   r®   r›   rm  r
   r9   )r)   r@   r£   r®   r¯   ró   r,   r,   r-   Ú_print_HadamardProduct@  s   ÿÿz0MathMLPresentationPrinter._print_HadamardProductc                 C  rÐ   )Nr=  z&#x1D7D8rÑ   ©r)   ÚZr£   r,   r,   r-   Ú_print_ZeroMatrixM  rX  z+MathMLPresentationPrinter._print_ZeroMatrixc                 C  rÐ   )Nr=  z&#x1D7D9rÑ   r;  r,   r,   r-   Ú_print_OneMatrixR  rX  z*MathMLPresentationPrinter._print_OneMatrixc                 C  rÐ   )Nrô   z	&#x1D540;rÑ   )r)   ÚIr£   r,   r,   r-   Ú_print_IdentityW  rX  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   ry  rz  rñ   r,   r,   r-   Ú_print_floor\  ó   

z&MathMLPresentationPrinter._print_floorc                 C  rA  )Nró   u   âŒˆu   âŒ‰rñ   r   r‰  rB  r,   r,   r-   Ú_print_ceilingg  rD  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;)	r4   rš   r®   r    r=   r›   rW  r9   rZ  )r)   r   rñ   Úsymbolsró   r,   r,   r-   r5  r  s   



z'MathMLPresentationPrinter._print_Lambdac                 C  s
   | j |Ž S r3   )rh  rÌ   r,   r,   r-   Ú_print_tuple‚  s   
z&MathMLPresentationPrinter._print_tuplec                 C  rÈ  r3   )r=   ÚlabelrÌ   r,   r,   r-   Ú_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   )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 ]\}}|r,| |  ¡ ¡ | |  	|¡¡ q| |¡ |S )Nr  ZAtomTr  rñ   )
r4   rš   r›   rm  Úparentr   r³   rJ  r`  r=   )r)   r   r£   r¥  rµ   r¯   r,   r,   r-   Ú_print_MatrixElement‘  s   
z.MathMLPresentationPrinter._print_MatrixElementc                 C  óJ   | j  d¡}| j  d¡}| | j  d¡¡ | |¡ | | j|jŽ ¡ |S )Nrñ   rô   z	&#x1d5a5;©r4   rš   r›   r9   rj  r®   ©r)   r   r£   rô   r,   r,   r-   Ú_print_elliptic_fœ  ó   
z+MathMLPresentationPrinter._print_elliptic_fc                 C  rN  )Nrñ   rô   z	&#x1d5a4;rO  rP  r,   r,   r-   Ú_print_elliptic_e¤  rR  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Æ   )r4   rš   r›   r9   rW  r    r®   r=   rb  rd  rZ  )r)   r   r£   rô   rs  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‰  rP  r,   r,   r-   Ú	_print_EiÃ  rR  z#MathMLPresentationPrinter._print_Eic                 C  ó~   | j  d¡}| j  d¡}| j  d¡}| | j  d¡¡ | |¡ | |  |jd ¡¡ | |¡ | |  |jdd … ¡¡ |S )Nrñ   r  ró   r!  r   r—   r‰  ©r)   r   r£   rs  ró   r,   r,   r-   Ú_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‰  rX  r,   r,   r-   Ú_print_jacobiÖ  ó   

z'MathMLPresentationPrinter._print_jacobic                 C  r[  )Nrñ   r  ró   rF  r   r—   rÆ   r‰  rX  r,   r,   r-   Ú_print_gegenbauerâ  r^  z+MathMLPresentationPrinter._print_gegenbauerc                 C  rW  )Nrñ   r  ró   r(  r   r—   r‰  rX  r,   r,   r-   Ú_print_chebyshevtî  rZ  z+MathMLPresentationPrinter._print_chebyshevtc                 C  rW  )Nrñ   r  ró   ÚUr   r—   r‰  rX  r,   r,   r-   Ú_print_chebyshevuù  rZ  z+MathMLPresentationPrinter._print_chebyshevuc                 C  rW  )Nrñ   r  ró   r\  r   r—   r‰  rX  r,   r,   r-   Ú_print_legendre  rZ  z)MathMLPresentationPrinter._print_legendrec                 C  r[  )Nrñ   r  ró   r\  r   r—   rÆ   r‰  rX  r,   r,   r-   Ú_print_assoc_legendre  r^  z/MathMLPresentationPrinter._print_assoc_legendrec                 C  rW  )Nrñ   r  ró   r%  r   r—   r‰  rX  r,   r,   r-   Ú_print_laguerre  rZ  z)MathMLPresentationPrinter._print_laguerrec                 C  r[  )Nrñ   r  ró   r%  r   r—   rÆ   r‰  rX  r,   r,   r-   Ú_print_assoc_laguerre&  r^  z/MathMLPresentationPrinter._print_assoc_laguerrec                 C  rW  )Nrñ   r  ró   ÚHr   r—   r‰  rX  r,   r,   r-   Ú_print_hermite2  rZ  z(MathMLPresentationPrinter._print_hermite)Fr3   )r   )”r/   r0   r1   rF   r6  r‘   rW  rZ  r\  r^  r`  rb  rd  rh  rj  rm  rœ   r°   r¾   r|  rÃ   rÉ   rÍ   rÓ   rÔ   rÖ   rØ   rß   r  rÏ   r‚  r†  r‡  rˆ  rŠ  r‹  ré   rê   r  r7  r8  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Å  r1  rÇ  r3  r.  rÉ  Z_print_frozensetrÎ  rØ  rÜ  rÞ  r;  r9  rß  r:  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,  r3  r5  r6  r8  r9  r:  r=  r>  r@  rC  rE  r5  rG  rI  rK  rM  rQ  rS  rU  rV  rY  r]  r_  r`  rb  rc  rd  re  rf  rh  r,   r,   r,   r-   r<  #  s"   M


/		&660'	,			
	r<  Ú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)r<  rB   rH   )r@   Úprinterr:   r,   r,   r-   Úmathml>  s   rl  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>

    rj  N)r<  rH   r=   r   ZtoprettyxmlÚprint)r@   rk  r:   rü   ÚxmlZ
pretty_xmlr,   r,   r-   Úprint_mathmlI  s   
ro  N)ri  )$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   r<  rl  ro  ZMathMLPrinterr,   r,   r,   r-   Ú<module>   sD    ?   R            '

$