o
    ݹiZ+                    @  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   R/home/ubuntu/veenaModal/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__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.   exprmathMLunistr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@   rO   rR   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
    _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ImpliesimpliesSymbolciMatrixSymbol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acotharccothasecarcsecasecharcsechacscarccscacscharccschloglnEqualityeq
UnequalityneqGreaterThangeqLessThanleqStrictGreaterThangtStrictLessThanltunion	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   oldrZ   )could_extract_minus_signr;   createElementappendChild
_print_Mulsympy.simplifyr   r   OnerF   as_coeff_mullenr   r   
_from_argsas_ordered_factors)	r.   rJ   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   rY   )	_as_ordered_termsrF   r   r;   r   r   appendr   pop)r.   rJ   r   argslastProcessed	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   TzAll 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   rF   )r.   rJ   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matrix	matrixrow)r;   r   rangerowscolsr   rF   )r.   mr   r   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   r^   r   r   )qr;   r   r   rB   strp)r.   r   r   xnum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   rF   r   )r.   r   r   x_1x_2r3   r3   r4   _print_Limit  s   

z!MathMLContentPrinter._print_Limitc                 C     | j dS )N
imaginaryir;   r   r.   r   r3   r3   r4   _print_ImaginaryUnit     z)MathMLContentPrinter._print_ImaginaryUnitc                 C  r   )N
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.htmlr^   u   φr;   r   r   rB   r.   r   r   r3   r3   r4   _print_GoldenRatio   s   z'MathMLContentPrinter._print_GoldenRatioc                 C  r   )N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   )N
notanumberr   r   r3   r3   r4   
_print_NaN0  r   zMathMLContentPrinter._print_NaNc                 C  r   )N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   uplimitr   )r;   r   r   r   rF   r   function)limitsr   	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   rB   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                   r4  r3   r3   r6  subr8  r3   r4   r9    r:  r#  zmml:msubzmml:msupzmml:msubsup)r;   r   r   rR   rQ   r   rB   )r.   symrs   r,  rQ   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   degreer^   )rP   expis_Rationalr   r;   r   r   r   rB   r   rF   baser   )r.   r   r   xmldegxmlcnr   r3   r3   r4   
_print_Pow  s$   


zMathMLContentPrinter._print_Powc                 C  ,   | j | |}|| j t| |S r:   r;   r   r   r   rB   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   rB   )r.   r   r   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   partialdiffr   r   rF  )
r;   r   r   r	   rJ   r   reversedvariable_countrF   r   )r.   r   r   diff_symbolr   r=  rZ   rF  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   rF   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   rF   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   rF   )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   rF   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   rF   )r.   seqdom_elementr(  r3   r3   r4   _print_list  s   z MathMLContentPrinter._print_listc                 C  rM  r:   rN  r.   r   rd  r3   r3   r4   
_print_int  rP  zMathMLContentPrinter._print_intc                 C  s,   | j d}|jD ]
}|| | q	|S )Nset)r;   r   r   r   rF   r\  r3   r3   r4   _print_FiniteSet  s   
z%MathMLContentPrinter._print_FiniteSetc                 C  >   | j d}|| j d |jD ]
}|| | q|S )Nr   setdiffr;   r   r   r   rF   r\  r3   r3   r4   _print_Complement  
   
z&MathMLContentPrinter._print_Complementc                 C  rj  )Nr   cartesianproductrl  r\  r3   r3   r4   _print_ProductSet  rn  z&MathMLContentPrinter._print_ProductSetc                 C  sZ   | j | |}|jD ]}| j d}|| | || q|| |j |S )Nr   )r;   r   r   	signaturer   rF   rJ   )r.   r   r   r   r   r3   r3   r4   _print_Lambda  s   
z"MathMLContentPrinter._print_Lambdar:   )-r6   r7   r8   rS   printmethodr   r   r   r   r   r   r   r   r   r  r  r  r
  r  r  r  r  r  r  r   rE  _print_MatrixSymbol_print_RandomSymbolrL  rO  rU  rZ  r]  r^  r_  rb  re  rg  _print_Implies
