
    Rie&                   0   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#dS )z
A MathML printer.
    )annotations)Any)Mul)S)default_sort_key)sympify)split_super_subrequires_partial)precedence_traditional
PRECEDENCEPRECEDENCE_TRADITIONAL)greek_unicode)Printerprint_function)prec_to_dpsrepr_dpsto_strc                  Z    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d Zd Z	dS )MathMLPrinterBasez^Contains common code required for MathMLContentPrinter and
    MathMLPresentationPrinter.
    Nzutf-8Fabbreviated[plainT&#xB7;)orderencodingfold_frac_powersfold_func_bracketsfold_short_fracinv_trig_styleln_notationlong_frac_ratio	mat_delimmat_symbol_style
mul_symbolroot_notationsymbol_namesmul_symbol_mathml_numberszdict[str, Any]_default_settingsc                     t          j         |           ddlm}m}  |             _         G d d|           fd}| j        _        d S )Nr   )DocumentTextc                      e Zd ZddZdS )+MathMLPrinterBase.__init__.<locals>.RawText c                v    | j         r1|                    d                    || j         |                     d S d S )Nz{}{}{})datawriteformat)selfwriterindent	addindentnewls        5lib/python3.11/site-packages/sympy/printing/mathml.pywritexmlz4MathMLPrinterBase.__init__.<locals>.RawText.writexml6   sC    9 KLLD!I!IJJJJJK K    Nr.   r.   r.   )__name__
__module____qualname__r9    r:   r8   RawTextr-   5   s.        K K K K K Kr:   r@   c                B                 }| |_         j        |_        |S N)r0   domownerDocument)r0   rr@   r3   s     r8   createRawTextNodez5MathMLPrinterBase.__init__.<locals>.createRawTextNode:   s#    		AAF"hAOHr:   )r   __init__xml.dom.minidomr*   r+   rC   createTextNode)r3   settingsr*   r+   rF   r@   s   `    @r8   rG   zMathMLPrinterBase.__init__+   s    x(((222222228::	K 	K 	K 	K 	Kd 	K 	K 	K
	 	 	 	 	 	 #4r:   c                    t          j        | |          }|                                }|                    dd          }|                                }|S )z2
        Prints the expression as MathML.
        asciixmlcharrefreplace)r   _printtoxmlencodedecode)r3   exprmathMLunistrxmlbstrress         r8   doprintzMathMLPrinterBase.doprintB   sJ     d++--)<==nn
r:   c                    ddl m}m}mm dfd	}|j        | _        ||_        dfd	}|j        | _        ||_        d S )Nr   )Elementr+   Node_write_datar.   c                d   |                     |dz   | j        z              |                                 }t          |                                          }|                                 |D ]F}|                     d|z              
|||         j                   |                     d           G| j        r|                     d           t          | j                  dk    r?| j        d         j	        	j
        k    r$| j        d                             |ddd           nO|                     |           | j        D ]}|                    |||z   ||           |                     |           |                     d| j        d|           d S |                     d	|z             d S )
N<z %s="">   r   r.   z</z/>%s)r1   tagName_get_attributeslistkeyssortvalue
childNodeslennodeType	TEXT_NODEr9   )r3   r4   r5   r6   r7   attrsa_namesa_namenoderZ   r[   s            r8   r9   z/MathMLPrinterBase.apply_patch.<locals>.writexmlV   s    LL#4555((**E5::<<((GLLNNN! # #X.///FE&M$7888T"""" .S!!!((A--*3t~EEOA&//BCCCCLL&&& $ I I"FY$6	4I I I ILL((($,,,=>>>>>Vt_-----r:   c                6     ||| j         |           d S rB   )r0   )r3   r4   r5   r6   r7   r[   s        r8   r9   z/MathMLPrinterBase.apply_patch.<locals>.writexmlu   s*    KFFDIItt DEEEEEr:   r;   )rH   rY   r+   rZ   r[   r9   _Element_writexml_old_Text_writexml_old)r3   rY   r+   r9   rZ   r[   s       @@r8   apply_patchzMathMLPrinterBase.apply_patchL   s     	EDDDDDDDDDDD	. 	. 	. 	. 	. 	. 	.8 &-%5"#	F 	F 	F 	F 	F 	F"&- r:   c                F    ddl m}m} | j        |_        | j        |_        d S )Nr   )rY   r+   )rH   rY   r+   rp   r9   rq   )r3   rY   r+   s      r8   restore_patchzMathMLPrinterBase.restore_patchz   s3    111111115/r:   rB   )
r<   r=   r>   __doc__r(   __annotations__rG   rW   rr   rt   r?   r:   r8   r   r      s          
 !#'#%-) )    "4 4 4 4.  ,! ,! ,!\0 0 0 0 0r:   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S )'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 r
||         c S |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)r3   e	translateclsns        r8   
mathml_tagzMathMLContentPrinter.mathml_tag   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
$ %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
 6
 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
 6
h 'k6
 6
 6
	p ;& 	$ 	$CAI~~ |###  K wwyyr:   c                   |                                 rr| j                            d          }|                    | j                            d                     |                    |                     |                      |S ddlm}  ||          \  }}|t          j        ur| j                            d          }|                    | j                            d                     |                    | 	                    |                     |                    | 	                    |                     |S |
                                \  }}|t          j        u r.t          |          dk    r| 	                    |d                   S | j        dk    r&t          j        |                                          }| j                            d          }|                    | j                            d                     |dk    r(|                    | 	                    |                     |D ]*}|                    | 	                    |                     +|S )	Napplyminusr   fractiondivider`   oldr~   )could_extract_minus_signrC   createElementappendChild
_print_Mulsympy.simplifyr   r   OnerN   as_coeff_mulrh   r   r   
_from_argsas_ordered_factors)	r3   rR   xr   numerdenomcoefftermsterms	            r8   r   zMathMLContentPrinter._print_Mul   s   ((** 	&&w//AMM$(0099:::MM$//4%00111H++++++x~~u&&w//AMM$(00::;;;MM$++e,,---MM$++e,,---H((**uAE>>c%jjAoo ;;uQx(((:N5))<<>>EH""7++	dh,,W55666A::MM$++e,,--- 	- 	-DMM$++d++,,,,r:   Nc                   |                      ||          }|                     |d                   }g }|dd          D ]}|                                r| j                            d          }|                    | j                            d                     |                    |           |                    |                     |                      |}||d         k    r|                    |           |                    |           |                     |          }||d         k    r(|                    |                     |                      t          |          dk    r|S | j                            d          }|                    | j                            d                     |r*|                    |                    d                     |*|S )Nr   r   r`   r   r   r}   )	_as_ordered_termsrN   r   rC   r   r   appendrh   pop)r3   rR   r   argslastProcessed	plusNodesargr   s           r8   
_print_AddzMathMLContentPrinter._print_Add   s   %%d%%88DG,,	8 	7 	7C++-- 7H**733dh44W==>>>m,,,dkk3$//000 !$r(??$$]333  /// $C 0 0$r(??$$T[[%5%5666y>>Q  H""7++	dh,,V44555 	,MM)--**+++  	,r:   c                   |j         d         j        dk    rt          d          | j                            d          }t          |j                   D ]\  }\  }}|t          |j                   dz
  k    rI|dk    rC| j                            d          }|                    |                     |                     nj| j                            d          }|                    |                     |                     |                    |                     |                     |                    |           |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
ValueErrorrC   r   	enumeraterh   r   rN   )r3   rR   rootir   cr  s          r8   _print_Piecewisez%MathMLContentPrinter._print_Piecewise  s*   9R=%%  / 0 0 0
 x%%k22"49-- 	$ 	$IAv1C	NNQ&&&199..{;;!!$++a..1111..w77!!$++a..111!!$++a..111U####r:   c           	     T   | j                             d          }t          |j                  D ]x}| j                             d          }t          |j                  D ]2}|                    |                     |||f                              3|                    |           y|S )Nmatrix	matrixrow)rC   r   rangerowscolsr   rN   )r3   mr   r  x_rjs         r8   _print_MatrixBasez&MathMLContentPrinter._print_MatrixBase  s    H""8,,qv 	 	A(((55C16]] 6 6AadG 4 45555MM#r:   c                   |j         dk    r[| j                            d          }|                    | j                            t          |j                                       |S | j                            d          }|                    | j                            d                     | j                            d          }|                    | j                            t          |j                                       | j                            d          }|                    | j                            t          |j                                        |                    |           |                    |           |S )Nr`   r   r   r   )qrC   r   r   rI   strp)r3   r   r   xnumxdenoms        r8   _print_Rationalz$MathMLContentPrinter._print_Rational&  s3   3!88&&t,,AMM$(11#ac((;;<<<HH""7++	dh,,X66777x%%d++00QS::;;;''--48223qs88<<===	d	fr:   c                   | j                             d          }|                    | j                             |                     |                               | j                             d          }| j                             d          }|                    |                     |j        d                              |                    |                     |j        d                              |                    |           |                    |           |                    |                     |j        d                              |S )Nr   bvarlowlimitr`      r   )rC   r   r   r   rN   r   )r3   r   r   x_1x_2s        r8   _print_Limitz!MathMLContentPrinter._print_Limit8  s   H""7++	dh,,T__Q-?-?@@AAAh$$V,,h$$Z00AF1I..///AF1I..///	c	c	dkk!&),,---r:   c                6    | j                             d          S )N
