
    wgV                      d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZmZ dd	lmZmZmZ dd
lmZ ddlmZmZ ddlmZmZmZ  G d de      Z G d de      Z G d de      Z  ee      dd       Z!ddZ"eZ#y)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                  L    e Zd ZU dZddddddddddddi d	d
Zded<   ddZd Zy)MathMLPrinterBasez^Contains common code required for MathMLContentPrinter and
    MathMLPresentationPrinter.
    Nzutf-8Fabbreviated[plainT&#xB7;)orderencodingfold_frac_powersfold_func_bracketsfold_short_fracinv_trig_styleln_notationlong_frac_ratio	mat_delimmat_symbol_style
mul_symbolroot_notationsymbol_namesmul_symbol_mathml_numberszdict[str, Any]_default_settingsc                     t        j                   |       ddlm}m}  |        _         G d d|       fd}| j
                  _        y )Nr   )DocumentTextc                      e Zd ZddZy)+MathMLPrinterBase.__init__.<locals>.RawTextc                v    | j                   r-|j                  dj                  || j                   |             y y )Nz{}{}{})datawriteformat)selfwriterindent	addindentnewls        Z/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/sympy/printing/mathml.pywritexmlz4MathMLPrinterBase.__init__.<locals>.RawText.writexml6   s+    99LLD!IJ     N) r:   r:   )__name__
__module____qualname__r8    r9   r7   RawTextr-   5   s    Kr9   r?   c                F            }| |_         j                  |_        |S N)r/   domownerDocument)r/   rr?   r2   s     r7   createRawTextNodez5MathMLPrinterBase.__init__.<locals>.createRawTextNode:   s!    	AAF"hhAOHr9   )r   __init__xml.dom.minidomr*   r+   rB   createTextNode)r2   settingsr*   r+   rE   r?   s   `    @r7   rF   zMathMLPrinterBase.__init__+   s@    x(2:	Kd 	K
	 #4r9   c                    t        j                  | |      }|j                         }|j                  dd      }|j	                         }|S )z2
        Prints the expression as MathML.
        asciixmlcharrefreplace)r   _printtoxmlencodedecode)r2   exprmathMLunistrxmlbstrress         r7   doprintzMathMLPrinterBase.doprintB   sA     d+--)<=nn
r9   rA   )r;   r<   r=   __doc__r(   __annotations__rF   rV   r>   r9   r7   r   r      sL    
 !#'#%-)~ "4.r9   r   c                      e Zd ZdZdZd Zd Zd'dZd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZeZeZd Zd Zd Zd Zd Z d Z!d Z"d  Z#d! Z$d" Z%e"Z&e"Z'e"Z(d# Z)d$ Z*d% Z+d& Z,y)(MathMLContentPrinterz}Prints an expression to the Content MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter4.html
    _mathml_contentc                   i ddddddddd	dd
dddddddddddddddddddddddi d d	d!d"d#d#d$d$d%d%d&d&d'd'd(d(d)d)d*d*d+d+d,d,d-d-d.d.d/d0d1d2d3d4i d5d6d7d8d9d:d;d8d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdX}|j                   j                  D ]  }|j                  }||v s||   c S  |j                   j                  }|j                         S )Y)Returns the MathML tag for an expression.Addplusr   times
DerivativediffNumbercnintPowpowerMaxmaxMinminAbsabsAndandOrorXorxorNotnotImpliesimpliesSymbolciMatrixSymbolRandomSymbolIntegralSumsumsincostancotcscsecsinhcoshtanhcothcschsechasinarcsinasinharcsinhacosarccosacosharccoshatanarctanatanharctanhatan2acotarccotacotharccothasecarcsecasecharcsechacscarccscacscharccschloglnEqualityeq
UnequalityneqGreaterThangeqLessThanleqStrictGreaterThangtStrictLessThanltunion	intersect)UnionIntersection	__class____mro__r;   lower)r2   e	translateclsns        r7   
mathml_tagz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I~ |#	$
 KK  wwyr9   c                ^   |j                         rh| j                  j                  d      }|j                  | j                  j                  d             |j                  | j	                  |              |S ddlm}  ||      \  }}|t        j                  ur| j                  j                  d      }|j                  | j                  j                  d             |j                  | j                  |             |j                  | j                  |             |S |j                         \  }}|t        j                  u r"t        |      dk(  r| j                  |d         S | j                  dk7  r#t        j                  |      j                         }| j                  j                  d      }|j                  | j                  j                  d             |dk7  r |j                  | j                  |             |D ]"  }|j                  | j                  |             $ |S )	Napplyminusr   fractiondivide   oldr`   )could_extract_minus_signrB   createElementappendChild
_print_Mulsympy.simplifyr   r   OnerM   as_coeff_mullenr   r   
_from_argsas_ordered_factors)	r2   rQ   xr   numerdenomcoefftermsterms	            r7   r   zMathMLContentPrinter._print_Mul   s   ((*&&w/AMM$((009:MM$//4%01H+~u&&w/AMM$((00:;MM$++e,-MM$++e,-H((*uAEE>c%jAo ;;uQx((::NN5)<<>EHH""7+	dhh,,W56A:MM$++e,- 	-DMM$++d+,	-r9   Nc                >   | j                  ||      }| j                  |d         }g }|dd  D ]  }|j                         r| j                  j	                  d      }|j                  | j                  j	                  d             |j                  |       |j                  | j                  |              |}||d   k(  s|j                  |       |j                  |       | j                  |      }||d   k(  s|j                  | j                  |              t        |      dk(  r|S | j                  j	                  d      }|j                  | j                  j	                  d             |r#|j                  |j                  d             |r#|S )Nr   r   r   r   r   r_   )	_as_ordered_termsrM   r   rB   r   r   appendr   pop)r2   rQ   r   argslastProcessed	plusNodesargr   s           r7   
_print_AddzMathMLContentPrinter._print_Add   sb   %%d%%8DG,	8 	7C++-HH**73dhh44W=>m,dkk3$/0 !$r(?$$]3  / $C 0$r(?$$T[[%56	7  y>Q  HH""7+	dhh,,V45MM)--*+ r9   c                Z   |j                   d   j                  dk7  rt        d      | j                  j	                  d      }t        |j                         D ]  \  }\  }}|t        |j                         dz
  k(  rA|dk(  r<| j                  j	                  d      }|j                  | j                  |             n[| j                  j	                  d      }|j                  | j                  |             |j                  | j                  |             |j                  |        |S )Nr   TzAll Piecewise expressions must contain an (expr, True) statement to be used as a default condition. Without one, the generated expression may not evaluate to anything under some condition.	piecewiser   	otherwisepiece)	r   cond
ValueErrorrB   r   	enumerater   r   rM   )r2   rQ   rootir   cr   s          r7   _print_Piecewisez%MathMLContentPrinter._print_Piecewise   s    99R=%  / 0 0
 xx%%k2"499- 	$IAv1C		NQ&&19..{;!!$++a.1..w7!!$++a.1!!$++a.1U#	$ r9   c           	     F   | j                   j                  d      }t        |j                        D ]m  }| j                   j                  d      }t        |j                        D ]'  }|j                  | j                  |||f                ) |j                  |       o |S )Nmatrix	matrixrow)rB   r   rangerowscolsr   rM   )r2   mr   r   x_rjs         r7   _print_MatrixBasez&MathMLContentPrinter._print_MatrixBase   s    HH""8,qvv 	A((((5C166] 6AadG 456MM#		
 r9   c                   |j                   dk(  rZ| j                  j                  d      }|j                  | j                  j	                  t        |j                                     |S | j                  j                  d      }|j                  | j                  j                  d             | j                  j                  d      }|j                  | j                  j	                  t        |j                                     | j                  j                  d      }|j                  | j                  j	                  t        |j                                      |j                  |       |j                  |       |S )Nr   rd   r   r   )qrB   r   r   rH   strp)r2   r   r   xnumxdenoms        r7   _print_Rationalz$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r9   c                l   | j                   j                  d      }|j                  | j                   j                  | j                  |                   | j                   j                  d      }| j                   j                  d      }|j                  | j	                  |j
                  d                |j                  | j	                  |j
                  d                |j                  |       |j                  |       |j                  | j	                  |j
                  d                |S )Nr   bvarlowlimitr      r   )rB   r   r   r   rM   r   )r2   r   r   x_1x_2s        r7   _print_Limitz!MathMLContentPrinter._print_Limit  s    HH""7+	dhh,,T__Q-?@Ahh$$V,hh$$Z0AFF1I./AFF1I./	c	c	dkk!&&),-r9   c                8    | j                   j                  d      S )N
imaginaryirB   r   r2   r   s     r7   _print_ImaginaryUnitz)MathMLContentPrinter._print_ImaginaryUnit      xx%%l33r9   c                8    | j                   j                  d      S )N
eulergammar  r  s     r7   _print_EulerGammaz&MathMLContentPrinter._print_EulerGamma  r
  r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )zwWe use unicode #x3c6 for Greek letter phi as defined here
        https://www.w3.org/2003/entities/2007doc/isogrk1.htmlrd   u   φrB   r   r   rH   r2   r   r   s      r7   _print_GoldenRatioz'MathMLContentPrinter._print_GoldenRatio  s9     HH""4(	dhh--.JKLr9   c                8    | j                   j                  d      S )Nexponentialer  r  s     r7   _print_Exp1z MathMLContentPrinter._print_Exp1   s    xx%%n55r9   c                8    | j                   j                  d      S )Npir  r  s     r7   	_print_PizMathMLContentPrinter._print_Pi#  s    xx%%d++r9   c                8    | j                   j                  d      S )Ninfinityr  r  s     r7   _print_Infinityz$MathMLContentPrinter._print_Infinity&      xx%%j11r9   c                8    | j                   j                  d      S )N
notanumberr  r  s     r7   
_print_NaNzMathMLContentPrinter._print_NaN)  r
  r9   c                8    | j                   j                  d      S )Nemptysetr  r  s     r7   _print_EmptySetz$MathMLContentPrinter._print_EmptySet,  r  r9   c                8    | j                   j                  d      S )Ntruer  r  s     r7   _print_BooleanTruez'MathMLContentPrinter._print_BooleanTrue/  s    xx%%f--r9   c                8    | j                   j                  d      S )Nfalser  r  s     r7   _print_BooleanFalsez(MathMLContentPrinter._print_BooleanFalse2  s    xx%%g..r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |j                  | j                   j                  d             |S )Nr   r   r  )rB   r   r   r  s      r7   _print_NegativeInfinityz,MathMLContentPrinter._print_NegativeInfinity5  sQ    HH""7+	dhh,,W56	dhh,,Z89r9   c                p      fdt        j                        }|j                           |      S )Nc                ,   j                   j                  d      }|j                  j                   j                  j                                     j                   j                  d      }|j                  j	                  | d   d                |j                  |       t        | d         dk(  rj                   j                  d      }|j                  j	                  | d   d                |j                  |       j                   j                  d      }|j                  j	                  | d   d                |j                  |       t        | d         dk(  rRj                   j                  d      }|j                  j	                  | d   d                |j                  |       t        |       dk(  r,|j                  j	                  j                               |S |j                   | dd               |S )	Nr   r   r      r   r   uplimitr  )rB   r   r   r   rM   r   function)limitsr   	bvar_elemlow_elemup_elemr   
lime_recurr2   s        r7   r3  z8MathMLContentPrinter._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Hr9   )listr/  reverse)r2   r   r/  r3  s   `` @r7   _print_Integralz$MathMLContentPrinter._print_Integral;  s,    	0 ahh&!!r9   c                $    | j                  |      S rA   )r6  r  s     r7   
_print_SumzMathMLContentPrinter._print_SumX  s     ##A&&r9   c                2     j                   j                   j                  |            } fd}d }t        |j                        \  }}} ||      }|D cg c]
  } ||       }}|D 	cg c]
  }	 ||	       }}	 j                   j                  d      }
|
j                   j                   j                  |             |s|s,|j                   j                   j                  |             |S  j                   j                  d      }|j                  |
       |j                   ||             |j                  |       |S |sV j                   j                  d      }|j                  |
       |j                   ||             |j                  |       |S  j                   j                  d      }|j                  |
       |j                   ||             |j                   ||             |j                  |       |S c c}w c c}	w )Nc                v   t        |       dkD  rj                  j                  d      }t        |       D ]  \  }}|dkD  rVj                  j                  d      }|j	                  j                  j                  d             |j	                  |       j                  j                  d      }|j	                  j                  j                  |             |j	                  |        |S j                  j                  d      }|j	                  j                  j                  | d                |S )Nr   zmml:mrowr   zmml:mo mml:mir   rB   r   r   r   rH   itemsmrowr   itemmomir2   s         r7   joinz0MathMLContentPrinter._print_Symbol.<locals>.join`  s    5zA~xx--j9(/ )GAt1u!XX33H=txx'>'>s'CD((,//9BNN488#:#:4#@A$$R() XX++H5txx66uQx@A	r9   c                @    | t         v rt        j                  |       S | S rA   r   getss    r7   r   z5MathMLContentPrinter._print_Symbol.<locals>.translater       M!$((++r9   r<  zmml:msubzmml:msupzmml:msubsup)rB   r   r   r	   namer   rH   )r2   symry   rD  r   rK  superssubssupsubmnamemsubmsupmsubsups   `             r7   _print_Symbolz"MathMLContentPrinter._print_Symbol]  s   XX##DOOC$89	$	 -SXX6fd,23S)C.3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.Hc                .   | j                   d   rZ|j                  j                  rC|j                  j                  dk(  r)| j                  j                  d      }|j                  | j                  j                  d             |j                  j                  dk7  r| j                  j                  d      }| j                  j                  d      }|j                  | j                  j                  t        |j                  j                                     |j                  |       |j                  |       |j                  | j                  |j                               |S | j                  j                  d      }| j                  j                  | j                  |            }|j                  |       |j                  | j                  |j                               |j                  | j                  |j                               |S )Nr%   r   r   r   r  degreerd   )	_settingsexpis_Rationalr   rB   r   r   r   rH   r   rM   baser   )r2   r   r   xmldegxmlcnr  s         r7   