_print_Not
_print_Xorri  rm  rp  rr  r3   r3   r3   r4   rU   T   sV    B
#	8rU   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 ZCdd ZDdd ZEeEZFdd ZGdd ZHdd ZIdd ZJdd ZKdd ZLdd ZMdd ZNdd ZOeOZPeOZQdd ZRdd ZSdd ZTeT ZUZVdd ZWdd ZXdd ZYdd ZZdd Z[dd Z\dd Z]dd Z^dd Z_dd Z`dd Zadd Zbdd Zcdd Zddd Zedd Zfdd Zgdd Zhdd ZiddÄ Zjddń ZkekZlddǄ ZmddɄ Zndd˄ Zodd̈́ Zpddτ Zqddф Zrddӄ ZsddՄ Ztddׄ Zuddل Zvddۄ Zwdd݄ Zxdd߄ Zydd Zzdd Z{dd Z|dd Z}dd Z~dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd 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 ZdS (  MathMLPresentationPrinterzPrints an expression to the Presentation MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter3.html
    _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 )NrW   r]   mnLimitz&#x2192;r[   &dd;r_   rr   r*  rv   z&int;rw   z&#x2211;ry   rz   r{   r|   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"   r  &InvisibleTimes;rZ   &#xD7;dotr   ldotz&#x2024;)rP   
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  rF   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  rF   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  rF   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   rP   r   r   setAttributerF   r   r   r   r   r   r   rB   r   r  r   )rJ   r'  r   r   r   fracr   xdenr   r   r   yr   r+  r3   r4   multiply  s@   










z6MathMLPresentationPrinter._print_Mul.<locals>.multiplyr'  r)  -)r;   r   r   r   rB   )r.   rJ   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   rF   r   rB   )r.   rJ   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 )Nmtablemtrmtdr    r*   r)  r   ]r  r  r'  )	r;   r   r   r   r   r   rF   rP   rB   )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   rP   r  r   rF   r   rB   )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   rF   r   r  rP   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   rB   rF   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   rB   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*  r  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 )NrB  r   &#x2020;r;   r   r   rF   r   rB   r.   r   rB  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 )NrB  z	&#x1D49E;r   r;   r   r   rB   rF   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   )r6  r  r3   r3   r4   	<genexpr>  s    z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>r)  r   r   rB  rC  r   Tr  r}  r   )r;   r   r   r  allr   rB   rW  rF   r  r  r   )	r.   rJ   
intsymbolsr'  r)  r  rB  rC  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 )N
munderoverr   r   r   r)  r'  r~  )r  r  r;   r   rF   r   rB   r   r  r  r
   )r.   r   r  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/  r1  r3   r3   r4   r     r3  z:MathMLPresentationPrinter._print_Symbol.<locals>.translatec                   r4  r3   r3   r5  r8  r3   r4   r9    r:  z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>c                   r4  r3   r3   r;  r8  r3   r4   r9    r:  r*  r   rA  rB  rC  boldmathvariant)rR   rQ   r;   r   r   rB   r   r  )	r.   r=  styler,  rQ   r>  r?  r@  r   r3   rD  r4   rE    s2   


z'MathMLPresentationPrinter._print_Symbolc                 C  s   | j || jd dS )Nr!   )r  )rE  rP   )r.   r=  r3   r3   r4   rt    s   z-MathMLPresentationPrinter._print_MatrixSymbolc                 C  s2   | j d}|dd || |jd  |S )Nmenclosenotationtopr   )r;   r   r  r   rF   r   )r.   rJ   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   rB   )r.   oprJ   rowr)  r3   r3   r4   _print_operator_after  s   
z/MathMLPresentationPrinter._print_operator_afterc                 C     |  d|jd S )N!r   r  r   r.   rJ   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  linethickness0r   r   r'  )r;   r   r  r   rF   r   r  r  )r.   rJ   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   msqrtmrootr   r  rB  r`   r   )rG  rH  rg   r   r   rP   r;   r   r   rF   rI  is_negativer  r   r  )r.   r   r   r  r  r3   r3   r4   rL  1  s`   $