imaginaryirC   r   r3   r   s     r8   _print_ImaginaryUnitz)MathMLContentPrinter._print_ImaginaryUnitF      x%%l333r:   c                6    | j                             d          S )N
eulergammar#  r$  s     r8   _print_EulerGammaz&MathMLContentPrinter._print_EulerGammaI  r&  r:   c                    | j                             d          }|                    | j                             d                     |S )zwWe use unicode #x3c6 for Greek letter phi as defined here
        https://www.w3.org/2003/entities/2007doc/isogrk1.htmlr   u   φrC   r   r   rI   r3   r   r   s      r8   _print_GoldenRatioz'MathMLContentPrinter._print_GoldenRatioL  sA     H""4((	dh--.JKKLLLr:   c                6    | j                             d          S )Nexponentialer#  r$  s     r8   _print_Exp1z MathMLContentPrinter._print_Exp1S  s    x%%n555r:   c                6    | j                             d          S )Npir#  r$  s     r8   	_print_PizMathMLContentPrinter._print_PiV  s    x%%d+++r:   c                6    | j                             d          S )Ninfinityr#  r$  s     r8   _print_Infinityz$MathMLContentPrinter._print_InfinityY      x%%j111r:   c                6    | j                             d          S )N
notanumberr#  r$  s     r8   
_print_NaNzMathMLContentPrinter._print_NaN\  r&  r:   c                6    | j                             d          S )Nemptysetr#  r$  s     r8   _print_EmptySetz$MathMLContentPrinter._print_EmptySet_  r7  r:   c                6    | j                             d          S )Ntruer#  r$  s     r8   _print_BooleanTruez'MathMLContentPrinter._print_BooleanTrueb  s    x%%f---r:   c                6    | j                             d          S )Nfalser#  r$  s     r8   _print_BooleanFalsez(MathMLContentPrinter._print_BooleanFalsee  s    x%%g...r:   c                    | j                             d          }|                    | j                             d                     |                    | j                             d                     |S )Nr   r   r5  )rC   r   r   r,  s      r8   _print_NegativeInfinityz,MathMLContentPrinter._print_NegativeInfinityh  s`    H""7++	dh,,W55666	dh,,Z88999r:   c                |      fdt          j                  }|                                  |          S )Nc                   j                             d          }|                    j                                                                                j                             d          }|                                        | d         d                              |                    |           t          | d                   dk    rƉj                             d          }|                                        | d         d                              |                    |           j                             d          }|                                        | d         d                              |                    |           t          | d                   dk    rcj                             d          }|                                        | d         d                              |                    |           t          |           dk    r.|                                        j                             n&|                     | dd                               |S )	Nr   r  r      r  r`   uplimitr  )rC   r   r   r   rN   rh   function)limitsr   	bvar_elemlow_elemup_elemr   
lime_recurr3   s        r8   rO  z8MathMLContentPrinter._print_Integral.<locals>.lime_recuro  s	   &&w//AMM$(001C1CDDEEE..v66I!!$++fQil";";<<<MM)$$$6!9~~""811*==$$T[[1%>%>???h'''(00;;##DKKq	!$=$=>>>g&&&6!9~~""(00;;##DKKq	!$=$=>>>g&&&6{{adkk!*556666jj44555Hr:   )rc   rK  reverse)r3   r   rK  rO  s   `` @r8   _print_Integralz$MathMLContentPrinter._print_Integraln  sW    	 	 	 	 	 	 	0 ahz&!!!r:   c                ,    |                      |          S rB   )rQ  r$  s     r8   
_print_SumzMathMLContentPrinter._print_Sum  s     ##A&&&r:   c                v     j                                                  |                    } fd}d t          |j                  \  }}} |          }fd|D             }fd|D             } j                             d          }|                     j                             |                     |s|s/|                     j                             |                     nH j                             d          }|                    |           |                     ||                     |                    |           n|sc j                             d          }	|	                    |           |	                     ||                     |                    |	           n j                             d          }
|
                    |           |
                     ||                     |
                     ||                     |                    |
           |S )	Nc                   t          |           dk    rj                            d          }t          |           D ]\  }}|dk    r\j                            d          }|                    j                            d                     |                    |           j                            d          }|                    j                            |                     |                    |           |S j                            d          }|                    j                            | d                              |S )Nr`   zmml:mrowr   zmml:mo mml:mirh   rC   r   r  r   rI   itemsmrowr  itemmomir3   s         r8   joinz0MathMLContentPrinter._print_Symbol.<locals>.join  s)   5zzA~~x--j99(// ) )GAt1uu!X33H==tx'>'>s'C'CDDD((,,,//99BNN48#:#:4#@#@AAA$$R((((X++H55tx66uQx@@AAA	r:   c                @    | t           v rt          j        |           S | S rB   r   getss    r8   r   z5MathMLContentPrinter._print_Symbol.<locals>.translate  #    M!!$(+++r:   c                &    g | ]} |          S r?   r?   .0supr   s     r8   
<listcomp>z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>  !    333S))C..333r:   c                &    g | ]} |          S r?   r?   rh  subr   s     r8   rj  z6MathMLContentPrinter._print_Symbol.<locals>.<listcomp>  !    ///3		#///r:   rW  zmml:msubzmml:msupzmml:msubsup)rC   r   r   r	   namer   rI   )r3   symr   r_  rp  superssubsmnamemsubmsupmsubsupr   s   `          @r8   _print_Symbolz"MathMLContentPrinter._print_Symbol  sF   X##DOOC$8$899	 	 	 	 	$	 	 	 -SX66fdy3333F333////$///&&x00$(11$77888 	( %tx66t<<====x--j99  '''  d,,,t$$$$ 
(x--j99  '''  f...t$$$$(00??##E***##DDJJ///##DDLL111w'''	r:   c                   | j         d         rF|j        j        r9|j        j        dk    r(| j                            d          }|                    | j                            d                     |j        j        dk    r| j                            d          }| j                            d          }|                    | j                            t          |j        j                                       |                    |           |                    |           |                    | 
                    |j                             |S | j                            d          }| j                            |                     |                    }|                    |           |                    | 
                    |j                             |                    | 
                    |j                             |S )Nr%   r`   r   r  r  degreer   )	_settingsexpis_Rationalr  rC   r   r   r  rI   r  rN   baser   )r3   r   r   xmldegxmlcnr  s         r8   
_print_PowzMathMLContentPrinter._print_Pow  s    N?+ 	0A 	EGqLL&&w//AMM$(0088999uw!||//99..t44!!$("9"9#aeg,,"G"GHHH""5)))f%%%MM$++af--...HH""7++h$$T__Q%7%788	c	dkk!&))***	dkk!%(()))r:   c                    | j                             |                     |                    }|                    | j                             t          |                               |S rB   rC   r   r   r   rI   r  r,  s      r8   _print_Numberz"MathMLContentPrinter._print_Number  P    H""4??1#5#566	dh--c!ff55666r:   c                   | j                             |                     |                    }t          |j        t          |j                            }|                    | j                             |                     |S rB   )	rC   r   r   mlib_to_str_mpf_r   _precr   rI   )r3   r   r   repr_es       r8   _print_Floatz!MathMLContentPrinter._print_Float  se    H""4??1#5#566QWhqw&7&788	dh--f55666r:   c                   | j                             d          }|                     |          }t          |j                  rd}|                    | j                             |                     | j                             d          }t          |j                  D ]\  }}|                    |                     |                     |dk    rd| j                             d          }|                    |                     t          |                               |                    |           |                    |           |                    |                     |j                             |S )Nr   partialdiffr  r`   rz  )
rC   r   r   r
   rR   r   reversedvariable_countrN   r   )r3   r   r   diff_symbolr  rq  r~   rz  s           r8   _print_Derivativez&MathMLContentPrinter._print_Derivative  s@   H""7++ooa((AF## 	('K	dh,,[99:::h$$V,,"1#344 	( 	(JCOODKK,,---qyy//99""4;;wu~~#>#>???'''	c	dkk!&))***r:   c                   | j                             d          }|                    | j                             |                     |                               |j        D ]*}|                    |                     |                     +|S Nr   )rC   r   r   r   r   rN   r3   r   r   r   s       r8   _print_Functionz$MathMLContentPrinter._print_Function   s|    H""7++	dh,,T__Q-?-?@@AAA6 	, 	,CMM$++c**++++r:   c                    | j                             |                     |                    }|j        D ]*}|                    |                     |                     +|S rB   )rC   r   r   r   r   rN   r  s       r8   _print_Basicz!MathMLContentPrinter._print_Basic  sZ    H""4??1#5#5666 	, 	,CMM$++c**++++r:   c                "   | j                             d          }| j                             |                     |                    }|                    |           |j        D ]*}|                    |                     |                     +|S r  )rC   r   r   r   r   rN   )r3   r   r   r  r   s        r8   _print_AssocOpz#MathMLContentPrinter._print_AssocOp  s    H""7++h$$T__Q%7%788	c6 	, 	,CMM$++c**++++r:   c                n   | j                             d          }|                    | j                             |                     |                               |                    |                     |j                             |                    |                     |j                             |S r  )rC   r   r   r   rN   lhsrhsr,  s      r8   _print_Relationalz&MathMLContentPrinter._print_Relational  s    H""7++	dh,,T__Q-?-?@@AAA	dkk!%(()))	dkk!%(()))r:   c                    | j                             d          }|D ]*}|                    |                     |                     +|S )zgMathML reference for the <list> element:
        https://www.w3.org/TR/MathML2/chapter4.html#contm.listrc   rC   r   r   rN   )r3   seqdom_elementr\  s       r8   _print_listz MathMLContentPrinter._print_list  sQ     h,,V44 	7 	7D##DKK$5$56666r:   c                    | j                             |                     |                    }|                    | j                             t          |                               |S rB   r  r3   r  r  s      r8   
_print_intzMathMLContentPrinter._print_int$  S    h,,T__Q-?-?@@ 7 7A ? ?@@@r:   c                    | j                             d          }|j        D ]*}|                    |                     |                     +|S )NsetrC   r   r   r   rN   r  s       r8   _print_FiniteSetz%MathMLContentPrinter._print_FiniteSet-  sN    H""5))6 	, 	,CMM$++c**++++r:   c                    | j                             d          }|                    | j                             d                     |j        D ]*}|                    |                     |                     +|S )Nr   setdiffrC   r   r   r   rN   r  s       r8   _print_Complementz&MathMLContentPrinter._print_Complement3  sp    H""7++	dh,,Y778886 	, 	,CMM$++c**++++r:   c                    | j                             d          }|                    | j                             d                     |j        D ]*}|                    |                     |                     +|S )Nr   cartesianproductr  r  s       r8   _print_ProductSetz&MathMLContentPrinter._print_ProductSet:  sq    H""7++	dh,,-?@@AAA6 	, 	,CMM$++c**++++r:   rB   ),r<   r=   r>   ru   printmethodr   r   r   r  r  r  r   r%  r)  r-  r0  r3  r6  r:  r=  r@  rC  rE  rQ  rS  rx  _print_MatrixSymbol_print_RandomSymbolr  r  r  r  r  r  r  r  r  r  _print_Implies
_print_Not
_print_Xorr  r  r  r?   r:   r8   rx   rx      sM         $K@ @ @D! ! !F   8  *    $  4 4 44 4 4  6 6 6, , ,2 2 24 4 42 2 2. . ./ / /  " " ":' ' '
6 6 6p ('  .  
    &            
 $NJJ        r:   rx   c                  8   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/Z0d0 Z1dd1Z2dd2Z3d3 Z4d4 Z5d5 Z6d6 Z7d7 Z8d8 Z9d9 Z:d: Z;d; Z<e<Z=d< Z>d= Z?d> Z@d? ZAd@ ZBdA ZCdB ZDdC ZEdD ZFeFZGeFZHdE ZIdF ZJdG ZKeKxZLZMdH ZNdI ZOdJ ZPdK ZQdL ZRdM ZSdN ZTdO ZUdP ZVdQ ZWdR ZXdS ZYdT ZZdU Z[dV Z\dW Z]dX Z^dY Z_dZ Z`d[ Zad\ ZbebZcd] Zdd^ Zed_ Zfd` Zgda Zhdb Zidc Zjdd Zkde Zldf Zmdg Zndh Zodi Zpdj Zqdk Zrdl Zsdm Ztdn Zudo Zvdp Zwdq Zxdr Zyds Zzdt Z{du Z|dv Z}dw Z~dx Zdy Zdz Zd{ Zd| Zd} Zd~ Zd Zd Zd Zd Zd ZdS )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@dAdGdHdI} fdJ}|j         j        D ]}|j        }||v r
