
    ЦiV                      S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJrJr  SS	KJrJrJr  SS
KJr  SSKJrJr  SSKJrJrJr   " S S\5      r " S S\5      r " S S\5      r \" \5      SS j5       r!SS jr"\r#g)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                  V    \ rS rSr% SrSSSSSSSSSSSS	0 S
S.rS\S'   SS jrS rSr	g)MathMLPrinterBase   zVContains 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_numberszdict[str, Any]_default_settingsc                   ^ ^ [         R                  " T U5        SSKJnJn  U" 5       T l         " S SU5      mUU 4S jnUT R
                  l        g )Nr   )DocumentTextc                      \ rS rSrSS jrSrg)+MathMLPrinterBase.__init__.<locals>.RawText5   c                ~    U R                   (       a,  UR                  SR                  X R                   U5      5        g g )Nz{}{}{})datawriteformat)selfwriterindent	addindentnewls        T/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/sympy/printing/mathml.pywritexml4MathMLPrinterBase.__init__.<locals>.RawText.writexml6   s)    99LLD!IJ      N) r>   r>   )__name__
__module____qualname____firstlineno__r:   __static_attributes__r=   r<   r9   RawTextr.   5   s    Kr<   rD   c                D   > T" 5       nXl         TR                  Ul        U$ N)r1   domownerDocument)r1   rrD   r4   s     r9   createRawTextNode5MathMLPrinterBase.__init__.<locals>.createRawTextNode:   s    	AF"hhAOHr<   )r   __init__xml.dom.minidomr+   r,   rG   createTextNode)r4   settingsr+   r,   rJ   rD   s   `    @r9   rL   MathMLPrinterBase.__init__+   s@    x(2:	Kd 	K
	 #4r<   c                    [         R                  " X5      nUR                  5       nUR                  SS5      nUR	                  5       nU$ )z"
Prints the expression as MathML.
asciixmlcharrefreplace)r   _printtoxmlencodedecode)r4   exprmathMLunistrxmlbstrress         r9   doprintMathMLPrinterBase.doprintB   s?     +--)<=nn
r<   )rG   rF   )
r?   r@   rA   rB   __doc__r)   __annotations__rL   r]   rC   r=   r<   r9   r   r      sL    
 !#'#%-)~ "4.r<   r   c                     \ rS rSrSrSrS rS rS)S jrS r	S	 r
S
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r\r\rS rS rS rS r S r!S r"S  r#S! r$S" r%S# r&\#r'\#r(\#r)S$ r*S% r+S& r,S' r-S(r.g)*MathMLContentPrinterM   zuPrints an expression to the Content MathML markup language.

References: https://www.w3.org/TR/MathML2/chapter4.html
_mathml_contentc                   0 SS_SS_SS_SS_S	S_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 S S	_S!S"_S#S#_S$S$_S%S%_S&S&_S'S'_S(S(_S)S)_S*S*_S+S+_S,S,_S-S-_S.S._S/S0_S1S2_S3S4_E0 S5S6_S7S8_S9S:_S;S8_S<S=_S>S?_S@SA_SBSC_SDSE_SFSG_SHSI_SJSK_SLSM_SNSO_SPSQ_SRSS_STSU_ESVSWSX.EnUR                   R                   H  nUR                  nXB;   d  M  X$   s  $    UR                   R                  nUR                  5       $ )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__r?   lower)r4   e	translateclsns        r9   
mathml_tagMathMLContentPrinter.mathml_tagT   s   6
66
76
 &6
 d	6

 46
 76
 56
 56
 56
 56
 $6
 56
 56
 y6
 d6
  D!6
" D#6
$ %6
& 5'6
( 5)6
* 5+6
, 5-6
. 5/6
0 516
2 536
4 F56
6 F76
8 F96
: F;6
< F=6
> F?6
@ HA6
B YC6
D HE6
F YG6
H HI6
J YK6
L XM6
N HO6
P YQ6
R HS6
T YU6
V HW6
X YY6
Z 4[6
\ ]6
^ %_6
` 5a6
b c6
d  e6
f dg6
h 'k6
	p ;;&&CA~ |# '
 KK  wwyr<   c                t   UR                  5       (       ah  U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U R	                  U* 5      5        U$ SSKJn  U" U5      u  pEU[        R                  La  U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U R                  U5      5        UR                  U R                  U5      5        U$ UR                  5       u  pgU[        R                  L a#  [        U5      S:X  a  U R                  US   5      $ U R                  S:w  a$  [        R                  " U5      R                  5       nU R                  R                  S5      nUR                  U R                  R                  S5      5        US:w  a   UR                  U R                  U5      5        U H#  nUR                  U R                  U5      5        M%     U$ )	Napplyminusr   fractiondivide   oldri   )could_extract_minus_signrG   createElementappendChild
_print_Mulsympy.simplifyr   r   OnerT   as_coeff_mullenr   r   
_from_argsas_ordered_factors)	r4   rX   xr   numerdenomcoefftermsterms	            r9   r   MathMLContentPrinter._print_Mul   s   ((**&&w/AMM$((009:MM$//4%01H+~&&w/AMM$((00:;MM$++e,-MM$++e,-H((*AEE>c%jAo ;;uQx((::NN5)<<>EHH""7+	dhh,,W56A:MM$++e,-DMM$++d+, r<   Nc                b   U R                  XS9nU R                  US   5      n/ nUSS   H  nUR                  5       (       a  U R                  R	                  S5      nUR                  U R                  R	                  S5      5        UR                  U5        UR                  U R                  U* 5      5        UnXcS   :X  a  UR                  U5        M  M  UR                  U5        U R                  U5      nXcS   :X  d  M  UR                  U R                  U5      5        M     [        U5      S:X  a  U$ U R                  R	                  S5      nUR                  U R                  R	                  S5      5        U(       a)  UR                  UR                  S5      5        U(       a  M)  U$ )Nr   r   r   r   r   rh   )	_as_ordered_termsrT   r   rG   r   r   appendr   pop)r4   rX   r   argslastProcessed	plusNodesargr   s           r9   
_print_AddMathMLContentPrinter._print_Add   sc   %%d%8DG,	8C++--HH**73dhh44W=>m,dkk3$/0 !r(?$$]3 #   / $C 0r(?$$T[[%56   y>Q  HH""7+	dhh,,V45MM)--*+ ir<   c                b   UR                   S   R                  S:w  a  [        S5      eU R                  R	                  S5      n[        UR                   5       H  u  nu  pEU[        UR                   5      S-
  :X  aB  US:X  a<  U R                  R	                  S5      nUR                  U R                  U5      5        O[U R                  R	                  S5      nUR                  U R                  U5      5        UR                  U R                  U5      5        UR                  U5        M     U$ )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
ValueErrorrG   r   	enumerater   r   rT   )r4   rX   rootir   cr   s          r9   _print_Piecewise%MathMLContentPrinter._print_Piecewise   s    99R=%  / 0 0
 xx%%k2"499-IAvC		NQ&&19..{;!!$++a.1..w7!!$++a.1!!$++a.1U# . r<   c           	     L   U R                   R                  S5      n[        UR                  5       Ho  nU R                   R                  S5      n[        UR                  5       H'  nUR                  U R                  XU4   5      5        M)     UR                  U5        Mq     U$ )Nmatrix	matrixrow)rG   r   rangerowscolsr   rT   )r4   mr   r   x_rjs         r9   _print_MatrixBase&MathMLContentPrinter._print_MatrixBase   s|    HH""8,qvvA((((5C166]AdG 45 #MM#	 
 r<   c                   UR                   S:X  aZ  U R                  R                  S5      nUR                  U R                  R	                  [        UR                  5      5      5        U$ U R                  R                  S5      nUR                  U R                  R                  S5      5        U R                  R                  S5      nUR                  U R                  R	                  [        UR                  5      5      5        U R                  R                  S5      nUR                  U R                  R	                  [        UR                   5      5      5        UR                  U5        UR                  U5        U$ )Nr   rm   r   r   )qrG   r   r   rN   strp)r4   r   r   xnumxdenoms        r9   _print_Rational$MathMLContentPrinter._print_Rational   s   33!8&&t,AMM$((11#acc(;<HHH""7+	dhh,,X67xx%%d+00QSS:;''-488223qss8<=	d	fr<   c                l   U R                   R                  S5      nUR                  U R                   R                  U R                  U5      5      5        U R                   R                  S5      nU R                   R                  S5      nUR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U5        UR                  U R	                  UR
                  S   5      5        U$ )Nr   bvarlowlimitr      r   )rG   r   r   r   rT   r   )r4   r   r   x_1x_2s        r9   _print_Limit!MathMLContentPrinter._print_Limit  s    HH""7+	dhh,,T__Q-?@Ahh$$V,hh$$Z0AFF1I./AFF1I./	c	c	dkk!&&),-r<   c                8    U R                   R                  S5      $ )N