z$MathMLPresentationPrinter._print_Powc                 C  rM  r:   rN  r  r3   r3   r4   rO  g  rP  z'MathMLPresentationPrinter._print_Numberc                 C  s   | j d}|| j d | j d}|| j d | j d}|| || |j ||   || |j || |S )Nr)     ⟨   ⟩r'  )r;   r   r   rB   rF   re   r  rc   )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   rB  r)  r  )
r	   rJ   r   r;   r   rW  rX  r   rB   rF   )r.   r   r  r   dimr=  numr   xxr  mnumr'  r  r3   r3   r4   rZ  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   rP   r   rB   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   r{  r)  rB  10z+infz-inf)r   rS  rQ  rR  rP   r;   r   splitr   rB   r
  r  )r.   rJ   dpsstr_real	separatorr'  mantrG  r{  r)  rB  r3   r3   r4   rU    s<   








z&MathMLPresentationPrinter._print_Floatc                 C  s   | j d}| j d}| j d}|| j d || || |jd  || | j d}||   || |jd  ||   || |S )Nr'  rA  r*  Lir   r   )r;   r   r   rB   rF   r   r  r  )r.   rJ   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   rB   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   rB   	left_openrF   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  rF   r   )r.   rJ   rG  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  rF   r  rB   )r.   r   rJ   r  r*  r'  r3   r3   r4   _print_re_im  s   

z&MathMLPresentationPrinter._print_re_imc                 C  r  )Nu   ℜr   r"  r   r.   rJ   rG  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   rB   r   r   rF   )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   rB   )r.   rJ   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.   rJ   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   rm  @  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   rp  H  r/  z+MathMLPresentationPrinter._print_ProductSetc                 C     |  |jS r:   )
_print_setr   )r.   r2  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  rF   r  )r.   r2  r&  r  r   r(  r3   r3   r4   r7  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  rF   r  rB   )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>r8  r   r)  r  r   r  r  )sympy.vectorr>  zerorF   r  separater&  r;   r   r  
componentssortr   r   rB   r  r  )r.   rJ   r>  r&  r'  systemvect
inneritemsr   kvr)  mbracr3   r3   r4   _print_BasisDependentt  sJ   







z/MathMLPresentationPrinter._print_BasisDependentc                 C     t |jtd}| |dS )Nr8  z&#x2227;r:  r   r   r=  r.   rJ   r   r3   r3   r4   
_print_And     z$MathMLPresentationPrinter._print_Andc                 C  rM  )Nr8  z&#x2228;rN  rO  r3   r3   r4   	_print_Or  rQ  z#MathMLPresentationPrinter._print_Orc                 C  rM  )Nr8  z&#x22BB;rN  rO  r3   r3   r4   rx    rQ  z$MathMLPresentationPrinter._print_Xorc                 C  s   |  |jdS )Nz&#x21D2;)r=  r   r  r3   r3   r4   rv    s   z(MathMLPresentationPrinter._print_Impliesc                 C  rM  )Nr8  z&#x21D4;rN  rO  r3   r3   r4   _print_Equivalent  rQ  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   rB   r   r;  r  rF   r  )r.   r   r'  r)  r   r3   r3   r4   rw    s   