||         c S |j         j        dKk    r
 |            S |j         j        }|                                S )Lr{   r   mnLimitz&#x2192;r   &dd;r   r   r^  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_   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;)primenu
primeomegafresnelsfresnelcLambertW	HeavisideBooleanTrueBooleanFalseNoneTypemathieusmathieucmathieusprimemathieucprimec                     j         d          j         d         dk    rdS  j         d         dk    rdS  j         d         dk    rdS  j         d         dk    rd	S t           j         d         t                    st           j         d         S )
Nr$   r  &InvisibleTimes;r~   &#xD7;dotr   ldotz&#x2024;)r{  
isinstancer  	TypeError)r3   s   r8   mul_symbol_selectionzBMathMLPresentationPrinter.mathml_tag.<locals>.mul_symbol_selection  s    |,4N<0F::))-88x-66x-77!z| <cBB 4~l33r:   r   r   )r3   r   r   r  r   r   s   `     r8   r   z$MathMLPresentationPrinter.mathml_tagK  sv   0
d0
Z0
 &0
 4	0

 d0
 0
 :0
 50
 50
 50
 50
 H0
 Y0
 H0
 Y0
  H!0
" Y#0
 0
$ H%0
& X'0
( )0
* *+0
, :-0
. 
/0
0  10
2 c30
4 	50
6 I70
8 Y90
: );0
< )=0
> )?0
@ YA0
B yC0
D yE0
 0
F !#"!#((_0
 0
 0
	d	4 	4 	4 	4 	4 ;& 	$ 	$CAI~~ |###  ;5(('')))K wwyyr:   Fc                    t          |          }||k     s|sJ||k    rD| j                            d          }|                    |                     |                     |S |                     |          S Nmfenced)r   rC   r   r   rN   )r3   r\  levelstrictprec_valbracs         r8   parenthesizez&MathMLPresentationPrinter.parenthesize  su    )$//uv8u3D3D8)))44DT[[..///K;;t$$$r:   c                Z     fd} j                             d          }|                                rj j                             d          }|                     j                             d                     |                    |            || |          }n |||          }|S )Nc                   ddl m}  ||           \  }}|t          j        urȉj                            d          }j        d         r6t          t          |                     dk     r|	                    dd           
                    |          }
                    |          }|                    |           |                    |           |                    |           |S |                                 \  }}	|t          j        u rCt          |	          dk    r0|                    
                    |	d                              |S j        d	k    r&t          j        |	                                          }	|dk    r
                    |          }
j                            d
          }|                    j                                                |                                |                    |
           |                    |           |	D ]}|                                        |t(          d                              ||	d         k    soj                            d
          }|                    j                                                |                                |                    |           |S )Nr   r   mfracr      bevelledr?  r`   r   r]  r   r   )r   r   r   r   rC   r   r{  rh   r  setAttributerN   r   r   r   r   r   r   rI   r   r  r   )rR   r[  r   r   r   fracr  xdenr   r   r   yr   r3   s                r8   multiplyz6MathMLPresentationPrinter._print_Mul.<locals>.multiply  s   //////#8D>>LE5AE!!x--g66>"34 :SYY!9K9K%%j&999{{5)){{5))  &&&  &&&  &&&,,..LE5~~#e**//  U1X!6!6777zU""u--@@BBzzKK&&H**400dh55dood6K6KLLMMM  ###  ### ( (  !2!24E9J!K!KLLLuRy((..t44AMM$("9"9$//$:O:O"P"PQQQ$$Q'''Kr:   r[  r]  -)rC   r   r   r   rI   )r3   rR   r  r[  r   s   `    r8   r   z$MathMLPresentationPrinter._print_Mul  s    !	 !	 !	 !	 !	D x%%f--((** 	(&&t,,AMM$(11#66777Q8TE4((DD8D$''Dr:   Nc                   | j                             d          }|                     ||          }|                    |                     |d                              |dd          D ]}|                                r^| j                             d          }|                    | j                             d                     |                     |           }n\| j                             d          }|                    | j                             d                     |                     |          }|                    |           |                    |           |S )Nr[  r   r   r`   r]  r  +)rC   r   r   r   rN   r   rI   )r3   rR   r   r[  r   r   r   r  s           r8   r   z$MathMLPresentationPrinter._print_Add  sD   x%%f--%%d%%88T!W--...8 	  	 C++-- 	%H**400dh55c::;;;KK%% H**400dh55c::;;;KK$$QQr:   c           	        | j                             d          }t          |j                  D ]}| j                             d          }t          |j                  D ]a}| j                             d          }|                    |                     |||f                              |                    |           b|                    |           | j        d         dk    r|S | j                             d          }| j        d         dk    r,|                    dd	           |                    d
d           |                    |           |S )Nmtablemtrmtdr"   r.   r  r   close]open)	rC   r   r  r  r  r   rN   r{  r  )r3   r  tabler  r   r  r  r  s           r8   r  z+MathMLPresentationPrinter._print_MatrixBase  sD   &&x00qv 	! 	!A&&u--A16]] ! !H**511dkk!AqD'22333a    a    >+&",,Lx%%i00>+&#--gs+++fc***r:   c                   |j         dk     r	|j          }n|j         }| j                            d          }|s| j        d         r|                    dd           |                    |                     |                     |                    |                     |j                             |j         dk     r| j                            d          }| j                            d          }|                    | j                            d                     |                    |           |                    |           |S |S )	Nr   r  r   r  r?  r[  r]  r  )	r  rC   r   r{  r  r   rN   r  rI   )r3   r   foldedr  r   r[  r]  s          r8   _get_printed_Rationalz/MathMLPresentationPrinter._get_printed_Rational  s$   377AAAH""7++ 	/T^$56 	/NN:v...	dkk!nn%%%	dkk!#&&'''3778))&11D''--BNN4822377888R   QKHr:   c                    |j         dk    r|                     |j                  S |                     || j        d                   S )Nr`   r   )r  rN   r  r  r{  r$  s     r8   r  z)MathMLPresentationPrinter._print_Rational	  s?    3!88;;qs###))!T^<M-NOOOr:   c                   | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     | j                             d          }|                     |j        d                   }| j                             d          }|                    | j                             |                     |                               |                     |j        d                   }|                    |           |                    |           |                    |           |                    |           |                    |           |                    |           |                    |                     |j        d                              |S )	Nr[  munderr^  limr`   r]  r  r   )rC   r   r   rI   rN   r   r   )	r3   r   r[  r  r^  r   r  arrowr  s	            r8   r   z&MathMLPresentationPrinter._print_Limit  s   x%%f--''11X##D))
tx..u55666H""6**kk!&)$$&&t,,$(11$//!2D2DEEFFFkk!&)$$	c	e	c21   QVAY//000r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  z&ImaginaryI;r+  r,  s      r8   r%  z.MathMLPresentationPrinter._print_ImaginaryUnit&  s>    H""4((	dh--n==>>>r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  r  r+  r,  s      r8   r-  z,MathMLPresentationPrinter._print_GoldenRatio+  >    H""4((	dh--i88999r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  z&ExponentialE;r+  r,  s      r8   r0  z%MathMLPresentationPrinter._print_Exp10  s?    H""4((	dh--.>??@@@r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  z&pi;r+  r,  s      r8   r3  z#MathMLPresentationPrinter._print_Pi5  s>    H""4((	dh--f55666r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  &#x221E;r+  r,  s      r8   r6  z)MathMLPresentationPrinter._print_Infinity:  >    H""4((	dh--j99:::r:   c                F   | j                             d          }| j                             d          }|                    | j                             d                     |                     |          }|                    |           |                    |           |S )Nr[  r]  r  )rC   r   r   rI   r6  )r3   r   r[  r  r   s        r8   rE  z1MathMLPresentationPrinter._print_NegativeInfinity?  s    x%%f--H""4((	dh--c22333  ##r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  z&#x210F;r+  r,  s      r8   _print_HBarz%MathMLPresentationPrinter._print_HBarH  r  r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  r  r+  r,  s      r8   r)  z+MathMLPresentationPrinter._print_EulerGammaM  r  r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  TribonacciConstantr+  r,  s      r8   _print_TribonacciConstantz3MathMLPresentationPrinter._print_TribonacciConstantR  s?    H""4((	dh--.BCCDDDr:   c                    | j                             d          }|                    |                     |j        d                              |                    | j                             d                     |S )Nrv  r   &#x2020;rC   r   r   rN   r   rI   r3   r   rv  s      r8   _print_Daggerz'MathMLPresentationPrinter._print_DaggerW  sf    x%%f--QVAY//00000<<===r:   c                   | j                             d          }|                    |                     |j        d                              | j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |S )Nr[  r   r]  z&#x2208;r`   r  )r3   r   r[  r]  s       r8   _print_Containsz)MathMLPresentationPrinter._print_Contains]  s    x%%f--QVAY//000X##D))
tx..z::;;;QVAY//000r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  z&#x210B;r+  r,  s      r8   _print_HilbertSpacez-MathMLPresentationPrinter._print_HilbertSpacef  r  r:   c                    | j                             d          }|                    | j                             d                     |                    |                     |j        d                              |S )Nrv  z	&#x1D49E;r   rC   r   r   rI   rN   r   r  s      r8   _print_ComplexSpacez-MathMLPresentationPrinter._print_ComplexSpacek  sf    x%%f--00==>>>QVAY//000r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  z&#x2131;r+  r,  s      r8   _print_FockSpacez*MathMLPresentationPrinter._print_FockSpaceq  r  r:   c                   dddd}| j                             d          }t          |j                  dk    rt	          d |j        D                       rv| j                             d          }|                    | j                             |t          |j                                                |                    |           nt          |j                  D ]}| j                             d          }|                    | j                             |d	                              t          |          d	k    r|                    |           t          |          d
k    rr| j                             d          }|                    |           |                    |                     |d	                              |                    |           t          |          dk    r| j                             d          }|                    |           |                    |                     |d	                              |                    |                     |d
                              |                    |           |                    | 	                    |j
        t          d         d                     t          |j                  D ]}| j                             d          }|                    | j                             d                     |                    |           |                    |                     |d                              |S )Nz&#x222B;z&#x222C;z&#x222D;)r`   r  rH  r[  rH  c              3  <   K   | ]}t          |          d k    V  dS )r`   N)rh   )rh  r  s     r8   	<genexpr>z<MathMLPresentationPrinter._print_Integral.<locals>.<genexpr>{  s,      (N(N3SQ(N(N(N(N(N(Nr:   r]  r`   r  rv  rw  r   Tr  r  r   )rC   r   rh   rK  allr   rI   r  rN   r  rJ  r   )	r3   rR   