imaginaryirG   r   r4   r   s     r9   _print_ImaginaryUnit)MathMLContentPrinter._print_ImaginaryUnit      xx%%l33r<   c                8    U R                   R                  S5      $ )N
eulergammar  r  s     r9   _print_EulerGamma&MathMLContentPrinter._print_EulerGamma  r  r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )zoWe use unicode #x3c6 for Greek letter phi as defined here
https://www.w3.org/2003/entities/2007doc/isogrk1.htmlrm   u   φrG   r   r   rN   r4   r   r   s      r9   _print_GoldenRatio'MathMLContentPrinter._print_GoldenRatio  s9     HH""4(	dhh--.JKLr<   c                8    U R                   R                  S5      $ )Nexponentialer  r  s     r9   _print_Exp1 MathMLContentPrinter._print_Exp1   s    xx%%n55r<   c                8    U R                   R                  S5      $ )Npir  r  s     r9   	_print_PiMathMLContentPrinter._print_Pi#  s    xx%%d++r<   c                8    U R                   R                  S5      $ )Ninfinityr  r  s     r9   _print_Infinity$MathMLContentPrinter._print_Infinity&      xx%%j11r<   c                8    U R                   R                  S5      $ )N
notanumberr  r  s     r9   
_print_NaNMathMLContentPrinter._print_NaN)  r  r<   c                8    U R                   R                  S5      $ )Nemptysetr  r  s     r9   _print_EmptySet$MathMLContentPrinter._print_EmptySet,  r1  r<   c                8    U R                   R                  S5      $ )Ntruer  r  s     r9   _print_BooleanTrue'MathMLContentPrinter._print_BooleanTrue/  s    xx%%f--r<   c                8    U R                   R                  S5      $ )Nfalser  r  s     r9   _print_BooleanFalse(MathMLContentPrinter._print_BooleanFalse2  s    xx%%g..r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U R                   R                  S5      5        U$ )Nr   r   r.  )rG   r   r   r"  s      r9   _print_NegativeInfinity,MathMLContentPrinter._print_NegativeInfinity5  sQ    HH""7+	dhh,,W56	dhh,,Z89r<   c                r   ^ ^^ UUU 4S jm[        TR                  5      nUR                  5         T" U5      $ )Nc                2  > TR                   R                  S5      nUR                  TR                   R                  TR                  T5      5      5        TR                   R                  S5      nUR                  TR	                  U S   S   5      5        UR                  U5        [        U S   5      S:X  a  TR                   R                  S5      nUR                  TR	                  U S   S   5      5        UR                  U5        TR                   R                  S5      nUR                  TR	                  U S   S   5      5        UR                  U5        [        U S   5      S:X  aR  TR                   R                  S5      nUR                  TR	                  U S   S   5      5        UR                  U5        [        U 5      S:X  a,  UR                  TR	                  TR                  5      5        U$ UR                  T" U SS  5      5        U$ )	Nr   r  r      r  r   uplimitr  )rG   r   r   r   rT   r   function)limitsr   	bvar_elemlow_elemup_elemr   
lime_recurr4   s        r9   rN  8MathMLContentPrinter._print_Integral.<locals>.lime_recur<  s   &&w/AMM$((001CDE..v6I!!$++fQil";<MM)$6!9~"8811*=$$T[[1%>?h'((00;##DKKq	!$=>g&6!9~"((00;##DKKq	!$=>g&6{adkk!**56 H j45Hr<   )listrJ  reverse)r4   r   rJ  rN  s   `` @r9   _print_Integral$MathMLContentPrinter._print_Integral;  s,    	0 ahh&!!r<   c                $    U R                  U5      $ rF   )rR  r  s     r9   
_print_SumMathMLContentPrinter._print_SumX  s     ##A&&r<   c                Z  ^  T R                   R                  T R                  U5      5      nU 4S jnS n[        UR                  5      u  pVnU" U5      nU Vs/ s H
  o" U5      PM     nnU V	s/ s H
  o" U	5      PM     nn	T R                   R                  S5      n
U
R                  T R                   R                  U5      5        U(       d  U(       d,  UR                  T R                   R                  U5      5        U$ T R                   R                  S5      nUR                  U
5        UR                  U" U5      5        UR                  U5         U$ U(       dV  T R                   R                  S5      nUR                  U
5        UR                  U" U5      5        UR                  U5        U$ T R                   R                  S5      nUR                  U
5        UR                  U" U5      5        UR                  U" U5      5        UR                  U5        U$ s  snf s  sn	f )Nc                |  > [        U 5      S:  a  TR                  R                  S5      n[        U 5       H  u  p#US:  aV  TR                  R                  S5      nUR	                  TR                  R                  S5      5        UR	                  U5        TR                  R                  S5      nUR	                  TR                  R                  U5      5        UR	                  U5        M     U$ TR                  R                  S5      nUR	                  TR                  R                  U S   5      5        U$ )Nr   zmml:mrowr   zmml:mo mml:mir   rG   r   r   r   rN   itemsmrowr   itemmomir4   s         r9   join0MathMLContentPrinter._print_Symbol.<locals>.join`  s    5zA~xx--j9(/GA1u!XX33H=txx'>'>s'CD((,//9BNN488#:#:4#@A$$R(  0 XX++H5txx66uQx@A	r<   c                F    U [         ;   a  [         R                  " U 5      $ U $ rF   r   getss    r9   r   5MathMLContentPrinter._print_Symbol.<locals>.translater       M!$((++r<   rZ  zmml:msubzmml:msupzmml:msubsup)rG   r   r   r	   namer   rN   )r4   symr   rb  r   rk  superssubssupsubmnamemsubmsupmsubsups   `             r9   _print_Symbol"MathMLContentPrinter._print_Symbol]  s   XX##DOOC$89	$	 -SXX6d,23FS)C.F3*./$3	#$/&&x0$((11$78txx66t<=$ 	! xx--j9  '  d,t$ 	 xx--j9  '  f.t$ 	 ((00?##E*##DJ/##DL1w'	3 4/s   H#0H(c                F   U R                   S   (       Gaa  UR                  R                  (       GaE  UR                  R                  S:X  Ga*  U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  R                  S:w  a  U R                  R                  S5      nU R                  R                  S5      nUR                  U R                  R                  [        UR                  R                  5      5      5        UR                  U5        UR                  U5        UR                  U R                  UR                  5      5        U$ U R                  R                  S5      nU R                  R                  U R                  U5      5      nUR                  U5        UR                  U R                  UR                  5      5        UR                  U R                  UR                  5      5        U$ )Nr&   r   r   r   r  degreerm   )	_settingsexpis_Rationalr  rG   r   r   r  rN   r  rT   baser   )r4   r   r   xmldegxmlcnr  s         r9   
_print_PowMathMLContentPrinter._print_Pow  sl    NN?++0A0A0AEEGGqL&&w/AMM$((0089uuww!|//9..t4!!$(("9"9#aeegg,"GH""5)f%MM$++aff-.HHH""7+hh$$T__Q%78	c	dkk!&&)*	dkk!%%()r<   c                    U R                   R                  U R                  U5      5      nUR                  U R                   R	                  [        U5      5      5        U$ rF   rG   r   r   r   rN   r  r"  s      r9   _print_Number"MathMLContentPrinter._print_Number  C    HH""4??1#56	dhh--c!f56r<   c                    U R                   R                  U R                  U5      5      n[        UR                  [        UR                  5      5      nUR                  U R                   R                  U5      5        U$ rF   )	rG   r   r   mlib_to_str_mpf_r   _precr   rN   )r4   r   r   repr_es       r9   _print_Float!MathMLContentPrinter._print_Float  sX    HH""4??1#56QWWhqww&78	dhh--f56r<   c                   U R                   R                  S5      nU R                  U5      n[        UR                  5      (       a  SnUR                  U R                   R                  U5      5        U R                   R                  S5      n[        UR                  5       H  u  pVUR                  U R                  U5      5        US:  d  M-  U R                   R                  S5      nUR                  U R                  [        U5      5      5        UR                  U5        M     UR                  U5        UR                  U R                  UR                  5      5        U$ )Nr   partialdiffr  r   rx  )
rG   r   r   r
   rX   r   reversedvariable_countrT   r   )r4   r   r   diff_symbolr  rl  ri   rx  s           r9   _print_Derivative&MathMLContentPrinter._print_Derivative  s   HH""7+ooa(AFF##'K	dhh,,[9:hh$$V,"1#3#34JCOODKK,-qy//9""4;;wu~#>?' 5 	
c	dkk!&&)*r<   c                   U R                   R                  S5      nUR                  U R                   R                  U R                  U5      5      5        UR                   H#  nUR                  U R                  U5      5        M%     U$ Nr   )rG   r   r   r   r   rT   r4   r   r   r   s       r9   _print_Function$MathMLContentPrinter._print_Function  sb    HH""7+	dhh,,T__Q-?@A66CMM$++c*+ r<   c                    U R                   R                  U R                  U5      5      nUR                   H#  nUR	                  U R                  U5      5        M%     U$ rF   )rG   r   r   r   r   rT   r  s       r9   _print_Basic!MathMLContentPrinter._print_Basic  sG    HH""4??1#5666CMM$++c*+ r<   c                   U R                   R                  S5      nU R                   R                  U R                  U5      5      nUR                  U5        UR                   H#  nUR                  U R                  U5      5        M%     U$ r  )rG   r   r   r   r   rT   )r4   r   r   r  r   s        r9   _print_AssocOp#MathMLContentPrinter._print_AssocOp  sg    HH""7+hh$$T__Q%78	c66CMM$++c*+ r<   c                V   U R                   R                  S5      nUR                  U R                   R                  U R                  U5      5      5        UR                  U R	                  UR
                  5      5        UR                  U R	                  UR                  5      5        U$ r  )rG   r   r   r   rT   lhsrhsr"  s      r9   _print_Relational&MathMLContentPrinter._print_Relational  sq    HH""7+	dhh,,T__Q-?@A	dkk!%%()	dkk!%%()r<   c                    U R                   R                  S5      nU H#  nUR                  U R                  U5      5        M%     U$ )z_MathML reference for the <list> element:
https://www.w3.org/TR/MathML2/chapter4.html#contm.listrP  rG   r   r   rT   )r4   seqdom_elementr_  s       r9   _print_list MathMLContentPrinter._print_list  s?     hh,,V4D##DKK$56 r<   c                    U R                   R                  U R                  U5      5      nUR                  U R                   R	                  [        U5      5      5        U$ rF   r  r4   r  r  s      r9   
_print_intMathMLContentPrinter._print_int  F    hh,,T__Q-?@ 7 7A ?@r<   c                    U R                   R                  S5      nUR                   H#  nUR                  U R	                  U5      5        M%     U$ )NsetrG   r   r   r   rT   r  s       r9   _print_FiniteSet%MathMLContentPrinter._print_FiniteSet  s>    HH""5)66CMM$++c*+ r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                   H#  nUR                  U R	                  U5      5        M%     U$ )Nr   setdiffrG   r   r   r   rT   r  s       r9   _print_Complement&MathMLContentPrinter._print_Complement   sY    HH""7+	dhh,,Y7866CMM$++c*+ r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                   H#  nUR                  U R	                  U5      5        M%     U$ )Nr   cartesianproductr  r  s       r9   _print_ProductSet&MathMLContentPrinter._print_ProductSet  sZ    HH""7+	dhh,,-?@A66CMM$++c*+ r<   c                l   U R                   R                  U R                  U5      5      nUR                   HO  nU R                   R                  S5      nUR	                  U R                  U5      5        UR	                  U5        MQ     UR	                  U R                  UR                  5      5        U$ )Nr  )rG   r   r   	signaturer   rT   rX   )r4   r   r   r   r  s        r9   _print_Lambda"MathMLContentPrinter._print_Lambda  s     HH""4??1#56;;C((((0COODKK,-MM#  	
dkk!&&)*r<   r=   rF   )/r?   r@   rA   rB   r_   printmethodr   r   r   r   r  r  r  r  r  r#  r'  r+  r/  r4  r8  r<  r@  rC  rR  rU  ru  _print_MatrixSymbol_print_RandomSymbolr  r  r  r  r  r  r  r  r  r  _print_Implies
_print_Not
_print_Xorr  r  r  r  rC   r=   r<   r9   rb   rb   M   s     $K@D!F8*$446,242./":'
6p ('.
&
 $NJJ	r<   rb   c                  L   \ rS rSrSrSrS rSS jrS rSS jr	S	 r
SS
 jrS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rSS jrS r\r S r!S  r"S! r#S" r$S# r%S$ r&S% r'S& r(S' r)S( r*S) r+S* r,S+ r-S, r.S- r/SS. jr0\0r1S/ r2SS0 jr3SS1 jr4S2 r5S3 r6S4 r7S5 r8S6 r9S7 r:S8 r;S9 r<S: r=\=r>S; r?S< r@S= rAS> rBS? rCS@ rDSA rESB rFSC rG\GrH\GrISD rJSE rKSF rL\L=rMrNSG rOSH rPSI rQSJ rRSK rSSL rTSM rUSN rVSO rWSP rXSQ rYSR rZSS r[ST r\SU r]SV r^SW r_SX r`SY raSZ rbS[ rc\crdS\ reS] rfS^ rgS_ rhS` riSa rjSb rkSc rlSd rmSe rnSf roSg rpSh rqSi rrSj rsSk rtSl ruSm rvSn rwSo rxSp rySq rzSr r{Ss r|St r}Su r~Sv rSw rSx rSy rSz rS{ rS| rS} rS~ rS rS rS rS rSrg)MathMLPresentationPrinteri  zzPrints an expression to the Presentation MathML markup language.

References: https://www.w3.org/TR/MathML2/chapter3.html
_mathml_presentationc                  ^  0 SS_SS_SS_SS_SS	_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_0 SS_S S_S!S"_S#S$_S%S&_S'S(_S)S*_S+S,_S-S._S/S0_S1S2_S3S4_S5S6_S7S8_S9S8_S:S;_S<S=_ES>S?S@SASBSCSDSESFS@SASGSHSISJ.EnU 4SK jnUR                   R                   H  nUR                  nXR;   d  M  X%   s  $    UR                   R                  SL:X  a  U" 5       $ UR                   R                  nUR                  5       $ )Mrf   rl   mnLimitz&#x2192;rj   &dd;rn   r   ra  r   z&int;r   z&#x2211;r   r   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                 2  > T R                   S   b  T R                   S   S:X  a  gT R                   S   S:X  a  gT R                   S   S:X  a  gT R                   S   S:X  a  g	[        T R                   S   [        5      (       d  [        eT R                   S   $ )
Nr%   r  &InvisibleTimes;ri   &#xD7;dotr   ldotz&#x2024;)ry  
isinstancer  	TypeError)r4   s   r9   mul_symbol_selectionBMathMLPresentationPrinter.mathml_tag.<locals>.mul_symbol_selectionX  s    |,4NN<0F:)-8-6-7!| <cBB~~l33r<   r   r   )r4   r   r   r  r   r   s   `     r9   r   $MathMLPresentationPrinter.mathml_tag#  sA   1
d1
Z1
 &1
 4	1

 d1
 1
 :1
 51
 51
 51
 51
 H1
 Y1
 H1
 Y1
  H!1
" Y#1
$ H%1
& X'1
( )1
* *+1
, :-1
. 
/1
0  11
2 c31
4 	51
6 I71
8 Y91
: );1
< )=1
> )?1
@ YA1
B yC1
D yE1
F !#"!#((a1
	f	4 ;;&&CA~ |# '
 ;;5('))KK  wwyr<   c                    [        U5      nXB:  d  U(       dB  XB::  a=  U R                  R                  S5      nUR                  U R	                  U5      5        U$ U R	                  U5      $ Nmfenced)r   rG   r   r   rT   )r4   r_  levelstrictprec_valbracs         r9   parenthesize&MathMLPresentationPrinter.parenthesizep  sX    )$/v83D88)))4DT[[./K;;t$$r<   c                H  ^  U 4S jnT R                   R                  S5      nUR                  5       (       ab  T R                   R                  S5      nUR                  T R                   R	                  S5      5        UR                  U5        U" U* U5      nU$ U" X5      nU$ )Nc                "  > SSK Jn  U" U 5      u  p4U[        R                  La  TR                  R                  S5      nTR                  S   (       a*  [        [        U 5      5      S:  a  UR                  SS5        TR                  U5      nTR                  U5      nUR                  U5        UR                  U5        UR                  U5        U$ U R                  5       u  pU[        R                  L a4  [        U	5      S:X  a%  UR                  TR                  U	S   5      5        U$ TR                  S	:w  a$  [        R                  " U	5      R!                  5       n	US:w  a  TR                  U5      n
TR                  R                  S
5      nUR                  TR                  R#                  TR%                  U 5      5      5        UR                  U
5        UR                  U5        U	 H  nUR                  TR'                  U[(        S   5      5        XS   :X  a  M5  TR                  R                  S
5      nUR                  TR                  R#                  TR%                  U 5      5      5        UR                  U5        M     U$ )Nr   r   mfracr      bevelledr;  r   r   r`  r   r   )r   r   r   r   rG   r   ry  r   r  setAttributerT   r   r   r   r   r   r   rN   r   r  r   )rX   r^  r   r   r   fracr	  xdenr   r   r   yr   r4   s                r9   multiply6MathMLPresentationPrinter._print_Mul.<locals>.multiply{  s   /#D>LEAEE!xx--g6>>"34SY!9K%%j&9{{5){{5)  &  &  &,,.LE~#e*/  U1X!67zzU"u-@@BzKK&HH**40dhh55dood6KLM  #  #  !2!24E9J!KLRy(..t4AMM$(("9"9$//$:O"PQ$$Q'  Kr<   r^  r`  -)rG   r   r   r   rN   )r4   rX   r  r^  r   s   `    r9   r   $MathMLPresentationPrinter._print_Muly  s    !	D xx%%f-((**&&t,AMM$((11#67QTE4(D  D'Dr<   Nc                   U R                   R                  S5      nU R                  XS9nUR                  U R	                  US   5      5        USS   H  nUR                  5       (       aX  U R                   R                  S5      nUR                  U R                   R                  S5      5        U R	                  U* 5      nOVU R                   R                  S5      nUR                  U R                   R                  S5      5        U R	                  U5      nUR                  U5        UR                  U5        M     U$ )Nr^  r   r   r   r`  r  +)rG   r   r   r   rT   r   rN   )r4   rX   r   r^  r   r   r   r  s           r9   r   $MathMLPresentationPrinter._print_Add  s   xx%%f-%%d%8T!W-.8C++--HH**40dhh55c:;KK% HH**40dhh55c:;KK$QQ  r<   c           	        U R                   R                  S5      n[        UR                  5       H  nU R                   R                  S5      n[        UR                  5       HS  nU R                   R                  S5      nUR                  U R                  XU4   5      5        UR                  U5        MU     UR                  U5        M     U R                  S   S:X  a  U$ U R                   R                  S5      nU R                  S   S:X  a$  UR                  SS	5        UR                  S
S5        UR                  U5        U$ )Nmtablemtrmtdr#   r>   r  r   close]open)	rG   r   r   r   r   r   rT   ry  r  )r4   r   tabler   r   r  r  r   s           r9   r  +MathMLPresentationPrinter._print_MatrixBase  s	   &&x0qvvA&&u-A166]HH**51dkk!qD'23a  # a   >>+&",Lxx%%i0>>+&#-gs+fc*r<   c                   UR                   S:  a  UR                   * nOUR                   nU R                  R                  S5      nU(       d  U R                  S   (       a  UR	                  SS5        UR                  U R                  U5      5        UR                  U R                  UR                  5      5        UR                   S:  a  U R                  R                  S5      nU R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U5        UR                  U5        U$ U$ )	Nr   r  r   r  r;  r^  r`  r  )	r  rG   r   ry  r  r   rT   r  rN   )r4   r   foldedr  r   r^  r`  s          r9   _get_printed_Rational/MathMLPresentationPrinter._get_printed_Rational  s    337AAHH""7+T^^$56NN:v.	dkk!n%	dkk!##&'33788))&1D''-BNN48822378R QKHr<   c                    UR                   S:X  a  U R                  UR                  5      $ U R                  XR                  S   5      $ )Nr   r   )r  rT   r  r  ry  r  s     r9   r  )MathMLPresentationPrinter._print_Rational  s;    33!8;;qss##))!^^<M-NOOr<   c                x   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        U R                   R                  S5      nU R	                  UR
                  S   5      nU R                   R                  S5      nUR                  U R                   R                  U R                  U5      5      5        U R	                  UR
                  S   5      nUR                  U5        UR                  U5        UR                  U5        UR                  U5        UR                  U5        UR                  U5        UR                  U R	                  UR
                  S   5      5        U$ )	Nr^  munderra  limr   r`  r  r   )rG   r   r   rN   rT   r   r   )	r4   r   r^  r#  ra  r   r  arrowr  s	            r9   r  &MathMLPresentationPrinter._print_Limit  sE   xx%%f-''1XX##D)
txx..u56HH""6*kk!&&)$&&t,$((11$//!2DEFkk!&&)$	c	e	c21 QVVAY/0r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  z&ImaginaryI;r!  r"  s      r9   r  .MathMLPresentationPrinter._print_ImaginaryUnit  s6    HH""4(	dhh--n=>r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  r  r!  r"  s      r9   r#  ,MathMLPresentationPrinter._print_GoldenRatio  6    HH""4(	dhh--i89r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  z&ExponentialE;r!  r"  s      r9   r'  %MathMLPresentationPrinter._print_Exp1	  s7    HH""4(	dhh--.>?@r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  z&pi;r!  r"  s      r9   r+  #MathMLPresentationPrinter._print_Pi  s6    HH""4(	dhh--f56r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  &#x221E;r!  r"  s      r9   r/  )MathMLPresentationPrinter._print_Infinity  6    HH""4(	dhh--j9:r<   c                ,   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        U R	                  U5      nUR                  U5        UR                  U5        U$ )Nr^  r`  r  )rG   r   r   rN   r/  )r4   r   r^  r  r   s        r9   rC  1MathMLPresentationPrinter._print_NegativeInfinity  sv    xx%%f-HH""4(	dhh--c23  #r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  z&#x210F;r!  r"  s      r9   _print_HBar%MathMLPresentationPrinter._print_HBar!  r3  r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  r  r!  r"  s      r9   r  +MathMLPresentationPrinter._print_EulerGamma&  r+  r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  TribonacciConstantr!  r"  s      r9   _print_TribonacciConstant3MathMLPresentationPrinter._print_TribonacciConstant+  s7    HH""4(	dhh--.BCDr<   c                    U R                   R                  S5      nUR                  U R                  UR                  S   5      5        UR                  U R                   R                  S5      5        U$ )Nrs  r   &#x2020;rG   r   r   rT   r   rN   r4   r   rs  s      r9   _print_Dagger'MathMLPresentationPrinter._print_Dagger0  sW    xx%%f-QVVAY/000<=r<   c                   U R                   R                  S5      nUR                  U R                  UR                  S   5      5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R                  UR                  S   5      5        U$ )Nr^  r   r`  z&#x2208;r   rA  )r4   r   r^  r`  s       r9   _print_Contains)MathMLPresentationPrinter._print_Contains6  s    xx%%f-QVVAY/0XX##D)
txx..z:;QVVAY/0r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  z&#x210B;r!  r"  s      r9   _print_HilbertSpace-MathMLPresentationPrinter._print_HilbertSpace?  r3  r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U R	                  UR
                  S   5      5        U$ )Nrs  z	&#x1D49E;r   rG   r   r   rN   rT   r   rB  s      r9   _print_ComplexSpace-MathMLPresentationPrinter._print_ComplexSpaceD  sW    xx%%f-00=>QVVAY/0r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  z&#x2131;r!  r"  s      r9   _print_FockSpace*MathMLPresentationPrinter._print_FockSpaceJ  r3  r<   c                6   SSSS.nU R                   R                  S5      n[        UR                  5      S::  a  [	        S UR                   5       5      (       an  U R                   R                  S5      nUR                  U R                   R                  U[        UR                  5         5      5        UR                  U5        GO[        UR                  5       GHo  nU R                   R                  S5      nUR                  U R                   R                  US	   5      5        [        U5      S	:X  a  UR                  U5        [        U5      S