_print_PowzMathMLContentPrinter._print_Pow  sf    NN?+0A0A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!%%()r9   c                    | j                   j                  | j                  |            }|j                  | j                   j	                  t        |                   |S rA   rB   r   r   r   rH   r   r  s      r7   _print_Numberz"MathMLContentPrinter._print_Number  C    HH""4??1#56	dhh--c!f56r9   c                    | j                   j                  | j                  |            }t        |j                  t        |j                              }|j                  | j                   j                  |             |S rA   )	rB   r   r   mlib_to_str_mpf_r   _precr   rH   )r2   r   r   repr_es       r7   _print_Floatz!MathMLContentPrinter._print_Float  sX    HH""4??1#56QWWhqww&78	dhh--f56r9   c                   | j                   j                  d      }| j                  |      }t        |j                        rd}|j                  | j                   j                  |             | j                   j                  d      }t        |j                        D ]  \  }}|j                  | j                  |             |dkD  s,| j                   j                  d      }|j                  | j                  t        |                   |j                  |        |j                  |       |j                  | j                  |j                               |S )Nr   partialdiffr   r   rW  )
rB   r   r   r
   rQ   r   reversedvariable_countrM   r   )r2   r   r   diff_symbolr  rL  r`   rW  s           r7   _print_Derivativez&MathMLContentPrinter._print_Derivative  s   HH""7+ooa(AFF#'K	dhh,,[9:hh$$V,"1#3#34 	(JCOODKK,-qy//9""4;;wu~#>?'	( 	
c	dkk!&&)*r9   c                   | j                   j                  d      }|j                  | j                   j                  | j                  |                   |j                  D ]"  }|j                  | j                  |             $ |S Nr   )rB   r   r   r   r   rM   r2   r   r   r   s       r7   _print_Functionz$MathMLContentPrinter._print_Function  sg    HH""7+	dhh,,T__Q-?@A66 	,CMM$++c*+	,r9   c                    | j                   j                  | j                  |            }|j                  D ]"  }|j	                  | j                  |             $ |S rA   )rB   r   r   r   r   rM   rq  s       r7   _print_Basicz!MathMLContentPrinter._print_Basic  sL    HH""4??1#5666 	,CMM$++c*+	,r9   c                   | j                   j                  d      }| j                   j                  | j                  |            }|j                  |       |j                  D ]"  }|j                  | j                  |             $ |S rp  )rB   r   r   r   r   rM   )r2   r   r   r  r   s        r7   _print_AssocOpz#MathMLContentPrinter._print_AssocOp  sl    HH""7+hh$$T__Q%78	c66 	,CMM$++c*+	,r9   c                V   | j                   j                  d      }|j                  | j                   j                  | j                  |                   |j                  | j	                  |j
                               |j                  | j	                  |j                               |S rp  )rB   r   r   r   rM   lhsrhsr  s      r7   _print_Relationalz&MathMLContentPrinter._print_Relational  sq    HH""7+	dhh,,T__Q-?@A	dkk!%%()	dkk!%%()r9   c                    | j                   j                  d      }|D ]"  }|j                  | j                  |             $ |S )zgMathML reference for the <list> element:
        https://www.w3.org/TR/MathML2/chapter4.html#contm.listr4  rB   r   r   rM   )r2   seqdom_elementrA  s       r7   _print_listz MathMLContentPrinter._print_list  sD     hh,,V4 	7D##DKK$56	7r9   c                    | j                   j                  | j                  |            }|j                  | j                   j	                  t        |                   |S rA   r`  r2   r   r~  s      r7   