intsymbolsr[  r]  r  rv  rw  ds	            r8   rQ  z)MathMLPresentationPrinter._print_Integralw  s   #
zBB
x%%f--t{q  S(N(N$+(N(N(N%N%N ''--BNN4822:c$+>N>N3OPPQQQR      ,, . .X++D11tx66z!}EEFFFs88q==$$R(((s88q==811&99D$$R((($$T[[Q%8%8999$$T***s88q=="h44Y??G''+++''CF(;(;<<<''CF(;(;<<<$$W---**4=*U:K26 + 8 8 	9 	9 	9 DK(( 	2 	2C&&t,,AMM$(11&99:::QT[[Q001111r:   c                V   t          |j                  }| j                            d          }|                     |d         d                   }|                     |d         d                   }| j                            d          }|                    | j                            |                     |                               | j                            d          }|                     |d         d                   }| j                            d          }	|	                    | j                            d                     |                    |           |                    |	           |                    |           |                    |           |                    |           |                    |           | j                            d          }
|
                    |           t          t          |j
                            dk    r.|
                    |                     |j
                             n\| j                            d          }|                    |                     |j
                             |
                    |           |
S )	N
munderoverr   r`   r  r]  r[  r  r  )rc   rK  rC   r   rN   r   rI   r   rh   r  rJ  )r3   r   rK  subsuprM  rN  summandlowvarequalr[  fences               r8   rS  z$MathMLPresentationPrinter._print_Sum  s-   ah''55;;vay|,,++fQil++(((..DH33DOOA4F4FGGHHHh$$V,,kk&)A,''&&t,,$(11#66777!!!7###37###x%%f--   s1:1$$T[[445555H**955Edkk!*55666U###r:   r   c                   	  fd}d 	t          |j                  \  }}} 	|          }	fd|D             }	fd|D             } j                            d          }|                     j                            |                     t          |          dk    ret          |          dk    r|}n j                            d          }|                    |           |                     ||                     nt          |          dk    rN j                            d          }|                    |           |                     ||                     nk j                            d	          }|                    |           |                     ||                     |                     ||                     |d
k    r|                    dd
           |S )Nc                   t          |           dk    rj                            d          }t          |           D ]\  }}|dk    r\j                            d          }|                    j                            d                     |                    |           j                            d          }|                    j                            |                     |                    |           |S j                            d          }|                    j                            | d                              |S )Nr`   r[  r   r]  rV  r^  rX  rY  s         r8   r_  z5MathMLPresentationPrinter._print_Symbol.<locals>.join  s)   5zzA~~x--f55(// ) )GAt1uu!X33D99tx'>'>s'C'CDDD((,,,//55BNN48#:#:4#@#@AAA$$R((((X++D11tx66uQx@@AAA	r:   c                @    | t           v rt          j        |           S | S rB   ra  rc  s    r8   r   z:MathMLPresentationPrinter._print_Symbol.<locals>.translate  re  r:   c                &    g | ]} |          S r?   r?   rg  s     r8   rj  z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>  rk  r:   c                &    g | ]} |          S r?   r?   rm  s     r8   rj  z;MathMLPresentationPrinter._print_Symbol.<locals>.<listcomp>  ro  r:   r^  r   ru  rv  rw  boldmathvariant)r	   rp  rC   r   r   rI   rh   r  )
r3   rq  styler_  rp  rr  rs  rt  r   r   s
   `        @r8   rx  z'MathMLPresentationPrinter._print_Symbol  s   	 	 	 	 	$	 	 	 -SX66fdy3333F333////$///&&t,,$(11$77888v;;!4yyA~~H**622e$$$dd4jj))))4yyA~~H**622e$$$dd6ll++++H**955e$$$dd4jj)))dd6ll+++F??NN=&111r:   c                F    |                      || j        d                   S )Nr#   )r=  )rx  r{  )r3   rq  s     r8   r  z-MathMLPresentationPrinter._print_MatrixSymbol  s/    !!#(,7I(J " L L 	Lr:   c                    | j                             d          }|                    dd           |                    |                     |j        d                              |S )Nmenclosenotationtopr   rC   r   r  r   rN   r   )r3   rR   encs      r8   _print_conjugatez*MathMLPresentationPrinter._print_conjugate  sV    h$$Z00U+++DIaL11222
r:   c                Z   | j                             d          }|                    |                     |t          d                              | j                             d          }|                    | j                             |                     |                    |           |S )Nr[  Funcr]  )rC   r   r   r  r   rI   )r3   oprR   rowr]  s        r8   _print_operator_afterz/MathMLPresentationPrinter._print_operator_after  s    h$$V,,))$
60BCCDDDX##D))
tx..r22333
r:   c                D    |                      d|j        d                   S )N!r   rJ  r   r3   rR   s     r8   _print_factorialz*MathMLPresentationPrinter._print_factorial  s    ))#ty|<<<r:   c                D    |                      d|j        d                   S )Nz!!r   rM  rN  s     r8   _print_factorial2z+MathMLPresentationPrinter._print_factorial2	  s    ))$	!===r:   c                   | j                             d          }| j                             d          }|                    dd           |                    |                     |j        d                              |                    |                     |j        d                              |                    |           |S )Nr  r  linethickness0r   r`   rC  )r3   rR   r  r  s       r8   _print_binomialz)MathMLPresentationPrinter._print_binomial  s    x%%i00x%%g../3///TYq\22333TYq\22333r:   c                	   |j         j        rt          |j         j                  dk    rj|j         j        dk    rY| j        d         rK|j         j        dk    rG| j                            d          }|                    | 	                    |j
                             |j         j        dk    ry| j                            d          }|                    | 	                    |j
                             |                    | 	                    |j         j                             |j         j        dk    rY| j                            d          }|                    | 	                    d                     |                    |           |S |S |j         j        r|j         j        dk    r|j         j        r| j                            d          }|                    | 	                    d                     | j                            d          }|                    |                     |j
        t          d	                              |                    |                     |j          | j        d
                              |                    |           |S | j                            d          }|                    |                     |j
        t          d	                              |                    |                     |j         | j        d
                              |S |j         j        r| j                            d          }|                    | 	                    d                     |j         dk    r.|                    | 	                    |j
                             n| j                            d          }|                    |                     |j
        t          d	                              |                    | 	                    |j                               |                    |           |S | j                            d          }|                    |                     |j
        t          d	                              |                    | 	                    |j                              |S )Nr`   r%   r  msqrtmrootr   r  rv  r   r   )r|  r}  r   r  r  r{  rC   r   r   rN   r~  is_negativer  r   r  )r3   r   r   r  rB  s        r8   r  z$MathMLPresentationPrinter._print_Pow  s    E 	#aeg,,!"3"31/ 9Euw!||H**733dkk!&11222uw!||H**733dkk!&11222dkk!%'22333uw"}}x--g66  Q000  ###5 	Au  h,,W55A///H**622d//
58IJJKKKd88!%$(N3E$FH H I I I"""
H**622d//
58IJJKKKd88$(N3E$FH H I I I5 
	h,,W55A///5B;;OODKK$7$78888..v66AMM$"3"3AFJu<M"N"NOOOMM$++quf"5"5666OOA&&&
H""6**	d''
50ABBCCC	dkk!%(()))r:   c                    | j                             |                     |                    }|                    | j                             t          |                               |S rB   r  r,  s      r8   r  z'MathMLPresentationPrinter._print_NumberK  r  r:   c                F   | j                             d          }|                    dd           |                    dd           |                    |                     |j                             |                    |                     |j                             |S )Nr  r     ⟩r      ⟨)rC   r   r  r   rN   r   r   )r3   r  r  s      r8   _print_AccumulationBoundsz3MathMLPresentationPrinter._print_AccumulationBoundsP  s    x%%i00'8,,,&(+++QU++,,,QU++,,,r:   c                   t          |j                  rd}n|                     |          }| j                            d          }d}t          |j                  D ]6\  }}||z  }|dk    r| j                            d          }| j                            d          }|                    | j                            |                     |                    |           |                    | 	                    |                     nG| j                            d          }|                    | j                            |                     |                    |           | 	                    |          }	|                    |	           8| j                            d          }
|dk    r| j                            d          }| j                            d          }|                    | j                            |                     |                    |           |                    | 	                    |                     nG| j                            d          }|                    | j                            |                     |
                    |           | j                            d          }| j                            d          }|                    |
           |                    |           |                    |           |                    | 	                    |j                             |S )Nz&#x2202;r[  r   r  rv  r]  r  )
r
   rR   r   rC   r   r  r  r   rI   rN   )r3   r   r-  r  dimrq  numr   xxr  mnumr[  r  s                r8   r  z+MathMLPresentationPrinter._print_DerivativeX  s   AF## 	#AA""A H""6** !122 	 	HC3JCaxxH**622X++D11tx66q99:::b!!!dkk#..////H**400dh55a88999MM!C  AMM!x%%f--!88&&v..A''--BNN4822155666MM"MM$++c**++++&&t,,AMM$(11!44555x%%f--x%%g.. 	QV,,---r:   c                   | j                             d          }| j                             d          }|                     |          dk    r;| j        d         r.|                    | j                             d                     n@|                    | j                             |                     |                               | j                             d          }|j        D ]*}|                    |                     |                     +|                    |           |                    |           |S )Nr[  r^  r   r    r   r  )rC   r   r   r{  r   rI   r   rN   )r3   r   r[  r   r  r   s         r8   r  z)MathMLPresentationPrinter._print_Function  s   x%%f--H""4((??1&&4>-+H&MM$(11$778888MM$(11$//!2D2DEEFFFH""9--6 	, 	,CMM$++c**++++r:   c                L   t          |j                  }t          |j        |d          }| j        d         }| j                            d          }d|v r|                    d          \  }}|d         dk    r
|dd          }| j                            d	          }|                    | j        	                    |                     |                    |           | j                            d
          }	|	                    | j        	                    |                     |                    |	           | j                            d          }
| j                            d	          }|                    | j        	                    d                     |
                    |           | j                            d	          }|                    | j        	                    |                     |
                    |           |                    |
           |S |dk    r| 
                    d           S |dk    r|                     d           S | j                            d	          }|                    | j        	                    |                     |S )NT)strip_zerosr'   r[  r   r   r  r`   r  r]  rv  10z+infz-inf)r   r  r  r  r{  rC   r   splitr   rI   r6  rE  )r3   rR   dpsstr_real	separatorr[  mantr|  r  r]  rv  s              r8   r  z&MathMLPresentationPrinter._print_Float  sW   $*%%tz3DAAA N#>?	x%%f--(??"..--KT31v}}!""g''--BNN4822488999R   ''--BNN48229==>>>R   8))&11D''--BNN4822488999R   ''--BNN4822377888R   T"""K''---//555''--BNN48228<<===Ir:   c                z   | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |           | j                             d          }|                    |                     |j        d                              |                    |           |S )Nr[  ru  r^  Lir   r  r`   r#  )r3   rR   r[  r  r^  r  s         r8   _print_polylogz(MathMLPresentationPrinter._print_polylog  s   x%%f--H""6**X##D))