z$MathMLPresentationPrinter._print_Notc                 C  (   | j d}|| j | | |S Nr*  r;   r   r   rB   r   r.   r   r*  r3   r3   r4   _print_bool     z%MathMLPresentationPrinter._print_boolc                 C  rT  rU  rV  rW  r3   r3   r4   _print_NoneType  rY  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  rB   rF   r  )	r.   r2  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 )Nr8  r'  r)  )r:  r   r   r;   r   r   rB   r   funcr   r  )r.   rJ   r   r'  r)  r3   r3   r4   _hprint_variadic_function  s   
z3MathMLPresentationPrinter._hprint_variadic_functionc                 C  s6   | j d}|| d  || |jd  |S )NrB  r   )r;   r   r   r  rF   r   )r.   rJ   rB  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   rF   r`  rB   r   ra  )r.   r   r'  r   r3   r3   r4   rb    s   
z+MathMLPresentationPrinter._print_Relationalc                 C  rM  r:   rN  rf  r3   r3   r4   rg    rP  z$MathMLPresentationPrinter._print_intc                 C  s   | j d}|j\}}| j d}|dd || j |j|  || | j d}|dd || j |j || |S )NrA  r*  r  r  )r;   r   _idr  r   rB   _variable_names_name)r.   r   rA  indexrF  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 )NrA  moverr*  r  r  r)  ^)r;   r   rk  r  r   rB   _vector_namesrm  )r.   r   rA  rn  rF  rp  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 )Nrp  r*  r  r  r  r)  rq  r;   r   r  r   rB   )r.   r   rp  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   rB   r.   rJ   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   rB   r  _exprr   r.   rJ   r'  r)  r3   r3   r4   _print_CurlB     

z%MathMLPresentationPrinter._print_Curlc                 C  r  )Nr'  r)  r  r   r   r  r  r3   r3   r4   _print_DivergenceM  r  z+MathMLPresentationPrinter._print_Divergencec                 C  rv  )Nr'  r   r)  r   rw  rz  r3   r3   r4   
_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  r3   r3   r4   _print_Gradientc     
z)MathMLPresentationPrinter._print_Gradientc                 C  r  )Nr'  r)  r3  r   r  r  r3   r3   r4   _print_Laplaciank  r  z*MathMLPresentationPrinter._print_Laplacianc                 C  .   | j d}|dd || j d |S )Nr*  r  normalz&#x2124;rt  r  r3   r3   r4   _print_Integerss     z)MathMLPresentationPrinter._print_Integersc                 C  r  )Nr*  r  r  z&#x2102;rt  r  r3   r3   r4   _print_Complexesy  r  z*MathMLPresentationPrinter._print_Complexesc                 C  r  )Nr*  r  r  z&#x211D;rt  r  r3   r3   r4   _print_Reals  r  z&MathMLPresentationPrinter._print_Realsc                 C  r  )Nr*  r  r  &#x2115;rt  r  r3   r3   r4   _print_Naturals  r  z)MathMLPresentationPrinter._print_Naturalsc                 C  sV   | j d}| j d}|dd || j d || || tj |S )NrA  r*  r  r  r  )r;   r   r  r   rB   rF   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'  rB  )r   r;   r   r   rB   rF   )r.   rJ   shiftra   r  r  r  r7  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 )NrA  r*  r   r   r'  )r;   r   r   rB   rF   r   r   r  )r.   r   rQ   r<  r*  r'  r3   r3   r4   _print_number_function  s   

z0MathMLPresentationPrinter._print_number_functionc                 C     |  |dS )NBr  r   r3   r3   r4   _print_bernoulli  r   z*MathMLPresentationPrinter._print_bernoullic                 C  r  )Nr  r  r   r3   r3   r4   _print_catalan  r   z(MathMLPresentationPrinter._print_catalanc                 C  r  )NEr  r   r3   r3   r4   _print_euler  r   z&MathMLPresentationPrinter._print_eulerc                 C  r  )NFr  r   r3   r3   r4   _print_fibonacci  r   z*MathMLPresentationPrinter._print_fibonaccic                 C  r  )NLr  r   r3   r3   r4   _print_lucas  r   z&MathMLPresentationPrinter._print_lucasc                 C  r  )Nz&#x03B3;r  r   r3   r3   r4   _print_stieltjes  r   z*MathMLPresentationPrinter._print_stieltjesc                 C  r  )NTr  r   r3   r3   r4   _print_tribonacci  r   z+MathMLPresentationPrinter._print_tribonaccic                 C  s`   | j d}| j d}|| j d || | j d}|| j d || |S )Nrp  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   rt   rB  r'  r)  r  sympy.matricesrt   r   r;   r   r  r   r  rF   r  rB   r.   rJ   rt   matr7  r  r)  r3   r3   r4   _print_Adjoint     