:X  a`  U R                   R                  S5      nUR                  U5        UR                  U R                  US	   5      5        UR                  U5        [        U5      S:X  d  M  U R                   R                  S5      nUR                  U5        UR                  U R                  US	   5      5        UR                  U R                  US
   5      5        UR                  U5        GMr     UR                  U R                  UR                  [        S   SS95        [        UR                  5       H|  nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R                  US   5      5        M~     U$ )Nz&#x222B;z&#x222C;z&#x222D;)r   r  rG  r^  rG  c              3  >   #    U  H  n[        U5      S :H  v   M     g7f)r   N)r   ).0r$  s     r9   	<genexpr><MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>T  s     (N+3SQ+s   r`  r   r  rs  rt  r   Tr  r  r   )rG   r   r   rJ  allr   rN   r  rT   r  rI  r   )	r4   rX   
intsymbolsr^  r`  r$  rs  rt  ds	            r9   rR  )MathMLPresentationPrinter._print_IntegralP  s`   #
zB
xx%%f-t{{q S(N$++(N%N%N''-BNN48822:c$++>N3OPQR   ,XX++D1txx66z!}EFs8q=$$R(s8q=8811&9D$$R($$T[[Q%89$$T*s8q="hh44Y?G''+''CF(;<''CF(;<$$W- -" 	**4==*U:K26 + 8 	9 DKK(C&&t,AMM$((11&9:QT[[Q01	 )
 r<   c                   [        UR                  5      nU R                  R                  S5      nU R	                  US   S   5      nU R	                  US   S   5      nU R                  R                  S5      nUR                  U R                  R                  U R                  U5      5      5        U R                  R                  S5      nU R	                  US   S   5      nU R                  R                  S5      n	U	R                  U R                  R                  S5      5        UR                  U5        UR                  U	5        UR                  U5        UR                  U5        UR                  U5        UR                  U5        U R                  R                  S5      n
U
R                  U5        [        [        UR                  5      5      S:X  a,  U
R                  U R	                  UR                  5      5        U
$ U R                  R                  S5      nUR                  U R	                  UR                  5      5        U
R                  U5        U
$ )	N
munderoverr   r   r  r`  r^  r  r  )rP  rJ  rG   r   rT   r   rN   r   r   r  rI  )r4   r   rJ  subsuprL  rM  summandlowvarequalr^  fences               r9   rU  $MathMLPresentationPrinter._print_Sumv  s   ahh''5;;vay|,++fQil+((((.DHH33DOOA4FGHhh$$V,kk&)A,'&&t,$((11#67!7#37#xx%%f- s1::1$T[[45 	 HH**95Edkk!**56U#r<   c                  ^  U 4S jnS n[        UR                  5      u  pVnU" U5      nU Vs/ s H
  o" U5      PM     nnU V	s/ s H
  o" U	5      PM     nn	T R                  R                  S5      n
U
R	                  T R                  R                  U5      5        [        U5      S:X  aV  [        U5      S:X  a  U
nOT R                  R                  S5      nUR	                  U
5        UR	                  U" U5      5        O[        U5      S:X  aD  T R                  R                  S5      nUR	                  U
5        UR	                  U" U5      5        OZT R                  R                  S5      nUR	                  U
5        UR	                  U" U5      5        UR	                  U" U5      5        US:X  a  UR                  S	S5        U$ s  snf s  sn	f )
Nc                |  > [        U 5      S:  a  TR                  R                  S5      n[        U 5       H  u  p#US:  aV  TR                  R                  S5      nUR	                  TR                  R                  S5      5        UR	                  U5        TR                  R                  S5      nUR	                  TR                  R                  U5      5        UR	                  U5        M     U$ TR                  R                  S5      nUR	                  TR                  R                  U S   5      5        U$ )Nr   r^  r   r`  rY  ra  r[  r\  s         r9   rb  5MathMLPresentationPrinter._print_Symbol.<locals>.join  s    5zA~xx--f5(/GA1u!XX33D9txx'>'>s'CD((,//5BNN488#:#:4#@A$$R(  0 XX++D1txx66uQx@A	r<   c                F    U [         ;   a  [         R                  " U 5      $ U $ rF   re  rg  s    r9   r   :MathMLPresentationPrinter._print_Symbol.<locals>.translate  rj  r<   ra  r   rr  rs  rt  boldmathvariant)r	   rk  rG   r   r   rN   r   r  )r4   rl  stylerb  r   rk  rm  rn  ro  rp  rq  r   s   `           r9   ru  'MathMLPresentationPrinter._print_Symbol  su   	$	 -SXX6d,23FS)C.F3*./$3	#$/&&t,$((11$78v;!4yA~HH**62e$d4j)4yA~HH**62e$d6l+HH**95e$d4j)d6l+F?NN=&13 4/s   G
Gc                <    U R                  UU R                  S   S9$ )Nr$   )rl  )ru  ry  )r4   rl  s     r9   r  -MathMLPresentationPrinter._print_MatrixSymbol  s+    !!#(,7I(J " L 	Lr<   c                    U R                   R                  S5      nUR                  SS5        UR                  U R	                  UR
                  S   5      5        U$ )Nmenclosenotationtopr   rG   r   r  r   rT   r   )r4   rX   encs      r9   _print_conjugate*MathMLPresentationPrinter._print_conjugate  sH    hh$$Z0U+DIIaL12
r<   c                8   U R                   R                  S5      nUR                  U R                  U[        S   5      5        U R                   R                  S5      nUR                  U R                   R                  U5      5        UR                  U5        U$ )Nr^  Funcr`  )rG   r   r   r  r   rN   )r4   oprX   rowr`  s        r9   _print_operator_after/MathMLPresentationPrinter._print_operator_after  st    hh$$V,))$
60BCDXX##D)
txx..r23
r<   c                @    U R                  SUR                  S   5      $ )N!r   r|  r   r4   rX   s     r9   _print_factorial*MathMLPresentationPrinter._print_factorial  s    ))#tyy|<<r<   c                @    U R                  SUR                  S   5      $ )Nz!!r   r  r  s     r9   _print_factorial2+MathMLPresentationPrinter._print_factorial2  s    ))$		!==r<   c                l   U R                   R                  S5      nU R                   R                  S5      nUR                  SS5        UR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  S   5      5        UR                  U5        U$ )Nr  r  linethickness0r   r   rt  )r4   rX   r   r	  s       r9   _print_binomial)MathMLPresentationPrinter._print_binomial  s    xx%%i0xx%%g./3/TYYq\23TYYq\23r<   c                "
   UR                   R                  (       Ga  [        UR                   R                  5      S:X  Ga  UR                   R                  S:w  Gaq  U R
                  S   (       Ga\  UR                   R                  S:X  aE  U R                  R                  S5      nUR                  U R                  UR                  5      5        UR                   R                  S:w  ay  U R                  R                  S5      nUR                  U R                  UR                  5      5        UR                  U R                  UR                   R                  5      5        UR                   R                  S:X  aN  U R                  R                  S5      nUR                  U R                  S5      5        UR                  W5        U$ W$ UR                   R                  (       Ga  UR                   R                  S:w  Gav  UR                   R                  (       a  U R                  R                  S5      nUR                  U R                  S5      5        U R                  R                  S5      nUR                  U R                  UR                  [        S	   5      5        UR                  U R                  UR                   * U R
                  S
   5      5        UR                  U5        U$ U R                  R                  S5      nUR                  U R                  UR                  [        S	   5      5        UR                  U R                  UR                   U R
                  S
   5      5        U$ UR                   R                  (       Ga  U R                  R                  S5      nUR                  U R                  S5      5        UR                   S:X  a,  UR                  U R                  UR                  5      5        U$ U R                  R                  S5      nUR                  U R                  UR                  [        S	   5      5        UR                  U R                  UR                   * 5      5        UR                  U5        U$ U R                  R                  S5      nUR                  U R                  UR                  [        S	   5      5        UR                  U R                  UR                   5      5        U$ )Nr   r&   r  msqrtmrootr   r  rs  ro   r   )rz  r{  rv   r  r  ry  rG   r   r   rT   r|  is_negativer  r   r  )r4   r   r   r	  rs  s        r9   r  $MathMLPresentationPrinter._print_Pow  sx    EE#aeegg,!"31//uuww!|HH**73dkk!&&12uuww!|HH**73dkk!&&12dkk!%%''23uuww"}xx--g6  Q0  #55Auu  hh,,W5A/HH**62d//
58IJKd88!%%$(NN3E$FH I"
HH**62d//
58IJKd88$(NN3E$FH I55hh,,W5A/55B;OODKK$78 
	 ..v6AMM$"3"3AFFJu<M"NOMM$++quuf"56OOA&
HH""6*	d''
50ABC	dkk!%%()r<   c                    U R                   R                  U R                  U5      5      nUR                  U R                   R	                  [        U5      5      5        U$ rF   r  r"  s      r9   r  'MathMLPresentationPrinter._print_Number$  r  r<   c                ,   U R                   R                  S5      nUR                  SS5        UR                  SS5        UR                  U R	                  UR
                  5      5        UR                  U R	                  UR                  5      5        U$ )Nr  r     ⟩r     ⟨)rG   r   r  r   rT   rt   rr   )r4   r   r   s      r9   _print_AccumulationBounds3MathMLPresentationPrinter._print_AccumulationBounds)  sq    xx%%i0'8,&(+QUU+,QUU+,r<   c                <   [        UR                  5      (       a  SnOU R                  U5      nU R                  R	                  S5      nSn[        UR                  5       GH  u  pVXF-  nUS:  a  U R                  R	                  S5      nU R                  R	                  S5      nUR                  U R                  R                  U5      5        UR                  U5        UR                  U R                  U5      5        OEU R                  R	                  S5      nUR                  U R                  R                  U5      5        UR                  U5        U R                  U5      n	UR                  U	5        GM     U R                  R	                  S5      n
US:  a  U R                  R	                  S5      nU R                  R	                  S5      nUR                  U R                  R                  U5      5        UR                  U5        UR                  U R                  U5      5        OEU R                  R	                  S5      nUR                  U R                  R                  U5      5        U
R                  U5        U R                  R	                  S5      nU R                  R	                  S5      nUR                  U
5        UR                  U5        UR                  U5        UR                  U R                  UR                  5      5        U$ )Nz&#x2202;r^  r   r  rs  r`  r  )
r
   rX   r   rG   r   r  r  r   rN   rT   )r4   r   rZ  r   dimrl  numr   xxr  mnumr^  r	  s                r9   r  +MathMLPresentationPrinter._print_Derivative1  sO   AFF##A"A HH""6* !1!12HCJCaxHH**62XX++D1txx66q9:b!dkk#./HH**40dhh55a89MM!C AMM! 3 xx%%f-!8&&v.A''-BNN48822156MM"MM$++c*+&&t,AMM$((11!45xx%%f-xx%%g. 	QVV,-r<   c                l   U R                   R                  S5      nU R                   R                  S5      nU R                  U5      S:X  a?  U R                  S   (       a+  UR	                  U R                   R                  S5      5        O9UR	                  U R                   R                  U R                  U5      5      5        U R                   R                  S5      nUR                   H#  nUR	                  U R                  U5      5        M%     UR	                  U5        UR	                  U5        U$ )Nr^  ra  r   r!   r   r  )rG   r   r   ry  r   rN   r   rT   )r4   r   r^  r   r  r   s         r9   r  )MathMLPresentationPrinter._print_Functiona  s    xx%%f-HH""4(??1&4>>-+HMM$((11$78MM$((11$//!2DEFHH""9-66CMM$++c*+ r<   c                   [        UR                  5      n[        UR                  USS9nU R                  S   nU R
                  R                  S5      nSU;   Ga  UR                  S5      u  pgUS   S:X  a  USS  nU R
                  R                  S	5      nUR                  U R
                  R                  U5      5        UR                  U5        U R
                  R                  S
5      n	U	R                  U R
                  R                  U5      5        UR                  U	5        U R
                  R                  S5      n
U R
                  R                  S	5      nUR                  U R
                  R                  S5      5        U
R                  U5        U R
                  R                  S	5      nUR                  U R
                  R                  U5      5        U
R                  U5        UR                  U
5        U$ US:X  a  U R                  S 5      $ US:X  a  U R                  S 5      $ U R
                  R                  S	5      nUR                  U R
                  R                  U5      5        U$ )NT)strip_zerosr(   r^  r   r   r  r   r  r`  rs  10z+infz-inf)r   r  r  r  ry  rG   r   splitr   rN   r/  rC  )r4   rX   dpsstr_real	separatorr^  mantrz  r  r`  rs  s              r9   r  &MathMLPresentationPrinter._print_Floato  s   $**%tzz3DA NN#>?	xx%%f-(?"..-KT1v}!"g''-BNN48822489R ''-BNN488229=>R 88))&1D''-BNN48822489R ''-BNN48822378R T"K''--//55''-BNN488228<=Ir<   c                L   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        U R                   R                  S5      nUR                  U R	                  UR
                  S   5      5        UR                  U5        U$ )Nr^  rr  ra  Lir   r  r   rL  )r4   rX   r^  r   ra  r   s         r9   _print_polylog(MathMLPresentationPrinter._print_polylog  s    xx%%f-HH""6*XX##D)
txx..t45	b	dkk$))A,/0xx%%i0TYYq\23r<   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  U R	                  U5      5      5        UR                  U5        U R                   R                  S5      nUR
                   H#  nUR                  U R                  U5      5        M%     UR                  U5        U$ )Nr^  ra  r  rG   r   r   rN   r   r   rT   )r4   r   r^  ra  r   r   s         r9   r  &MathMLPresentationPrinter._print_Basic  s    xx%%f-XX##D)
txx..tq/ABCxx%%i066CT[[-. r<   c                    U R                   R                  S5      nU R                   R                  S5      nUR                   H#  nUR                  U R	                  U5      5        M%     UR                  U5        U$ )Nr^  r  r  )r4   r   r^  r   r   s        r9   _print_Tuple&MathMLPresentationPrinter._print_Tuple  s`    xx%%f-HH""9-66CMM$++c*+ r<   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  UR                  :X  aO  UR	                  SS5        UR	                  SS5        UR                  U R                  UR                  5      5        OUR                  (       a  UR	                  SS5        OUR	                  SS5        UR                  (       a  UR	                  SS	5        OUR	                  SS
5        UR                  U R                  UR                  5      5        UR                  U R                  UR                  5      5        UR                  U5        U$ )Nr^  r  r  }r  {)r  (r   )	rG   r   startendr  r   rT   
right_open	left_open)r4   r   r^  r   s       r9   _print_Interval)MathMLPresentationPrinter._print_Interval  s   xx%%f-xx%%i077aeegs+fc*T[[12||!!'3/!!'3/{{!!&#.!!&#.T[[12T[[/0r<   c                6   U R                   R                  S5      nU R                   R                  S5      nUR                  SS5        UR                  SS5        UR                  U R	                  UR
                  S   5      5        UR                  U5        U$ )Nr^  r  r  |r  r   rt  )r4   rX   rz  r^  r   s        r9   
_print_Abs$MathMLPresentationPrinter._print_Abs  sv    xx%%f-HH""9-	w$	vs#	dkk$))A,/0r<   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  U5      5        UR                  U5        U R                   R                  S5      nUR                  U R                  U5      5        UR                  U5        U$ )Nr^  ra  rk  frakturr  )rG   r   r  r   rN   rT   )r4   r   rX   r^  ra  r   s         r9   _print_re_im&MathMLPresentationPrinter._print_re_im  s    xx%%f-XX##D)
y1
txx..q12xx%%i0T*+r<   c                @    U R                  SUR                  S   5      $ )NRr   r  r   r4   rX   rz  s      r9   	_print_re#MathMLPresentationPrinter._print_re        diil33r<   c                @    U R                  SUR                  S   5      $ )NIr   r  r  s      r9   	_print_im#MathMLPresentationPrinter._print_im  r  r<   c                l   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  U R	                  U5      5      5        UR                  U5        UR
                   H#  nUR                  U R                  U5      5        M%     U$ )Nr^  ra  r  )r4   r   r^  ra  r   s        r9   r  (MathMLPresentationPrinter._print_AssocOp  s    xx%%f-XX##D)
txx..tq/ABC66CT[[-. r<   c                   U R                   R                  S5      nUR                  U R                  UR                  S   U5      5        UR                  SS   H{  nU R                   R                  S5      nUR                  U R                   R                  U5      5        U R                  XS5      nUR                  U5        UR                  U5        M}     U$ )Nr^  r   r   r`  )rG   r   r   r  r   rN   )r4   rX   symbolprecr^  r   r   r  s           r9   _print_SetOp&MathMLPresentationPrinter._print_SetOp  s    xx%%f-**499Q<>?99QR=C&&t,AMM$((11&9:!!#,AQQ ! r<   c                :    [         S   nU R                  USU5      $ )Nr   z&#x222A;r   r  r4   rX   r  s      r9   _print_Union&MathMLPresentationPrinter._print_Union  s!    %g.  z488r<   c                :    [         S   nU R                  USU5      $ )Nr   z&#x2229;r  r  s      r9   _print_Intersection-MathMLPresentationPrinter._print_Intersection  s!    %n5  z488r<   c                :    [         S   nU R                  USU5      $ )N
Complementz&#x2216;r  r  s      r9   r  +MathMLPresentationPrinter._print_Complement  !    %l3  z488r<   c                :    [         S   nU R                  USU5      $ )NSymmetricDifference&#x2206;r  r  s      r9   _print_SymmetricDifference4MathMLPresentationPrinter._print_SymmetricDifference  s"    %&;<  z488r<   c                :    [         S   nU R                  USU5      $ )N
ProductSetz&#x00d7;r  r  s      r9   r  +MathMLPresentationPrinter._print_ProductSet  r  r<   c                8    U R                  UR                  5      $ rF   )
_print_setr   )r4   rh  s     r9   r  *MathMLPresentationPrinter._print_FiniteSet  s    qvv&&r<   c                    [        U[        S9nU R                  R                  S5      nUR	                  SS5        UR	                  SS5        U H#  nUR                  U R                  U5      5        M%     U$ )Nkeyr  r  r  r  r  )sortedr   rG   r   r  r   rT   )r4   rh  r]  r   r_  s        r9   r  $MathMLPresentationPrinter._print_set  si    q./xx%%i0'3'&#&DT[[./ r<   c                6   U R                   R                  S5      nUS   R                  (       ad  US   R                  (       dP  U R                   R                  S5      nUR	                  U R                  US   5      5        UR	                  U5        O#UR	                  U R                  US   5      5        USS   H  nU R                   R                  S5      nUR	                  U R                   R                  U5      5        UR                  (       aM  UR                  (       d<  U R                   R                  S5      nUR	                  U R                  U5      5        OU R                  U5      nUR	                  U5        UR	                  U5        M     U$ )Nr^  r   r  r   r`  )rG   r   
is_Booleanis_Notr   rT   rN   )r4   r   r  r^  r   r   r   r  s           r9   _print_LogOp&MathMLPresentationPrinter._print_LogOp!  s+   xx%%f-7d1gnn88)))4DT[[a12T"T[[a128C&&t,AMM$((11&9:~~cjjHH**95dkk#./KK$QQ  r<   c                   SSK Jn  XR                  :X  a  U R                  UR                  5      $ [	        X5      (       a  UR                  5       R                  5       nOSU4/nU R                  R                  S5      nU GHu  u  pV[        UR                  R                  5       5      nUR                  S S9  [        U5       GH,  u  nu  pU
S:X  a  U(       aV  U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U5        UR                  U R                  U	5      5        M  U
S	:X  ay  U R                  R                  S5      nUR                  U R                  R                  S
5      5        UR                  U5        UR                  U R                  U	5      5        GM  U(       aV  U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U5        U R                  R                  S5      nUR                  U R                  U
5      5        UR                  U5        U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U5        UR                  U R                  U	5      5        GM/     GMx     U$ )Nr   )Vectorr^  c                (    U S   R                  5       $ )Nr   )__str__)r   s    r9   <lambda>AMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>C  s    1Q4<<>r<   r  r   r`  r  r   r  r  r  )sympy.vectorr  zerorT   r  separater]  rG   r   rP  
componentssortr   r   rN   )r4   rX   r  r]  r^  systemvect
inneritemsr   kvr`  mbracs                r9   _print_BasisDependent/MathMLPresentationPrinter._print_BasisDependent5  s1   '99;;tyy))d##MMO))+EYKExx%%f-!LFdoo3356JOO"9O:&z2	6A6!XX33D9txx'>'>s'CD((,$$T[[^4"W//5BNN488#:#:3#?@$$R($$T[[^4!XX33D9txx'>'>s'CD((, HH229=E%%dkk!n5$$U+//5BNN488#:#:;M#NO$$R($$T[[^4/ 3 "6 r<   c                V    [        UR                  [        S9nU R                  US5      $ )Nr  z&#x2227;r  r   r   r  r4   rX   r   s      r9   
_print_And$MathMLPresentationPrinter._print_And_  &    dii%56  z22r<   c                V    [        UR                  [        S9nU R                  US5      $ )Nr  z&#x2228;r  r  s      r9   	_print_Or#MathMLPresentationPrinter._print_Orc  r  r<   c                V    [        UR                  [        S9nU R                  US5      $ )Nr  z&#x22BB;r  r  s      r9   r  $MathMLPresentationPrinter._print_Xorg  r  r<   c                :    U R                  UR                  S5      $ )Nz&#x21D2;)r  r   r  s     r9   r  (MathMLPresentationPrinter._print_Impliesk  s      J77r<   c                V    [        UR                  [        S9nU R                  US5      $ )Nr  z&#x21D4;r  r  s      r9   _print_Equivalent+MathMLPresentationPrinter._print_Equivalentn  r  r<   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  S   R
                  (       aI  U R                   R                  S5      nUR                  U R                  UR                  S   5      5        OU R                  UR                  S   5      nUR                  U5        U$ )Nr^  r`  z&#xAC;r   r  )rG   r   r   rN   r   r  rT   )r4   r   r^  r`  r   s        r9   r  $MathMLPresentationPrinter._print_Notr  s    xx%%f-XX##D)
txx..x89FF1I  &&y1AMM$++affQi01AFF1I&Ar<   c                    U R                   R                  S5      nUR                  U R                   R                  U R	                  U5      5      5        U$ Nra  rG   r   r   rN   r   r4   r   ra  s      r9   _print_bool%MathMLPresentationPrinter._print_bool  ?    XX##D)
txx..tq/ABC	r<   c                    U R                   R                  S5      nUR                  U R                   R                  U R	                  U5      5      5        U$ r  r   r!  s      r9   _print_NoneType)MathMLPresentationPrinter._print_NoneType  r$  r<   c                   SnU R                   R                  S5      nUR                  SS5        UR                  SS5        UR                  R                  (       aF  UR
                  R                  (       a+  UR                  R                  (       a  USSS	U4nOUS	SSU4nOUR                  R                  (       a  X!S   UR                  -
  US   4nO~UR
                  R                  (       a#  [        U5      n[        U5      [        U5      U4nO@[        U5      S
:  a&  [        U5      n[        U5      [        U5      X!S   4nO[        U5      nU H  nXb:X  aX  U R                   R                  S5      nUR                  U R                   R                  U5      5        UR                  U5        M`  UR                  U R                  U5      5        M     U$ )Nu   …r  r  r  r  r  r   r   r      ra  )rG   r   r  r  is_infinitestopstepis_positiveiternextr   tupler   rN   rT   )r4   rh  dotsr   printsetitelra  s           r9   _print_Range&MathMLPresentationPrinter._print_Range  sp   xx%%i0'3'&#&77166#5#5vv!!Q4/Ar4/WW  rUQVV^QrU2HVVaBBxb4/HVaZaBBxb426HQxHBzXX++D1txx66t<=  $  R1  r<   c                   [        UR                  [        S9nU R                  R	                  S5      nU R                  R	                  S5      nUR                  U R                  R                  [        UR                  5      R                  5       5      5        UR                  U5        U R                  R	                  S5      nU H#  nUR                  U R                  U5      5        M%     UR                  U5        U$ )Nr  r^  r`  r  )r  r   r   rG   r   r   rN   r  funcr   rT   )r4   rX   r   r^  r`  r   r  s          r9   _hprint_variadic_function3MathMLPresentationPrinter._hprint_variadic_function  s    dii%56xx%%f-XX##D)
txx..DII/E/E/GHIxx%%i0FT[[01 r<   c                    U R                   R                  S5      nUR                  U R                  S 5      5        UR                  U R	                  UR
                  S   5      5        U$ )Nrs  r   )rG   r   r   r'  rT   r   )r4   rX   rs  s      r9   
_print_exp$MathMLPresentationPrinter._print_exp  sS    xx%%f-))$/0TYYq\23r<   c                   U R                   R                  S5      nUR                  U R                  UR                  5      5        U R                   R                  S5      nUR                  U R                   R                  U R                  U5      5      5        UR                  U5        UR                  U R                  UR                  5      5        U$ )Nr^  r`  )rG   r   r   rT   r  rN   r   r  r4   r   r^  r   s       r9   r  +MathMLPresentationPrinter._print_Relational  s    xx%%f-QUU+,HH""4(	dhh--dooa.@ABQUU+,r<   c                    U R                   R                  U R                  U5      5      nUR                  U R                   R	                  [        U5      5      5        U$ rF   r  r  s      r9   r  $MathMLPresentationPrinter._print_int  r  r<   c                &   U R                   R                  S5      nUR                  u  p4U R                   R                  S5      nUR                  SS5        UR	                  U R                   R                  UR                  U   5      5        UR	                  U5        U R                   R                  S5      nUR                  SS5        UR	                  U R                   R                  UR                  5      5        UR	                  U5        U$ )Nrr  ra  rk  rj  )rG   r   _idr  r   rN   _variable_names_name)r4   r   rr  indexr  ra  s         r9   _print_BaseScalar+MathMLPresentationPrinter._print_BaseScalar  s    xx%%f-XX##D)
v.
txx..v/E/Ee/LMNXX##D)
v.
txx..v||<=r<   c                *   U R                   R                  S5      nUR                  u  p4U R                   R                  S5      nU R                   R                  S5      nUR                  SS5        UR	                  U R                   R                  UR                  U   5      5        UR	                  U5        U R                   R                  S5      nUR	                  U R                   R                  S5      5        UR	                  U5        UR	                  U5        U R                   R                  S5      nUR                  SS5        UR	                  U R                   R                  UR                  5      5        UR	                  U5        U$ )Nrr  moverra  rk  rj  r`  ^)rG   r   rD  r  r   rN   _vector_namesrF  )r4   r   rr  rG  r  rK  ra  r`  s           r9   _print_BaseVector+MathMLPresentationPrinter._print_BaseVector  s*   xx%%f-&&w/XX##D)
v.
txx..v/C/CE/JKL"XX##D)
txx..s34"XX##D)
v.
txx..v||<=r<   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        UR                  U5        U R                   R                  S5      nUR                  U R                   R	                  S5      5        UR                  U5        U$ )NrK  ra  rk  rj  r  r`  rL  rG   r   r  r   rN   )r4   r   rK  ra  r`  s        r9   _print_VectorZero+MathMLPresentationPrinter._print_VectorZero  s    &&w/XX##D)
v.
txx..s34"XX##D)
txx..s34"r<   c                   U R                   R                  S5      nUR                  nUR                  nUR	                  U R                  U[        S   5      5        U R                   R                  S5      nUR	                  U R                   R                  S5      5        UR	                  U5        UR	                  U R                  U[        S   5      5        U$ )Nr^  r   r`  r  rG   r   _expr1_expr2r   r  r   rN   r4   rX   r^  vec1vec2r`  s         r9   _print_Cross&MathMLPresentationPrinter._print_Cross      xx%%f-{{{{**4E1BCDXX##D)
txx..x89**4E1BCDr<   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  [        S   5      5        U$ )Nr^  r`  &#x2207;r  r   rG   r   r   rN   r  _exprr   r4   rX   r^  r`  s       r9   _print_Curl%MathMLPresentationPrinter._print_Curl      xx%%f-XX##D)
txx..z:;XX##D)
txx..x89**4::z%7HIJr<   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  [        S   5      5        U$ )Nr^  r`  r_  r   r   r`  rb  s       r9   _print_Divergence+MathMLPresentationPrinter._print_Divergence  re  r<   c                   U R                   R                  S5      nUR                  nUR                  nUR	                  U R                  U[        S   5      5        U R                   R                  S5      nUR	                  U R                   R                  S5      5        UR	                  U5        UR	                  U R                  U[        S   5      5        U$ )Nr^  r   r`  r   rU  rX  s         r9   
_print_Dot$MathMLPresentationPrinter._print_Dot  r]  r<   c                L   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  [        S   5      5        U$ )Nr^  r`  r_  r   r`  rb  s       r9   _print_Gradient)MathMLPresentationPrinter._print_Gradient$  |    xx%%f-XX##D)
txx..z:;**4::z%7HIJr<   c                L   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  [        S   5      5        U$ )Nr^  r`  r  r   r`  rb  s       r9   _print_Laplacian*MathMLPresentationPrinter._print_Laplacian,  ro  r<   c                    U R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        U$ )Nra  rk  normalz&#x2124;rQ  r"  s      r9   _print_Integers)MathMLPresentationPrinter._print_Integers4  D    HH""4(	}h/	dhh--j9:r<   c                    U R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        U$ )Nra  rk  rt  z&#x2102;rQ  r"  s      r9   _print_Complexes*MathMLPresentationPrinter._print_Complexes:  rw  r<   c                    U R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        U$ )Nra  rk  rt  z&#x211D;rQ  r"  s      r9   _print_Reals&MathMLPresentationPrinter._print_Reals@  rw  r<   c                    U R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        U$ )Nra  rk  rt  &#x2115;rQ  r"  s      r9   _print_Naturals)MathMLPresentationPrinter._print_NaturalsF  rw  r<   c                h   U R                   R                  S5      nU R                   R                  S5      nUR                  SS5        UR                  U R                   R	                  S5      5        UR                  U5        UR                  U R                  [        R                  5      5        U$ )Nrr  ra  rk  rt  r  )rG   r   r  r   rN   rT   r   Zero)r4   r   rp  r   s       r9   _print_Naturals0*MathMLPresentationPrinter._print_Naturals0L  s}    hh$$V,HH""4(	}h/	dhh--j9:AFF+,
r<   c                   UR                   S   UR                   S   -
  nUR                   S   nU R                  R                  S5      nU R                  R                  S5      nUR                  SS5        UR                  SS	5        UR	                  U R                  U5      5        UR	                  U5        UR	                  U R                  U5      5        U$ )
Nr   r   r  rs  r  r  r  r  r  )r   rG   r   r  r   rT   )r4   rX   shiftrp   ro  r   s         r9   _print_SingularityFunction4MathMLPresentationPrinter._print_SingularityFunctionU  s    		!tyy|+		!hh$$V,xx%%i0'8,&(+U+,E*+
r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  NaNr!  r"  s      r9   r4  $MathMLPresentationPrinter._print_NaNa  s6    HH""4(	dhh--e45r<   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  U5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        [        UR
                  5      S:X  a  U$ U R                   R                  S5      nU R                   R                  S5      nUR
                  SS   H#  nUR                  U R	                  U5      5        M%     UR                  U5        UR                  U5        U$ )Nrr  ra  r   r   r^  r  )rG   r   r   rN   rT   r   r   )r4   r   rk  rp  ra  r^  r  r   s           r9   _print_number_function0MathMLPresentationPrinter._print_number_functionf  s     hh$$V,XX##D)
txx..t45AFF1I./qvv;!Jxx%%f-HH""9-66!":CMM$++c*+ r<   c                &    U R                  US5      $ )NBr  r  s     r9   _print_bernoulli*MathMLPresentationPrinter._print_bernoulliy      **1c22r<   c                &    U R                  US5      $ )Nr  r  r  s     r9   _print_catalan(MathMLPresentationPrinter._print_catalan~  r  r<   c                &    U R                  US5      $ )NEr  r  s     r9   _print_euler&MathMLPresentationPrinter._print_euler  r  r<   c                &    U R                  US5      $ )NFr  r  s     r9   _print_fibonacci*MathMLPresentationPrinter._print_fibonacci  r  r<   c                &    U R                  US5      $ )NLr  r  s     r9   _print_lucas&MathMLPresentationPrinter._print_lucas  r  r<   c                &    U R                  US5      $ )Nz&#x03B3;r  r  s     r9   _print_stieltjes*MathMLPresentationPrinter._print_stieltjes  s    **1j99r<   c                &    U R                  US5      $ )NTr  r  s     r9   _print_tribonacci+MathMLPresentationPrinter._print_tribonacci  r  r<   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U$ )NrK  r`  r1  ~r!  )r4   r   r   r`  s       r9   _print_ComplexInfinity0MathMLPresentationPrinter._print_ComplexInfinity  s    HH""7+XX##D)
txx..z:;	bXX##D)
txx..s34	br<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nr`  z&#x2205;r!  r"  s      r9   r8  )MathMLPresentationPrinter._print_EmptySet  r3  r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nr`  z	&#x1D54C;r!  r"  s      r9   _print_UniversalSet-MathMLPresentationPrinter._print_UniversalSet  6    HH""4(	dhh--k:;r<   c                   SSK Jn  UR                  nU R                  R	                  S5      n[        X25      (       dM  U R                  R	                  S5      nUR                  U R                  U5      5        UR                  U5        O UR                  U R                  U5      5        U R                  R	                  S5      nUR                  U R                  R                  S5      5        UR                  U5        U$ )Nr   r   rs  r  r`  r@  	sympy.matricesr   r   rG   r   r  r   rT   rN   r4   rX   r   matro  r   r`  s          r9   _print_Adjoint(MathMLPresentationPrinter._print_Adjoint  s    /hhhh$$V,#,,88)))4DT[[-.OOD!OODKK,-XX##D)
txx..z:;
r<   c                   SSK Jn  UR                  nU R                  R	                  S5      n[        X25      (       dM  U R                  R	                  S5      nUR                  U R                  U5      5        UR                  U5        O UR                  U R                  U5      5        U R                  R	                  S5      nUR                  U R                  R                  S5      5        UR                  U5        U$ )Nr   r  rs  r  r`  r  r  r  s          r9   _print_Transpose*MathMLPresentationPrinter._print_Transpose  s    /hhhh$$V,#,,88)))4DT[[-.OOD!OODKK,-XX##D)
txx..s34
r<   c                   SSK Jn  UR                  nU R                  R	                  S5      n[        X25      (       dM  U R                  R	                  S5      nUR                  U R                  U5      5        UR                  U5        O UR                  U R                  U5      5        UR                  U R                  S5      5        U$ )Nr   r  rs  r  r   )r  r   r   rG   r   r  r   rT   )r4   rX   r   r  ro  r   s         r9   _print_Inverse(MathMLPresentationPrinter._print_Inverse  s    /hhhh$$V,#,,88)))4DT[[-.OOD!OODKK,-B(
r<   c           	        SSK Jn  U R                  R                  S5      nUR                  n[        US   [        5      (       a#  US   R                  5       [        USS  5      -   nO[        U5      n[        X5      (       a  UR                  5       (       an  US   S:X  a  USS  nO	US   * US'   U R                  R                  S5      nUR                  U R                  R                  S5      5        UR                  U5        US S  H  nUR                  U R                  U[        U5      S5      5        U R                  R                  S5      nUR                  U R                  R                  S	5      5        UR                  U5        M     UR                  U R                  US   [        U5      S5      5        U$ )
Nr   )MatMulr^  r   r   r`  r  Fr  )!sympy.matrices.expressions.matmulr  rG   r   r   r  r   r   rP  r   r   rN   r  r   )r4   rX   r  r   r   r`  r   s          r9   _print_MatMul'MathMLPresentationPrinter._print_MatMul  sy   <HH""6*yyd1gs##7--/$tABx.@D:Dd##(E(E(G(GAw"}ABx7(Q''-BNN48822378MM"9CMM$++C1G1M,13 4''-BNN488223EFGMM"  	
d''R2H2N(-/ 	0r<   c                   SSK Jn  UR                  UR                  pCU R                  R                  S5      n[        X25      (       dM  U R                  R                  S5      nUR                  U R                  U5      5        UR                  U5        O UR                  U R                  U5      5        UR                  U R                  U5      5        U$ )Nr   r  rs  r  )	r  r   r|  rz  rG   r   r  r   rT   )r4   rX   r   r|  rz  ro  r   s          r9   _print_MatPow'MathMLPresentationPrinter._print_MatPow  s    /IItxxchh$$V,$--88)))4DT[[./OOD!OODKK-.C()
r<   c           	        U R                   R                  S5      nUR                  nUS S  H  nUR                  U R	                  U[        U5      S5      5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        M     UR                  U R	                  US   [        U5      S5      5        U$ )Nr^  r   Fr`  z&#x2218;)rG   r   r   r   r  r   rN   )r4   rX   r   r   r   r`  s         r9   _print_HadamardProduct0MathMLPresentationPrinter._print_HadamardProduct  s    HH""6*yy9CMM!!#'=d'CUKM''-BNN48822:>?MM"  	
d2h(>t(DeL	Nr<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nr  z&#x1D7D8r!  r4   Zr   s      r9   _print_ZeroMatrix+MathMLPresentationPrinter._print_ZeroMatrix  r3  r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nr  z&#x1D7D9r!  r  s      r9   _print_OneMatrix*MathMLPresentationPrinter._print_OneMatrix  r3  r<   c                    U R                   R                  S5      nUR                  U R                   R                  S5      5        U$ )Nra  z	&#x1D540;r!  )r4   r  r   s      r9   _print_Identity)MathMLPresentationPrinter._print_Identity  r  r<   c                6   U R                   R                  S5      nU R                   R                  S5      nUR                  SS5        UR                  SS5        UR                  U R	                  UR
                  S   5      5        UR                  U5        U$ )Nr^  r  r  u   ⌋r  u   ⌊r   rt  r?  s       r9   _print_floor&MathMLPresentationPrinter._print_floor  v    xx%%f-HH""9-	w)	vx(	dkk!&&),-r<   c                6   U R                   R                  S5      nU R                   R                  S5      nUR                  SS5        UR                  SS5        UR                  U R	                  UR
                  S   5      5        UR                  U5        U$ )Nr^  r  r  u   ⌉r  u   ⌈r   rt  r?  s       r9   _print_ceiling(MathMLPresentationPrinter._print_ceiling  r  r<   c                D   U R                   R                  S5      nU R                   R                  S5      nUR                  S   n[        U5      S:X  a  U R	                  US   5      nOU R	                  U5      nUR                  U5        U R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR                  S   5      5        UR                  U5        U$ )Nr  r^  r   r   r`  z&#x21A6;)rG   r   r   r   rT   r   rN   )r4   r   r   r^  symbolsr`  s         r9   r  'MathMLPresentationPrinter._print_Lambda'  s    HH""9-xx%%f-&&)w<1kk'!*-Gkk'*G!XX##D)
txx..z:;QVVAY/0	dr<   c                    U R                   R                  S5      nU H#  nUR                  U R                  U5      5        M%     U$ r  r  )r4   r   r   r   s       r9   _print_tuple&MathMLPresentationPrinter._print_tuple7  s9    HH""9-AMM$++a.) r<   c                8    U R                  UR                  5      $ rF   )rT   labelr  s     r9   _print_IndexedBase,MathMLPresentationPrinter._print_IndexedBase=  s    {{177##r<   c                t   U R                   R                  S5      nUR                  U R                  UR                  5      5        [        UR                  5      S:X  a/  UR                  U R                  UR                  S   5      5        U$ UR                  U R                  UR                  5      5        U$ )Nrr  r   r   )rG   r   r   rT   r|  r   indicesr"  s      r9   _print_Indexed(MathMLPresentationPrinter._print_Indexed@  s    HH""6*	dkk!&&)*qyy>QMM$++aiil34H	dkk!)),-r<   c                   U R                   R                  S5      nUR                  U R                  UR                  [
        S   SS95        U R                   R                  S5      nUR                  SS5        UR                  SS5        UR                   H#  nUR                  U R                  U5      5        M%     UR                  U5        U$ )	Nrr  AtomTrW  r  r  r>   r  )	rG   r   r   r  parentr   r  r  rT   )r4   r   r   r   r   s        r9   _print_MatrixElement.MathMLPresentationPrinter._print_MatrixElementI  s    HH""6*	d''*V2Dt'TUxx%%i0'2&&"%AT[[^, 	dr<   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U R                   R                  S5      nUR	                  SS5        UR
                   H#  nUR                  U R                  U5      5        M%     UR                  U5        U$ )Nr^  ra  z	&#x1d5a5;r  
separatorsr  rG   r   r   rN   r  r   rT   r4   r   r   ra  r  r   s         r9   _print_elliptic_f+MathMLPresentationPrinter._print_elliptic_fT      HH""6*XX##D)
txx..{;<	bHH""9-	|S)AMM$++a.) 	ar<   c                   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U R                   R                  S5      nUR	                  SS5        UR
                   H#  nUR                  U R                  U5      5        M%     UR                  U5        U$ )Nr^  ra  z	&#x1d5a4;r  r  r  r  r  s         r9   _print_elliptic_e+MathMLPresentationPrinter._print_elliptic_e`  r  r<   c                "   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        U R                   R                  S5      n[	        UR
                  5      S:X  a  UR                  SS5        OUR                  SS5        UR
                   H#  nUR                  U R                  U5      5        M%     UR                  U5        U$ )	Nr^  ra  z	&#x1d6f1;r  r  r  r  z;|)rG   r   r   rN   r   r   r  rT   r  s         r9   _print_elliptic_pi,MathMLPresentationPrinter._print_elliptic_pil  s    HH""6*XX##D)
txx..{;<	bHH""9-qvv;!NN<-NN<.AMM$++a.) 	ar<   c                <   U R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  5      5        U$ )Nr^  ra  EirL  )r4   r   r   ra  s       r9   	_print_Ei#MathMLPresentationPrinter._print_Ei{  so    HH""6*XX##D)
txx..t45	b	dkk!&&)*r<   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nr^  rr  r`  r  r   r   rL  r4   r   r   r  r`  s        r9   _print_expint'MathMLPresentationPrinter._print_expint      HH""6*HH""6*XX##D)
txx..s34	b	dkk!&&),-	a	dkk!&&*-.r<   c                N   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  SS 5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nr^  rt  r`  Pr   r   rG  rL  r  s        r9   _print_jacobi'MathMLPresentationPrinter._print_jacobi      HH""6*HH""9-XX##D)
txx..s34	b	dkk!&&),-	dkk!&&1+./	a	dkk!&&*-.r<   c                N   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  SS 5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nr^  rt  r`  r  r   r   r  rL  r  s        r9   _print_gegenbauer+MathMLPresentationPrinter._print_gegenbauer  r  r<   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nr^  rr  r`  r  r   r   rL  r  s        r9   _print_chebyshevt+MathMLPresentationPrinter._print_chebyshevt  r	  r<   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nr^  rr  r`  Ur   r   rL  r  s        r9   _print_chebyshevu+MathMLPresentationPrinter._print_chebyshevu  r	  r<   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nr^  rr  r`  r  r   r   rL  r  s        r9   _print_legendre)MathMLPresentationPrinter._print_legendre  r	  r<   c                N   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  SS 5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nr^  rt  r`  r  r   r   r  rL  r  s        r9   _print_assoc_legendre/MathMLPresentationPrinter._print_assoc_legendre  r  r<   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nr^  rr  r`  r  r   r   rL  r  s        r9   _print_laguerre)MathMLPresentationPrinter._print_laguerre  r	  r<   c                N   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U R	                  UR
                  SS 5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nr^  rt  r`  r  r   r   r  rL  r  s        r9   _print_assoc_laguerre/MathMLPresentationPrinter._print_assoc_laguerre  r  r<   c                   U R                   R                  S5      nU R                   R                  S5      nU R                   R                  S5      nUR                  U R                   R                  S5      5        UR                  U5        UR                  U R	                  UR
                  S   5      5        UR                  U5        UR                  U R	                  UR
                  SS  5      5        U$ )Nr^  rr  r`  Hr   r   rL  r  s        r9   _print_hermite(MathMLPresentationPrinter._print_hermite  r	  r<   r=   )FrF   )r   )r?   r@   rA   rB   r_   r  r   r  r   r   r  r  r  r  r  r#  r'  r+  r/  rC  r7  r  r=  rC  rF  rI  rM  rP  rR  rU  ru  r  r  rv  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  _print_Determinantr  r  r  r  r  r  r  r  r  r  r  r  _print_frozensetr  r
  r  r  r  r  r  r  r"  r<  r@  r&  r5  r9  
_print_Min
_print_Maxr<  r  r  rH  rN  rR  r[  rc  rg  rj  rm  rq  ru  ry  r|  r  r  r  r4  r  r  _print_bellr  r  r  r  r  r  r  r8  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'  rC   r=   r<   r9   r  r    s    )KKZ%-^($(P,








$L>4lL (=>4l
.`%N	0 $	44	99999' "('T33383
 %%
@
 87J
$					

&3 #K3333:3

:


 $	

	

			
	
	r<   r  c                v    US:X  a  [        U5      R                  U 5      $ [        U5      R                  U 5      $ )zReturns the MathML representation of expr. If printer is presentation
then prints Presentation MathML else prints content MathML.
presentation)r  r]   rb   )rX   printerrO   s      r9   mathmlr1    s8    
 . (2::4@@#H-55d;;r<   c                    US:X  a  [        U5      nO[        U5      nUR                  [        U 5      5      nUR	                  5       n[        U5        g)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)r  rb   rT   r   toprettyxmlprint)rX   r0  rO   rh  xml
pretty_xmls         r9   print_mathmlr7    sF    2 . %h/ *
((74=
!C"J	*r<   N)content)$r_   
__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   r  r   rb   r  r1  r7  MathMLPrinterr=   r<   r9   <module>rE     s    #   " / & H? ? @ : E E5 5pJ, J^W 1 Wt. !"< #< H %r<   