tx..t44555	b	dkk$)A,//000x%%i00TYq\22333r:   c                   | j                             d          }| j                             d          }|                    | j                             |                     |                               |                    |           | j                             d          }|j        D ]*}|                    |                     |                     +|                    |           |S )Nr[  r^  r  rC   r   r   rI   r   r   rN   )r3   r   r[  r^  r  r   s         r8   r  z&MathMLPresentationPrinter._print_Basic  s    x%%f--X##D))
tx..tq/A/ABBCCCx%%i006 	/ 	/CT[[--....r:   c                    | j                             d          }| j                             d          }|j        D ]*}|                    |                     |                     +|                    |           |S )Nr[  r  r  )r3   r   r[  r   r   s        r8   _print_Tuplez&MathMLPresentationPrinter._print_Tuple  sw    x%%f--H""9--6 	, 	,CMM$++c**++++r:   c                   | j                             d          }| j                             d          }|j        |j        k    rZ|                    dd           |                    dd           |                    |                     |j                             n|j        r|                    dd           n|                    dd           |j        r|                    dd	           n|                    dd
           |                    |                     |j                             |                    |                     |j                             |                    |           |S )Nr[  r  r  }r   {)r  (r   )	rC   r   startendr  r   rN   
right_open	left_open)r3   r  r[  r  s       r8   _print_Intervalz)MathMLPresentationPrinter._print_Interval  s[   x%%f--x%%i007aegs+++fc***T[[112222| 0!!'3////!!'3///{ /!!&#....!!&#...T[[11222T[[//000r:   c                V   | j                             d          }| j                             d          }|                    dd           |                    dd           |                    |                     |j        d                              |                    |           |S )Nr[  r  r  |r   r   rC  )r3   rR   r|  r[  r   s        r8   
_print_Absz$MathMLPresentationPrinter._print_Abs  s    x%%f--H""9--	w$$$	vs###	dkk$)A,//000r:   c                   | j                             d          }| j                             d          }|                    dd           |                    | j                             |                     |                    |           | j                             d          }|                    |                     |                     |                    |           |S )Nr[  r^  r<  frakturr  )rC   r   r  r   rI   rN   )r3   r  rR   r[  r^  r  s         r8   _print_re_imz&MathMLPresentationPrinter._print_re_im  s    x%%f--X##D))
y111
tx..q11222x%%i00T**+++r:   c                D    |                      d|j        d                   S )NRr   r  r   r3   rR   r|  s      r8   	_print_rez#MathMLPresentationPrinter._print_re        dil333r:   c                D    |                      d|j        d                   S )NIr   r  r  s      r8   	_print_imz#MathMLPresentationPrinter._print_im  r  r:   c                |   | j                             d          }| j                             d          }|                    | j                             |                     |                               |                    |           |j        D ]*}|                    |                     |                     +|S )Nr[  r^  rq  )r3   r   r[  r^  r   s        r8   r  z(MathMLPresentationPrinter._print_AssocOp  s    x%%f--X##D))
tx..tq/A/ABBCCC6 	/ 	/CT[[--....r:   c                   | j                             d          }|                    |                     |j        d         |                     |j        dd          D ]}| j                             d          }|                    | j                             |                     |                     ||          }|                    |           |                    |           |S )Nr[  r   r`   r]  )rC   r   r   r  r   rI   )r3   rR   symbolprecr[  r   r   r  s           r8   _print_SetOpz&MathMLPresentationPrinter._print_SetOp  s    x%%f--**49Q<>>???9QRR= 	  	 C&&t,,AMM$(11&99:::!!#t,,AQQr:   c                J    t           d         }|                     |d|          S )Nr   z&#x222A;r   r  r3   rR   r  s      r8   _print_Unionz&MathMLPresentationPrinter._print_Union&  s$    %g.  z4888r:   c                J    t           d         }|                     |d|          S )Nr   z&#x2229;r  r  s      r8   _print_Intersectionz-MathMLPresentationPrinter._print_Intersection*  s$    %n5  z4888r:   c                J    t           d         }|                     |d|          S )N
Complementz&#x2216;r  r  s      r8   r  z+MathMLPresentationPrinter._print_Complement.  $    %l3  z4888r:   c                J    t           d         }|                     |d|          S )NSymmetricDifference&#x2206;r  r  s      r8   _print_SymmetricDifferencez4MathMLPresentationPrinter._print_SymmetricDifference2  s%    %&;<  z4888r:   c                J    t           d         }|                     |d|          S )N
ProductSetz&#x00d7;r  r  s      r8   r  z+MathMLPresentationPrinter._print_ProductSet6  r  r:   c                6    |                      |j                  S rB   )
_print_setr   )r3   rd  s     r8   r  z*MathMLPresentationPrinter._print_FiniteSet:  s    qv&&&r:   c                   t          |t                    }| j                            d          }|                    dd           |                    dd           |D ]*}|                    |                     |                     +|S )Nkeyr  r  ru  r   rv  )sortedr   rC   r   r  r   rN   )r3   rd  rZ  r  r\  s        r8   r  z$MathMLPresentationPrinter._print_set=  s    q.///x%%i00'3'''&#&&& 	0 	0DT[[..////r:   c                N   | j                             d          }|d         j        rk|d         j        s^| j                             d          }|                    |                     |d                              |                    |           n.|                    |                     |d                              |dd          D ]}| j                             d          }|                    | j                             |                     |j        rJ|j        sC| j                             d          }|                    |                     |                     n|                     |          }|                    |           |                    |           |S )Nr[  r   r  r`   r]  )rC   r   
is_Booleanis_Notr   rN   rI   )r3   r   r  r[  r  r   r   r  s           r8   _print_LogOpz&MathMLPresentationPrinter._print_LogOpH  s   x%%f--7 	3d1gn 	38)))44DT[[a11222T""""T[[a112228 		  		 C&&t,,AMM$(11&99:::~ %cj %H**955dkk#..////KK$$QQr:   c                n   ddl m} ||j        k    r|                     |j                  S t	          ||          r'|                                                                }nd|fg}| j                            d          }|D ]\  }}t          |j
                                                  }|                    d            t          |          D ][\  }\  }	}
|
dk    r|r\| j                            d          }|                    | j                            d                     |                    |           |                    |                     |	                     |
d	k    r| j                            d          }|                    | j                            d
                     |                    |           |                    |                     |	                     "|r\| j                            d          }|                    | j                            d                     |                    |           | j                            d          }|                    |                     |
                     |                    |           | j                            d          }|                    | j                            d                     |                    |           |                    |                     |	                     ]|S )Nr   )Vectorr[  c                6    | d                                          S )Nr   )__str__)r   s    r8   <lambda>zAMathMLPresentationPrinter._print_BasisDependent.<locals>.<lambda>j  s    1Q4<<>> r:   r  r`   r]  r  r   r  r  r  )sympy.vectorr  zerorN   r  separaterZ  rC   r   rc   
componentsre   r  r   rI   )r3   rR   r  rZ  r[  systemvect
inneritemsr  kvr]  mbracs                r8   _print_BasisDependentz/MathMLPresentationPrinter._print_BasisDependent\  s   ''''''49;;ty)))dF## 	 MMOO))++EEYKEx%%f--! 	5 	5LFDdo335566JOO"9"9O:::&z22 5 5	6Aq66 -!X33D99tx'>'>s'C'CDDD((,,,$$T[[^^4444"WW//55BNN48#:#:3#?#?@@@$$R((($$T[[^^4444 -!X33D99tx'>'>s'C'CDDD((,,, H229==E%%dkk!nn555$$U+++//55BNN48#:#:;M#N#NOOO$$R((($$T[[^^4444/50 r:   c                d    t          |j        t                    }|                     |d          S )Nr  z&#x2227;r  r   r   r  r3   rR   r   s      r8   
_print_Andz$MathMLPresentationPrinter._print_And  -    di%5666  z222r:   c                d    t          |j        t                    }|                     |d          S )Nr  z&#x2228;r  r  s      r8   	_print_Orz#MathMLPresentationPrinter._print_Or  r  r:   c                d    t          |j        t                    }|                     |d          S )Nr  z&#x22BB;r  r  s      r8   r  z$MathMLPresentationPrinter._print_Xor  r  r:   c                8    |                      |j        d          S )Nz&#x21D2;)r  r   rN  s     r8   r  z(MathMLPresentationPrinter._print_Implies  s      J777r:   c                d    t          |j        t                    }|                     |d          S )Nr  z&#x21D4;r  r  s      r8   _print_Equivalentz+MathMLPresentationPrinter._print_Equivalent  r  r:   c                   | j                             d          }| j                             d          }|                    | j                             d                     |                    |           |j        d         j        rN| j                             d          }|                    |                     |j        d                              n |                     |j        d                   }|                    |           |S )Nr[  r]  z&#xAC;r   r  )rC   r   r   rI   r   r  rN   )r3   r   r[  r]  r   s        r8   r  z$MathMLPresentationPrinter._print_Not  s    x%%f--X##D))
tx..x88999F1I  	'&&y11AMM$++afQi001111AF1I&&Ar:   c                    | j                             d          }|                    | j                             |                     |                               |S Nr^  rC   r   r   rI   r   r3   r   r^  s      r8   _print_boolz%MathMLPresentationPrinter._print_bool  J    X##D))
tx..tq/A/ABBCCC	r:   c                    | j                             d          }|                    | j                             |                     |                               |S r  r  r  s      r8   _print_NoneTypez)MathMLPresentationPrinter._print_NoneType  r  r:   c                   d}| j                             d          }|                    dd           |                    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}n|j        j        r/t          |          }t          |          t          |          |f}nXt          |          d
k    r6t          |          }t          |          t          |          ||d         f}nt          |          }|D ]}||k    r]| j                             d          }|                    | j                             |                     |                    |           e|                    |                     |                     |S )Nu   …r  r  ru  r   rv  r   r   r`      r^  )rC   r   r  ry  is_infinitestopstepis_positiveiternextrh   tupler   rI   rN   )r3   rd  dotsr  printsetitelr^  s           r8   _print_Rangez&MathMLPresentationPrinter._print_Range  s   x%%i00'3'''&#&&&7 	 16#5 	 v! 0Q4/Ar4/W  		 QrUQV^QrU2HHV 	 aBBxxb4/HHVVaZZaBBxxb426HHQxxH 	2 	2BTzzX++D11tx66t<<===  $$$$  R1111r:   c                (   t          |j        t                    }| j                            d          }| j                            d          }|                    | j                            t          |j                  	                                                     |                    |           | j                            d          }|D ]*}|                    | 
                    |                     +|                    |           |S )Nr  r[  r]  r  )r  r   r   rC   r   r   rI   r  funcr   rN   )r3   rR   r   r[  r]  r  r  s          r8   _hprint_variadic_functionz3MathMLPresentationPrinter._hprint_variadic_function  s    di%5666x%%f--X##D))
tx..DI/E/E/G/GHHIIIx%%i00 	2 	2FT[[001111r:   c                    | j                             d          }|                    |                     d                      |                    |                     |j        d                              |S )Nrv  r   )rC   r   r   r0  rN   r   )r3   rR   rv  s      r8   
_print_expz$MathMLPresentationPrinter._print_exp  sd    x%%f--))$//000TYq\22333r:   c                   | j                             d          }|                    |                     |j                             | j                             d          }|                    | j                             |                     |                               |                    |           |                    |                     |j                             |S )Nr[  r]  )rC   r   r   rN   r  rI   r   r  r3   r   r[  r   s       r8   r  z+MathMLPresentationPrinter._print_Relational  s    x%%f--QU++,,,H""4((	dh--dooa.@.@AABBBQU++,,,r:   c                    | j                             |                     |                    }|                    | j                             t          |                               |S rB   r  r  s      r8   r  z$MathMLPresentationPrinter._print_int  r  r:   c                6   | j                             d          }|j        \  }}| j                             d          }|                    dd           |                    | j                             |j        |                              |                    |           | j                             d          }|                    dd           |                    | j                             |j                             |                    |           |S )Nru  r^  r<  r;  )rC   r   _idr  r   rI   _variable_names_name)r3   r   ru  indexr  r^  s         r8   _print_BaseScalarz+MathMLPresentationPrinter._print_BaseScalar  s    x%%f--vX##D))
v...
tx..v/Ee/LMMNNNX##D))
v...
tx..v|<<===r:   c                L   | j                             d          }|j        \  }}| j                             d          }| j                             d          }|                    dd           |                    | j                             |j        |                              |                    |           | j                             d          }|                    | j                             d                     |                    |           |                    |           | j                             d          }|                    dd           |                    | j                             |j                             |                    |           |S )Nru  moverr^  r<  r;  r]  ^)rC   r   r  r  r   rI   _vector_namesr  )r3   r   ru  r  r  r  r^  r]  s           r8   _print_BaseVectorz+MathMLPresentationPrinter._print_BaseVector  sc   x%%f--v&&w//X##D))
v...
tx..v/CE/JKKLLL"X##D))
tx..s33444"X##D))
v...
tx..v|<<===r:   c                   | j                             d          }| j                             d          }|                    dd           |                    | j                             d                     |                    |           | j                             d          }|                    | j                             d                     |                    |           |S )Nr  r^  r<  r;  rT  r]  r  rC   r   r  r   rI   )r3   r   r  r^  r]  s        r8   _print_VectorZeroz+MathMLPresentationPrinter._print_VectorZero  s    &&w//X##D))
v...
tx..s33444"X##D))
tx..s33444"r:   c                   | j                             d          }|j        }|j        }|                    |                     |t          d                              | j                             d          }|                    | j                             d                     |                    |           |                    |                     |t          d                              |S )Nr[  r   r]  r  rC   r   _expr1_expr2r   r  r   rI   r3   rR   r[  vec1vec2r]  s         r8   _print_Crossz&MathMLPresentationPrinter._print_Cross      x%%f--{{**4E1BCCDDDX##D))
tx..x88999**4E1BCCDDDr:   c                   | j                             d          }| j                             d          }|                    | j                             d                     |                    |           | j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        t          d                              |S )Nr[  r]  &#x2207;r  r   rC   r   r   rI   r  _exprr   r3   rR   r[  r]  s       r8   _print_Curlz%MathMLPresentationPrinter._print_Curl*      x%%f--X##D))
tx..z::;;;X##D))
tx..x88999**4:z%7HIIJJJr:   c                   | j                             d          }| j                             d          }|                    | j                             d                     |                    |           | j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        t          d                              |S )Nr[  r]  r  r   r   r  r   s       r8   _print_Divergencez+MathMLPresentationPrinter._print_Divergence5  r  r:   c                   | j                             d          }|j        }|j        }|                    |                     |t          d                              | j                             d          }|                    | j                             d                     |                    |           |                    |                     |t          d                              |S )Nr[  r   r]  r   r  r  s         r8   
_print_Dotz$MathMLPresentationPrinter._print_Dot@  r  r:   c                d   | j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        t          d                              |S )Nr[  r]  r  r   r  r   s       r8   _print_Gradientz)MathMLPresentationPrinter._print_GradientK      x%%f--X##D))
tx..z::;;;**4:z%7HIIJJJr:   c                d   | j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        t          d                              |S )Nr[  r]  r  r   r  r   s       r8   _print_Laplacianz*MathMLPresentationPrinter._print_LaplacianS  r	  r:   c                    | j                             d          }|                    dd           |                    | j                             d                     |S )Nr^  r<  normalz&#x2124;r  r,  s      r8   _print_Integersz)MathMLPresentationPrinter._print_Integers[  R    H""4((	}h///	dh--j99:::r:   c                    | j                             d          }|                    dd           |                    | j                             d                     |S )Nr^  r<  r  z&#x2102;r  r,  s      r8   _print_Complexesz*MathMLPresentationPrinter._print_Complexesa  r  r:   c                    | j                             d          }|                    dd           |                    | j                             d                     |S )Nr^  r<  r  z&#x211D;r  r,  s      r8   _print_Realsz&MathMLPresentationPrinter._print_Realsg  r  r:   c                    | j                             d          }|                    dd           |                    | j                             d                     |S )Nr^  r<  r  &#x2115;r  r,  s      r8   _print_Naturalsz)MathMLPresentationPrinter._print_Naturalsm  r  r:   c                   | j                             d          }| j                             d          }|                    dd           |                    | j                             d                     |                    |           |                    |                     t          j                             |S )Nru  r^  r<  r  r  )rC   r   r  r   rI   rN   r   Zero)r3   r   rn  r   s       r8   _print_Naturals0z*MathMLPresentationPrinter._print_Naturals0s  s    h$$V,,H""4((	}h///	dh--j99:::AF++,,,
r:   c                   |j         d         |j         d         z
  }|j         d         }| j                            d          }| j                            d          }|                    dd           |                    dd	           |                    |                     |                     |                    |           |                    |                     |                     |S )
Nr   r`   r  rv  r  r  r\  r   r]  )r   rC   r   r  r   rN   )r3   rR   shiftr   ri  r  s         r8   _print_SingularityFunctionz4MathMLPresentationPrinter._print_SingularityFunction|  s    	!ty|+	!h$$V,,x%%i00'8,,,&(+++U++,,,E**+++
r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  NaNr+  r,  s      r8   r:  z$MathMLPresentationPrinter._print_NaN  s>    H""4((	dh--e44555r:   c                   | j                             d          }| j                             d          }|                    | j                             |                     |                    |           |                    |                     |j        d                              t          |j                  dk    r|S | j                             d          }| j                             d          }|j        dd          D ]*}|                    |                     |                     +|                    |           |                    |           |S )Nru  r^  r   r`   r[  r  )rC   r   r   rI   rN   r   rh   )r3   r   rp  rn  r^  r[  r  r   s           r8   _print_number_functionz0MathMLPresentationPrinter._print_number_function  s/    h$$V,,X##D))
tx..t44555AF1I..///qv;;!Jx%%f--H""9--6!"": 	, 	,CMM$++c**++++r:   c                .    |                      |d          S )NBr   r$  s     r8   _print_bernoulliz*MathMLPresentationPrinter._print_bernoulli      **1c222r:   c                .    |                      |d          S )Nr  r#  r$  s     r8   _print_catalanz(MathMLPresentationPrinter._print_catalan  r%  r:   c                .    |                      |d          S )NEr#  r$  s     r8   _print_eulerz&MathMLPresentationPrinter._print_euler  r%  r:   c                .    |                      |d          S )NFr#  r$  s     r8   _print_fibonacciz*MathMLPresentationPrinter._print_fibonacci  r%  r:   c                .    |                      |d          S )NLr#  r$  s     r8   _print_lucasz&MathMLPresentationPrinter._print_lucas  r%  r:   c                .    |                      |d          S )Nz&#x03B3;r#  r$  s     r8   _print_stieltjesz*MathMLPresentationPrinter._print_stieltjes  s    **1j999r:   c                .    |                      |d          S )NTr#  r$  s     r8   _print_tribonacciz+MathMLPresentationPrinter._print_tribonacci  r%  r:   c                   | j                             d          }| j                             d          }|                    | j                             d                     |                    |           | j                             d          }|                    | j                             d                     |                    |           |S )Nr  r]  r  ~r+  )r3   r   r   r]  s       r8   _print_ComplexInfinityz0MathMLPresentationPrinter._print_ComplexInfinity  s    H""7++X##D))
tx..z::;;;	bX##D))
tx..s33444	br:   c                    | j                             d          }|                    | j                             d                     |S )Nr]  z&#x2205;r+  r,  s      r8   r=  z)MathMLPresentationPrinter._print_EmptySet  r  r:   c                    | j                             d          }|                    | j                             d                     |S )Nr]  z	&#x1D54C;r+  r,  s      r8   _print_UniversalSetz-MathMLPresentationPrinter._print_UniversalSet  >    H""4((	dh--k::;;;r:   c                ,   ddl m} |j        }| j                            d          }t          ||          sX| j                            d          }|                    |                     |                     |                    |           n(|                    |                     |                     | j                            d          }|                    | j                            d                     |                    |           |S )Nr   r   rv  r  r]  r  	sympy.matricesr   r   rC   r   r  r   rN   rI   r3   rR   r   matri  r  r]  s          r8   _print_Adjointz(MathMLPresentationPrinter._print_Adjoint  s    //////hh$$V,,#|,, 	.8)))44DT[[--...OOD!!!!OODKK,,---X##D))
tx..z::;;;
r:   c                ,   ddl m} |j        }| j                            d          }t          ||          sX| j                            d          }|                    |                     |                     |                    |           n(|                    |                     |                     | j                            d          }|                    | j                            d                     |                    |           |S )Nr   r>  rv  r  r]  r4  r?  rA  s          r8   _print_Transposez*MathMLPresentationPrinter._print_Transpose  s    //////hh$$V,,#|,, 	.8)))44DT[[--...OOD!!!!OODKK,,---X##D))
tx..s33444
r:   c                   ddl m} |j        }| j                            d          }t          ||          sX| j                            d          }|                    |                     |                     |                    |           n(|                    |                     |                     |                    |                     d                     |S )Nr   r>  rv  r  r   )r@  r   r   rC   r   r  r   rN   )r3   rR   r   rB  ri  r  s         r8   _print_Inversez(MathMLPresentationPrinter._print_Inverse  s    //////hh$$V,,#|,, 	.8)))44DT[[--...OOD!!!!OODKK,,---B(((
r:   c           	        ddl m} | j                            d          }|j        }t          |d         t                    r3|d                                         t          |dd                    z   }nt          |          }t          ||          r|	                                r|d         dk    r|dd          }n|d          |d<   | j                            d          }|
                    | j                            d                     |
                    |           |d d         D ]}|
                    |                     |t          |          d                     | j                            d          }|
                    | j                            d	                     |
                    |           |
                    |                     |d         t          |          d                     |S )
Nr   )MatMulr[  r`   r   r]  r  Fr  )!sympy.matrices.expressions.matmulrI  rC   r   r   r  r   r   rc   r   r   rI   r  r   )r3   rR   rI  r   r   r]  r   s          r8   _print_MatMulz'MathMLPresentationPrinter._print_MatMul  s   <<<<<<H""6**yd1gs## 	7--//$tABBx..@DD::DdF## 	(E(E(G(G 	Aw"}}ABBx7(Q''--BNN4822377888MM"9 	 	CMM$++C1G1M1M,13 3 4 4 4''--BNN48223EFFGGGMM"	d''R2H2N2N(-/ / 	0 	0 	0r:   c                   ddl m} |j        |j        }}| j                            d          }t          ||          sX| j                            d          }|                    |                     |                     |                    |           n(|                    |                     |                     |                    |                     |                     |S )Nr   r>  rv  r  )	r@  r   r~  r|  rC   r   r  r   rN   )r3   rR   r   r~  r|  ri  r  s          r8   _print_MatPowz'MathMLPresentationPrinter._print_MatPow  s    //////Itxch$$V,,$-- 	/8)))44DT[[..///OOD!!!!OODKK--...C(()))
r:   c           	        | j                             d          }|j        }|d d         D ]}|                    |                     |t          |          d                     | j                             d          }|                    | j                             d                     |                    |           |                    |                     |d         t          |          d                     |S )Nr[  r   Fr]  z&#x2218;)rC   r   r   r   r  r   rI   )r3   rR   r   r   r   r]  s         r8   _print_HadamardProductz0MathMLPresentationPrinter._print_HadamardProduct   s    H""6**y9 	 	CMM!!#'=d'C'CUKKM M M''--BNN4822:>>???MM"	d2h(>t(D(DeLL	N 	N 	Nr:   c                    | j                             d          }|                    | j                             d                     |S )Nr  z&#x1D7D8r+  r3   Zr   s      r8   _print_ZeroMatrixz+MathMLPresentationPrinter._print_ZeroMatrix-  r  r:   c                    | j                             d          }|                    | j                             d                     |S )Nr  z&#x1D7D9r+  rQ  s      r8   _print_OneMatrixz*MathMLPresentationPrinter._print_OneMatrix2  r  r:   c                    | j                             d          }|                    | j                             d                     |S )Nr^  z	&#x1D540;r+  )r3   r  r   s      r8   _print_Identityz)MathMLPresentationPrinter._print_Identity7  r<  r:   c                V   | j                             d          }| j                             d          }|                    dd           |                    dd           |                    |                     |j        d                              |                    |           |S )Nr[  r  r  u   ⌋r   u   ⌊r   rC  r  s       r8   _print_floorz&MathMLPresentationPrinter._print_floor<      x%%f--H""9--	w)))	vx(((	dkk!&),,---r:   c                V   | j                             d          }| j                             d          }|                    dd           |                    dd           |                    |                     |j        d                              |                    |           |S )Nr[  r  r  u   ⌉r   u   ⌈r   rC  r  s       r8   _print_ceilingz(MathMLPresentationPrinter._print_ceilingE  rZ  r:   c                   | j                             d          }| j                             d          }|j        d         }t          |          dk    r|                     |d                   }n|                     |          }|                    |           | j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |           |S )Nr  r[  r   r`   r]  z&#x21A6;)rC   r   r   rh   rN   r   rI   )r3   r   r   r[  symbolsr]  s         r8   _print_Lambdaz'MathMLPresentationPrinter._print_LambdaN  s   H""9--x%%f--&)w<<1kk'!*--GGkk'**G!!!X##D))
tx..z::;;;QVAY//000	dr:   c                    | j                             d          }|D ]*}|                    |                     |                     +|S r  r  )r3   r   r   r  s       r8   _print_tuplez&MathMLPresentationPrinter._print_tuple^  sJ    H""9-- 	* 	*AMM$++a..))))r:   c                6    |                      |j                  S rB   )rN   labelr$  s     r8   _print_IndexedBasez,MathMLPresentationPrinter._print_IndexedBased  s    {{17###r:   c                   | j                             d          }|                    |                     |j                             t          |j                  dk    r5|                    |                     |j        d                              |S |                    |                     |j                             |S )Nru  r`   r   )rC   r   r   rN   r~  rh   indicesr,  s      r8   _print_Indexedz(MathMLPresentationPrinter._print_Indexedg  s    H""6**	dkk!&))***qy>>QMM$++ail33444H	dkk!),,---r:   c                   | j                             d          }|                    |                     |j        t
          d         d                     | j                             d          }|                    dd           |                    dd           |j        D ]*}|                    |                     |                     +|                    |           |S )	Nru  AtomTr*  r  r  r.   r   )	rC   r   r   r  parentr   r  rf  rN   )r3   r   r   r  r  s        r8   _print_MatrixElementz.MathMLPresentationPrinter._print_MatrixElementp  s    H""6**	d''*V2Dt'TTUUUx%%i00'2&&&&"%%% 	- 	-AT[[^^,,,,	dr:   c                   | j                             d          }| j                             d          }|                    | j                             d                     |                    |           | j                             d          }|                    dd           |j        D ]*}|                    |                     |                     +|                    |           |S )Nr[  r^  z	&#x1d5a5;r  
separatorsr  rC   r   r   rI   r  r   rN   r3   r   r   r^  r  r  s         r8   _print_elliptic_fz+MathMLPresentationPrinter._print_elliptic_f{      H""6**X##D))
tx..{;;<<<	bH""9--	|S))) 	* 	*AMM$++a..))))	ar:   c                   | j                             d          }| j                             d          }|                    | j                             d                     |                    |           | j                             d          }|                    dd           |j        D ]*}|                    |                     |                     +|                    |           |S )Nr[  r^  z	&#x1d5a4;r  rm  r  rn  ro  s         r8   _print_elliptic_ez+MathMLPresentationPrinter._print_elliptic_e  rq  r:   c                >   | j                             d          }| j                             d          }|                    | j                             d                     |                    |           | j                             d          }t	          |j                  dk    r|                    dd           n|                    dd           |j        D ]*}|                    |                     |                     +|                    |           |S )	Nr[  r^  z	&#x1d6f1;r  r  rm  r  z;|)rC   r   r   rI   rh   r   r  rN   ro  s         r8   _print_elliptic_piz,MathMLPresentationPrinter._print_elliptic_pi  s    H""6**X##D))
tx..{;;<<<	bH""9--qv;;!NN<----NN<... 	* 	*AMM$++a..))))	ar:   c                L   | j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j                             |S )Nr[  r^  Eir#  )r3   r   r   r^  s       r8   	_print_Eiz#MathMLPresentationPrinter._print_Ei  s    H""6**X##D))
tx..t44555	b	dkk!&))***r:   c                    | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |           |                    |                     |j        dd                               |S )Nr[  ru  r]  r)  r   r`   r#  r3   r   r   r  r]  s        r8   _print_expintz'MathMLPresentationPrinter._print_expint      H""6**H""6**X##D))
tx..s33444	b	dkk!&),,---	a	dkk!&*--...r:   c                   | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |                     |j        dd                              |                    |           |                    |                     |j        dd                               |S )Nr[  rw  r]  Pr   r`   rH  r#  rz  s        r8   _print_jacobiz'MathMLPresentationPrinter._print_jacobi      H""6**H""9--X##D))
tx..s33444	b	dkk!&),,---	dkk!&1+..///	a	dkk!&*--...r:   c                   | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |                     |j        dd                              |                    |           |                    |                     |j        dd                               |S )Nr[  rw  r]  r  r   r`   r  r#  rz  s        r8   _print_gegenbauerz+MathMLPresentationPrinter._print_gegenbauer  r  r:   c                    | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |           |                    |                     |j        dd                               |S )Nr[  ru  r]  r4  r   r`   r#  rz  s        r8   _print_chebyshevtz+MathMLPresentationPrinter._print_chebyshevt  r|  r:   c                    | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |           |                    |                     |j        dd                               |S )Nr[  ru  r]  Ur   r`   r#  rz  s        r8   _print_chebyshevuz+MathMLPresentationPrinter._print_chebyshevu  r|  r:   c                    | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |           |                    |                     |j        dd                               |S )Nr[  ru  r]  r~  r   r`   r#  rz  s        r8   _print_legendrez)MathMLPresentationPrinter._print_legendre  r|  r:   c                   | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |                     |j        dd                              |                    |           |                    |                     |j        dd                               |S )Nr[  rw  r]  r~  r   r`   r  r#  rz  s        r8   _print_assoc_legendrez/MathMLPresentationPrinter._print_assoc_legendre  r  r:   c                    | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |           |                    |                     |j        dd                               |S )Nr[  ru  r]  r/  r   r`   r#  rz  s        r8   _print_laguerrez)MathMLPresentationPrinter._print_laguerre  r|  r:   c                   | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |                     |j        dd                              |                    |           |                    |                     |j        dd                               |S )Nr[  rw  r]  r/  r   r`   r  r#  rz  s        r8   _print_assoc_laguerrez/MathMLPresentationPrinter._print_assoc_laguerre  r  r:   c                    | j                             d          }| j                             d          }| j                             d          }|                    | j                             d                     |                    |           |                    |                     |j        d                              |                    |           |                    |                     |j        dd                               |S )Nr[  ru  r]  Hr   r`   r#  rz  s        r8   _print_hermitez(MathMLPresentationPrinter._print_hermite  r|  r:   )FrB   )r   )r<   r=   r>   ru   r  r   r  r   r   r  r  r  r   r%  r-  r0  r3  r6  rE  r  r)  r  r  r  r!  r$  r&  rQ  rS  rx  r  r  rE  rJ  rO  rQ  rU  r  r  r^  r  r  r  ro  r  rs  r}  r  _print_Determinantr  r  r  r  r  r  r  r  r  r  r  r  _print_frozensetr  r  r  r  r  r  r  r  r  r@  rC  r  r  r  
_print_Min
_print_Maxr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r:  r   r$  _print_bellr'  r*  r-  r0  r2  r5  r8  r=  r;  rC  rE  rG  rK  rM  rO  rS  rU  rW  rY  r\  r_  ra  rd  rg  rk  rp  rs  ru  rx  r{  r  r  r  r  r  r  r  r  r  r?   r:   r8   r  r  D  s         )KJ J JX% % % %- - -^   (  $   (P P P  ,  
  
  
  
  
    
  
  
      
    $ $ $L  >4 4 4 4lL L L (    = = => > >  4 4 4l  
  . . .`  % % %N  	 	 	    0    $	 	 	4 4 4 44 4 4 4  	 	 	9 9 99 9 99 9 99 9 99 9 9' ' '   "  (' ' 'T3 3 33 3 33 3 38 8 83 3 3    
 %%  
  @
 
 
 87J      
    $	 	 		 	 		 	 		 	 		 	 	              
 
 
  
  &3 3 3 #K3 3 33 3 33 3 33 3 3: : :3 3 3    
  
        :      
  
  
         $ $ $  	 	 	
 
 

 
 
    	 	 	
 
 

 
 
	 	 		 	 		 	 	
 
 
	 	 	
 
 
	 	 	 	 	r:   r  contentc                    |dk    r"t          |                              |           S t          |                              |           S )zReturns the MathML representation of expr. If printer is presentation
    then prints Presentation MathML else prints content MathML.
    presentation)r  rW   rx   )rR   printerrJ   s      r8   mathmlr    sG    
 .  (22::4@@@#H--55d;;;r:   c                *   |dk    rt          |          }nt          |          }|                    t          |                     }|                                 |                                }|                                 t          |           dS )a  
    Prints a pretty representation of the MathML code for expr. If printer is
    presentation then prints Presentation MathML else prints content MathML.

    Examples
    ========

    >>> ##
    >>> from sympy import print_mathml
    >>> from sympy.abc import x
    >>> print_mathml(x+1) #doctest: +NORMALIZE_WHITESPACE
    <apply>
        <plus/>
        <ci>x</ci>
        <cn>1</cn>
    </apply>
    >>> print_mathml(x+1, printer='presentation')
    <mrow>
        <mi>x</mi>
        <mo>+</mo>
        <mn>1</mn>
    </mrow>

    r  N)r  rx   rN   r   rr   toprettyxmlrt   print)rR   r  rJ   rd  xml
pretty_xmls         r8   print_mathmlr  (  s    2 .  %h// **
((74==
!
!CMMOOO""JOO	*r:   N)r  )$ru   
__future__r   typingr   sympy.core.mulr   sympy.core.singletonr   sympy.core.sortingr   sympy.core.sympifyr   sympy.printing.conventionsr	   r
   sympy.printing.precedencer   r   r   &sympy.printing.pretty.pretty_symbologyr   sympy.printing.printerr   r   mpmath.libmpr   r   r   r  r   rx   r  r  r  MathMLPrinterr?   r:   r8   <module>r     s    # " " " " "             " " " " " " / / / / / / & & & & & & H H H H H H H H? ? ? ? ? ? ? ? ? ? @ @ @ @ @ @ : : : : : : : : E E E E E E E E E Eh0 h0 h0 h0 h0 h0 h0 h0V    ,   HV V V V V 1 V V Vr. !""< < < #"<" " " "L %r:   