_print_intzMathMLContentPrinter._print_int  F    hh,,T__Q-?@ 7 7A ?@r9   c                    | j                   j                  d      }|j                  D ]"  }|j                  | j	                  |             $ |S )NsetrB   r   r   r   rM   rq  s       r7   _print_FiniteSetz%MathMLContentPrinter._print_FiniteSet  sC    HH""5)66 	,CMM$++c*+	,r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |j                  D ]"  }|j                  | j	                  |             $ |S )Nr   setdiffrB   r   r   r   rM   rq  s       r7   _print_Complementz&MathMLContentPrinter._print_Complement   s^    HH""7+	dhh,,Y7866 	,CMM$++c*+	,r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |j                  D ]"  }|j                  | j	                  |             $ |S )Nr   cartesianproductr  rq  s       r7   _print_ProductSetz&MathMLContentPrinter._print_ProductSet  s_    HH""7+	dhh,,-?@A66 	,CMM$++c*+	,r9   c                h   | j                   j                  | j                  |            }|j                  D ]N  }| j                   j                  d      }|j	                  | j                  |             |j	                  |       P |j	                  | j                  |j                               |S )Nr   )rB   r   r   	signaturer   rM   rQ   )r2   r   r   r   r  s        r7   _print_Lambdaz"MathMLContentPrinter._print_Lambda  s     HH""4??1#56;; 	C((((0COODKK,-MM#	 	
dkk!&&)*r9   rA   )-r;   r<   r=   rW   printmethodr   r   r   r   r   r   r  r	  r  r  r  r  r  r  r!  r$  r'  r)  r6  r8  rU  _print_MatrixSymbol_print_RandomSymbolr^  ra  rh  rn  rr  rt  rv  rz  r  r  _print_Implies
_print_Not
_print_Xorr  r  r  r  r>   r9   r7   rZ   rZ   M   s     $K@D!F8*$446,242./":'
6p ('.
&
 $NJJ	r9   rZ   c                  6   e Zd ZdZdZd ZddZd ZddZd Z	dd	Z
d
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZddZd ZeZd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,d+ Z-d, Z.dd-Z/e/Z0d. Z1dd/Z2dd0Z3d1 Z4d2 Z5d3 Z6d4 Z7d5 Z8d6 Z9d7 Z:d8 Z;d9 Z<e<Z=d: Z>d; Z?d< Z@d= ZAd> ZBd? ZCd@ ZDdA ZEdB ZFeFZGeFZHdC ZIdD ZJdE ZKeKxZLZMdF ZNdG ZOdH ZPdI ZQdJ ZRdK ZSdL ZTdM ZUdN ZVdO ZWdP ZXdQ ZYdR ZZdS Z[dT Z\dU Z]dV Z^dW Z_dX Z`dY ZadZ ZbebZcd[ Zdd\ Zed] Zfd^ Zgd_ Zhd` Zida Zjdb Zkdc Zldd Zmde Zndf Zodg Zpdh Zqdi Zrdj Zsdk Ztdl Zudm Zvdn Zwdo Zxdp Zydq Zzdr Z{ds Z|dt Z}du Z~dv Zdw Zdx Zdy Zdz Zd{ Zd| Zd} Zd~ Zd Zd Zd Zy)MathMLPresentationPrinterzPrints an expression to the Presentation MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter3.html
    _mathml_presentationc                    i dddddddddd	d
dddddddddddddddddddddddi ddd dd!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d8d:d;d<d=d>d?d@dAdBdCdDdEdFd@dAdGdHdIdJ} fdK}|j                   j                  D ]  }|j                  }||v s||   c S  |j                   j                  dLk(  r |       S |j                   j                  }|j                         S )Mr]   rc   mnLimitz&#x2192;ra   &dd;re   rx   rC  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                     j                   d    j                   d   dk(  ry j                   d   dk(  ry j                   d   dk(  ry j                   d   dk(  ry	t         j                   d   t              st         j                   d   S )
Nr$   r  &InvisibleTimes;r`   &#xD7;dotr   ldotz&#x2024;)rX  
isinstancer   	TypeError)r2   s   r7   mul_symbol_selectionzBMathMLPresentationPrinter.mathml_tag.<locals>.mul_symbol_selectionX  s    |,4NN<0F:)-8-6-7!| <cB~~l33r9   r   r   )r2   r   r   r  r   r   s   `     r7   r   z$MathMLPresentationPrinter.mathml_tag#  sJ   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I~ |#	$
 ;;5('))KK  wwyr9   c                    t        |      }||k  s|sB||k  r=| j                  j                  d      }|j                  | j	                  |             |S | j	                  |      S Nmfenced)r   rB   r   r   rM   )r2   rA  levelstrictprec_valbracs         r7   parenthesizez&MathMLPresentationPrinter.parenthesizep  s\    )$/uv8u3D88)))4DT[[./K;;t$$r9   c                >     fd} j                   j                  d      }|j                         rb j                   j                  d      }|j                   j                   j	                  d             |j                  |        || |      }|S  |||      }|S )Nc                   ddl m}  ||       \  }}|t        j                  urj                  j                  d      }j                  d   r)t        t        |             dk  r|j                  dd       j                  |      }j                  |      }|j                  |       |j                  |       |j                  |       |S | j                         \  }}	|t        j                  u r3t        |	      dk(  r%|j                  j                  |	d                |S j                  d	k7  r#t        j                  |	      j!                         }	|dk7  rj                  |      }
j                  j                  d
      }|j                  j                  j#                  j%                  |                    |j                  |
       |j                  |       |	D ]  }|j                  j'                  |t(        d                ||	d   k(  r4j                  j                  d
      }|j                  j                  j#                  j%                  |                    |j                  |        |S )Nr   r   mfracr      bevelledr#  r   r   rB  r   r   )r   r   r   r   rB   r   rX  r   r   setAttributerM   r   r   r   r   r   r   rH   r   r  r   )rQ   r@  r   r   r   fracr   xdenr   r   r   yr   r2   s                r7   multiplyz6MathMLPresentationPrinter._print_Mul.<locals>.multiply{  s   /#D>LE5AEE!xx--g6>>"34SY!9K%%j&9{{5){{5)  &  &  &,,.LE5~#e*/  U1X!67zzU"u-@@BzKK&HH**40dhh55dood6KLM  #  # (  !2!24E9J!KLuRy(..t4AMM$(("9"9$//$:O"PQ$$Q'( Kr9   r@  rB  -)rB   r   r   r   rH   )r2   rQ   r  r@  r   s   `    r7   r   z$MathMLPresentationPrinter._print_Muly  s    !	D xx%%f-((*&&t,AMM$((11#67QTE4(D  D$'Dr9   Nc                |   | j                   j                  d      }| j                  ||      }|j                  | j	                  |d                |dd  D ]  }|j                         rX| j                   j                  d      }|j                  | j                   j                  d             | j	                  |       }nV| j                   j                  d      }|j                  | j                   j                  d             | j	                  |      }|j                  |       |j                  |        |S )Nr@  r   r   r   rB  r  +)rB   r   r   r   rM   r   rH   )r2   rQ   r   r@  r   r   r   r  s           r7   r   z$MathMLPresentationPrinter._print_Add  s   xx%%f-%%d%%8T!W-.8 	 C++-HH**40dhh55c:;KK% HH**40dhh55c:;KK$QQ	  r9   c           	        | j                   j                  d      }t        |j                        D ]  }| j                   j                  d      }t        |j                        D ]S  }| j                   j                  d      }|j                  | j                  |||f                |j                  |       U |j                  |        | j                  d   dk(  r|S | j                   j                  d      }| j                  d   dk(  r$|j                  dd	       |j                  d
