
~9\c           @  s3  d  Z  d d l m Z m Z d d l m Z 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 d d l m Z d d	 l m Z d d
 l j Z d d l m Z d e f d     YZ d e f d     YZ d e f d     YZ d d  Z d d  Z  e Z! d
 S(   s   
A MathML printer.
i(   t   print_functiont   division(   t   sympifyt   St   Mul(   t   ranget   string_typest   default_sort_key(   t   _coeff_isneg(   t   split_super_subt   requires_partial(   t   precedence_traditionalt
   PRECEDENCE(   t   greek_unicode(   t   PrinterN(   t   prec_to_dpst   MathMLPrinterBasec           B  s   e  Z d  Z i d d 6d d 6e d 6e d 6d d 6d d 6e d	 6d d
 6d d 6d d 6d d 6e d 6i  d 6d d 6Z d d  Z d   Z d   Z	 d   Z
 RS(   s^   Contains common code required for MathMLContentPrinter and
    MathMLPresentationPrinter.
    t   orders   utf-8t   encodingt   fold_frac_powerst   fold_func_bracketst   fold_short_fract   abbreviatedt   inv_trig_stylet   ln_notationt   long_frac_ratiot   [t	   mat_delimt   plaint   mat_symbol_stylet
   mul_symbolt   root_notationt   symbol_namess   &#xB7;t   mul_symbol_mathml_numbersc           sj   t  j  |  d d l m } m } |    _ d | f d     Y     f d   } |  j _ d  S(   Ni(   t   Documentt   Textt   RawTextc           B  s   e  Z d  d  d  d  Z RS(   t    c         S  s/   |  j  r+ | j d j | |  j  |   n  d  S(   Nu   {}{}{}(   t   datat   writet   format(   t   selft   writert   indentt	   addindentt   newl(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   writexml3   s    	(   t   __name__t
   __module__R.   (    (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR$   2   s   c           s"       } |  | _   j | _ | S(   N(   R&   t   domt   ownerDocument(   R&   t   r(   R$   R)   (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   createRawTextNode7   s    		(   R   t   __init__t   xml.dom.minidomR"   R#   R1   t   createTextNode(   R)   t   settingsR"   R#   R4   (    (   R$   R)   s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR5   (   s    c         C  s@   t  j |  |  } | j   } | j d d  } | j   } | S(   s2   
        Prints the expression as MathML.
        t   asciit   xmlcharrefreplace(   R   t   _printt   toxmlt   encodet   decode(   R)   t   exprt   mathMLt   unistrt   xmlbstrt   res(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   doprint?   s
    c           s   d d l  m } m } m   m  d d d    f d  } | j |  _ | | _ d d d  f d  } | j |  _ | | _ d  S(   Ni(   t   ElementR#   t   Nodet   _write_dataR%   c   	        sa  | j  | d |  j  |  j   } t | j    } | j   x@ | D]8 } | j  d |   | | | j  | j  d  qG W|  j rL| j  d  t |  j  d k r |  j d j	   j
 k r |  j d j | d d d  nH | j  |  x+ |  j D]  } | j | | | | |  q W| j  |  | j  d |  j | f  n | j  d	 |  d  S(
   Nt   <s    %s="s   "t   >i   i    R%   s   </%s>%ss   />%s(   R'   t   tagNamet   _get_attributest   listt   keyst   sortt   valuet
   childNodest   lent   nodeTypet	   TEXT_NODER.   (	   R)   R*   R+   R,   R-   t   attrst   a_namest   a_namet   node(   RF   RG   (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR.   S   s(    
	 c           s!     | d | |  j  | f  d  S(   Ns   %s%s%s(   R&   (   R)   R*   R+   R,   R-   (   RG   (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR.   r   s    (   R6   RE   R#   RF   RG   R.   t   _Element_writexml_oldt   _Text_writexml_old(   R)   RE   R#   R.   (    (   RF   RG   s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   apply_patchI   s    "	c         C  s2   d d l  m } m } |  j | _ |  j | _ d  S(   Ni(   RE   R#   (   R6   RE   R#   RX   R.   RY   (   R)   RE   R#   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   restore_patchw   s    N(   R/   R0   t   __doc__t   Nonet   Falset   Truet   _default_settingsR5   RD   RZ   R[   (    (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR      s(   
	
	.t   MathMLContentPrinterc           B  s  e  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 e Z e Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s}   Prints an expression to the Content MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter4.html
    t   _mathml_contentc         C  s"  i d d 6d d 6d d 6d d 6d d	 6d
 d 6d d 6d d 6d d 6d	 d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d d% 6d& d' 6d( d) 6d* d+ 6d, d- 6d. d/ 6d0 d1 6d2 d3 6} x1 | j  j D]# } | j } | | k r | | Sq W| j  j } | j   S(4   s)   Returns the MathML tag for an expression.t   plust   Addt   timesR   t   difft
   Derivativet   cnt   Numbert   intt   powert   Powt   cit   Symbolt   MatrixSymbolt   RandomSymbolt   Integralt   sumt   Sumt   sint   cost   tant   cott   arcsint   asint   arcsinht   asinht   arccost   acost   arccosht   acosht   arctant   atant   arctanht   atanht   arccott   acott   atan2t   lnt   logt   eqt   Equalityt   neqt
   Unequalityt   geqt   GreaterThant   leqt   LessThant   gtt   StrictGreaterThant   ltt   StrictLessThan(   t	   __class__t   __mro__R/   t   lower(   R)   t   et	   translatet   clst   n(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   mathml_tag   sJ    
	c   	      C  s  t  |  rR |  j j d  } | j |  j j d   | j |  j |   | Sd d l m } | |  \ } } | t j k	 r |  j j d  } | j |  j j d   | j |  j	 |   | j |  j	 |   | S| j
   \ } } | t j k r"t |  d k r"|  j	 | d  S|  j d k rIt j |  j   } n  |  j j d  } | j |  j j d	   | d k r| j |  j	 |   n  x$ | D] } | j |  j	 |   qW| S(
   Nt   applyt   minusi(   t   fractiont   dividei   i    t   oldRe   (   R   R1   t   createElementt   appendChildt
   _print_Mult   sympy.simplifyR   R   t   OneR;   t   as_coeff_mulRQ   R   R   t
   _from_argst   as_ordered_factors(	   R)   R?   t   xR   t   numert   denomt   coefft   termst   term(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR      s2    !c         C  st  |  j  | d | } |  j | d  } g  } x | d D] } t |  r |  j j d  } | j |  j j d   | j |  | j |  j |   | } | | d k r| j |  qq9 | j |  |  j |  } | | d k r9 | j |  j |   q9 q9 Wt |  d k r"| S|  j j d  } | j |  j j d   x  | ro| j | j d   qPW| S(   NR   i    i   R   R   iRc   (	   t   _as_ordered_termsR;   R   R1   R   R   t   appendRQ   t   pop(   R)   R?   R   t   argst   lastProcessedt	   plusNodest   argR   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   _print_Add   s.    	c         C  s   |  j  j d  } xp t | j  D]_ } |  j  j d  } x7 t | j  D]& } | j |  j | | | f   qJ W| j |  q" W| S(   Nt   matrixt	   matrixrow(   R1   R   R   t   rowst   colsR   R;   (   R)   t   mR   t   it   x_rt   j(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_MatrixBase   s    $c         C  s   | j  d k rG |  j j d  } | j |  j j t | j    | S|  j j d  } | j |  j j d   |  j j d  } | j |  j j t | j    |  j j d  } | j |  j j t | j     | j |  | j |  | S(   Ni   Rh   R   R   (   t   qR1   R   R   R7   t   strt   p(   R)   R   R   t   xnumt   xdenom(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Rational   s    """c         C  s   |  j  j d  } | j |  j  j |  j |    |  j  j d  } |  j  j d  } | j |  j | j d   | j |  j | j d   | j |  | j |  | j |  j | j d   | S(   NR   t   bvart   lowlimiti   i   i    (   R1   R   R   R   R;   R   (   R)   R   R   t   x_1t   x_2(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Limit	  s    "c         C  s   |  j  j d  S(   Nt
   imaginaryi(   R1   R   (   R)   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_ImaginaryUnit  s    c         C  s   |  j  j d  S(   Nt
   eulergamma(   R1   R   (   R)   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_EulerGamma  s    c         C  s/   |  j  j d  } | j |  j  j d   | S(   sv   We use unicode #x3c6 for Greek letter phi as defined here
        http://www.w3.org/2003/entities/2007doc/isogrk1.htmlRh   u   φ(   R1   R   R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_GoldenRatio  s    c         C  s   |  j  j d  S(   Nt   exponentiale(   R1   R   (   R)   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Exp1$  s    c         C  s   |  j  j d  S(   Nt   pi(   R1   R   (   R)   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt	   _print_Pi'  s    c         C  s   |  j  j d  S(   Nt   infinity(   R1   R   (   R)   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Infinity*  s    c         C  sH   |  j  j d  } | j |  j  j d   | j |  j  j d   | S(   NR   R   R   (   R1   R   R   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_NegativeInfinity-  s    c           s8       f d    t    j  } | j    |  S(   Nc           s   j  j d  } | j  j  j  j       j  j d  } | j  j |  d d   | j |  t |  d  d k r j  j d  } | j  j |  d d   | j |   j  j d  } | j  j |  d d   | j |  n  t |  d  d k rZ j  j d  } | j  j |  d d   | j |  n  t |   d k r| j  j   j   n | j  |  d   | S(	   NR   R   i    i   R   i   t   uplimiti   (   R1   R   R   R   R;   RQ   t   function(   t   limitsR   t	   bvar_elemt   low_elemt   up_elem(   R   t
   lime_recurR)   (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR   4  s(    "(   RL   R   t   reverse(   R)   R   R   (    (   R   R   R)   s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Integral3  s    
c         C  s   |  j  |  S(   N(   R   (   R)   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   _print_SumP  s    c           s    j  j   j |   }   f d   } d   } t | j  \ } } } | |  } g  | D] } | |  ^ q^ } g  | D] }	 | |	  ^ q} }   j  j d  }
 |
 j   j  j |   | s*| s | j   j  j |   q  j  j d  } | j |
  | j | |   | j |  n | sr  j  j d  } | j |
  | j | |   | j |  nR   j  j d  } | j |
  | j | |   | j | |   | j |  | S(   Nc           s   t  |   d k r   j j d  } x t |   D] \ } } | d k r   j j d  } | j   j j d   | j |  n    j j d  } | j   j j |   | j |  q1 W| S  j j d  } | j   j j |  d   | Sd  S(   Ni   s   mml:mrowi    s   mml:mot    s   mml:mi(   RQ   R1   R   t	   enumerateR   R7   (   t   itemst   mrowR   t   itemt   mot   mi(   R)   (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   joinX  s    c         S  s!   |  t  k r t  j |   S|  Sd  S(   N(   R   t   get(   t   s(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR   j  s    s   mml:mis   mml:msubs   mml:msups   mml:msubsup(   R1   R   R   R	   t   nameR   R7   (   R)   t   symRm   R   R   R   t   superst   subst   supt   subt   mnamet   msubt   msupt   msubsup(    (   R)   s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_SymbolU  s6    	c         C  s[  |  j  d r | j j r | j j d k r |  j j d  } | j |  j j d   | j j d k r |  j j d  } |  j j d  } | j |  j j t	 | j j    | j |  | j |  n  | j |  j
 | j   | S|  j j d  } |  j j |  j |   } | j |  | j |  j
 | j   | j |  j
 | j   | S(   NR   i   R   t   rooti   t   degreeRm   (   t	   _settingst   expt   is_RationalR   R1   R   R   R   R7   R   R;   t   baseR   (   R)   R   R   t   xmldegt   xmlciR   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   _print_Pow  s$    %c         C  s>   |  j  j |  j |   } | j |  j  j t |    | S(   N(   R1   R   R   R   R7   R   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Number  s    c         C  s  |  j  j d  } |  j |  } t |  r6 d } n  | j |  j  j |   |  j  j d  } x} t | j  D]l \ } } | j |  j |   | d k rq |  j  j d  } | j |  j t |    | j |  qq qq W| j |  | j |  j | j	   | S(   NR   t   partialdiffR   i   R   (
   R1   R   R   R
   R   t   reversedt   variable_countR;   R   R?   (   R)   R   R   t   diff_symbolR   R   Re   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Derivative  s    	c         C  sb   |  j  j d  } | j |  j  j |  j |    x' | j D] } | j |  j |   q> W| S(   NR   (   R1   R   R   R   R   R;   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Function  s
    "c         C  sI   |  j  j |  j |   } x' | j D] } | j |  j |   q% W| S(   N(   R1   R   R   R   R   R;   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Basic  s    c         C  sh   |  j  j d  } |  j  j |  j |   } | j |  x' | j D] } | j |  j |   qD W| S(   NR   (   R1   R   R   R   R   R;   (   R)   R   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_AssocOp  s    c         C  sj   |  j  j d  } | j |  j  j |  j |    | j |  j | j   | j |  j | j   | S(   NR   (   R1   R   R   R   R;   t   lhst   rhs(   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Relational  s
    "c         C  s=   |  j  j d  } x$ | D] } | j |  j |   q W| S(   sf   MathML reference for the <list> element:
        http://www.w3.org/TR/MathML2/chapter4.html#contm.listRL   (   R1   R   R   R;   (   R)   t   seqt   dom_elementR   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_list  s    c         C  s>   |  j  j |  j |   } | j |  j  j t |    | S(   N(   R1   R   R   R   R7   R   (   R)   R   R  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   _print_int  s    N(    R/   R0   R\   t   printmethodR   R   R]   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   _print_MatrixSymbolt   _print_RandomSymbolR   R   R  R  R  R  R  R  R  (    (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyRa   }   s:   	+	#														8								t   MathMLPresentationPrinterc           B  s>  e  Z d  Z d Z d   Z e d  Z d   Z dr d  Z	 d   Z
 dr d  Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d d  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' dr d$  Z( e( Z) d%   Z* dr d&  Z+ dr d'  Z, d(   Z- d)   Z. d*   Z/ d+   Z0 d,   Z1 d-   Z2 d.   Z3 d/   Z4 e4 Z5 d0   Z6 d1   Z7 d2   Z8 d3   Z9 d4   Z: d5   Z; d6   Z< d7   Z= d8   Z> e> Z? e> Z@ d9   ZA d:   ZB d;   ZC eC ZD ZE d<   ZF d=   ZG d>   ZH d?   ZI d@   ZJ dA   ZK dB   ZL dC   ZM dD   ZN dE   ZO dF   ZP dG   ZQ dH   ZR dI   ZS dJ   ZT dK   ZU dL   ZV dM   ZW dN   ZX dO   ZY eY ZZ dP   Z[ dQ   Z\ dR   Z] dS   Z^ dT   Z_ dU   Z` dV   Za dW   Zb dX   Zc dY   Zd dZ   Ze d[   Zf d\   Zg d]   Zh d^   Zi d_   Zj d`   Zk da   Zl db   Zm dc   Zn dd   Zo de   Zp df   Zq dg   Zr dh   Zs di   Zt dj   Zu dk   Zv dl   Zw dm   Zx dn   Zy do   Zz dp   Z{ dq   Z| RS(s   s   Prints an expression to the Presentation MathML markup language.

    References: https://www.w3.org/TR/MathML2/chapter3.html
    t   _mathml_presentationc           s  i* d d 6d d 6d d 6d d 6d d	 6d
 d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6d) d* 6d+ d, 6d- d. 6d/ d0 6d1 d2 6d3 d4 6d5 d6 6d7 d8 6d7 d9 6d: d; 6d< d= 6d> d? 6d@ dA 6dB dC 6dD dE 6dF dG 6dH dI 6dJ dK 6dL dM 6}   f dN   } x1 | j  j D]# } | j } | | k rH| | SqHW| j  j dO k r|   S| j  j } | j   S(P   s)   Returns the MathML tag for an expression.t   mnRi   s   &#x2192;t   Limits   &dd;Rg   Rj   R   Rn   s   &int;Rq   s   &#x2211;Rs   Rt   Ru   Rv   Rw   Rx   Ry   Rz   R{   R|   R}   R~   R   R   R   R   R   R   R   R   t   =R   s   &#x2260;R   s   &#x2265;R   s   &#x2264;R   RI   R   RH   R   s   &#x3A6;t   lerchphis   &#x3B6;t   zetas   &#x3B7;t   dirichlet_etas   &#x39A;t
   elliptic_ks   &#x3B3;t
   lowergammas   &#x393;t
   uppergammat   gammas   &#x3D5;t   totients   &#x3BB;t   reduced_totients   &#x3BD;t   primenus   &#x3A9;t
   primeomegaR   t   fresnelst   Ct   fresnelcs   &#x398;t	   HeavisideR_   t   BooleanTrueR^   t   BooleanFalseR]   t   NoneTypec             s     j  d d  k s&   j  d d k r* d S  j  d d k rA d S  j  d d k rX d S  j  d d k ro d	 St   j  d t  s t  n   j  d Sd  S(
   NR   R]   s   &InvisibleTimes;Re   s   &#xD7;t   dots   &#xB7;t   ldots   &#x2024;(   R   R]   t
   isinstanceR   t	   TypeError(    (   R)   (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   mul_symbol_selection  s    	R   (   R   R   R/   R   (   R)   R   R   R.  R   R   (    (   R)   s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     sh    
	c         C  sh   t  |  } | | k  s+ | rW | | k rW |  j j d  } | j |  j |   | S|  j |  Sd  S(   Nt   mfenced(   R   R1   R   R   R;   (   R)   R   t   levelt   strictt   prec_valt   brac(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   parenthesize7  s    c           s     f d   }   j  j d  } t |  rx   j  j d  } | j   j  j d   | j |  | | |  } n | | |  } | S(   Nc           s-  d d l  m } | |   \ } } | t j k	 r   j j d  }   j d r{ t t |    d k  r{ | j	 d d  n    j
 |  }   j
 |  } | j |  | j |  | j |  | S|  j   \ } }	 | t j k rt |	  d k r| j   j
 |	 d	   | S  j d
 k r<t j |	  j   }	 n  | d k r  j
 |  }
   j j d  } | j   j j   j |     | j |
  | j |  n  x~ |	 D]v }   j
 |  }
 | j |
  | |	 d k s  j j d  } | j   j j   j |     | j |  qqW| S(   Ni(   R   t   mfracR   i   t   bevelledt   truei   i    R   R   (   R   R   R   R   R1   R   R   RQ   R   t   setAttributeR;   R   R   R   R   R   R   R7   R   (   R?   R   R   R   R   t   fracR   t   xdenR   R   R   t   yR   (   R)   (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   multiplyB  s@    %!""R   R   t   -(   R1   R   R   R   R7   (   R)   R?   R<  R   R   (    (   R)   s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR   @  s    #c         C  s   |  j  j d  } |  j | d | } | j |  j | d   x | d D] } t |  r |  j  j d  } | j |  j  j d   |  j |  } n: |  j  j d  } | j |  j  j d   |  j |  } | j |  | j |  qL W| S(   NR   R   i    i   R   R=  t   +(   R1   R   R   R   R;   R   R7   (   R)   R?   R   R   R   R   R   R;  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR   p  s    c         C  s  |  j  j d  } x t | j  D]~ } |  j  j d  } xV t | j  D]E } |  j  j d  } | j |  j | | | f   | j |  qJ W| j |  q" W|  j d d k r | S|  j  j d  } |  j d d k r| j d d  | j d	 d
  n  | j |  | S(   Nt   mtablet   mtrt   mtdR   R%   R/  R   t   opent   closet   ](	   R1   R   R   R   R   R   R;   R   R8  (   R)   R   t   tableR   R   R   R;  R3  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s      c         C  s   | j  d k  r | j  } n	 | j  } |  j j d  } | sJ |  j d r] | j d d  n  | j |  j |   | j |  j | j   | j  d k  r |  j j d  } |  j j d  } | j |  j j d   | j |  | j |  | S| Sd  S(	   Ni    R5  R   R6  R7  R   R   R=  (	   R   R1   R   R   R8  R   R;   R   R7   (   R)   R   t   foldedR   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _get_printed_Rational  s     	c         C  s6   | j  d k r |  j | j  S|  j | |  j d  S(   Ni   R   (   R   R;   R   RG  R   (   R)   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s    c   	      C  s0  |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   |  j  j d  } |  j | j d  } |  j  j d  } | j |  j  j |  j |    |  j | j d  } | j |  | j |  | j |  | j |  | j |  | j |  | j |  j | j d   | S(	   NR   t   munderR   t   limi   R   i   i    (   R1   R   R   R7   R;   R   R   (	   R)   R   R   RH  R   R   R   t   arrowR   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s"    "c         C  s/   |  j  j d  } | j |  j  j d   | S(   NR   s   &ImaginaryI;(   R1   R   R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s    c         C  s/   |  j  j d  } | j |  j  j d   | S(   NR   s   &#x3A6;(   R1   R   R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s    c         C  s/   |  j  j d  } | j |  j  j d   | S(   NR   s   &ExponentialE;(   R1   R   R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s    c         C  s/   |  j  j d  } | j |  j  j d   | S(   NR   s   &pi;(   R1   R   R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s    c         C  s/   |  j  j d  } | j |  j  j d   | S(   NR   s   &#x221E;(   R1   R   R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s    c         C  sj   |  j  j d  } |  j  j d  } | j |  j  j d   |  j |  } | j |  | j |  | S(   NR   R   R=  (   R1   R   R   R7   R   (   R)   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s    c   	      C  st  i d d 6d d 6d d 6} |  j  j d  } t | j  d k r t d   | j D  r |  j  j d	  } | j |  j  j | t | j    | j |  n;x8t | j  D]'} |  j  j d	  } | j |  j  j | d   t |  d k r
| j |  n  t |  d k re|  j  j d
  } | j |  | j |  j | d   | j |  n  t |  d k r |  j  j d  } | j |  | j |  j | d   | j |  j | d   | j |  q q W| j |  j	 | j
 t d d t  xi t | j  D]X } |  j  j d	  } | j |  j  j d   | j |  | j |  j | d   qW| S(   Ns   &#x222B;i   s   &#x222C;i   s   &#x222D;i   R   c         s  s!   |  ] } t  |  d  k Vq d S(   i   N(   RQ   (   t   .0RI  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pys	   <genexpr>  s    R   R   R   R   R1  s   &dd;i    (   R1   R   RQ   R   t   allR   R7   R  R;   R4  R   R   R_   (	   R)   R?   t
   intsymbolsR   R   RI  R   R   t   d(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s<    .&
c         C  s  t  | j  } |  j j d  } |  j | d d  } |  j | d d  } |  j j d  } | j |  j j |  j |    |  j j d  } |  j | d d  } |  j j d  }	 |	 j |  j j d   | j |  | j |	  | j |  | j |  | j |  | j |  |  j j d  }
 |
 j |  t t	 | j
   d k r{|
 j |  j | j
   n8 |  j j d  } | j |  j | j
   |
 j |  |
 S(	   Nt
   munderoveri    i   i   R   R   R  R/  (   RL   R   R1   R   R;   R   R7   R   RQ   R   R   (   R)   R   R   t   subsupR   R   t   summandt   lowt   vart   equalR   t   fence(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s0    "R   c           s    f d   } d   } t  | j  \ } } } | |  } g  | D] } | |  ^ qC } g  | D] }	 | |	  ^ qb }   j j d  }
 |
 j   j j |   t |  d k rt |  d k r |
 } q  j j d  } | j |
  | j | |   n t |  d k rN  j j d  } | j |
  | j | |   nE   j j d  } | j |
  | j | |   | j | |   | d k r| j d	 d  n  | S(
   Nc           s   t  |   d k r   j j d  } x t |   D] \ } } | d k r   j j d  } | j   j j d   | j |  n    j j d  } | j   j j |   | j |  q1 W| S  j j d  } | j   j j |  d   | Sd  S(   Ni   R   i    R   R   R   (   RQ   R1   R   R   R   R7   (   R   R   R   R   R   R   (   R)   (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR   /  s    c         S  s!   |  t  k r t  j |   S|  Sd  S(   N(   R   R   (   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR   A  s    R   i    R   R   R   t   boldt   mathvariant(   R	   R   R1   R   R   R7   RQ   R8  (   R)   R   t   styleR   R   R   R   R   R   R   R   R   (    (   R)   s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR   .  s2    		c         C  s   |  j  | d |  j d S(   NRX  R   (   R   R   (   R)   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR  d  s    c         C  sC   |  j  j d  } | j d d  | j |  j | j d   | S(   Nt   mencloset   notationt   topi    (   R1   R   R8  R   R;   R   (   R)   R?   t   enc(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_conjugatej  s    c         C  sk   |  j  j d  } | j |  j | t d   |  j  j d  } | j |  j  j |   | j |  | S(   NR   t   FuncR   (   R1   R   R   R4  R   R7   (   R)   t   opR?   t   rowR   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_operator_afterp  s    c         C  s   |  j  d | j d  S(   Nt   !i    (   Ra  R   (   R)   R?   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_factorialx  s    c         C  s   |  j  d | j d  S(   Ns   !!i    (   Ra  R   (   R)   R?   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_factorial2{  s    c         C  s   |  j  j d  } |  j  j d  } | j d d  | j |  j | j d   | j |  j | j d   | j |  | S(   NR/  R5  t   linethicknesst   0i    i   (   R1   R   R8  R   R;   R   (   R)   R?   R3  R9  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_binomial~  s    c         C  sQ  | j  j r1t | j  j  d k r1| j  j d k r1|  j d r1| j  j d k r |  j j d  } | j |  j	 | j
   n  | j  j d k r |  j j d  } | j |  j	 | j
   | j |  j	 | j  j   n  | j  j d k r*|  j j d  } | j |  j	 d   | j |  | S| Sn  | j  j rF| j  j d k rF| j  j r|  j j d  } | j |  j	 d   |  j j d  } | j |  j | j
 t d	   | j |  j | j  |  j d
   | j |  | S|  j j d  } | j |  j | j
 t d	   | j |  j | j  |  j d
   | Sn  | j  j r|  j j d  } | j |  j	 d   | j  d k r| j |  j	 | j
   nY |  j j d  } | j |  j | j
 t d	   | j |  j	 | j    | j |  | S|  j j d  } | j |  j | j
 t d	   | j |  j	 | j    | S(   Ni   R   i   t   msqrtt   mrootiR5  R   Rl   R   (   R   R   t   absR   R   R   R1   R   R   R;   R   t   is_negativeR4  R   RG  (   R)   R   R   R9  R[  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     sX    6    c         C  s>   |  j  j |  j |   } | j |  j  j t |    | S(   N(   R1   R   R   R   R7   R   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR     s    c         C  sh   |  j  j d  } | j d d  | j d d  | j |  j | j   | j |  j | j   | S(   NR/  RB  u   ⟨RC  u   ⟩(   R1   R   R8  R   R;   t   mint   max(   R)   R   R3  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_AccumulationBounds  s    c         C  sJ  t  |  r d } n |  j |  } |  j j d  } d } x t | j  D] \ } } | | 7} | d k r |  j j d  } |  j j d  } | j |  j j |   | j |  | j |  j |   n+ |  j j d  } | j |  j j |   | j |  |  j |  }	 | j |	  qL W|  j j d  }
 | d k r|  j j d  } |  j j d  } | j |  j j |   | j |  | j |  j |   n+ |  j j d  } | j |  j j |   |
 j |  |  j j d  } |  j j d  } | j |
  | j |  | j |  | j |  j | j	   | S(   Ns   &#x2202;R   i    i   R   R   R5  (
   R
   R   R1   R   R  R  R   R7   R;   R?   (   R)   R   RN  R   t   dimR   t   numR   t   xxR;  t   mnumR   R9  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR    sF    	
c         C  s   |  j  j d  } |  j  j d  } |  j |  d k rb |  j d rb | j |  j  j d   n" | j |  j  j |  j |    |  j  j d  } x' | j D] } | j |  j |   q W| j |  | j |  | S(   NR   R   R   R   R   R/  (   R1   R   R   R   R   R7   R   R;   (   R)   R   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR    s    ""c         C  s  t  | j  } t j | j | d t } |  j d } |  j j d  } d | k r| j	 d  \ } } | d d k r | d } n  |  j j d  } | j
 |  j j |   | j
 |  |  j j d	  }	 |	 j
 |  j j |   | j
 |	  |  j j d
  }
 |  j j d  } | j
 |  j j d   |
 j
 |  |  j j d  } | j
 |  j j |   |
 j
 |  | j
 |
  | S| d k r|  j d   S| d k r|  j d   S|  j j d  } | j
 |  j j |   | Sd  S(   Nt   strip_zerosR!   R   R   i    R>  i   R  R   R   t   10s   +infs   -inf(   R   t   _prect   mlibt   to_strt   _mpf_R_   R   R1   R   t   splitR   R7   R   R]   R   (   R)   R?   t   dpst   str_realt	   separatorR   t   mantR   R  R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Float  s<    c         C  s   |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  |  j  j d  } | j |  j | j d   | j |  | S(   NR   R   R   t   Lii    R/  i   (   R1   R   R   R7   R;   R   (   R)   R?   R   R   R   R3  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_polylog/  s    c         C  s   |  j  j d  } |  j  j d  } | j |  j  j |  j |    | j |  |  j  j d  } x' | j D] } | j |  j |   qo W| j |  | S(   NR   R   R/  (   R1   R   R   R7   R   R   R;   (   R)   R   R   R   R3  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR  =  s    "c         C  s_   |  j  j d  } |  j  j d  } x' | j D] } | j |  j |   q. W| j |  | S(   NR   R/  (   R1   R   R   R   R;   (   R)   R   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_TupleH  s    c         C  s  |  j  j d  } |  j  j d  } | j | j k rr | j d d  | j d d  | j |  j | j   n | j r | j d d  n | j d d  | j r | j d d	  n | j d d
  | j |  j | j   | j |  j | j   | j |  | S(   NR   R/  RB  t   {RC  t   }t   (R   t   )RD  (	   R1   R   t   startt   endR8  R   R;   t	   left_opent
   right_open(   R)   R   R   R3  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_IntervalP  s     		c         C  sr   |  j  j d  } |  j  j d  } | j d d  | j d d  | j |  j | j d   | j |  | S(   NR   R/  RB  t   |RC  i    (   R1   R   R8  R   R;   R   (   R)   R?   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   _print_Absh  s    c         C  s   |  j  j d  } |  j  j d  } | j d d  | j |  j  j |   | j |  |  j  j d  } | j |  j |   | j |  | S(   NR   R   RW  t   frakturR/  (   R1   R   R8  R   R7   R;   (   R)   t   cR?   R   R   R3  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_re_ims  s    c         C  s   |  j  d | j d  S(   Nt   Ri    (   R  R   (   R)   R?   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt	   _print_re~  s    c         C  s   |  j  d | j d  S(   Nt   Ii    (   R  R   (   R)   R?   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt	   _print_im  s    c         C  s   |  j  j d  } |  j  j d  } | j |  j  j |  j |    | j |  x' | j D] } | j |  j |   q] W| S(   NR   R   (   R1   R   R   R7   R   R   R;   (   R)   R   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR    s    "c         C  s   |  j  j d  } | j |  j | j d   xi | j d D]Z } |  j  j d  } | j |  j  j |   |  j |  } | j |  | j |  q= W| S(   NR   i    i   R   (   R1   R   R   R;   R   R7   (   R)   R?   t   symbolR   R   R   R;  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_SetOp  s    c         C  s   |  j  | d  S(   Ns   &#x222A;(   R  (   R)   R?   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Union  s    c         C  s   |  j  | d  S(   Ns   &#x2229;(   R  (   R)   R?   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Intersection  s    c         C  s   |  j  | d  S(   Ns   &#x2216;(   R  (   R)   R?   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Complement  s    c         C  s   |  j  | d  S(   Ns   &#x2206;(   R  (   R)   R?   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_SymmetricDifference  s    c         C  s   |  j  | j  S(   N(   t
   _print_setR   (   R)   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_FiniteSet  s    c         C  so   t  | d t } |  j j d  } | j d d  | j d d  x$ | D] } | j |  j |   qK W| S(   Nt   keyR/  RB  R  RC  R  (   t   sortedR   R1   R   R8  R   R;   (   R)   R   R   R3  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR    s    c         C  s.  |  j  j d  } | d j ri | d j ri |  j  j d  } | j |  j | d   | j |  n | j |  j | d   x | d D] } |  j  j d  } | j |  j  j |   | j r | j r |  j  j d  } | j |  j |   n |  j |  } | j |  | j |  q W| S(   NR   i    R/  i   R   (   R1   R   t
   is_Booleant   is_NotR   R;   R7   (   R)   R   R  R   R3  R   R   R;  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_LogOp  s     c         C  sa  d d l  m } | | j k r/ |  j | j  St | |  rS | j   j   } n d | f g } |  j j d  } x| D]\ } } t	 | j
 j    } | j d d    xt |  D]\ } \ }	 }
 |
 d k r4| r|  j j d  } | j |  j j d	   | j |  n  | j |  j |	   q |
 d k r|  j j d  } | j |  j j d
   | j |  | j |  j |	   q | r|  j j d  } | j |  j j d	   | j |  n  |  j j d  } | j |  j |
   | j |  |  j j d  } | j |  j j d   | j |  | j |  j |	   q Wq{ W| S(   Ni(   t   Vectori    R   R  c         S  s   |  d j    S(   Ni    (   t   __str__(   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   <lambda>  R%   i   R   R>  R=  R/  s   &InvisibleTimes;(   t   sympy.vectorR  t   zeroR;   R,  t   separateR   R1   R   RL   t
   componentsRN   R   R   R7   (   R)   R?   R  R   R   t   systemt   vectt
   inneritemsR   t   kt   vR   t   mbrac(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_BasisDependent  sD    c         C  s%   t  | j d t } |  j | d  S(   NR  s   &#x2227;(   R  R   R   R  (   R)   R?   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   _print_And  s    c         C  s%   t  | j d t } |  j | d  S(   NR  s   &#x2228;(   R  R   R   R  (   R)   R?   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt	   _print_Or  s    c         C  s%   t  | j d t } |  j | d  S(   NR  s   &#x22BB;(   R  R   R   R  (   R)   R?   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   _print_Xor  s    c         C  s   |  j  | j d  S(   Ns   &#x21D2;(   R  R   (   R)   R?   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Implies  s    c         C  s%   t  | j d t } |  j | d  S(   NR  s   &#x21D4;(   R  R   R   R  (   R)   R?   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Equivalent  s    c         C  s   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j d j r |  j  j d  } | j |  j | j d   n |  j | j d  } | j |  | S(   NR   R   s   &#xAC;i    R/  (   R1   R   R   R7   R   R  R;   (   R)   R   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   _print_Not  s     c         C  s8   |  j  j d  } | j |  j  j |  j |    | S(   NR   (   R1   R   R   R7   R   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_bool  s    "c         C  s8   |  j  j d  } | j |  j  j |  j |    | S(   NR   (   R1   R   R   R7   R   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_NoneType  s    "c         C  s\  d } |  j  j d  } | j d d  | j d d  | j j re | | d | j | d f } n | j j r t |  } t |  t |  | f } nO t	 |  d k r t |  } t |  t |  | | d f } n t
 |  } xk | D]c } | | k r>|  j  j d	  } | j |  j  j |   | j |  q | j |  j |   q W| S(
   Nu   …R/  RB  R  RC  R  ii   R   (   R1   R   R8  R  t   is_infinitet   stept   stopt   itert   nextRQ   t   tupleR   R7   R;   (   R)   R   t   dotsR3  t   printsett   itt   elR   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Range  s(    !%c         C  s   t  | j d t } |  j j d  } |  j j d  } | j |  j j t | j  j	     | j |  |  j j d  } x$ | D] } | j |  j
 |   q W| j |  | S(   NR  R   R   R/  (   R  R   R   R1   R   R   R7   R   t   funcR   R;   (   R)   R?   R   R   R   R3  R  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _hprint_variadic_function8  s    (c         C  sI   |  j  j d  } | j |  j d    | j |  j | j d   | S(   NR   i    (   R1   R   R   R   R]   R;   R   (   R)   R?   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   _print_expF  s    c         C  s   |  j  j d  } | j |  j | j   |  j  j d  } | j |  j  j |  j |    | j |  | j |  j | j   | S(   NR   R   (   R1   R   R   R;   R	  R7   R   R
  (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR  L  s    "c         C  s>   |  j  j |  j |   } | j |  j  j t |    | S(   N(   R1   R   R   R   R7   R   (   R)   R   R  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR  U  s    c         C  s   |  j  j d  } | j \ } } |  j  j d  } | j d d  | j |  j  j | j |   | j |  |  j  j d  } | j d d  | j |  j  j | j   | j |  | S(   NR   R   RW  RV  (   R1   R   t   _idR8  R   R7   t   _variable_namest   _name(   R)   R   R   t   indexR  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_BaseScalarZ  s     c         C  s  |  j  j d  } | j \ } } |  j  j d  } |  j  j d  } | j d d  | j |  j  j | j |   | j |  |  j  j d  } | j |  j  j d   | j |  | j |  |  j  j d  } | j d d  | j |  j  j | j   | j |  | S(   NR   t   moverR   RW  RV  R   t   ^(   R1   R   R  R8  R   R7   t   _vector_namesR  (   R)   R   R   R  R  R  R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_BaseVectorg  s      c         C  s   |  j  j d  } |  j  j d  } | j d d  | j |  j  j d   | j |  |  j  j d  } | j |  j  j d   | j |  | S(   NR  R   RW  RV  Rf  R   R  (   R1   R   R8  R   R7   (   R)   R   R  R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_VectorZeroy  s    c         C  s   |  j  j d  } | j } | j } | j |  j | t d   |  j  j d  } | j |  j  j d   | j |  | j |  j | t d   | S(   NR   R   R   s   &#xD7;(   R1   R   t   _expr1t   _expr2R   R4  R   R7   (   R)   R?   R   t   vec1t   vec2R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Cross  s    		c         C  s   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  |  j  j d  } | j |  j  j d   | j |  | j |  j | j t d   | S(   NR   R   s   &#x2207;s   &#xD7;R   (   R1   R   R   R7   R4  t   _exprR   (   R)   R?   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Curl  s     c         C  s   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  |  j  j d  } | j |  j  j d   | j |  | j |  j | j t d   | S(   NR   R   s   &#x2207;s   &#xB7;R   (   R1   R   R   R7   R4  R  R   (   R)   R?   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Divergence  s     c         C  s   |  j  j d  } | j } | j } | j |  j | t d   |  j  j d  } | j |  j  j d   | j |  | j |  j | t d   | S(   NR   R   R   s   &#xB7;(   R1   R   R  R  R   R4  R   R7   (   R)   R?   R   R  R  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   _print_Dot  s    		c         C  sn   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j t d   | S(   NR   R   s   &#x2207;R   (   R1   R   R   R7   R4  R  R   (   R)   R?   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Gradient  s     c         C  sn   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j t d   | S(   NR   R   s   &#x2206;R   (   R1   R   R   R7   R4  R  R   (   R)   R?   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Laplacian  s     c         C  s?   |  j  j d  } | j d d  | j |  j  j d   | S(   NR   RW  t   normals   &#x2124;(   R1   R   R8  R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Integers  s    c         C  s?   |  j  j d  } | j d d  | j |  j  j d   | S(   NR   RW  R  s   &#x2102;(   R1   R   R8  R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Complexes  s    c         C  s?   |  j  j d  } | j d d  | j |  j  j d   | S(   NR   RW  R  s   &#x211D;(   R1   R   R8  R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Reals  s    c         C  s?   |  j  j d  } | j d d  | j |  j  j d   | S(   NR   RW  R  s   &#x2115;(   R1   R   R8  R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Naturals  s    c         C  sw   |  j  j d  } |  j  j d  } | j d d  | j |  j  j d   | j |  | j |  j t j   | S(   NR   R   RW  R  s   &#x2115;(   R1   R   R8  R   R7   R;   R   t   Zero(   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Naturals0  s    c         C  s   | j  d | j  d } | j  d } |  j j d  } |  j j d  } | j d d  | j d d	  | j |  j |   | j |  | j |  j |   | S(
   Ni    i   i   R   R/  RB  u   ⟨RC  u   ⟩(   R   R1   R   R8  R   R;   (   R)   R?   t   shiftRk   R   R3  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_SingularityFunction  s    c         C  s/   |  j  j d  } | j |  j  j d   | S(   NR   t   NaN(   R1   R   R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt
   _print_NaN  s    c         C  sk   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | S(   NR   R   t   Bi    (   R1   R   R   R7   R;   R   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_bernoulli  s    c         C  sk   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | S(   NR   R   R$  i    (   R1   R   R   R7   R;   R   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_catalan  s    c         C  sk   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | S(   NR   R   t   Fi    (   R1   R   R   R7   R;   R   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_fibonacci  s    c         C  sk   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | S(   NR   R   t   Li    (   R1   R   R   R7   R;   R   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_lucas  s    c         C  sk   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | S(   NR   R   t   Ti    (   R1   R   R   R7   R;   R   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_tribonacci  s    c         C  s   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  |  j  j d  } | j |  j  j d   | j |  | S(   NR  R   s   &#x221E;t   ~(   R1   R   R   R7   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_ComplexInfinity  s    c         C  s/   |  j  j d  } | j |  j  j d   | S(   NR   s   &#x2205;(   R1   R   R   R7   (   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_EmptySet&  s    c         C  s   d d l  m } | j } |  j j d  } t | |  sr |  j j d  } | j |  j |   | j |  n | j |  j |   |  j j d  } | j |  j j d   | j |  | S(   Ni(   Ro   R   R/  R   s   &#x2020;(	   t   sympy.matricesRo   R   R1   R   R,  R   R;   R7   (   R)   R?   Ro   t   matR   R3  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Adjoint+  s    	c         C  s   d d l  m } | j } |  j j d  } t | |  sr |  j j d  } | j |  j |   | j |  n | j |  j |   |  j j d  } | j |  j j d   | j |  | S(   Ni(   Ro   R   R/  R   R  (	   R  Ro   R   R1   R   R,  R   R;   R7   (   R)   R?   Ro   R  R   R3  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Transpose:  s    	c         C  s   d d l  m } | j } |  j j d  } t | |  sr |  j j d  } | j |  j |   | j |  n | j |  j |   | j |  j d   | S(   Ni(   Ro   R   R/  (   R  Ro   R   R1   R   R,  R   R;   (   R)   R?   Ro   R  R   R3  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_InverseI  s    	c         C  s  d d l  m } |  j j d  } | j } t | d t  r_ | d j   t | d  } n t |  } t | |  r t	 |  r | d d k r | d } n | d | d <|  j j d  } | j
 |  j j d   | j
 |  n  xl | d  D]` } | j
 |  j | t |  t   |  j j d  } | j
 |  j j d   | j
 |  q W| j
 |  j | d t |  t   | S(	   Ni(   t   MatMulR   i    i   R   R=  s   &InvisibleTimes;(   t   sympyR  R1   R   R   R,  R   R   RL   R   R   R7   R4  R   R^   (   R)   R?   R  R   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_MatMulV  s,    	!

c         C  s   d d l  m } | j | j } } |  j j d  } t | |  s| |  j j d  } | j |  j |   | j |  n | j |  j |   | j |  j |   | S(   Ni(   Ro   R   R/  (	   R  Ro   R   R   R1   R   R,  R   R;   (   R)   R?   Ro   R   R   R   R3  (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_MatPows  s    c         C  s/   |  j  j d  } | j |  j  j d   | S(   NR  s   &#x1D7D8(   R1   R   R   R7   (   R)   t   ZR   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_ZeroMatrix  s    c         C  s/   |  j  j d  } | j |  j  j d   | S(   NR   s	   &#x1D540;(   R1   R   R   R7   (   R)   R  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Identity  s    c         C  sr   |  j  j d  } |  j  j d  } | j d d  | j d d  | j |  j | j d   | j |  | S(   NR   R/  RB  u   ⌊RC  u   ⌋i    (   R1   R   R8  R   R;   R   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_floor  s    c         C  sr   |  j  j d  } |  j  j d  } | j d d  | j d d  | j |  j | j d   | j |  | S(   NR   R/  RB  u   ⌈RC  u   ⌉i    (   R1   R   R8  R   R;   R   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_ceiling  s    c         C  s   |  j  j d  } |  j  j d  } | j d } t |  d k rY |  j | d  } n |  j |  } | j |  |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  | S(   NR/  R   i    i   R   s   &#x21A6;(   R1   R   R   RQ   R;   R   R7   (   R)   R   R   R   t   symbolsR   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Lambda  s    c         C  s=   |  j  j d  } x$ | D] } | j |  j |   q W| S(   NR/  (   R1   R   R   R;   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_tuple  s    c         C  s   |  j  | j  S(   N(   R;   t   label(   R)   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_IndexedBase  s    c         C  s~   |  j  j d  } | j |  j | j   t | j  d k ra | j |  j | j d   | S| j |  j | j   | S(   NR   i   i    (   R1   R   R   R;   R   RQ   t   indices(   R)   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_Indexed  s    c         C  s   |  j  j d  } | j |  j | j t d d t  |  j  j d  } | j d d  | j d d  x' | j D] } | j |  j	 |   qt W| j |  | S(   NR   t   AtomR1  R/  RB  R%   RC  (
   R1   R   R   R4  t   parentR   R_   R8  R  R;   (   R)   R   R   R3  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_MatrixElement  s    &c         C  s   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  |  j  j d  } | j d d  x' | j D] } | j |  j |   qv W| j |  | S(   NR   R   s	   &#x1d5a5;R/  t
   separatorsR  (   R1   R   R   R7   R8  R   R;   (   R)   R   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_elliptic_f  s    c         C  s   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  |  j  j d  } | j d d  x' | j D] } | j |  j |   qv W| j |  | S(   NR   R   s	   &#x1d5a4;R/  R	  R  (   R1   R   R   R7   R8  R   R;   (   R)   R   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_elliptic_e  s    c         C  s   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  |  j  j d  } t | j  d k r | j d d  n | j d d  x' | j D] } | j |  j |   q W| j |  | S(	   NR   R   s	   &#x1d6f1;R/  i   R	  R  s   ;|(   R1   R   R   R7   RQ   R   R8  R;   (   R)   R   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_elliptic_pi  s    c         C  sg   |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j   | S(   NR   R   t   Ei(   R1   R   R   R7   R;   R   (   R)   R   R   R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt	   _print_Ei  s    c         C  s   |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  | j |  j | j d   | S(   NR   R   R   t   Ei    i   (   R1   R   R   R7   R;   R   (   R)   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_expint  s    c         C  s   |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  j | j d d !  | j |  | j |  j | j d   | S(   NR   R   R   t   Pi    i   i   (   R1   R   R   R7   R;   R   (   R)   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_jacobi  s     c         C  s   |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  j | j d d !  | j |  | j |  j | j d   | S(   NR   R   R   R$  i    i   i   (   R1   R   R   R7   R;   R   (   R)   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_gegenbauer  s     c         C  s   |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  | j |  j | j d   | S(   NR   R   R   R  i    i   (   R1   R   R   R7   R;   R   (   R)   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_chebyshevt  s    c         C  s   |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  | j |  j | j d   | S(   NR   R   R   t   Ui    i   (   R1   R   R   R7   R;   R   (   R)   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_chebyshevu&  s    c         C  s   |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  | j |  j | j d   | S(   NR   R   R   R  i    i   (   R1   R   R   R7   R;   R   (   R)   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_legendre1  s    c         C  s   |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  j | j d d !  | j |  | j |  j | j d   | S(   NR   R   R   R  i    i   i   (   R1   R   R   R7   R;   R   (   R)   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_assoc_legendre<  s     c         C  s   |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  | j |  j | j d   | S(   NR   R   R   R  i    i   (   R1   R   R   R7   R;   R   (   R)   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_laguerreH  s    c         C  s   |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  j | j d d !  | j |  | j |  j | j d   | S(   NR   R   R   R  i    i   i   (   R1   R   R   R7   R;   R   (   R)   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_assoc_laguerreS  s     c         C  s   |  j  j d  } |  j  j d  } |  j  j d  } | j |  j  j d   | j |  | j |  j | j d   | j |  | j |  j | j d   | S(   NR   R   R   t   Hi    i   (   R1   R   R   R7   R;   R   (   R)   R   R   R;  R   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   _print_hermite_  s    N(}   R/   R0   R\   R  R   R^   R4  R   R]   R   R   RG  R   R   R   R   R   R   R   R   R   R   R   R  R  R]  Ra  Rc  Rd  Rg  R   R   Rn  R  R  R~  R  R  R  R  R  t   _print_DeterminantR  R  R  R  R  R  R  R  R  R  R  t   _print_frozensetR  R  R  R  R  R  R  R  R  t   _print_BooleanTruet   _print_BooleanFalseR  R  R  t
   _print_Mint
   _print_MaxR  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  t   _print_bellR  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R   R  R  R  R  R
  R  R  R  R  R  R  R  R  R  R  R  R  R  (    (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyR    s   	G		0											&	6								6			0		'																		*										
																											
																															t   contentc         K  s6   | d k r t  |  j |   St |  j |   Sd S(   s   Returns the MathML representation of expr. If printer is presentation
    then prints Presentation MathML else prints content MathML.
    t   presentationN(   R  RD   Ra   (   R?   t   printerR8   (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   mathmlk  s    c         K  sj   | d k r t  |  } n t |  } | j t |    } | j   | j   } | j   t |  d S(   s*  
    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.printing.mathml 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  Ra   R;   R   RZ   t   toprettyxmlR[   t   print(   R?   R&  R8   R   t   xmlt
   pretty_xml(    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   print_mathmlu  s    

("   R\   t
   __future__R    R   R  R   R   R   t   sympy.core.compatibilityR   R   R   t   sympy.core.functionR   t   sympy.printing.conventionsR	   R
   t   sympy.printing.precedenceR   R   t&   sympy.printing.pretty.pretty_symbologyR   t   sympy.printing.printerR   t   mpmath.libmpt   libmpRv  R   R   Ra   R  R'  R,  t   MathMLPrinter(    (    (    s4   lib/python2.7/site-packages/sympy/printing/mathml.pyt   <module>   s,   k m     
&