z(MathMLPresentationPrinter._print_Adjointc                 C  r  )Nr   r  rB  r'  r)  r  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   r  rB  r'  r   )
r  rt   r   r;   r   r  r   r  rF   r  )r.   rJ   rt   r  r7  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   rB   r  r
   )r.   rJ   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   r  rB  r'  )r  rt   rI  rG  r;   r   r  r   r  rF   r  )r.   rJ   rt   rI  rG  r7  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
   rB   )r.   rJ   r   r   r   r)  r3   r3   r4   _print_HadamardProduct@  s   z0MathMLPresentationPrinter._print_HadamardProductc                 C  r  )Nr{  z&#x1D7D8r  r.   Zr   r3   r3   r4   _print_ZeroMatrixM  r  z+MathMLPresentationPrinter._print_ZeroMatrixc                 C  r  )Nr{  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   rF   r   r  rB   r  )r.   r   r'  symbolsr)  r3   r3   r4   rr  r  s   



z'MathMLPresentationPrinter._print_Lambdac                 C  s
   | j | S r:   )r  r   r3   r3   r4   _print_tuple  s   
z&MathMLPresentationPrinter._print_tuplec                 C  r6  r:   )rF   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 )NrA  r   r   )r;   r   r   rF   rI  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 )NrA  AtomTr  r'  )
r;   r   r   r  parentr   r   r  r  rF   )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   rB   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   rB   r  r   r   rF   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'  rA  r)  r  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'  rC  r)  Pr   r   r  r  r  r3   r3   r4   _print_jacobi     

z'MathMLPresentationPrinter._print_jacobic                 C  r  )Nr'  rC  r)  r  r   r   r   r  r  r3   r3   r4   _print_gegenbauer  r  z+MathMLPresentationPrinter._print_gegenbauerc                 C  r  )Nr'  rA  r)  r  r   r   r  r  r3   r3   r4   _print_chebyshevt  r  z+MathMLPresentationPrinter._print_chebyshevtc                 C  r  )Nr'  rA  r)  Ur   r   r  r  r3   r3   r4   _print_chebyshevu  r  z+MathMLPresentationPrinter._print_chebyshevuc                 C  r  )Nr'  rA  r)  r  r   r   r  r  r3   r3   r4   _print_legendre  r  z)MathMLPresentationPrinter._print_legendrec                 C  r  )Nr'  rC  r)  r  r   r   r   r  r  r3   r3   r4   _print_assoc_legendre  r  z/MathMLPresentationPrinter._print_assoc_legendrec                 C  r  )Nr'  rA  r)  r  r   r   r  r  r3   r3   r4   _print_laguerre  r  z)MathMLPresentationPrinter._print_laguerrec                 C  r  )Nr'  rC  r)  r  r   r   r   r  r  r3   r3   r4   _print_assoc_laguerre&  r  z/MathMLPresentationPrinter._print_assoc_laguerrec                 C  r  )Nr'  rA  r)  Hr   r   r  r  r3   r3   r4   _print_hermite2  r  z(MathMLPresentationPrinter._print_hermite)Fr:   )r   )r6   r7   r8   rS   rs  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   rE  rt  ru  r  r  r   r  r  rL  rO  r  rZ  r]  rU  r  r^  r  r   r!  _print_Determinantr"  r%  r&  r_  r*  r.  r0  rm  r4  rp  ri  r7  _print_frozensetr=  rL  rP  rR  rx  rv  rS  rw  rX  r  r  rZ  rg  ri  
_print_Min
_print_Maxrj  rb  rg  ro  rs  ru  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  _print_bellr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r3   r3   r3   r4   ry  #  s"   M


/		&660'	,			
	ry  contentc                 K  s$   |dkrt || S t|| S )zReturns the MathML representation of expr. If printer is presentation
    then prints Presentation MathML else prints content MathML.
    presentation)ry  rO   rU   )rJ   printerrC   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)ry  rU   rF   r   toprettyxmlprint)rJ   r  rC   r2  xml
pretty_xmlr3   r3   r4   print_mathmlI  s   
r  N)r  )$rS   
__future__r   typingr   sympy.core.mulr   sympy.core.singletonr   sympy.core.sortingr   sympy.core.sympifyr   sympy.printing.conventionsr   r	   sympy.printing.precedencer
   r   r   &sympy.printing.pretty.pretty_symbologyr   sympy.printing.printerr   r   mpmath.libmpr   r   r   rQ  r   rU   ry  r  r  MathMLPrinterr3   r3   r3   r4   <module>   sD    ?   R            '

$