d       |j                  |       |S )Nmtablemtrmtdr"   r:   r  r   close]open)	rB   r   r   r   r   r   rM   rX  r  )r2   r   tabler   r   r   r  r  s           r7   r   z+MathMLPresentationPrinter._print_MatrixBase  s   &&x0qvv 	!A&&u-A166] !HH**51dkk!AqD'23a ! a 	! >>+&",Lxx%%i0>>+&#-gs+fc*r9   c                   |j                   dk  r|j                    }n|j                   }| j                  j                  d      }|s| j                  d   r|j	                  dd       |j                  | j                  |             |j                  | j                  |j                               |j                   dk  r| j                  j                  d      }| j                  j                  d      }|j                  | j                  j                  d             |j                  |       |j                  |       |S |S )	Nr   r  r   r  r#  r@  rB  r  )	r   rB   r   rX  r  r   rM   r   rH   )r2   r   foldedr   r   r@  rB  s          r7   _get_printed_Rationalz/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Hr9   c                    |j                   dk(  r| j                  |j                        S | j                  || j                  d         S )Nr   r   )r   rM   r   r  rX  r  s     r7   r   z)MathMLPresentationPrinter._print_Rational  s=    33!8;;qss##))!T^^<M-NOOr9   c                x   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             | j                   j                  d      }| j	                  |j
                  d         }| j                   j                  d      }|j                  | j                   j                  | j                  |                   | j	                  |j
                  d         }|j                  |       |j                  |       |j                  |       |j                  |       |j                  |       |j                  |       |j                  | j	                  |j
                  d                |S )	Nr@  munderrC  limr   rB  r  r   )rB   r   r   rH   rM   r   r   )	r2   r   r@  r  rC  r   r  arrowr  s	            r7   r  z&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r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  z&ImaginaryI;r  r  s      r7   r	  z.MathMLPresentationPrinter._print_ImaginaryUnit  s6    HH""4(	dhh--n=>r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  r  r  r  s      r7   r  z,MathMLPresentationPrinter._print_GoldenRatio  6    HH""4(	dhh--i89r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  z&ExponentialE;r  r  s      r7   r  z%MathMLPresentationPrinter._print_Exp1	  s7    HH""4(	dhh--.>?@r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  z&pi;r  r  s      r7   r  z#MathMLPresentationPrinter._print_Pi  s6    HH""4(	dhh--f56r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  &#x221E;r  r  s      r7   r  z)MathMLPresentationPrinter._print_Infinity  6    HH""4(	dhh--j9:r9   c                ,   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             | j	                  |      }|j                  |       |j                  |       |S )Nr@  rB  r  )rB   r   r   rH   r  )r2   r   r@  r  r   s        r7   r)  z1MathMLPresentationPrinter._print_NegativeInfinity  sv    xx%%f-HH""4(	dhh--c23  #r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  z&#x210F;r  r  s      r7   _print_HBarz%MathMLPresentationPrinter._print_HBar!  r  r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  r  r  r  s      r7   r  z+MathMLPresentationPrinter._print_EulerGamma&  r  r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  TribonacciConstantr  r  s      r7   _print_TribonacciConstantz3MathMLPresentationPrinter._print_TribonacciConstant+  s7    HH""4(	dhh--.BCDr9   c                    | j                   j                  d      }|j                  | j                  |j                  d                |j                  | j                   j                  d             |S )NrS  r   &#x2020;rB   r   r   rM   r   rH   r2   r   rS  s      r7   _print_Daggerz'MathMLPresentationPrinter._print_Dagger0  sW    xx%%f-QVVAY/000<=r9   c                   | j                   j                  d      }|j                  | j                  |j                  d                | j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j                  |j                  d                |S )Nr@  r   rB  z&#x2208;r   r  )r2   r   r@  rB  s       r7   _print_Containsz)MathMLPresentationPrinter._print_Contains6  s    xx%%f-QVVAY/0XX##D)
txx..z:;QVVAY/0r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  z&#x210B;r  r  s      r7   _print_HilbertSpacez-MathMLPresentationPrinter._print_HilbertSpace?  r  r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |j                  | j	                  |j
                  d                |S )NrS  z	&#x1D49E;r   rB   r   r   rH   rM   r   r   s      r7   _print_ComplexSpacez-MathMLPresentationPrinter._print_ComplexSpaceD  sW    xx%%f-00=>QVVAY/0r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  z&#x2131;r  r  s      r7   _print_FockSpacez*MathMLPresentationPrinter._print_FockSpaceJ  r  r9   c                    dddd}| j                   j                  d      }t        |j                        dk  rt	        d |j                  D              rn| j                   j                  d      }|j                  | j                   j                  |t        |j                                        |j                  |       nt        |j                        D ]j  }| j                   j                  d      }|j                  | j                   j                  |d	                t        |      d	k(  r|j                  |       t        |      d
k(  r`| j                   j                  d      }|j                  |       |j                  | j                  |d	                |j                  |       t        |      dk(  s| j                   j                  d      }|j                  |       |j                  | j                  |d	                |j                  | j                  |d
                |j                  |       m |j                  | j                  |j                  t        d   d             t        |j                        D ]{  }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j                  |d                } |S )Nz&#x222B;z&#x222C;z&#x222D;)r   r  r,  r@  r,  c              3  8   K   | ]  }t        |      d k(    yw)r   N)r   ).0r  s     r7   	<genexpr>z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>T  s     (N3SQ(Ns   rB  r   r  rS  rT  r   Tr  r  r   )rB   r   r   r/  allr   rH   rk  rM   r  r.  r   )	r2   rQ   
intsymbolsr@  rB  r  rS  rT  ds	            r7   r6  z)MathMLPresentationPrinter._print_IntegralP  sg   #
zB
xx%%f-t{{q S(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( 	2C&&t,AMM$((11&9:QT[[Q01		2
 r9   c                   t        |j                        }| j                  j                  d      }| j	                  |d   d         }| j	                  |d   d         }| j                  j                  d      }|j                  | j                  j                  | j                  |                   | j                  j                  d      }| j	                  |d   d         }| j                  j                  d      }	|	j                  | j                  j                  d             |j                  |       |j                  |	       |j                  |       |j                  |       |j                  |       |j                  |       | j                  j                  d      }
|
j                  |       t        t        |j                              dk(  r,|
j                  | j	                  |j                               |
S | j                  j                  d      }|j                  | j	                  |j                               |
j                  |       |
S )	N
munderoverr   r   r  rB  r@  r  r  )r4  r/  rB   r   rM   r   rH   r   r   r   r.  )r2   r   r/  subsupr1  r2  summandlowvarequalr@  fences               r7   r8  z$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#r9   c                     fd}d }t        |j                        \  }}} ||      }|D cg c]
  } ||       }}|D 	cg c]
  }	 ||	       }}	 j                  j                  d      }
|
j	                   j                  j                  |             t        |      dk(  rUt        |      dk(  r|
}n j                  j                  d      }|j	                  |
       |j	                   ||             nt        |      dk(  rD j                  j                  d      }|j	                  |
       |j	                   ||             nZ j                  j                  d      }|j	                  |
       |j	                   ||             |j	                   ||             |dk(  r|j                  d	d       |S c c}w c c}	w )
Nc                v   t        |       dkD  rj                  j                  d      }t        |       D ]  \  }}|dkD  rVj                  j                  d      }|j	                  j                  j                  d             |j	                  |       j                  j                  d      }|j	                  j                  j                  |             |j	                  |        |S j                  j                  d      }|j	                  j                  j                  | d                |S )Nr   r@  r   rB  r;  rC  r=  r>  s         r7   rD  z5MathMLPresentationPrinter._print_Symbol.<locals>.join  s    5zA~xx--f5(/ )GAt1u!XX33D9txx'>'>s'CD((,//5BNN488#:#:4#@A$$R() XX++D1txx66uQx@A	r9   c                @    | t         v rt        j                  |       S | S rA   rF  rH  s    r7   r   z:MathMLPresentationPrinter._print_Symbol.<locals>.translate  rJ  r9   rC  r   rR  rS  rT  boldmathvariant)r	   rK  rB   r   r   rH   r   r  )r2   rL  stylerD  r   rK  rM  rN  rO  rP  rQ  r   s   `           r7   rU  z'MathMLPresentationPrinter._print_Symbol  su   	$	 -SXX6fd,23S)C.3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                B    | j                  || j                  d         S )Nr#   )r   )rU  rX  )r2   rL  s     r7   r  z-MathMLPresentationPrinter._print_MatrixSymbol  s+    !!#(,7I(J " L 	Lr9   c                    | j                   j                  d      }|j                  dd       |j                  | j	                  |j
                  d                |S )Nmenclosenotationtopr   rB   r   r  r   rM   r   )r2   rQ   encs      r7   _print_conjugatez*MathMLPresentationPrinter._print_conjugate  sH    hh$$Z0U+DIIaL12
r9   c                8   | j                   j                  d      }|j                  | j                  |t        d                | j                   j                  d      }|j                  | j                   j                  |             |j                  |       |S )Nr@  FuncrB  )rB   r   r   r  r   rH   )r2   oprQ   rowrB  s        r7   _print_operator_afterz/MathMLPresentationPrinter._print_operator_after  st    hh$$V,))$
60BCDXX##D)
txx..r23
r9   c                @    | j                  d|j                  d         S )N!r   r-  r   r2   rQ   s     r7   _print_factorialz*MathMLPresentationPrinter._print_factorial  s    ))#tyy|<<r9   c                @    | j                  d|j                  d         S )Nz!!r   r0  r1  s     r7   _print_factorial2z+MathMLPresentationPrinter._print_factorial2  s    ))$		!==r9   c                l   | j                   j                  d      }| j                   j                  d      }|j                  dd       |j                  | j	                  |j
                  d                |j                  | j	                  |j
                  d                |j                  |       |S )Nr  r  linethickness0r   r   r&  )r2   rQ   r  r  s       r7   _print_binomialz)MathMLPresentationPrinter._print_binomial  s    xx%%i0xx%%g./3/TYYq\23TYYq\23r9   c                	   |j                   j                  rt        |j                   j                        dk(  r|j                   j                  dk7  ri| j
                  d   rY|j                   j                  dk(  rE| j                  j                  d      }|j                  | j                  |j                               |j                   j                  dk7  ry| j                  j                  d      }|j                  | j                  |j                               |j                  | j                  |j                   j                               |j                   j                  dk(  rN| j                  j                  d      }|j                  | j                  d             |j                         |S S |j                   j                  r|j                   j                  dk7  rq|j                   j                  r| j                  j                  d      }|j                  | j                  d             | j                  j                  d      }|j                  | j                  |j                  t        d	                |j                  | j                  |j                    | j
                  d
                |j                  |       |S | j                  j                  d      }|j                  | j                  |j                  t        d	                |j                  | j                  |j                   | j
                  d
                |S |j                   j                  r| j                  j                  d      }|j                  | j                  d             |j                   dk(  r,|j                  | j                  |j                               |S | j                  j                  d      }|j                  | j                  |j                  t        d	                |j                  | j                  |j                                 |j                  |       |S | j                  j                  d      }|j                  | j                  |j                  t        d	                |j                  | j                  |j                                |S )Nr   r%   r  msqrtmrootr   r  rS  rf   r   )rY  rZ  rm   r   r   rX  rB   r   r   rM   r[  is_negativer  r   r  )r2   r   r   r  r%  s        r7   r^  z$MathMLPresentationPrinter._print_Pow  sl    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!%%()r9   c                    | j                   j                  | j                  |            }|j                  | j                   j	                  t        |                   |S rA   r`  r  s      r7   ra  z'MathMLPresentationPrinter._print_Number$  rb  r9   c                ,   | j                   j                  d      }|j                  dd       |j                  dd       |j                  | j	                  |j
                               |j                  | j	                  |j                               |S )Nr  r     ⟩r     ⟨)rB   r   r  r   rM   rk   ri   )r2   r   r  s      r7   _print_AccumulationBoundsz3MathMLPresentationPrinter._print_AccumulationBounds)  sq    xx%%i0'8,&(+QUU+,QUU+,r9   c                .   t        |j                        rd}n| j                  |      }| j                  j	                  d      }d}t        |j                        D ]  \  }}||z  }|dk\  r| j                  j	                  d      }| j                  j	                  d      }|j                  | j                  j                  |             |j                  |       |j                  | j                  |             nE| j                  j	                  d      }|j                  | j                  j                  |             |j                  |       | j                  |      }	|j                  |	        | j                  j	                  d      }
|dk\  r| j                  j	                  d      }| j                  j	                  d      }|j                  | j                  j                  |             |j                  |       |j                  | j                  |             nE| j                  j	                  d      }|j                  | j                  j                  |             |
j                  |       | j                  j	                  d      }| j                  j	                  d      }|j                  |
       |j                  |       |j                  |       |j                  | j                  |j                               |S )Nz&#x2202;r@  r   r  rS  rB  r  )
r
   rQ   r   rB   r   rk  rl  r   rH   rM   )r2   r   r  r   dimrL  numr   xxr  mnumr@  r  s                r7   rn  z+MathMLPresentationPrinter._print_Derivative1  sU   AFF#A"A HH""6* !1!12 	HC3JC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!	 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,-r9   c                \   | j                   j                  d      }| j                   j                  d      }| j                  |      dk(  r:| j                  d   r+|j	                  | j                   j                  d             n9|j	                  | j                   j                  | j                  |                   | j                   j                  d      }|j                  D ]"  }|j	                  | j                  |             $ |j	                  |       |j	                  |       |S )Nr@  rC  r   r    r   r  )rB   r   r   rX  r   rH   r   rM   )r2   r   r@  r   r  r   s         r7   rr  z)MathMLPresentationPrinter._print_Functiona  s    xx%%f-HH""4(??1&4>>-+HMM$((11$78MM$((11$//!2DEFHH""9-66 	,CMM$++c*+	,r9   c                   t        |j                        }t        |j                  |d      }| j                  d   }| j
                  j                  d      }d|v r|j                  d      \  }}|d   dk(  r|dd  }| j
                  j                  d	      }|j                  | j
                  j                  |             |j                  |       | j
                  j                  d
      }	|	j                  | j
                  j                  |             |j                  |	       | j
                  j                  d      }
| j
                  j                  d	      }|j                  | j
                  j                  d             |
j                  |       | j
                  j                  d	      }|j                  | j
                  j                  |             |
j                  |       |j                  |
       |S |dk(  r| j                  d       S |dk(  r| j                  d       S | j
                  j                  d	      }|j                  | j
                  j                  |             |S )NT)strip_zerosr'   r@  r   r   r  r   r  rB  rS  10z+infz-inf)r   rf  rd  re  rX  rB   r   splitr   rH   r  r)  )r2   rQ   dpsstr_real	separatorr@  mantrY  r  rB  rS  s              r7   rh  z&MathMLPresentationPrinter._print_Floato  s   $**%tzz3DA NN#>?	xx%%f-(?"..-KT3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<=Ir9   c                L   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  d                |j                  |       | j                   j                  d      }|j                  | j	                  |j
                  d                |j                  |       |S )Nr@  rR  rC  Lir   r  r   r  )r2   rQ   r@  r   rC  r  s         r7   _print_polylogz(MathMLPresentationPrinter._print_polylog  s    xx%%f-HH""6*XX##D)
txx..t45	b	dkk$))A,/0xx%%i0TYYq\23r9   c                   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  | j	                  |                   |j                  |       | j                   j                  d      }|j
                  D ]"  }|j                  | j                  |             $ |j                  |       |S )Nr@  rC  r  rB   r   r   rH   r   r   rM   )r2   r   r@  rC  r  r   s         r7   rt  z&MathMLPresentationPrinter._print_Basic  s    xx%%f-XX##D)
txx..tq/ABCxx%%i066 	/CT[[-.	/r9   c                    | j                   j                  d      }| j                   j                  d      }|j                  D ]"  }|j                  | j	                  |             $ |j                  |       |S )Nr@  r  r  )r2   r   r@  r   r   s        r7   _print_Tuplez&MathMLPresentationPrinter._print_Tuple  se    xx%%f-HH""9-66 	,CMM$++c*+	,r9   c                   | j                   j                  d      }| j                   j                  d      }|j                  |j                  k(  rO|j	                  dd       |j	                  dd       |j                  | j                  |j                               n|j                  r|j	                  dd       n|j	                  dd       |j                  r|j	                  dd	       n|j	                  dd
       |j                  | j                  |j                               |j                  | j                  |j                               |j                  |       |S )Nr@  r  r  }r  {)r  (r   )	rB   r   startendr  r   rM   
right_open	left_open)r2   r   r@  r  s       r7   _print_Intervalz)MathMLPresentationPrinter._print_Interval  s   xx%%f-xx%%i077aeegs+fc*T[[12||!!'3/!!'3/{{!!&#.!!&#.T[[12T[[/0r9   c                6   | j                   j                  d      }| j                   j                  d      }|j                  dd       |j                  dd       |j                  | j	                  |j
                  d                |j                  |       |S )Nr@  r  r  |r  r   r&  )r2   rQ   rY  r@  r   s        r7   
_print_Absz$MathMLPresentationPrinter._print_Abs  sv    xx%%f-HH""9-	w$	vs#	dkk$))A,/0r9   c                   | j                   j                  d      }| j                   j                  d      }|j                  dd       |j                  | j                   j	                  |             |j                  |       | j                   j                  d      }|j                  | j                  |             |j                  |       |S )Nr@  rC  r  frakturr  )rB   r   r  r   rH   rM   )r2   r   rQ   r@  rC  r  s         r7   _print_re_imz&MathMLPresentationPrinter._print_re_im  s    xx%%f-XX##D)
y1
txx..q12xx%%i0T*+r9   c                @    | j                  d|j                  d         S )NRr   rf  r   r2   rQ   rY  s      r7   	_print_rez#MathMLPresentationPrinter._print_re        diil33r9   c                @    | j                  d|j                  d         S )NIr   ri  rj  s      r7   	_print_imz#MathMLPresentationPrinter._print_im  rl  r9   c                h   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  | j	                  |                   |j                  |       |j
                  D ]"  }|j                  | j                  |             $ |S )Nr@  rC  rT  )r2   r   r@  rC  r   s        r7   rv  z(MathMLPresentationPrinter._print_AssocOp  s    xx%%f-XX##D)
txx..tq/ABC66 	/CT[[-.	/r9   c                   | j                   j                  d      }|j                  | j                  |j                  d   |             |j                  dd  D ]{  }| j                   j                  d      }|j                  | j                   j                  |             | j                  ||      }|j                  |       |j                  |       } |S )Nr@  r   r   rB  )rB   r   r   r  r   rH   )r2   rQ   symbolprecr@  r   r   r  s           r7   _print_SetOpz&MathMLPresentationPrinter._print_SetOp  s    xx%%f-**499Q<>?99QR= 	 C&&t,AMM$((11&9:!!#t,AQQ	  r9   c                :    t         d   }| j                  |d|      S )Nr   z&#x222A;r   rt  r2   rQ   rs  s      r7   _print_Unionz&MathMLPresentationPrinter._print_Union  s!    %g.  z488r9   c                :    t         d   }| j                  |d|      S )Nr   z&#x2229;rv  rw  s      r7   _print_Intersectionz-MathMLPresentationPrinter._print_Intersection  s!    %n5  z488r9   c                :    t         d   }| j                  |d|      S )N
Complementz&#x2216;rv  rw  s      r7   r  z+MathMLPresentationPrinter._print_Complement  !    %l3  z488r9   c                :    t         d   }| j                  |d|      S )NSymmetricDifference&#x2206;rv  rw  s      r7   _print_SymmetricDifferencez4MathMLPresentationPrinter._print_SymmetricDifference  s"    %&;<  z488r9   c                :    t         d   }| j                  |d|      S )N
ProductSetz&#x00d7;rv  rw  s      r7   r  z+MathMLPresentationPrinter._print_ProductSet  r}  r9   c                8    | j                  |j                        S rA   )
_print_setr   )r2   rI  s     r7   r  z*MathMLPresentationPrinter._print_FiniteSet  s    qvv&&r9   c                    t        |t              }| j                  j                  d      }|j	                  dd       |j	                  dd       |D ]"  }|j                  | j                  |             $ |S )Nkeyr  r  rX  r  rY  )sortedr   rB   r   r  r   rM   )r2   rI  r?  r  rA  s        r7   r  z$MathMLPresentationPrinter._print_set  sn    q./xx%%i0'3'&#& 	0DT[[./	0r9   c                
   | j                   j                  d      }|d   j                  r_|d   j                  sP| j                   j                  d      }|j	                  | j                  |d                |j	                  |       n#|j	                  | j                  |d                |dd  D ]  }| j                   j                  d      }|j	                  | j                   j                  |             |j                  rH|j                  s<| j                   j                  d      }|j	                  | j                  |             n| j                  |      }|j	                  |       |j	                  |        |S )Nr@  r   r  r   rB  )rB   r   
is_Booleanis_Notr   rM   rH   )r2   r   rr  r@  r  r   r   r  s           r7   _print_LogOpz&MathMLPresentationPrinter._print_LogOp!  s0   xx%%f-7d1gnn88)))4DT[[a12T"T[[a128 		 C&&t,AMM$((11&9:~~cjjHH**95dkk#./KK$QQ		  r9   c                   ddl m} ||j                  k(  r| j                  |j                        S t	        ||      r|j                         j                         }nd|fg}| j                  j                  d      }|D ]i  \  }}t        |j                  j                               }|j                  d        t        |      D ]  \  }\  }	}
|
dk(  ry|rV| j                  j                  d      }|j                  | j                  j                  d             |j                  |       |j                  | j                  |	             |
d	k(  rx| j                  j                  d      }|j                  | j                  j                  d
             |j                  |       |j                  | j                  |	             |rV| j                  j                  d      }|j                  | j                  j                  d             |j                  |       | j                  j                  d      }|j                  | j                  |
             |j                  |       | j                  j                  d      }|j                  | j                  j                  d             |j                  |       |j                  | j                  |	             ! l |S )Nr   )Vectorr@  c                (    | d   j                         S )Nr   )__str__)r   s    r7   <lambda>zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>C  s    1Q4<<> r9   r  r   rB  r  r   r  r  r  )sympy.vectorr  zerorM   r  separater?  rB   r   r4  
componentssortr   r   rH   )r2   rQ   r  r?  r@  systemvect
inneritemsr   kvrB  mbracs                r7   _print_BasisDependentz/MathMLPresentationPrinter._print_BasisDependent5  s@   '499;;tyy))dF#MMO))+EYKExx%%f-! 	5LFDdoo3356JOO"9O:&z2 5	6Aq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/5	56 r9   c                \    t        |j                  t              }| j                  |d      S )Nr  z&#x2227;r  r   r   r  r2   rQ   r   s      r7   
_print_Andz$MathMLPresentationPrinter._print_And_  &    dii%56  z22r9   c                \    t        |j                  t              }| j                  |d      S )Nr  z&#x2228;r  r  s      r7   	_print_Orz#MathMLPresentationPrinter._print_Orc  r  r9   c                \    t        |j                  t              }| j                  |d      S )Nr  z&#x22BB;r  r  s      r7   r  z$MathMLPresentationPrinter._print_Xorg  r  r9   c                :    | j                  |j                  d      S )Nz&#x21D2;)r  r   r1  s     r7   r  z(MathMLPresentationPrinter._print_Impliesk  s      J77r9   c                \    t        |j                  t              }| j                  |d      S )Nr  z&#x21D4;r  r  s      r7   _print_Equivalentz+MathMLPresentationPrinter._print_Equivalentn  r  r9   c                
   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  d   j
                  rI| j                   j                  d      }|j                  | j                  |j                  d                n| j                  |j                  d         }|j                  |       |S )Nr@  rB  z&#xAC;r   r  )rB   r   r   rH   r   r  rM   )r2   r   r@  rB  r   s        r7   r  z$MathMLPresentationPrinter._print_Notr  s    xx%%f-XX##D)
txx..x89FF1I  &&y1AMM$++affQi01AFF1I&Ar9   c                    | j                   j                  d      }|j                  | j                   j                  | j	                  |                   |S NrC  rB   r   r   rH   r   r2   r   rC  s      r7   _print_boolz%MathMLPresentationPrinter._print_bool  ?    XX##D)
txx..tq/ABC	r9   c                    | j                   j                  d      }|j                  | j                   j                  | j	                  |                   |S r  r  r  s      r7   _print_NoneTypez)MathMLPresentationPrinter._print_NoneType  r  r9   c                   d}| j                   j                  d      }|j                  dd       |j                  dd       |j                  j                  r<|j
                  j                  r&|j                  j                  r|ddd	|f}n|d	dd|f}n|j                  j                  r||d   |j                  z
  |d   f}ny|j
                  j                  r#t        |      }t        |      t        |      |f}n@t        |      d
kD  r't        |      }t        |      t        |      ||d   f}nt        |      }|D ]~  }||k(  rW| j                   j                  d      }|j                  | j                   j                  |             |j                  |       _|j                  | j                  |              |S )Nu   …r  r  rX  r  rY  r   r   r      rC  )rB   r   r  r\  is_infinitestopstepis_positiveiternextr   tupler   rH   rM   )r2   rI  dotsr  printsetitelrC  s           r7   _print_Rangez&MathMLPresentationPrinter._print_Range  s{   xx%%i0'3'&#&77166#5#5vv!!Q4/Ar4/WW  QrUQVV^QrU2HVVaBBxb4/HVaZaBBxb426HQxH 	2BTzXX++D1txx66t<=  $  R1	2 r9   c                   t        |j                  t              }| j                  j	                  d      }| j                  j	                  d      }|j                  | j                  j                  t        |j                        j                                      |j                  |       | j                  j	                  d      }|D ]"  }|j                  | j                  |             $ |j                  |       |S )Nr  r@  rB  r  )r  r   r   rB   r   r   rH   r   funcr   rM   )r2   rQ   r   r@  rB  r  rr  s          r7   _hprint_variadic_functionz3MathMLPresentationPrinter._hprint_variadic_function  s    dii%56xx%%f-XX##D)
txx..DII/E/E/GHIxx%%i0 	2FT[[01	2r9   c                    | j                   j                  d      }|j                  | j                  d              |j                  | j	                  |j
                  d                |S )NrS  r   )rB   r   r   r  rM   r   )r2   rQ   rS  s      r7   
_print_expz$MathMLPresentationPrinter._print_exp  sS    xx%%f-))$/0TYYq\23r9   c                   | j                   j                  d      }|j                  | j                  |j                               | j                   j                  d      }|j                  | j                   j                  | j                  |                   |j                  |       |j                  | j                  |j                               |S )Nr@  rB  )rB   r   r   rM   rx  rH   r   ry  r2   r   r@  r   s       r7   rz  z+MathMLPresentationPrinter._print_Relational  s    xx%%f-QUU+,HH""4(	dhh--dooa.@ABQUU+,r9   c                    | j                   j                  | j                  |            }|j                  | j                   j	                  t        |                   |S rA   r`  r  s      r7   r  z$MathMLPresentationPrinter._print_int  r  r9   c                (   | j                   j                  d      }|j                  \  }}| j                   j                  d      }|j                  dd       |j	                  | j                   j                  |j                  |                |j	                  |       | j                   j                  d      }|j                  dd       |j	                  | j                   j                  |j                               |j	                  |       |S )NrR  rC  r  r  )rB   r   _idr  r   rH   _variable_names_name)r2   r   rR  indexr  rC  s         r7   _print_BaseScalarz+MathMLPresentationPrinter._print_BaseScalar  s    xx%%f-vXX##D)
v.
txx..v/E/Ee/LMNXX##D)
v.
txx..v||<=r9   c                ,   | j                   j                  d      }|j                  \  }}| j                   j                  d      }| j                   j                  d      }|j                  dd       |j	                  | j                   j                  |j                  |                |j	                  |       | j                   j                  d      }|j	                  | j                   j                  d             |j	                  |       |j	                  |       | j                   j                  d      }|j                  dd       |j	                  | j                   j                  |j                               |j	                  |       |S )NrR  moverrC  r  r  rB  ^)rB   r   r  r  r   rH   _vector_namesr  )r2   r   rR  r  r  r  rC  rB  s           r7   _print_BaseVectorz+MathMLPresentationPrinter._print_BaseVector  s,   xx%%f-v&&w/XX##D)
v.
txx..v/C/CE/JKL"XX##D)
txx..s34"XX##D)
v.
txx..v||<=r9   c                   | j                   j                  d      }| j                   j                  d      }|j                  dd       |j                  | j                   j	                  d             |j                  |       | j                   j                  d      }|j                  | j                   j	                  d             |j                  |       |S )Nr  rC  r  r  r7  rB  r  rB   r   r  r   rH   )r2   r   r  rC  rB  s        r7   _print_VectorZeroz+MathMLPresentationPrinter._print_VectorZero  s    &&w/XX##D)
v.
txx..s34"XX##D)
txx..s34"r9   c                   | j                   j                  d      }|j                  }|j                  }|j	                  | j                  |t        d                | j                   j                  d      }|j	                  | j                   j                  d             |j	                  |       |j	                  | j                  |t        d                |S )Nr@  r   rB  r  rB   r   _expr1_expr2r   r  r   rH   r2   rQ   r@  vec1vec2rB  s         r7   _print_Crossz&MathMLPresentationPrinter._print_Cross      xx%%f-{{{{**4E1BCDXX##D)
txx..x89**4E1BCDr9   c                   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       | j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  t        d                |S )Nr@  rB  &#x2207;r  r   rB   r   r   rH   r  _exprr   r2   rQ   r@  rB  s       r7   _print_Curlz%MathMLPresentationPrinter._print_Curl      xx%%f-XX##D)
txx..z:;XX##D)
txx..x89**4::z%7HIJr9   c                   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       | j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  t        d                |S )Nr@  rB  r  r   r   r  r  s       r7   _print_Divergencez+MathMLPresentationPrinter._print_Divergence  r  r9   c                   | j                   j                  d      }|j                  }|j                  }|j	                  | j                  |t        d                | j                   j                  d      }|j	                  | j                   j                  d             |j	                  |       |j	                  | j                  |t        d                |S )Nr@  r   rB  r   r  r  s         r7   
_print_Dotz$MathMLPresentationPrinter._print_Dot  r  r9   c                L   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  t        d                |S )Nr@  rB  r  r   r  r  s       r7   _print_Gradientz)MathMLPresentationPrinter._print_Gradient$  |    xx%%f-XX##D)
txx..z:;**4::z%7HIJr9   c                L   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  t        d                |S )Nr@  rB  r  r   r  r  s       r7   _print_Laplacianz*MathMLPresentationPrinter._print_Laplacian,  r  r9   c                    | j                   j                  d      }|j                  dd       |j                  | j                   j	                  d             |S )NrC  r  normalz&#x2124;r  r  s      r7   _print_Integersz)MathMLPresentationPrinter._print_Integers4  D    HH""4(	}h/	dhh--j9:r9   c                    | j                   j                  d      }|j                  dd       |j                  | j                   j	                  d             |S )NrC  r  r  z&#x2102;r  r  s      r7   _print_Complexesz*MathMLPresentationPrinter._print_Complexes:  r  r9   c                    | j                   j                  d      }|j                  dd       |j                  | j                   j	                  d             |S )NrC  r  r  z&#x211D;r  r  s      r7   _print_Realsz&MathMLPresentationPrinter._print_Reals@  r  r9   c                    | j                   j                  d      }|j                  dd       |j                  | j                   j	                  d             |S )NrC  r  r  &#x2115;r  r  s      r7   _print_Naturalsz)MathMLPresentationPrinter._print_NaturalsF  r  r9   c                h   | j                   j                  d      }| j                   j                  d      }|j                  dd       |j                  | j                   j	                  d             |j                  |       |j                  | j                  t        j                               |S )NrR  rC  r  r  r  )rB   r   r  r   rH   rM   r   Zero)r2   r   rP  r   s       r7   _print_Naturals0z*MathMLPresentationPrinter._print_Naturals0L  s}    hh$$V,HH""4(	}h/	dhh--j9:AFF+,
r9   c                   |j                   d   |j                   d   z
  }|j                   d   }| j                  j                  d      }| j                  j                  d      }|j                  dd       |j                  dd	       |j	                  | j                  |             |j	                  |       |j	                  | j                  |             |S )
Nr   r   r  rS  r  r  r?  r  r@  )r   rB   r   r  r   rM   )r2   rQ   shiftrg   rO  r  s         r7   _print_SingularityFunctionz4MathMLPresentationPrinter._print_SingularityFunctionU  s    		!tyy|+		!hh$$V,xx%%i0'8,&(+U+,E*+
r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  NaNr  r  s      r7   r  z$MathMLPresentationPrinter._print_NaNa  s6    HH""4(	dhh--e45r9   c                   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  |             |j                  |       |j                  | j	                  |j
                  d                t        |j
                        dk(  r|S | j                   j                  d      }| j                   j                  d      }|j
                  dd  D ]"  }|j                  | j	                  |             $ |j                  |       |j                  |       |S )NrR  rC  r   r   r@  r  )rB   r   r   rH   rM   r   r   )r2   r   rK  rP  rC  r@  r  r   s           r7   _print_number_functionz0MathMLPresentationPrinter._print_number_functionf  s     hh$$V,XX##D)
txx..t45AFF1I./qvv;!Jxx%%f-HH""9-66!": 	,CMM$++c*+	,r9   c                &    | j                  |d      S )NBr  r  s     r7   _print_bernoulliz*MathMLPresentationPrinter._print_bernoulliy      **1c22r9   c                &    | j                  |d      S )Nr  r  r  s     r7   _print_catalanz(MathMLPresentationPrinter._print_catalan~  r	  r9   c                &    | j                  |d      S )NEr  r  s     r7   _print_eulerz&MathMLPresentationPrinter._print_euler  r	  r9   c                &    | j                  |d      S )NFr  r  s     r7   _print_fibonacciz*MathMLPresentationPrinter._print_fibonacci  r	  r9   c                &    | j                  |d      S )NLr  r  s     r7   _print_lucasz&MathMLPresentationPrinter._print_lucas  r	  r9   c                &    | j                  |d      S )Nz&#x03B3;r  r  s     r7   _print_stieltjesz*MathMLPresentationPrinter._print_stieltjes  s    **1j99r9   c                &    | j                  |d      S )NTr  r  s     r7   _print_tribonacciz+MathMLPresentationPrinter._print_tribonacci  r	  r9   c                   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       | j                   j                  d      }|j                  | j                   j                  d             |j                  |       |S )Nr  rB  r  ~r  )r2   r   r   rB  s       r7   _print_ComplexInfinityz0MathMLPresentationPrinter._print_ComplexInfinity  s    HH""7+XX##D)
txx..z:;	bXX##D)
txx..s34	br9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrB  z&#x2205;r  r  s      r7   r!  z)MathMLPresentationPrinter._print_EmptySet  r  r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrB  z	&#x1D54C;r  r  s      r7   _print_UniversalSetz-MathMLPresentationPrinter._print_UniversalSet  6    HH""4(	dhh--k:;r9   c                   ddl m} |j                  }| j                  j	                  d      }t        ||      sM| j                  j	                  d      }|j                  | j                  |             |j                  |       n |j                  | j                  |             | j                  j	                  d      }|j                  | j                  j                  d             |j                  |       |S )Nr   rz   rS  r  rB  r  	sympy.matricesrz   r   rB   r   r  r   rM   rH   r2   rQ   rz   matrO  r  rB  s          r7   _print_Adjointz(MathMLPresentationPrinter._print_Adjoint  s    /hhhh$$V,#|,88)))4DT[[-.OOD!OODKK,-XX##D)
txx..z:;
r9   c                   ddl m} |j                  }| j                  j	                  d      }t        ||      sM| j                  j	                  d      }|j                  | j                  |             |j                  |       n |j                  | j                  |             | j                  j	                  d      }|j                  | j                  j                  d             |j                  |       |S )Nr   r"  rS  r  rB  r  r#  r%  s          r7   _print_Transposez*MathMLPresentationPrinter._print_Transpose  s    /hhhh$$V,#|,88)))4DT[[-.OOD!OODKK,-XX##D)
txx..s34
r9   c                   ddl m} |j                  }| j                  j	                  d      }t        ||      sM| j                  j	                  d      }|j                  | j                  |             |j                  |       n |j                  | j                  |             |j                  | j                  d             |S )Nr   r"  rS  r  r   )r$  rz   r   rB   r   r  r   rM   )r2   rQ   rz   r&  rO  r  s         r7   _print_Inversez(MathMLPresentationPrinter._print_Inverse  s    /hhhh$$V,#|,88)))4DT[[-.OOD!OODKK,-B(
r9   c           	     f   ddl m} | j                  j                  d      }|j                  }t        |d   t              r#|d   j                         t        |dd        z   }nt        |      }t        ||      r}|j                         rm|d   dk(  r|dd  }n	|d    |d<   | j                  j                  d      }|j                  | j                  j                  d             |j                  |       |d d D ]  }|j                  | j                  |t        |      d             | j                  j                  d      }|j                  | j                  j                  d	             |j                  |        |j                  | j                  |d   t        |      d             |S )
Nr   )MatMulr@  r   r   rB  r  Fr  )!sympy.matrices.expressions.matmulr-  rB   r   r   r  r   r   r4  r   r   rH   r  r   )r2   rQ   r-  r   r   rB  r   s          r7   _print_MatMulz'MathMLPresentationPrinter._print_MatMul  sw   <HH""6*yyd1gs#7--/$tABx.@D:DdF#(E(E(GAw"}ABx7(Q''-BNN48822378MM"9 	CMM$++C1G1M,13 4''-BNN488223EFGMM"	 	
d''R2H2N(-/ 	0r9   c                   ddl m} |j                  |j                  }}| j                  j                  d      }t        ||      sM| j                  j                  d      }|j                  | j                  |             |j                  |       n |j                  | j                  |             |j                  | j                  |             |S )Nr   r"  rS  r  )	r$  rz   r[  rY  rB   r   r  r   rM   )r2   rQ   rz   r[  rY  rO  r  s          r7   _print_MatPowz'MathMLPresentationPrinter._print_MatPow  s    /IItxxchh$$V,$-88)))4DT[[./OOD!OODKK-.C()
r9   c           	        | j                   j                  d      }|j                  }|d d D ]  }|j                  | j	                  |t        |      d             | j                   j                  d      }|j                  | j                   j                  d             |j                  |        |j                  | j	                  |d   t        |      d             |S )Nr@  r   FrB  z&#x2218;)rB   r   r   r   r  r   rH   )r2   rQ   r   r   r   rB  s         r7   _print_HadamardProductz0MathMLPresentationPrinter._print_HadamardProduct  s    HH""6*yy9 	CMM!!#'=d'CUKM''-BNN48822:>?MM"	 	
d2h(>t(DeL	Nr9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )Nr  z&#x1D7D8r  r2   Zr   s      r7   _print_ZeroMatrixz+MathMLPresentationPrinter._print_ZeroMatrix  r  r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )Nr  z&#x1D7D9r  r5  s      r7   _print_OneMatrixz*MathMLPresentationPrinter._print_OneMatrix  r  r9   c                    | j                   j                  d      }|j                  | j                   j                  d             |S )NrC  z	&#x1D540;r  )r2   rn  r   s      r7   _print_Identityz)MathMLPresentationPrinter._print_Identity  r   r9   c                6   | j                   j                  d      }| j                   j                  d      }|j                  dd       |j                  dd       |j                  | j	                  |j
                  d                |j                  |       |S )Nr@  r  r  u   ⌋r  u   ⌊r   r&  r  s       r7   _print_floorz&MathMLPresentationPrinter._print_floor  v    xx%%f-HH""9-	w)	vx(	dkk!&&),-r9   c                6   | j                   j                  d      }| j                   j                  d      }|j                  dd       |j                  dd       |j                  | j	                  |j
                  d                |j                  |       |S )Nr@  r  r  u   ⌉r  u   ⌈r   r&  r  s       r7   _print_ceilingz(MathMLPresentationPrinter._print_ceiling  r>  r9   c                B   | j                   j                  d      }| j                   j                  d      }|j                  d   }t        |      dk(  r| j	                  |d         }n| j	                  |      }|j                  |       | j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j                  d                |j                  |       |S )Nr  r@  r   r   rB  z&#x21A6;)rB   r   r   r   rM   r   rH   )r2   r   r   r@  symbolsrB  s         r7   r  z'MathMLPresentationPrinter._print_Lambda'  s    HH""9-xx%%f-&&)w<1kk'!*-Gkk'*G!XX##D)
txx..z:;QVVAY/0	dr9   c                    | j                   j                  d      }|D ]"  }|j                  | j                  |             $ |S r  r|  )r2   r   r   r   s       r7   _print_tuplez&MathMLPresentationPrinter._print_tuple7  s>    HH""9- 	*AMM$++a.)	*r9   c                8    | j                  |j                        S rA   )rM   labelr  s     r7   _print_IndexedBasez,MathMLPresentationPrinter._print_IndexedBase=  s    {{177##r9   c                r   | j                   j                  d      }|j                  | j                  |j                               t        |j                        dk(  r/|j                  | j                  |j                  d                |S |j                  | j                  |j                               |S )NrR  r   r   )rB   r   r   rM   r[  r   indicesr  s      r7   _print_Indexedz(MathMLPresentationPrinter._print_Indexed@  s    HH""6*	dkk!&&)*qyy>QMM$++aiil34H	dkk!)),-r9   c                   | j                   j                  d      }|j                  | j                  |j                  t
        d   d             | j                   j                  d      }|j                  dd       |j                  dd       |j                  D ]"  }|j                  | j                  |             $ |j                  |       |S )	NrR  AtomTr  r  r  r:   r  )	rB   r   r   r  parentr   r  rI  rM   )r2   r   r   r  r   s        r7   _print_MatrixElementz.MathMLPresentationPrinter._print_MatrixElementI  s    HH""6*	d''*V2Dt'TUxx%%i0'2&&"% 	-AT[[^,	-	dr9   c                   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       | j                   j                  d      }|j	                  dd       |j
                  D ]"  }|j                  | j                  |             $ |j                  |       |S )Nr@  rC  z	&#x1d5a5;r  
separatorsrb  rB   r   r   rH   r  r   rM   r2   r   r   rC  r  r   s         r7   _print_elliptic_fz+MathMLPresentationPrinter._print_elliptic_fT      HH""6*XX##D)
txx..{;<	bHH""9-	|S) 	*AMM$++a.)	*	ar9   c                   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       | j                   j                  d      }|j	                  dd       |j
                  D ]"  }|j                  | j                  |             $ |j                  |       |S )Nr@  rC  z	&#x1d5a4;r  rP  rb  rQ  rR  s         r7   _print_elliptic_ez+MathMLPresentationPrinter._print_elliptic_e`  rT  r9   c                   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       | j                   j                  d      }t	        |j
                        dk(  r|j                  dd       n|j                  dd       |j
                  D ]"  }|j                  | j                  |             $ |j                  |       |S )	Nr@  rC  z	&#x1d6f1;r  r  rP  rb  z;|)rB   r   r   rH   r   r   r  rM   rR  s         r7   _print_elliptic_piz,MathMLPresentationPrinter._print_elliptic_pil  s    HH""6*XX##D)
txx..{;<	bHH""9-qvv;!NN<-NN<. 	*AMM$++a.)	*	ar9   c                <   | j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                               |S )Nr@  rC  Eir  )r2   r   r   rC  s       r7   	_print_Eiz#MathMLPresentationPrinter._print_Ei{  so    HH""6*XX##D)
txx..t45	b	dkk!&&)*r9   c                   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  d                |j                  |       |j                  | j	                  |j
                  dd               |S )Nr@  rR  rB  r  r   r   r  r2   r   r   r  rB  s        r7   _print_expintz'MathMLPresentationPrinter._print_expint      HH""6*HH""6*XX##D)
txx..s34	b	dkk!&&),-	a	dkk!&&*-.r9   c                N   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  d                |j                  | j	                  |j
                  dd              |j                  |       |j                  | j	                  |j
                  dd               |S )Nr@  rT  rB  Pr   r   r,  r  r]  s        r7   _print_jacobiz'MathMLPresentationPrinter._print_jacobi      HH""6*HH""9-XX##D)
txx..s34	b	dkk!&&),-	dkk!&&1+./	a	dkk!&&*-.r9   c                N   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  d                |j                  | j	                  |j
                  dd              |j                  |       |j                  | j	                  |j
                  dd               |S )Nr@  rT  rB  r  r   r   r  r  r]  s        r7   _print_gegenbauerz+MathMLPresentationPrinter._print_gegenbauer  rc  r9   c                   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  d                |j                  |       |j                  | j	                  |j
                  dd               |S )Nr@  rR  rB  r  r   r   r  r]  s        r7   _print_chebyshevtz+MathMLPresentationPrinter._print_chebyshevt  r_  r9   c                   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  d                |j                  |       |j                  | j	                  |j
                  dd               |S )Nr@  rR  rB  Ur   r   r  r]  s        r7   _print_chebyshevuz+MathMLPresentationPrinter._print_chebyshevu  r_  r9   c                   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  d                |j                  |       |j                  | j	                  |j
                  dd               |S )Nr@  rR  rB  ra  r   r   r  r]  s        r7   _print_legendrez)MathMLPresentationPrinter._print_legendre  r_  r9   c                N   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  d                |j                  | j	                  |j
                  dd              |j                  |       |j                  | j	                  |j
                  dd               |S )Nr@  rT  rB  ra  r   r   r  r  r]  s        r7   _print_assoc_legendrez/MathMLPresentationPrinter._print_assoc_legendre  rc  r9   c                   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  d                |j                  |       |j                  | j	                  |j
                  dd               |S )Nr@  rR  rB  r  r   r   r  r]  s        r7   _print_laguerrez)MathMLPresentationPrinter._print_laguerre  r_  r9   c                N   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  d                |j                  | j	                  |j
                  dd              |j                  |       |j                  | j	                  |j
                  dd               |S )Nr@  rT  rB  r  r   r   r  r  r]  s        r7   _print_assoc_laguerrez/MathMLPresentationPrinter._print_assoc_laguerre  rc  r9   c                   | j                   j                  d      }| j                   j                  d      }| j                   j                  d      }|j                  | j                   j                  d             |j                  |       |j                  | j	                  |j
                  d                |j                  |       |j                  | j	                  |j
                  dd               |S )Nr@  rR  rB  Hr   r   r  r]  s        r7   _print_hermitez(MathMLPresentationPrinter._print_hermite  r_  r9   )FrA   )r   )r;   r<   r=   rW   r  r   r  r   r   r   r  r   r  r	  r  r  r  r  r)  r  r  r  r  r  r  r  r
  r6  r8  rU  r  r  r(  r-  r2  r4  r8  r^  ra  rA  rn  rr  rh  rR  rt  rV  r`  rc  _print_Determinantrf  rk  ro  rv  rt  rx  rz  r  r  r  r  r  _print_frozensetr  r  r  r  r  r  r  r  r  r$  r'  r  r  r  
_print_Min
_print_Maxr  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  _print_bellr  r  r  r  r  r  r  r!  r  r'  r)  r+  r/  r1  r3  r7  r9  r;  r=  r@  r  rD  rG  rJ  rN  rS  rV  rX  r[  r^  rb  re  rg  rj  rl  rn  rp  rr  ru  r>   r9   r7   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

:


 $	

	

			
	
	r9   r  c                t    |dk(  rt        |      j                  |       S t        |      j                  |       S )zReturns the MathML representation of expr. If printer is presentation
    then prints Presentation MathML else prints content MathML.
    presentation)r  rV   rZ   )rQ   printerrI   s      r7   mathmlr~    s8    
 . (2::4@@#H-55d;;r9   c                    |dk(  rt        |      }nt        |      }|j                  t        |             }|j	                         }t        |       y)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  rZ   rM   r   toprettyxmlprint)rQ   r}  rI   rI  xml
pretty_xmls         r7   print_mathmlr    sF    2 . %h/ *
((74=
!C"J	*r9   N)content)$rW   
__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   rd  r   rZ   r  r~  r  MathMLPrinterr>   r9   r7   <module>r     s    #   " / & H? ? @ : E E5 5pJ, J^W 1 Wt. !"< #< H %r9   