
    wg             	         U d Z ddlmZ ddlmZmZmZ ddlZddlm	Z	m
Z
mZmZmZmZmZmZ ddlmZ ddlmZ ddlmZmZ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#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-m.Z. ddl/m0Z0m1Z2 ddl3m4Z4m5Z5 ddl6Z6erddl7m8Z8 ddl9m:Z: g dZ;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/d0d1d2d3d4d5d6d7d8i d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKd,dLdMdNdDdOdPdQdRdSdTdUdVdWdXdYdZd[Z<h d\Z=i d]d^ d_d` dadb dcdd dedf dgdh didj dkdl dmdn dodp dqdr dsdt dudv dwdx dydz d{d| d}d~ d d d d d d d dZ>de?d<    e@e      ZA e6j                  d       e6j                  d      fZCddZD G d de(      ZEddZF e)eE      d        ZGd ZHddZIy)zC
A Printer which converts an expression into its LaTeX equivalent.
    )annotations)AnyCallableTYPE_CHECKINGN)AddFloatModMulNumberSSymbolExpr)greeks)Tuple)FunctionAppliedUndef
Derivative)AssocOp)Pow)default_sort_key)SympifyError)trueBooleanTrueBooleanFalse)precedence_traditional)Printerprint_function)split_super_subrequires_partial)
precedence
PRECEDENCE)prec_to_dpsto_str)has_varietysift)	NDimArray)BasisDependent)arcsinarccosarctansincostansinhcoshtanhsqrtlnlogseccsccotcothreimfracrootargAlphaz
\mathrm{A}Betaz
\mathrm{B}Gamma\GammaDeltaz\DeltaEpsilonz
\mathrm{E}Zetaz
\mathrm{Z}Etaz
\mathrm{H}Thetaz\ThetaIotaz
\mathrm{I}Kappaz
\mathrm{K}Lambdaz\LambdaMuz
\mathrm{M}Nuz
\mathrm{N}Xiz\XiomicronoOmicronz
\mathrm{O}Piz\PiRhoz
\mathrm{P}Sigmaz\SigmaTauz
\mathrm{T}Upsilonz\UpsilonPhiz\PhiChiz
\mathrm{X}Psiz\PsiOmegaz\Omegalamdaz\lambdaLamdakhiz\chiKhi
varepsilonz\varepsilonvarkappaz	\varkappavarphiz\varphivarpiz\varpivarrhoz\varrhoz	\varsigmaz	\vartheta)varsigmavartheta>
   wpellethmhobethhbaralephgimeldalethhslashmathringc                    d| z   dz   S )Nz
\mathring{} ss    Y/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/sympy/printing/latex.py<lambda>rt   [   s    -/$.     ddddotc                    d| z   dz   S )Nz\ddddot{ro   rp   rq   s    rs   rt   rt   \   s    Ad* ru   dddotc                    d| z   dz   S )Nz\dddot{ro   rp   rq   s    rs   rt   rt   ]       z!|D( ru   ddotc                    d| z   dz   S )Nz\ddot{ro   rp   rq   s    rs   rt   rt   ^   s    ik$& ru   dotc                    d| z   dz   S )Nz\dot{ro   rp   rq   s    rs   rt   rt   _       XaZ_ ru   checkc                    d| z   dz   S )Nz\check{ro   rp   rq   s    rs   rt   rt   `   rz   ru   brevec                    d| z   dz   S )Nz\breve{ro   rp   rq   s    rs   rt   rt   a   rz   ru   acutec                    d| z   dz   S )Nz\acute{ro   rp   rq   s    rs   rt   rt   b   rz   ru   gravec                    d| z   dz   S )Nz\grave{ro   rp   rq   s    rs   rt   rt   c   rz   ru   tildec                    d| z   dz   S )Nz\tilde{ro   rp   rq   s    rs   rt   rt   d   rz   ru   hatc                    d| z   dz   S )Nz\hat{ro   rp   rq   s    rs   rt   rt   e   r   ru   barc                    d| z   dz   S )Nz\bar{ro   rp   rq   s    rs   rt   rt   f   r   ru   vecc                    d| z   dz   S )Nz\vec{ro   rp   rq   s    rs   rt   rt   g   r   ru   primec                    d| z   dz   S N{z}'rp   rq   s    rs   rt   rt   h   s    s1uTz ru   prmc                    d| z   dz   S r   rp   rq   s    rs   rt   rt   i   s    SU4Z ru   boldc                    d| z   dz   S Nz\boldsymbol{ro   rp   rq   s    rs   rt   rt   k   s    oa', ru   bmc                    d| z   dz   S r   rp   rq   s    rs   rt   rt   l   s    OA%d* ru   c                    d| z   dz   S )Nz	\mathcal{ro   rp   rq   s    rs   rt   rt   m       \!^D( ru   c                    d| z   dz   S )Nz	\mathscr{ro   rp   rq   s    rs   rt   rt   n   r   ru   c                    d| z   dz   S )Nz
\mathfrak{ro   rp   rq   s    rs   rt   rt   o   s    mAod* ru   c                    d| z   dz   S )Nz\left\|{z	}\right\|rp   rq   s    rs   rt   rt   q   s    k!mL0 ru   c                    d| z   dz   S )Nz\left\langle{z}\right\ranglerp   rq   s    rs   rt   rt   r   s    %a'(99 ru   c                    d| z   dz   S Nz\left|{z}\right|rp   rq   s    rs   rt   rt   s       Z\+- ru   c                    d| z   dz   S r   rp   rq   s    rs   rt   rt   t   r   ru   )calscrfraknormavgabsmagzdict[str, Callable[[str], str]]modifier_dictz[0-9][} ]*$z(\d|\\frac{\d+}{\d+})c                    | j                  dd      } dD ]  }| j                  |d|z         }  | j                  dd      } | j                  dd      } | S )z
    Escape a string such that latex interprets it as plaintext.

    We cannot use verbatim easily with mathjax, so escaping is easier.
    Rules from https://tex.stackexchange.com/a/34586/41112.
    \z\textbackslashz&%$#_{}~z\textasciitilde^z\textasciicircum)replace)rr   cs     rs   latex_escaper      s_     	
		$)*A #IIa"#			#)*A			#*+AHru   c            
      "    e Zd ZU dZ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i dddddddddddddddZded<   dNd ZdOd!ZdOd"ZdPdOd#Z	d$ Z
dOd%ZdQd&ZdQd'ZdPdQd(ZdQd)ZdQd*ZdQd+ZdRd,Zd- ZdSd.ZeZeZd/ ZdNd0Zd1 Zd2 Zd3 Zd4 Zd5 Zd6 Zd7 Zd8 Z d9 Z!d: Z"dTd;Z#d< Z$d= Z%dUd>Z&dVd?Z'd@ Z(dA Z)dB Z*dWdCZ+dD Z,dE Z-dF Z.dG Z/dH Z0dI Z1dJ Z2dXdKZ3dNdYdLZ4dM Z5dN Z6e7dO        Z8dP Z9dQ Z:dR Z;dNdOdSZ<e<xZ=Z>dNdTZ?dNdUZ@dNdVZAdNdWZBdNdXZCdNdYZDdZ ZEd[ ZFd\ ZGd] ZHd^ ZIdNd_ZJdNd`ZKdNdaZLdNdbZMdNdcZNdNddZOdNdeZPdNdfZQdNdgZRdNdhZSdNdiZTdZdjZUdNdkZVdNdlZWdNdmZXdNdOdnZYeYZZdNdoZ[dNdpZ\dNdqZ]dNdrZ^dNdsZ_dNdtZ`dNduZadNdvZbdNdwZcdNdxZdd[dyZedOdzZfdNd{ZgdNd|ZhdNd}ZidNd~ZjdNdZkdNdZldNdZmdNdZndNdZodNdZpd\dOdZqd\dOdZrdNdZsdNdZtdNdZudNdZvdNdZwdNdZxdNdZydNdZzdNdZ{dNdZ|dNdZ}dNdZ~dNdZdNdZdNdZdNdZdNdZdNdZdNdZdNdZdNdZdNdZd]dZdNdZdNdZdNdZdNdZd Zd Zd^d_dZeZd^d`dZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdNdZd Zd Zd Zd Zd Zd Zd Zd Zd ZdadZdbdZd Zd Zd Zd Zd ZdÄ ZdĄ Zdń ZdƄ ZdNdǄZdȄ ZdɄ Zdʄ Zd˄ Zd̄ Zd̈́ Zd΄ ZdNdτZdNdЄZdNdфZdNd҄ZdNdӄZdԄ ZdՄ Zdք ZeZdׄ ZŐdNd؄ZƐdNdلZǐdNdڄZȐdNdۄZɐdNd܄ZʐdNd݄ZːdNdބZ̐dNd߄Zd ZeZeZeZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd  Zd Zd Zd Zd Zd ZdNdZdNdZdc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dN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d% Zd& Zd' Zd( Zd) Zd* Zd+ Zd, Zd- Zd. Z d/ Z!d0 Z"d1 Z#d2 Z$d3 Z%d4 Z&d5 Z'd6 Z(d7 Z)d8 Z*d9 Z+d: Z,d; Z-d< Z.d= Z/dNd>Z0dNd?Z1dNd@Z2dNdAZ3dNdBZ4dNdCZ5dD Z6dE Z7dF Z8dG Z9dH Z:dI Z;dJ Z<dK Z=dL Z> fdMZ? xZ@S (d  LatexPrinter_latex	full_precFfold_frac_powersfold_func_bracketsfold_short_fracNinv_trig_styleabbreviateditexln_notationlong_frac_ratio	mat_delim[mat_strmodeplain
mul_symbolordersymbol_namesroot_notationTmat_symbol_styleimaginary_unitiperiodddagger)gothic_re_imdecimal_separatorperm_cyclicparenthesize_superminmaxdiff_operatoradjoint_stylezdict[str, Any]_default_settingsc                   t        j                  | |       d| j                  v r g d}| j                  d   |vrt        d      | j                  d   !| j                  d   dk(  rd| j                  d<   ddd	d
d}	 || j                  d      | j                  d<   	 || j                  d   xs d   | j                  d<   ddd| _        dddddddd}| j                  d   }|j                  ||      | j                  d<   ddddd }| j                  d!   }|j                  ||      | j                  d"<   y # t        $ r | j                  d   | j                  d<   Y w xY w# t        $ rQ | j                  d   j                         dv r|d   | j                  d<   n| j                  d   | j                  d<   Y w xY w)#Nr   )inliner   equationz	equation*zB'mode' must be one of 'inline', 'plain', 'equation' or 'equation*'r   r   T z \,.\,  \cdot  \times )Nldotr}   timesr   mul_symbol_latexr}   mul_symbol_latex_numbers) r   r   z\,z\:\;z\quad)])(r   r   z
\mathrm{i}z\text{i}jz
\mathrm{j}z\text{j})Nr   ritir   rjtjr   imaginary_unit_latexr   z
\mathrm{d}z\text{d})Nr   rdtdr   diff_operator_latex)r   __init__	_settings
ValueErrorKeyErrorstrip_delim_dictget)selfsettingsvalid_modesmul_symbol_tableimaginary_unit_table	imag_unitdiff_operator_tabler   s           rs   r   zLatexPrinter.__init__   s   x(T^^#(K~~f%[8  "= > > >>+,4v&(204DNN,-  	
	- !=> NN-.

	1 !=!FG NN56 "%3/  
 NN#34	1E1I1I)U^1_-. 	
 70C0G0GWd0e,-I  	-|, NN-.	-  	1|,224BC %U+ 9: NN<0 9:	1s%   =D8 #E# 8%E E #AF=<F=c                $    dj                  |      S )Nz\left({}\right)formatr   rr   s     rs   _add_parenszLatexPrinter._add_parens   s    !((++ru   c                $    dj                  |      S )Nz\left( {}\right)r   r  s     rs   _add_parens_lspacezLatexPrinter._add_parens_lspace   s    "))!,,ru   c                    t        |      }|r"|r | j                  | j                  |            S ||k  s|s%||k  r | j                  | j                  |            S | j                  |      S N)r   r  _print)r   itemlevelis_negstrictprec_vals         rs   parenthesizezLatexPrinter.parenthesize   se    )$/f##DKK$566uv8u3D##DKK$566;;t$$ru   c                p    d|v r1| j                   d   r| j                  |      S dj                  |      S |S )z
        Protect superscripts in s

        If the parenthesize_super option is set, protect with parentheses, else
        wrap in braces.
        r   r   z{{{}}})r   r  r   r  s     rs   r   zLatexPrinter.parenthesize_super   s=     !8~~23''**q))ru   c                    t        j                  | |      }| j                  d   dk(  r|S | j                  d   dk(  rd|z  S | j                  d   rd|z  S | j                  d   }d|d|d	|dS )
Nr   r   r   z$%s$r   z$$%s$$z\begin{ro   z\end{)r   doprintr   )r   exprtexenv_strs       rs   r  zLatexPrinter.doprint	  st    oodD)>>&!W,J^^F#x/S= ^^F#s?"nnV,G.5sGDDru   c                    |j                   xr |j                  xs0 |j                  xr" |t        j                  uxr |j
                  du  S )z
        Returns True if the expression needs to be wrapped in brackets when
        printed, False otherwise. For example: a + b => True; a => False;
        10 => False; -10 => True.
        F)
is_Integeris_nonnegativeis_Atomr   NegativeOneis_Rationalr   r  s     rs   _needs_bracketszLatexPrinter._needs_brackets  sT     __<)<)< J I$amm*C +H.2.>.>%.GK 	Kru   c                    | j                  |      sy|j                  r| j                  |      sy|j                  r| j	                  |      sy|j
                  s|j                  ryy)a  
        Returns True if the expression needs to be wrapped in brackets when
        passed as an argument to a function, False otherwise. This is a more
        liberal version of _needs_brackets, in that many expressions which need
        to be wrapped in brackets when added/subtracted/raised to a power do
        not need them when passed to a function. Such an example is a*b.
        FT)r  is_Mul_mul_is_cleanis_Pow_pow_is_cleanis_Addis_Functionr  s     rs   _needs_function_bracketsz%LatexPrinter._needs_function_brackets   sZ     ##D) {{4#5#5d#;T%7%7%= 0 0ru   c                0   ddl m} ddlm} ddlm} j                  r|s4j                         r$yt              t        d   k  ryj                  ryj                  ryt        fdt        fD              ry|st        fd|||fD              ryy	)
a  
        Returns True if the expression needs to be wrapped in brackets when
        printed as part of a Mul, False otherwise. This is True for Add,
        but also for some container objects that would not need brackets
        when appearing last in a Mul, e.g. an Integral. ``last=True``
        specifies that this expr is the last to appear in a Mul.
        ``first=True`` specifies that this expr is the first to appear in
        a Mul.
        r   )Product)Sum)IntegralTr
   c              3  @   K   | ]  }j                  |        y wr  has.0xr  s     rs   	<genexpr>z3LatexPrinter._needs_mul_brackets.<locals>.<genexpr>N       +qtxx{+   c              3  @   K   | ]  }j                  |        y wr  r)  r+  s     rs   r.  z3LatexPrinter._needs_mul_brackets.<locals>.<genexpr>Q  s     BADHHQKBr0  F)sympy.concrete.productsr%  sympy.concrete.summationsr&  sympy.integrals.integralsr'  r  could_extract_minus_signr   r!   is_Relationalis_Piecewiseanyr	   )r   r  firstlastr%  r&  r'  s    `     rs   _needs_mul_bracketsz LatexPrinter._needs_mul_brackets7  s     	416;;T::<#D)Ju,==+SF++B(GS)ABBru   c                n    j                   ryt        fdt        fD              ryj                  ryy)z
        Returns True if the expression needs to be wrapped in brackets when
        printed as part of an Add, False otherwise.  This is False for most
        things.
        Tc              3  @   K   | ]  }j                  |        y wr  r)  r+  s     rs   r.  z3LatexPrinter._needs_add_brackets.<locals>.<genexpr>^  r/  r0  F)r6  r8  r	   r!  r  s    `rs   _needs_add_bracketsz LatexPrinter._needs_add_bracketsV  s1     +SF++;;ru   c                B    |j                   D ]  }|j                  s y y)NFT)argsr"  r   r  r<   s      rs   r  zLatexPrinter._mul_is_cleand  s$    99 	C	 ru   c                :    | j                  |j                         S r  )r  baser  s     rs   r   zLatexPrinter._pow_is_cleanj  s    ''		222ru   c                    |	d|d|dS |S )N\left(	\right)^{ro   rp   r   r  exps      rs   _do_exponentzLatexPrinter._do_exponentm  s    ?.2C88Kru   c                &   | j                  |j                  j                        }|j                  rK|j                  D cg c]  }| j	                  |       }}d}|j                  |dj                  |            S dj                  |      S c c}w )Nz"\operatorname{{{}}}\left({}\right), z\text{{{}}})_deal_with_super_sub	__class____name__r@  r  r   join)r   r  namerM   lsrr   s         rs   _print_BasiczLatexPrinter._print_Basics  sv    (()@)@A99*.))4Q$++a.4B45A88D$))B-00!((..	 5s    Bc                    d|z  S N	\text{%s}rp   r   es     rs   _print_boolzLatexPrinter._print_bool|      aru   c                    d|z  S rT  rp   rV  s     rs   _print_NoneTypezLatexPrinter._print_NoneType  rY  ru   c                    | j                  ||      }d}t        |      D ]U  \  }}|dk(  rn|j                         r	|dz  }| }n|dz  }| j                  |      }| j	                  |      rd|z  }||z  }W |S )N)r   r   r    -  + \left(%s\right))_as_ordered_terms	enumerater5  r  r>  )r   r  r   termsr  r   termterm_texs           rs   
_print_AddzLatexPrinter._print_Add  s    &&t5&9 ' 	GAtAv..0uuu{{4(H''--88OC	 
ru   c                F   ddl m} |j                  dk(  ry ||      }|j                  }|j                  }|j                  d   |dz
  k(  r
||dz
  ggz   }d}|D ]   }|t        |      j                  dd      z  }" |j                  d	d
      }|j                  dd      }|S )Nr   Permutation\left( \right)   r   ,r   r   \left( r   \right)) sympy.combinatorics.permutationsrh  sizecyclic_form
array_formstrr   )r   r  rh  	expr_permsizrd  r   s          rs   _print_CyclezLatexPrinter._print_Cycle  s    @99>$4 $$	ii??2#')!cAgYK/I 	3AAsE22H	3##C4##C4ru   c                   ddl m} ddlm} |j                  }| |d| dddd	       n| j
                  j                  d
d      }|r| j                  |      S |j                  dk(  ry|j                  D cg c]  }| j                  |       }}t        t        |            D cg c]  }| j                  |       }}dj                  |      }dj                  |      }	dj                  ||	f      }
d|
z  S c c}w c c}w )Nr   rg  )sympy_deprecation_warningzw
                Setting Permutation.print_cyclic is deprecated. Instead use
                init_printing(perm_cyclic=z).
                z1.6z#deprecated-permutation-print_cyclic   )deprecated_since_versionactive_deprecations_target
stacklevelr   Tri   &  \\ z \begin{pmatrix} %s \end{pmatrix})ro  rh  sympy.utilities.exceptionsrx  print_cyclicr   r   rv  rp  rr  r  rangelenrO  )r   r  rh  rx  r   r<   lowerupperrow1row2mats              rs   _print_PermutationzLatexPrinter._print_Permutation  s    @H!.."%++6- 8 */+P ..,,]DAK$$T**99>$-1__=cS!==-23u:->?cS!??zz% zz% llD$<(2S88 >?s   9C=)Dc                n    |j                   \  }}d| j                  |      d| j                  |      dS )Nz\sigma_{z}(r   r@  r  )r   r  permvars       rs   _print_AppliedPermutationz&LatexPrinter._print_AppliedPermutation  s,    II	c%)[[%6C8HIIru   c                *   t        |j                        }| j                  d   rdnd}d| j                  v r| j                  d   nd }d| j                  v r| j                  d   nd }t        |j                  ||||      }| j                  d   }d|v rO|j                  d      \  }}	|	d	   d
k(  r|	dd  }	| j                  d   dk(  r|j                  dd      }||d|	dS |dk(  ry|dk(  ry| j                  d   dk(  r|j                  dd      }|S )Nr   FTr   r   )strip_zeros	min_fixed	max_fixedr   rW  r   +rk  r   comma.z{,}z10^{ro   z+infz\inftyz-infz- \infty)r"   _precr   mlib_to_str_mpf_splitr   )
r   r  dpsr   lowhighstr_real	separatormantrH  s
             rs   _print_FloatzLatexPrinter._print_Float  s   $**%4$','>dnnU#D(-(?t~~e$Ttzz3ES\`a NN#=>	(?"..-KT31v}!"g~~12g=||C.%)9c::~~12g=#++C6Oru   c                    |j                   }|j                  }| j                  |t        d         d| j                  |t        d         S )Nr
   r   _expr1_expr2r  r!   r   r  vec1vec2s       rs   _print_CrosszLatexPrinter._print_Cross  sJ    {{{{"&"3"3D*U:K"L"&"3"3D*U:K"LN 	Nru   c                R    |j                   }d| j                  |t        d         z  S )Nz\nabla\times %sr
   _exprr  r!   r   r  r   s      rs   _print_CurlzLatexPrinter._print_Curl  s(    jj!D$5$5c:e;L$MMMru   c                R    |j                   }d| j                  |t        d         z  S )Nz\nabla\cdot %sr
   r  r  s      rs   _print_DivergencezLatexPrinter._print_Divergence  s(    jj 4#4#4S*U:K#LLLru   c                    |j                   }|j                  }| j                  |t        d         d| j                  |t        d         S )Nr
   r   r  r  s       rs   
_print_DotzLatexPrinter._print_Dot  sJ    {{{{!%!2!24E9J!K!%!2!24E9J!KM 	Mru   c                R    |j                   }d| j                  |t        d         z  S )Nz	\nabla %sr
   r  r   r  funcs      rs   _print_GradientzLatexPrinter._print_Gradient  (    zzd//j6GHHHru   c                R    |j                   }d| j                  |t        d         z  S )Nz	\Delta %sr
   r  r  s      rs   _print_LaplacianzLatexPrinter._print_Laplacian  r  ru   c                    ddl m}  j                  d    j                  d   d fd}d fdt        |t              r>|j
                  }|d   t        j                  u st        d |dd  D              r |      S d	}|j                         r| }d
}|j                  r
|dz  }d}nd} ||d      \  }}|t        j                  u r't        ddd	      |j
                  vr| ||      z  }n ||      }	 ||      }
t        |
j                               } j                  d   } j                  d   r5|dk  r0d|
vr, j                  |d	      r|d|	d|
z  }n_||	d|
z  }nS|Dt        |	j                               ||z  kD  r$ j                  |d      r|d|
dd|	dz  }n|j                  rt        j                  }t        j                  }|j
                  D ]h  } j                  |d	      sHt         |||z        j                               ||z  kD  s |j                   |j                   cxu rd	u r	n n||z  }d||z  }j  j                  |d      r|d ||      d|
dd ||      d	z  }n7|d ||      d|
d ||      z  }n|d|
d|	z  }n|d|	d|
dz  }|r|dz  }|S ) Nr   )fractionr   r   c                   | j                   st        j                  |             S j                  dvr| j	                         }nt        | j                        }t        |d d      \  }}t        |d d      \  }} ||z   |z         S )N)oldnonec                    t        | d      xs t        | d      xs( t        | t              xr t        | j                  d      S )N_scale_factoris_physical_constant)hasattr
isinstancer   rC  r-  s    rs   rt   z:LatexPrinter._print_Mul.<locals>.convert.<locals>.<lambda>  sD    ?8S8yW^_`bxWy 8H)!S1  G&qvv/EF ru   T)binaryc                    t        | d      S )Nr  )r  r  s    rs   rt   z:LatexPrinter._print_Mul.<locals>.convert.<locals>.<lambda>  s    ?8S ru   )r  rs  r  r   as_ordered_factorslistr@  r%   )r  r@  unitsnonunitsprefixesconvert_argsr   s        rs   convertz(LatexPrinter._print_Mul.<locals>.convert  s    ;;4;;t,--::_4224D		?D #'t .HPT#Vx #'u.S\`"a%#Hx$7%$?@@ru   c           	     v   dx}}t        |       D ]  \  }}j                  |      }t        |d      sut        |d      sij                  ||dk(  |t	        |       dz
  k(        rd|z  }t
        d   j                  |      rt
        d   j                  |      r|z  }n|r|z  }n|r|z  }||z  }|} |S )Nr   r  r  r   rk  )r9  r:  r_  )ra  r  r  r;  r  _between_two_numbers_psearchmatch)	r@  _texlast_term_texr   rc  rd  	numbersepr   r  s	         rs   r  z-LatexPrinter._print_Mul.<locals>.convert_args  s    #%%D=$T? )4;;t,o6'$H^:_//Q!V673t9q=6H 0 K#5#@.q188G.q177A	)	)I%D  (#)$ Kru   c              3  <   K   | ]  }t        |t                y wr  )r  r   )r,  r<   s     rs   r.  z*LatexPrinter._print_Mul.<locals>.<genexpr>:  s     &S3z#v'>&S   rk  F- r   Tr   )exactrj  )evaluater   r      r   )r:  rE  z
\right) / z / z	\frac{1}{ro   rn  \frac{}{r   returnrs  )sympy.simplifyr  r   r  r
   r@  r   Oner8  r5  r!  r   r  r  r;  r  is_commutative)r   r  r  r  r@  include_parensr  numerdenomsnumersdenomldenomratioabr-  r  r  r  s   `               @@@rs   
_print_MulzLatexPrinter._print_Mul  s   +(:;	(BC		A 	8 dC 99DAw!%%3&S$qr(&S#S#D))((*5DC{{s
!%CD1uAEE>c!R%8		I 74= C U^FU^F(FNN#45E~~/0Vq[v%++E+>ffEEC88C"'%,6++E+=!9f6 6C\\AA"ZZ #33AE3B #GAaCL$6$6$8 9E&L H!"!1!1Q5E5E!N!NFAFA# ///=&qz69gaj J J &qz69gaj J J &)VLLC66::3JC
ru   c                    |j                   r-| j                  |j                         j                               S | j                  |j                               S r  )
is_aliasedr  as_polyas_exprr  s     rs   _print_AlgebraicNumberz#LatexPrinter._print_AlgebraicNumberz  s<    ??;;t||~55788;;t||~..ru   c                    | j                  |j                        }|j                  rd| dS | j                  |j                  j	                               }d| d| dS )NrE  rn  rK  )r  pis_inertalphar  )r   r  r  r  s       rs   _print_PrimeIdealzLatexPrinter._print_PrimeIdeal  sZ    KK==QCw''DJJ..012eWG,,ru   c                t   |j                   j                  rB|j                   j                  }|j                   j                  }t	        |      dk(  ru|dk7  rp| j
                  d   ra| j                  |j                        }|dk(  rd|z  }n| j
                  d   rd||fz  }nd||fz  }|j                   j                  rd|z  S |S | j
                  d	   r|dk7  r| j                  |j                  t        d
         }|j                  j                  r| j                  |      }|j                  j                  r"| j                  |j                  |d|      S |d|d|dS |j                   j                  r|j                  j                  r|j                  dk(  r|j                  d|j                   dS |j                  j                  rt|j                  j                  }|j                  j                  }||z  t	        |      k(  r7|j                   dk(  r	d|d|dS d|d|dt	        |j                         dS | j                  |      S |j                  j                  r6| j                  |j                  | j                  |j                               S d}| j!                  ||      S )Nrk  r   r  z	\sqrt{%s}r   z\root{%d}{%s}z\sqrt[%d]{%s}z\frac{1}{%s}r   r   /rH  ^{ro   rj  z\frac{1}{\frac{r  }}z\frac{1}{(\frac{z})^{z%s^{%s})rH  r  r  qr   r   r  rC  is_negativer  r!   	is_Symbolr   r"  r  r  _helper_print_standard_power)r   r  r  r  rC  r  base_pbase_qs           rs   
_print_PowzLatexPrinter._print_Pow  s.   88XXZZAXXZZA1v{qAv$..*I{{499-6&-C^^F+*aY6C*aY6C88''*S00J 23Q((Ju4EF99&&2248D99((;;tyyA6F;GG(,a33%%$))*B*B99>)-DHH==99(("&))++F"&))++F#f+588r>AG#PP * IOPVX[\`\d\dXe#fft,,99  ;;tyydkk$((.C;DD00s;;ru   c                   | j                  |j                        }| j                  |j                  t        d         }|j                  j
                  r| j                  |      }ns|j                  j                  rd|z  }nWt        |j                  t              r=|j                  d      r,t        j                  d|      r|j                  d      r|dd }|||fz  S )Nr   z{%s}rE  z\\left\(\\d?d?dotrn     i)r  rH  r  rC  r!   r  r   is_Floatr  r   
startswithr8   r  endswith)r   r  templaterH  rC  s        rs   r  z)LatexPrinter._helper_print_standard_power  s    kk$((#   Ju,=>99**40DYYT>DJ/	*-t4j)2;D4+%%ru   c                >    | j                  |j                  d         S Nr   r  r@  r  s     rs   _print_UnevaluatedExprz#LatexPrinter._print_UnevaluatedExpr  s    {{499Q<((ru   c           
         t        |j                        dk(  r9dt        |j                  d   D cg c]  } j                  |       c}      z  }n< fd}dt        j                  d|j                  D cg c]
  } ||       c}      z  }t        |j                  t              r#|d j                  |j                        z  z  }|S | j                  |j                        z  }|S c c}w c c}w )Nrk  z\sum_{%s=%s}^{%s} r   c           	     |    dt        | d   | d   | d   fD cg c]  }j                  |       c}      z  S c c}w Nz%s \leq %s \leq %srk  r   r  tupler  lrr   r   s     rs   _format_ineqz-LatexPrinter._print_Sum.<locals>._format_ineq  C    ,AaD!A$!3EFa4;;q>FGH HF   9
z\sum_{\substack{%s}} \\r_  	r  limitsr  r  rs  rO  r  functionr   r   r  r   r  r  r  s   `     rs   
_print_SumzLatexPrinter._print_Sum  s    t{{q 't{{1~>!t{{1~>?@CH +4;;!Ga,q/!GHIC dmmS)%DMM(BBBC 
 4;;t}}--C
 ? "H   C,
7C1c           
         t        |j                        dk(  r9dt        |j                  d   D cg c]  } j                  |       c}      z  }n< fd}dt        j                  d|j                  D cg c]
  } ||       c}      z  }t        |j                  t              r#|d j                  |j                        z  z  }|S | j                  |j                        z  }|S c c}w c c}w )Nrk  z\prod_{%s=%s}^{%s} r   c           	     |    dt        | d   | d   | d   fD cg c]  }j                  |       c}      z  S c c}w r  r  r  s     rs   r  z1LatexPrinter._print_Product.<locals>._format_ineq  r  r  z\prod_{\substack{%s}} r  r_  r  r  s   `     rs   _print_ProductzLatexPrinter._print_Product  s    t{{q (t{{1~>!t{{1~>?@CH ,4;;!Ga,q/!GHIC dmmS)%DMM(BBBC 
 4;;t}}--C
 ? "Hr  c                   ddl m} g }||j                  k(  r|j                  j                  S t	        ||      r|j                         j                         }nd|fg}|D ]  \  }}t        |j                  j                               }|j                  d        |D ]  \  }}	|	dk(  r|j                  d|j                  z          *|	dk(  r|j                  d|j                  z          Nd	| j                  |	      z   d
z   }
|j                  d|
z   |j                  z            dj                  |      }|d   dk7  r|dd  }|S |dd  }|S )Nr   )Vectorc                (    | d   j                         S r  )__str__r  s    rs   rt   z4LatexPrinter._print_BasisDependent.<locals>.<lambda>  s    !A$,,. ru   keyrk  r^  rj  r]  rE  rn  r   -   )sympy.vectorr  zero_latex_formr  separateitemsr  
componentssortappendr  rO  )r   r  r  o1r*  systemvect
inneritemskvarg_stroutstrs               rs   _print_BasisDependentz"LatexPrinter._print_BasisDependent  sB   '49999(((dF#MMO))+EYKE! 
	?LFDdoo3356JOO 8O9" ?16IIeamm34"WIIeamm34'$++a.8:EGIIego=>?
	? ''"+!9ABZF  ABZFru   c                    | j                  |j                        }d|z   dz   ddj                  t        | j                   |j                              z  z   }|S )Nr   ro   _{%s}rl  )r  rC  rO  mapindices)r   r  tex_baser  s       rs   _print_IndexedzLatexPrinter._print_Indexed  sP    ;;tyy)(l3wT\\**,  , ,
ru   c                8    | j                  |j                        S r  )r  labelr  s     rs   _print_IndexedBasezLatexPrinter._print_IndexedBase  s    {{4::&&ru   c                d   | j                  |j                        }|j                  | j                  |j                        }|j                  | j                  |j                        }n| j                  t        j
                        }dj                  ||      }dj                  ||      S |S )Nz%{lower}\mathrel{{..}}\nobreak {upper})r  r  z{{{label}}}_{{{interval}}})r>  interval)r  r>  r  r  r   Zeror   )r   r  r>  r  r  rA  s         rs   
_print_IdxzLatexPrinter._print_Idx  s    DJJ'::!KK

+Ezz%DJJ/AFF+@GG!5 H 2H/66( 7 4 4 ru   c           	        t        |j                        rd}n| j                  d   }d}d}t        |j                        D ]d  \  }}||z  }|dk(  r||d| j                  |      z  }*||d| j                  | j                  |            d| j                  |      dz  }f |dk(  r
d	|d
|d}nd	|d| j                  |      d|d}t        d |j                  D              r+|d| j                  |j                  t        d   dd      S |d| j                  |j                  t        d   dd      S )Nz\partialr   r   r   rk  r   r  ro   r  r  }}{c              3  <   K   | ]  }|j                           y wr  r5  r,  r   s     rs   r.  z1LatexPrinter._print_Derivative.<locals>.<genexpr>:  s     ?q))+?r  r
   Tr
  r  F)r   r  r   reversedvariable_countr  r   r8  r@  r  r!   )r   r  diff_symbolr  dimr-  nums          rs   _print_DerivativezLatexPrinter._print_Derivative$  sQ   DII&%K..)>?Kt223 	:FAs3JCax;A??(,(?(?A(O(,C(8: :	: !8&137C  ,7C8H#NC?TYY??"D$5$5dii2<U2C9=9= %6 %? @ @
  1 1$))2<U2C9>9= !2 !? @ 	@ru   c                     |j                   \  }}} j                  |      } fd|D        } fd|D        }dj                  d t        ||      D              }d|d|dS )Nc              3  @   K   | ]  }j                  |        y wr  r  r,  rW  r   s     rs   r.  z+LatexPrinter._print_Subs.<locals>.<genexpr>H       1T[[^1r0  c              3  @   K   | ]  }j                  |        y wr  rR  rS  s     rs   r.  z+LatexPrinter._print_Subs.<locals>.<genexpr>I  rT  r0  z\\ c              3  8   K   | ]  }|d    dz   |d   z     yw)r   =rk  Nrp   )r,  rW  s     rs   r.  z+LatexPrinter._print_Subs.<locals>.<genexpr>J  s(      !B"#AaD3J1!B   z\left. z \right|_{\substack{ z }})r@  r  rO  zip)	r   subsr  r  new
latex_expr	latex_old	latex_new
latex_subss	   `        rs   _print_SubszLatexPrinter._print_SubsE  sk    c3[[&
1S1	1S1	[[ !B'*9i'@!B B
9C9CE 	Eru   c           
        dg }}| j                   d   }t        |j                        dk  rnt        d |j                  D              rRddt        |j                        dz
  z  z   dz   }|j                  D cg c]  }d	|| j	                  |d
          }}nt        |j                        D ]  }|d
   }|dz  }t        |      dkD  r| j                   d   dk7  r| j                   d   s|dz  }t        |      dk(  r0|d| j	                  |d         d| j	                  |d         dz  }t        |      dk(  r|d| j	                  |d         z  z  }|j                  d
d	|| j	                  |              |d| j                  |j                  t        d   t        d |j                  D              d      dj                  |      S c c}w )Nr   r      c              3  8   K   | ]  }t        |      d k(    yw)rk  N)r  )r,  lims     rs   r.  z/LatexPrinter._print_Integral.<locals>.<genexpr>T  s     (N3SQ(NrX  z\ir   rk  ntz\, r   z\intr   r   r   z\limitsr%  _{}^{r  ro   ^{%s}r   r
   c              3  <   K   | ]  }|j                           y wr  rG  rH  s     rs   r.  z/LatexPrinter._print_Integral.<locals>.<genexpr>o  s     >o`aq?Y?Y?[>or  TrI  )r   r  r  allr  rJ  insertr  r  r!   r8  r@  rO  )r   r  r  symbolsrL  symbolrd  s          rs   _print_IntegralzLatexPrinter._print_IntegralO  s   2Wnn%:; t{{q S(N$++(N%N #s4;;/!344t;C%)[[2! &1$++fQi2HI 2G 2  , SQws8a<~~f-9$(NN6$:z)3x1}t{{3q6/B/3{{3q6/B D D3x1}w$++c!f*=>>qT[[=P"QRS" !$"3"3DMM4>u4E;>>oeienen>o;o;? #4 #A  WWW-	/ 	/+2s   7 Gc                   |j                   \  }}}}d| j                  |      z  }t        |      dk(  s"|t        j                  t        j
                  fv r|d| j                  |      z  z  }n)|| j                  |      d| j                  |      dz  }t        |t              r|d| j                  |      dS |d| j                  |      S )	Nz\lim_{%s \to z+-z%s}r   ro   rE  rn  r   )r@  r  rs  r   InfinityNegativeInfinityr  r   )r   r  rW  zz0dirr  s          rs   _print_LimitzLatexPrinter._print_Limits  s    		1b#Q/s8trajj!2D2D%EE6DKKO++CBS1ABBCa!+.A??"DKKN33ru   c                   | j                  |      }|j                  d      }|j                  d      }|t        v rd|z  }|S t        |      dk(  s|j	                  d      s
|dk(  s|dk(  r|}|S |dkD  r)|dkD  r$d|dt        ||       d	|t        ||      d }|S |dkD  rd|d| d	||d }|S |dkD  rd|d| d	||d }|S d
|z  }|S )ak  
        Logic to decide how to render a function to latex
          - if it is a recognized latex name, use the appropriate latex command
          - if it is a single letter, excluding sub- and superscripts, just use that letter
          - if it is a longer name, then put \operatorname{} around it and be
            mindful of undercores in the name
        r   _z\%srk  r   r   \operatorname{Nro   z\operatorname{%s})rL  findaccepted_latex_functionsr  r  r   )r   r  superscriptidxsubscriptidxrP  s        rs   _hprint_FunctionzLatexPrinter._hprint_Function  s&    ((.3yy~++D=D$ # Y!^tt48I^_`M`D   !lQ&6:#l>:;\.9:;=   !#.))+  !,'')
  ,d2ru   c                0   |j                   j                  }t        | d|z         r&t        |t              s t        | d|z         ||      S |j                  D cg c]  }t        | j                  |             }}| j                  d   }d}| j                  d   xr/ t        |      dk(  xr | j                  |j                  d          }g d}	||	v r.|dk(  rn(|d	k(  r|d
   dk(  rdnd|dd z   }n|dk(  r|dd }d}|d}|r|t        v rd|z  }
nDd|z  }
n>|+| j                  |      }| j                  |      }|d|d}
n| j                  |      }
|r|t        v r|
dz  }
n|
dz  }
n|
dz  }
|r
||
d|z  z  }
|
dj                  |      z  S c c}w )a#  
        Render functions to LaTeX, handling functions that LaTeX knows about
        e.g., sin, cos, ... by using the proper LaTeX command (\sin, \cos, ...).
        For single-letter function names, render them as regular LaTeX math
        symbols. For multi-letter function names that LaTeX does not know
        about, (e.g., Li, sech) use \operatorname{} so that the function name
        is rendered in Roman font and LaTeX handles spacing properly.

        expr is the expression involving the function
        exp is an exponent
        _print_r   Fr   rk  r   )asinacosatanacscasecacotasinhacoshatanhacschasechacothr   fullrj  hararcNpowerTz\%s^{-1}z\operatorname{%s}^{-1}r  ro   z {%s}%s{\left(%s \right)}rh  rl  )r  rN  r  r  r   getattrr@  rs  r  r   r  r#  rz  r}  r   rO  )r   r  rH  r  r<   r@  r   inv_trig_power_casecan_fold_bracketsinv_trig_tablerP  func_texs               rs   _print_FunctionzLatexPrinter._print_Function  s    yy!!4T)*t\2274T!124==59YY?cCC()?D? "^^,<=N"' $/C D !@D	Q!@11$))A,?? N ~%!]2#v-$(HOD$qr(JD#w.8D*.' ,1)"33&-D4t;D006228<%-s3,,T2 33 H$DEMD--"s3&#((4.((s @s   !Fc                6    | j                  t        |            S r  )r}  rs  r  s     rs   _print_UndefinedFunctionz%LatexPrinter._print_UndefinedFunction  s    $$SY//ru   c                x    d| j                  |j                        d| j                  |j                        dS )Nr   z}_{\circ}\left({z}\right))r  r  r  r  s     rs   _print_ElementwiseApplyFunctionz,LatexPrinter._print_ElementwiseApplyFunction  s,    KK&KK		"
 	
ru   c                ^    ddl m} ddlm}m} ddlm} ddlm} ddl	m
} |d|d|d	|d
|d|diS )Nr   )KroneckerDelta)gamma
lowergamma)beta)
DiracDelta)rU   z\deltar@   \gammaz\operatorname{B}z\operatorname{Chi})(sympy.functions.special.tensor_functionsr  'sympy.functions.special.gamma_functionsr  r  &sympy.functions.special.beta_functionsr  'sympy.functions.special.delta_functionsr  'sympy.functions.special.error_functionsrU   )r   r  r  r  r  r  rU   s          rs   _special_function_classesz&LatexPrinter._special_function_classes  s;    KM?F?		I)I*, 	,ru   c                    | j                   D ]9  }t        ||      s|j                  |j                  k(  s*| j                   |   c S  | j                  t	        |            S r  )r  
issubclassrN  r}  rs  )r   r  clss      rs   _print_FunctionClassz!LatexPrinter._print_FunctionClass  sX    11 	;C$$#,,)F55c::	; $$SY//ru   c                    |j                   \  }}t        |      dk(  r| j                  |d         }n| j                  t        |            }d|d| j                  |      d}|S )Nrk  r   rm  z	 \mapsto  \right))r@  r  r  r  )r   r  rl  r  s       rs   _print_LambdazLatexPrinter._print_Lambda
  sX    		w<1kk'!*-Gkk%.1G18$++d:KL
ru   c                     y)Nz\left( x \mapsto x \right)rp   r  s     rs   _print_IdentityFunctionz$LatexPrinter._print_IdentityFunction  s    ,ru   c                   t        |j                  t              }|D cg c]  }d| j                  |      z   }}dt	        |j
                        j                         ddj                  |      d}||d|dS |S c c}w )	Nr"  r  r   rE  rK  rn  r  ro   )sortedr@  r   r  rs  r  r  rO  )r   r  rH  r@  rm  texargsr  s          rs   _hprint_variadic_functionz&LatexPrinter._hprint_variadic_function  sv    dii%56=AB654;;v..BB'*499~';';'='+yy'9;?!$c**J Cs   Bc                \    d| j                  |j                  d         z  }||d|dS |S )Nz\left\lfloor{%s}\right\rfloorr   r  ro   r  r   r  rH  r  s       rs   _print_floorzLatexPrinter._print_floor%  s2    .TYYq\1JJ?!$c**Jru   c                \    d| j                  |j                  d         z  }||d|dS |S )Nz\left\lceil{%s}\right\rceilr   r  ro   r  r  s       rs   _print_ceilingzLatexPrinter._print_ceiling-  s2    ,t{{499Q</HH?!$c**Jru   c                    | j                   d   s"d| j                  |j                  d         z  }n!d| j                  |j                  d         z  }||d|dS |S )Nr   z\log{\left(%s \right)}r   z\ln{\left(%s \right)}r  ro   )r   r  r@  r  s       rs   
_print_logzLatexPrinter._print_log5  sY    ~~m,+dkk$))A,.GGC*T[[1-FFC?!$c**Jru   c                \    d| j                  |j                  d         z  }||d|dS |S )N\left|{%s}\right|r   r  ro   r  r  s       rs   
_print_AbszLatexPrinter._print_Abs@  s2    "T[[1%>>?!$c**Jru   c                   | j                   d   r*d| j                  |j                  d   t        d         z  }n5dj	                  | j                  |j                  d   t        d               }| j                  ||      S )Nr   z\Re{%s}r   Atomz\operatorname{{re}}{{{}}}r   r  r@  r!   r   rI  r  s       rs   	_print_rezLatexPrinter._print_reH  r    >>.)t001z&?QRRC.55d6G6G		RSV`agVh6ijC  c**ru   c                   | j                   d   r*d| j                  |j                  d   t        d         z  }n5dj	                  | j                  |j                  d   t        d               }| j                  ||      S )Nr   z\Im{%s}r   r  z\operatorname{{im}}{{{}}}r  r  s       rs   	_print_imzLatexPrinter._print_imP  r  ru   c                   ddl m}m} t        |j                  d   |      r| j                  |j                  d   d      S t        |j                  d   |      r| j                  |j                  d   d      S |j                  d   j                  r!d| j                  |j                  d         z  S d| j                  |j                  d         z  S )Nr   )
EquivalentImpliesz\not\Leftrightarrowz\not\Rightarrowz\neg \left(%s\right)z\neg %s)	sympy.logic.boolalgr  r  r  r@  _print_Equivalent_print_Implies
is_Booleanr  )r   rW  r  r  s       rs   
_print_NotzLatexPrinter._print_NotX  s    =affQi,))!&&)5KLLaffQi)&&qvvay2DEEFF1I  *T[[-CCCAFF1I 666ru   c                B   |d   }|j                   r!|j                  sd| j                  |      z  }nd| j                  |      z  }|dd  D ]P  }|j                   r(|j                  s|d|d| j                  |      dz  }7|d|d| j                  |      z  }R |S )Nr   r_  r  rk  r   z \left(rn  )r  is_Notr  )r   r@  charr<   r  s        rs   _print_LogOpzLatexPrinter._print_LogOpc  s    1g>>#**$t{{3'77C$++c**C8 	<C~~cjjt{{37GHHD$++c*:;;		< 
ru   c                \    t        |j                  t              }| j                  |d      S )Nr"  z\wedger  r@  r   r  r   rW  r@  s      rs   
_print_AndzLatexPrinter._print_Andr  s&    aff"23  y11ru   c                \    t        |j                  t              }| j                  |d      S )Nr"  z\veer  r  s      rs   	_print_OrzLatexPrinter._print_Orv  s&    aff"23  w//ru   c                \    t        |j                  t              }| j                  |d      S )Nr"  z\veebarr  r  s      rs   
_print_XorzLatexPrinter._print_Xorz  s&    aff"23  z22ru   c                B    | j                  |j                  |xs d      S )Nz\Rightarrow)r  r@  )r   rW  altchars      rs   r  zLatexPrinter._print_Implies~  s      )BNCCru   c                d    t        |j                  t              }| j                  ||xs d      S )Nr"  z\Leftrightarrowr  )r   rW  r  r@  s       rs   r  zLatexPrinter._print_Equivalent  s,    aff"23  w'D2DEEru   c                \    d| j                  |j                  d         z  }||d|dS |S )Nz\overline{%s}r   r  ro   r  r  s       rs   _print_conjugatezLatexPrinter._print_conjugate  s2    TYYq\!::?!$c**Jru   c                l    d}d| j                  |j                  d         z  }|
|d|d|S ||S )Nz\operatorname{polar\_lift}r  r   r  ro   r  )r   r  rH  r  r<   s        rs   _print_polar_liftzLatexPrinter._print_polar_lift  s?    ,#dkk$))A,&???#'c22"C((ru   c                h    d| j                  |j                  d         z  }| j                  ||      S )Nze^{%s}r   )r  r@  rI  r  s       rs   _print_ExpBasezLatexPrinter._print_ExpBase  s2     $++diil33  c**ru   c                     y)NrW  rp   rG  s      rs   _print_Exp1zLatexPrinter._print_Exp1  s    ru   c                b    d| j                  |j                  d         z  }|d|d|S d|z  S )Nr_  r   zK^{ro   zK%sr  r  s       rs   _print_elliptic_kzLatexPrinter._print_elliptic_k  s7     4;;tyy|#<<?"%s++C<ru   c                    d| j                  |j                  d         d| j                  |j                  d         d}|d|d|S d|z  S )	NrE  r   	\middle| rk  rn  zF^{ro   zF%sr  r  s       rs   _print_elliptic_fzLatexPrinter._print_elliptic_f  sK    [[1&DIIaL(AC?"%s++C<ru   c                   t        |j                        dk(  rBd| j                  |j                  d         d| j                  |j                  d         d}n!d| j                  |j                  d         z  }|d|d	|S d
|z  S )Nr  rE  r   r  rk  rn  r_  zE^{ro   zE%sr  r@  r  r  s       rs   _print_elliptic_ezLatexPrinter._print_elliptic_e  sx    tyy>QTYYq\*DKK		!,EGC %t{{499Q<'@@C?"%s++C<ru   c           	        t        |j                        dk(  rad| j                  |j                  d         d| j                  |j                  d         d| j                  |j                  d         d}nAd| j                  |j                  d         d| j                  |j                  d         d}|d	|d
|S d|z  S )Nr%  rE  r   ; rk  r  r  rn  z\Pi^{ro   z\Pi%sr  r  s       rs   _print_elliptic_pizLatexPrinter._print_elliptic_pi  s    tyy>QTYYq\*DKK		!,ETYYq\*,C  TYYq\*DKK		!,EGC?$'--c>!ru   c                    |j                   d   }t        |j                         dk(  r|j                   d   n|j                   d   }d| d| d}|d|d|S d|z  S )	Nr   rk  rE  rK  rn  z\operatorname{B}^{ro   z\operatorname{B}%s)r@  r  )r   r  rH  r-  yr  s         rs   _print_betazLatexPrinter._print_beta  sd    IIaL		Na/DIIaLTYYq\s"QCw'?14c::(3..ru   c           
         |j                   D cg c]  }| j                  |       }}d|d   d|d   d}|d|d|d   d|d	   d
|d|
S d|d|d   d|d	   d|S c c}w )NrE  r   rK  rk  rn  rx  z}_{(r  r%  z)}^{ro   z)}r  )r   r  rH  operatorr<   largsr  s          rs   _print_betainczLatexPrinter._print_betainc  s}    -1YY7cS!77(-a%(;?=EuQxQVWXQY[^`cdd  9A%(ERSHVYZZ 8s   A%c                *    | j                  ||d      S )NI)r  )r  rG  s      rs   _print_betainc_regularizedz'LatexPrinter._print_betainc_regularized  s    ""4s";;ru   c                    d| j                  |j                  d         d| j                  |j                  d         d}|d|d|S d|z  S )	NrE  r   rK  rk  rn  z\Gamma^{ro   z\Gamma%sr  r  s       rs   _print_uppergammazLatexPrinter._print_uppergamma  O    (,DIIaL(A(,DIIaL(AC ?'*C00$$ru   c                    d| j                  |j                  d         d| j                  |j                  d         d}|d|d|S d|z  S )	NrE  r   rK  rk  rn  z\gamma^{ro   \gamma%sr  r  s       rs   _print_lowergammazLatexPrinter._print_lowergamma  r  ru   c                    d| j                  |j                  d         z  }|#| j                  |j                        d|d|S | j                  |j                        |S Nr_  r   r  ro   )r  r@  r  r  s       rs   _hprint_one_arg_funcz!LatexPrinter._hprint_one_arg_func  sT     4;;tyy|#<<?#';;tyy#93DD"kk$))4c::ru   c                b    d| j                  |j                  d         z  }|d|d|S d|z  S )Nr_  r   z\operatorname{Chi}^{ro   z\operatorname{Chi}%sr  r  s       rs   
_print_ChizLatexPrinter._print_Chi  s8     4;;tyy|#<<?36<<*S00ru   c                    d| j                  |j                  d         z  }| j                  |j                  d         }|d|d|d|S d|d|S )Nr_  rk  r   z\operatorname{E}_{rg  ro   r  )r   r  rH  r  nus        rs   _print_expintzLatexPrinter._print_expint  sW     4;;tyy|#<<[[1&?68#sCC  24S99ru   c                b    d| j                  |j                  d         z  }|d|d|S d|z  S )Nr_  r   zS^{ro   zS%sr  r  s       rs   _print_fresnelszLatexPrinter._print_fresnels
  7     4;;tyy|#<<?"%s++C<ru   c                b    d| j                  |j                  d         z  }|d|d|S d|z  S )Nr_  r   zC^{ro   zC%sr  r  s       rs   _print_fresnelczLatexPrinter._print_fresnelc  r  ru   c                n    d| j                  |j                  d   t        d         z  }|	d|d|dS |S )Nz!%sr   FuncrE  rF  ro   r  r@  r!   r  s       rs   _print_subfactorialz LatexPrinter._print_subfactorial  s;    t((1z&7IJJ?.1377Jru   c                l    d| j                  |j                  d   t        d         z  }||d|dS |S )Nz%s!r   r  r  ro   r  r  s       rs   _print_factorialzLatexPrinter._print_factorial"  s;    t((1z&7IJJ?!$c**Jru   c                l    d| j                  |j                  d   t        d         z  }||d|dS |S )Nz%s!!r   r  r  ro   r  r  s       rs   _print_factorial2zLatexPrinter._print_factorial2*  s;    ))$))A,
68JKK?!$c**Jru   c                    d| j                  |j                  d         d| j                  |j                  d         d}||d|dS |S )Nz{\binom{r   r  rk  r  r  ro   r  r  s       rs   _print_binomialzLatexPrinter._print_binomial2  sI    %)[[1%>%)[[1%>@ ?!$c**Jru   c                    |j                   \  }}d| j                  |t        d         z  }d|d| j                  |      d}| j	                  ||      S )Nr  r  r   	}^{\left(\right)}r@  r  r!   r  rI  )r   r  rH  nr2  rC  r  s          rs   _print_RisingFactorialz#LatexPrinter._print_RisingFactorial;  sP    yy1t((Jv,>??+/Q@  c**ru   c                    |j                   \  }}d| j                  |t        d         z  }d| j                  |      d|d}| j	                  ||      S )Nr  r  z{\left(z
\right)}_{ro   r  )r   r  rH  r  r2  subr  s          rs   _print_FallingFactorialz$LatexPrinter._print_FallingFactorialC  sP    yy1d'':f+=>>+/;;q>3?  c**ru   c                    d|z  }d}||j                  d      dk(  r	|d|d}nd}|d| j                  |j                        d	| j                  |j                        d
}|r| j	                  ||      }|S )Nr  Fr   rj  r  ro   Trf  }\left(rn  )ry  r  r   argumentrI  )r   r  rH  symr  need_exps         rs   _hprint_BesselBasezLatexPrinter._hprint_BesselBaseK  sz    sm?xx}"$'-+.DJJ0G+/;;t}}+EG ##C-C
ru   c                    |syd}|d d D ]  }|d| j                  |      z  z  } || j                  |d         z  }|S )Nr   rj  z%s, rR  )r   r   rr   r   s       rs   _hprint_veczLatexPrinter._hprint_vec\  sU    Sb 	)A$++a.((A	)	T[[R!!ru   c                (    | j                  ||d      S )NJr'  rG  s      rs   _print_besseljzLatexPrinter._print_besselje      &&tS#66ru   c                (    | j                  ||d      S )Nr  r,  rG  s      rs   _print_besselizLatexPrinter._print_besselih  r.  ru   c                (    | j                  ||d      S )NKr,  rG  s      rs   _print_besselkzLatexPrinter._print_besselkk  r.  ru   c                (    | j                  ||d      S )NYr,  rG  s      rs   _print_besselyzLatexPrinter._print_besselyn  r.  ru   c                (    | j                  ||d      S )Nr  r,  rG  s      rs   	_print_ynzLatexPrinter._print_ynq  r.  ru   c                (    | j                  ||d      S )Nr   r,  rG  s      rs   	_print_jnzLatexPrinter._print_jnt  r.  ru   c                (    | j                  ||d      S )NzH^{(1)}r,  rG  s      rs   _print_hankel1zLatexPrinter._print_hankel1w      &&tS)<<ru   c                (    | j                  ||d      S )NzH^{(2)}r,  rG  s      rs   _print_hankel2zLatexPrinter._print_hankel2z  r=  ru   c                (    | j                  ||d      S )Nzh^{(1)}r,  rG  s      rs   
_print_hn1zLatexPrinter._print_hn1}  r=  ru   c                (    | j                  ||d      S )Nzh^{(2)}r,  rG  s      rs   
_print_hn2zLatexPrinter._print_hn2  r=  ru   c                h    d| j                  |j                  d         z  }|
|d|d|S ||S r  r  r   r  rH  notationr  s        rs   _hprint_airyzLatexPrinter._hprint_airy  s:     4;;tyy|#<<?#+S#66&,,ru   c                l    d| j                  |j                  d         z  }|d|d|d|S |d|S )Nr_  r   r   z
^\prime}^{ro   z^\primer  rE  s        rs   _hprint_airy_primezLatexPrinter._hprint_airy_prime  s:     4;;tyy|#<<?,4c3??%-s33ru   c                (    | j                  ||d      S NAirG  rG  s      rs   _print_airyaizLatexPrinter._print_airyai        sD11ru   c                (    | j                  ||d      S NBirM  rG  s      rs   _print_airybizLatexPrinter._print_airybi  rO  ru   c                (    | j                  ||d      S rK  rI  rG  s      rs   _print_airyaiprimezLatexPrinter._print_airyaiprime      &&tS$77ru   c                (    | j                  ||d      S rQ  rU  rG  s      rs   _print_airybiprimezLatexPrinter._print_airybiprime  rW  ru   c                ^   d| j                  t        |j                              d| j                  t        |j                              d| j	                  |j                        d| j	                  |j                        d| j                  |j
                        d}|	d|d|d	}|S )
Nz{{}_{z}F_{}\left(\begin{matrix} r~  z \end{matrix}\middle| {
} \right)}r   rg  ro   )r  r  apbqr)  r$  r  s       rs   _print_hyperzLatexPrinter._print_hyper  s{     [[TWW&CL(Atww')9)9$'')Bkk$--(	* ?"%s+C
ru   c                b   d| j                  t        |j                              d| j                  t        |j                              d| j                  t        |j                              d| j                  t        |j
                              d| j                  |j
                        d| j                  |j                        d| j                  |j                        d| j                  |j                        d| j                  |j                        d}|	d	|d|d
}|S )Nz{G_{rK  rg  r[  r}   \\z \end{matrix} \middle| {r\  r   ro   )
r  r  r]  r^  r   anr)  aotherbotherr$  r  s       rs   _print_meijergzLatexPrinter._print_meijerg  s     [[TWW&CL(Akk#dgg,'S\)Btww')9)9$++)Ftww')9)9$++)Fkk$--(* ?"%s+C
ru   c                b    d| j                  |j                  d         z  }|d|d|S d|z  S )Nr_  r   z\eta^{ro   z\eta%sr  r  s       rs   _print_dirichlet_etaz!LatexPrinter._print_dirichlet_eta  s7     4;;tyy|#<<?%(#..3ru   c                    t        |j                        dk(  r-dt        t        | j                  |j                              z  }n!d| j	                  |j                  d         z  }|d|d|S d|z  S )Nr  z\left(%s, %s\right)r_  r   z\zeta^{ro   z\zeta%sr  r@  r  r9  r  r  s       rs   _print_zetazLatexPrinter._print_zeta  sf    tyy>Q(5T[[$))1L+MMC$t{{499Q<'@@C?&)3//Cru   c                    t        |j                        dk(  r-dt        t        | j                  |j                              z  }n!d| j	                  |j                  d         z  }|	d|d|dS d|z  S )	Nr  z_{%s}\left(%s\right)r8  r   r  r  ro   r   ri  r  s       rs   _print_stieltjeszLatexPrinter._print_stieltjes  sf    tyy>Q)E#dkk4992M,NNCT[[166C?'*C00S  ru   c                x    dt        t        | j                  |j                              z  }|d|z  S d|d|S )Nz\left(%s, %s, %s\right)z\Phi%sz\Phi^{ro   )r  r9  r  r@  r  s       rs   _print_lerchphizLatexPrinter._print_lerchphi  s?    (5T[[$))1L+MM;s?" !$c**ru   c                |    t        | j                  |j                        \  }}d|z  }|d|d|S d|d|d|S )Nr_  z\operatorname{Li}_{ro   rg  r9  r  r@  )r   r  rH  rr   rr  r  s         rs   _print_polylogzLatexPrinter._print_polylog  sF    4;;		*1 1$;23S99 34c3??ru   c           	         t        | j                  |j                        \  }}}}d|d|d|d|d	}|d|z   d|z  z   }|S )NP_{r  rl  \right)}\left(rn  rE  \right)^{%s}rp  )r   r  rH  r  r  r  r-  r  s           rs   _print_jacobizLatexPrinter._print_jacobi  sI    dii0
1a?@!QJ?c/Os$;;C
ru   c                    t        | j                  |j                        \  }}}d|d|d|d}|d|z   d|z  z   }|S )NzC_{r  rt  rn  rE  ru  rp  r   r  rH  r  r  r-  r  s          rs   _print_gegenbauerzLatexPrinter._print_gegenbauer  E    dkk499-1a<=q!D?c/Os$;;C
ru   c                x    t        | j                  |j                        \  }}d|d|d}|d|z   d|z  z   }|S )NzT_{r#  rn  rE  ru  rp  r   r  rH  r  r-  r  s         rs   _print_chebyshevtzLatexPrinter._print_chebyshevt  A    4;;		*1*+Q/?c/Os$;;C
ru   c                x    t        | j                  |j                        \  }}d|d|d}|d|z   d|z  z   }|S )NzU_{r#  rn  rE  ru  rp  r|  s         rs   _print_chebyshevuzLatexPrinter._print_chebyshevu  r~  ru   c                x    t        | j                  |j                        \  }}d|d|d}|d|z   d|z  z   }|S )Nrs  r#  rn  rE  ru  rp  r|  s         rs   _print_legendrezLatexPrinter._print_legendre  r~  ru   c                    t        | j                  |j                        \  }}}d|d|d|d}|d|z   d|z  z   }|S )Nrs  r  rt  rn  rE  ru  rp  rx  s          rs   _print_assoc_legendrez"LatexPrinter._print_assoc_legendre  rz  ru   c                x    t        | j                  |j                        \  }}d|d|d}|d|z   d|z  z   }|S )NzH_{r#  rn  rE  ru  rp  r|  s         rs   _print_hermitezLatexPrinter._print_hermite  r~  ru   c                x    t        | j                  |j                        \  }}d|d|d}|d|z   d|z  z   }|S )NL_{r#  rn  rE  ru  rp  r|  s         rs   _print_laguerrezLatexPrinter._print_laguerre  r~  ru   c                    t        | j                  |j                        \  }}}d|d|d|d}|d|z   d|z  z   }|S )Nr  r  rt  rn  rE  ru  rp  rx  s          rs   _print_assoc_laguerrez"LatexPrinter._print_assoc_laguerre  rz  ru   c           	         t        | j                  |j                        \  }}}}d|d|d|d|d	}|d|z   d|z  z   }|S )NzY_{rg  r#  rl  rn  rE  ru  rp  r   r  rH  r  mthetaphir  s           rs   
_print_YnmzLatexPrinter._print_Ynm  J    t{{DII61eS23QsC?c/Os$;;C
ru   c           	         t        | j                  |j                        \  }}}}d|d|d|d|d	}|d|z   d|z  z   }|S )NzZ_{rg  r#  rl  rn  rE  ru  rp  r  s           rs   
_print_ZnmzLatexPrinter._print_Znm"  r  ru   c           
     x    t        | j                  |      \  }}}|rdnd}|sdnd|z  }||d|d|d|d|
S )Nz	^{\prime}r   rh  rE  rK  rn  )r9  r  )	r   	characterr@  r   rH  r  r  rr  sups	            rs   __print_mathieu_functionsz&LatexPrinter.__print_mathieu_functions)  sA    dkk4(1a#lb33<c1aCPPru   c                >    | j                  d|j                  |      S )NCr  &_LatexPrinter__print_mathieu_functionsr@  rG  s      rs   _print_mathieuczLatexPrinter._print_mathieuc/      --c499#-FFru   c                >    | j                  d|j                  |      S )Nr   r  r  rG  s      rs   _print_mathieuszLatexPrinter._print_mathieus2  r  ru   c                @    | j                  d|j                  d|      S )Nr  Tr   rH  r  rG  s      rs   _print_mathieucprimez!LatexPrinter._print_mathieucprime5       --c499Dc-RRru   c                @    | j                  d|j                  d|      S )Nr   Tr  r  rG  s      rs   _print_mathieusprimez!LatexPrinter._print_mathieusprime8  r  ru   c                    |j                   dk7  rUd}|j                  }|j                  dk  rd}| }| j                  d   rd|||j                   fz  S d|||j                   fz  S | j                  |j                        S )Nrk  r   r   r  r   z	%s%d / %dz%s\frac{%d}{%d})r  r  r   r  )r   r  signr  s       rs   _print_RationalzLatexPrinter._print_Rational;  s~    66Q;DAvvzB~~/0#tQ&777%q$&&(999;;tvv&&ru   c                V   | j                  |j                        }|j                  rt        d |j                  D              st	        |j
                        dkD  r|dz  }t	        |j
                        dkD  r|| j                  |j
                        z  }n-|j
                  r!|| j                  |j
                  d         z  }|dz  }t	        |j                        dkD  r#|| j                  |j                        z  }d|z  S || j                  |j                  d         z  }d|z  S )Nc              3  B   K   | ]  }|t         j                  k7    y wr  )r   rB  )r,  r  s     rs   r.  z,LatexPrinter._print_Order.<locals>.<genexpr>J  s     >aa166k>s   rk  r  r   \rightarrow zO\left(%s\right))r  r  pointr8  r  	variables)r   r  rr   s      rs   _print_OrderzLatexPrinter._print_OrderH  s    KK		"::#>4::>>t~~"IA4>>"Q&T[[00T[[!233 A4::"T[[,, #Q&& T[[A//"Q&&ru   c                    | j                   d   j                  |      }||S | j                  |j                  |      S )Nr   style)r   r   rL  rP  )r   r  r  rP  s       rs   _print_SymbolzLatexPrinter._print_SymbolX  s@    NN>266t<K((%(@@ru   c                T   d|v r|g g }}}nJt        |      \  }}}t        |      }|D cg c]  }t        |       }}|D cg c]  }t        |       }}|dk(  rdj                  |      }|r|ddj                  |      z  z  }|r|ddj                  |      z  z  }|S c c}w c c}w )Nr   r   \mathbf{{{}}}rh  r   r8  )r   	translater   rO  )r   stringr  rP  supersrZ  r  r   s           rs   rL  z!LatexPrinter._deal_with_super_suba  s    &=!'R$&D!0!8D&$T?D067in7F7.23sIcN3D3 F?#**40D Gchhv...DGchhtn,,D 83s   B B%c                    | j                   d   rd}d}nd}d}d||ddd	d
}| j                  |j                        d||j                     d| j                  |j                        S )Nr   z\gtz\lt><rW  z\geqz\leqz\neq)z==r  r  z>=z<=z!=r   )r   r  lhsrel_oprhs)r   r  gtltcharmaps        rs   _print_RelationalzLatexPrinter._print_Relationalw  sv    >>&!BBBB 
 "[[2$T[[14;;txx3HJ 	Jru   c           	     <   |j                   d d D cg c]*  \  }}| j                  |      d| j                  |      , }}}|j                   d   j                  t        k(  r;|j	                  d| j                  |j                   d   j
                        z         nb|j	                  | j                  |j                   d   j
                        d| j                  |j                   d   j                               d}|dj                  |      z  S c c}}w )Nrj  z & \text{for}\: z%s & \text{otherwise}z\begin{cases} %s \end{cases}ra  )r@  r  condr   r-  r  rO  )r   r  rW  r   ecpairsr  s         rs   _print_PiecewisezLatexPrinter._print_Piecewise  s    #yy"~/q! /3kk!ndkk!nM / /99R=%NN3;;tyy}'9'9:; < NN KK		"(:(:; KK		"(:(:;= > .V[[)))/s   /Dc                   g }t        |j                        D ]F  }|j                  dj                  ||d d f   D cg c]  }| j	                  |       c}             H | j
                  d   }|+| j
                  d   dk(  rd}n|j                  dk  du rd}nd	}d
}|j                  d|      }|d	k(  r%|j                  ddd|j                  z  z   dz         }|dj                  |      z  S c c}w )Nr}  r   r   r   smallmatrix
   Tmatrixarray \begin{%MATSTR%}%s\end{%MATSTR%}%MATSTR%r  r   r   }%sr  )r  rowsr-  rO  r  r   colsr   )r   r  linesliner   r   out_strs          rs   _print_matrix_contentsz#LatexPrinter._print_matrix_contents  s    $))$ 	NDLLT$']$KT[[^$KLM	N ..+?~~f%1'IIO,&G%G5//*g6goodC#dii-,?%,GHGE***! %Ls   C/c                    | j                  |      }| j                  d   r,| j                  d   }| j                  |   }d|z   |z   dz   |z   }|S )Nr   \left\right)r  r   r   )r   r  r  
left_delimright_delims        rs   _print_MatrixBasezLatexPrinter._print_MatrixBase  s`    --d3>>+&4J**:6K+g5 "-.Gru   c                    | j                  |j                  t        d   d      }| j                  |j                         d| j                  |j
                         }d| d| dS )Nr  Tr  rl  r   }_{ro   )r  parentr!   r  r   r   )r   r  matrix_part
index_parts       rs   _print_MatrixElementz!LatexPrinter._print_MatrixElement  sd    ''Z5GPT'UDFF+,Adkk$&&.A-BC
K=j\44ru   c                
     fd} j                  |j                  t        d   d      dz    ||j                  |j                  j                        z   dz    ||j
                  |j                  j                        z   dz   S )Nc                    t        |       } | d   dk(  r| d= | d   dk(  rd | d<   | d   |k(  rd | d<   dj                  fd| D              S )Nr  rk  r   :c              3  H   K   | ]  }|j                  |      nd  y wNr   rR  )r,  xir   s     rs   r.  zFLatexPrinter._print_MatrixSlice.<locals>.latexslice.<locals>.<genexpr>  s"     R"r~DKKO2ERs   ")r  rO  )r-  rM  r   s     rs   
latexslicez3LatexPrinter._print_MatrixSlice.<locals>.latexslice  s\    QAtqyaDtqy!ts{!88RPQRRRru   r  Tr  \left[rK  \right])r  r  r!   rowslicer  colslicer  )r   r  r  s   `  rs   _print_MatrixSlicezLatexPrinter._print_MatrixSlice  s    	S !!$++z&/A$!OR[[4==$++*:*:;<>BC4==$++*:*:;<>HI 	Jru   c                8    | j                  |j                        S r  )r  blocksr  s     rs   _print_BlockMatrixzLatexPrinter._print_BlockMatrix  s    {{4;;''ru   c                    |j                   }ddlm}m} t	        ||      s,t	        ||      s |j
                  rd| j                  |      z  S | j                  |t        |      d      }d|v rd|z  S d|z  S )Nr   MatrixSymbolBlockMatrixz\left(%s\right)^{T}Tr   z%s^{T})	r<   sympy.matricesr  r  r  is_MatrixExprr  r  r   )r   r  r  r  r  rr   s         rs   _print_TransposezLatexPrinter._print_Transpose  st    hh<3-3,1B1B)DKK,<<<!!#'=d'CTJAax-11!|#ru   c                B    |j                   }d| j                  |      z  S )Nz!\operatorname{tr}\left(%s \right))r<   r  r   r  r  s      rs   _print_TracezLatexPrinter._print_Trace  s    hh3dkk#6FFFru   c                N   dddd}|j                  | j                  d   d      }|j                  }ddlm}m} t        ||      s0t        ||      s$|j                  rd| j                  |      d	|d
S | j                  |t        |      d      }d|v r	d|d	|d
S |d|d
S )Nz\daggerz\astz
\mathsf{H})r   star	hermitianr   r   r  rE  rF  ro   Tr   r  )r   r   r<   r  r  r  r  r  r  r  r   )r   r  style_to_latexr   r  r  r  rr   s           rs   _print_AdjointzLatexPrinter._print_Adjoint  s    # &

 '**4>>/+JJWhh<3-3,1B1B.2kk#.>NN!!#'=d'CTJAax23]CC%&66ru   c                    ddl m  fd}t        j                        }j	                         r5|d   dk(  r|dd  }n	|d    |d<   ddj                  t        ||            z   S dj                  t        ||            S )Nr   )MatMulc                    t        | t              rt        |       sj                  |       S j                  | t	              d      S NF)r  r
   r  r  r   )r-  r  r  r   s    rs   rt   z,LatexPrinter._print_MatMul.<locals>.<lambda>  s@    Z3-?
STV\H]4;;q> a!7!=uE ru   rj  rk  r  r   )sympyr  r  r@  r5  rO  r9  )r   r  parensr@  r  s   ``  @rs   _print_MatMulzLatexPrinter._print_MatMul  s     F DII((*Aw"}ABx7(Q#((3vt#455588C-..ru   c                    |j                   }|j                  rDddlm} t	        ||      rd| j                  |j                        z  S d| j                  |      z  S d| j                  |      z  S )Nr   )r  r  )r<   r  &sympy.matrices.expressions.blockmatrixr  r  r  r  r  )r   r  r  r  s       rs   _print_DeterminantzLatexPrinter._print_Determinant  se    hhJ#{++d.I.I#**.UUU'$++c*:::#d&A&A#&FFFru   c                \   |Xd| j                  |j                  d   t        d   d      d| j                  |j                  d   t        d   d      d|d	S | j                  |j                  d   t        d   d      d| j                  |j                  d   t        d   d      S )
NrE  r   r
   Tr  z \bmod rk  rF  ro   r  rG  s      rs   
_print_ModzLatexPrinter._print_Mod  s    ?""499Q<E1B*. # 0""499Q<E1B*. # 0  "&!2!2499Q<3=e3D:> "3 "@ "&!2!2499Q<3=e3D:> "3 "@A 	Aru   c                ~    |j                   }t        d   | j                  dj                  fd|D              S )Nr   z \circ c              3  4   K   | ]  } |d         ywTr  Nrp   r,  r<   r  precs     rs   r.  z6LatexPrinter._print_HadamardProduct.<locals>.<genexpr>!       <VCd++<   r@  r!   r  rO  r   r  r@  r  r  s      @@rs   _print_HadamardProductz#LatexPrinter._print_HadamardProduct  s:    yy% ""<t<> 	>ru   c                n    t        |j                        t        d   k  rd}nd}| j                  ||      S )Nr
   z%s^{\circ \left({%s}\right)}z%s^{\circ {%s}})r   rH  r!   r  )r   r  r  s      rs   _print_HadamardPowerz!LatexPrinter._print_HadamardPower#  s5    !$((+j.??6H)H00x@@ru   c                ~    |j                   }t        d   | j                  dj                  fd|D              S )Nr   	 \otimes c              3  4   K   | ]  } |d         ywr  rp   r  s     rs   r.  z7LatexPrinter._print_KroneckerProduct.<locals>.<genexpr>0  r  r  r  r  s      @@rs   _print_KroneckerProductz$LatexPrinter._print_KroneckerProduct*  s<    yy% ""  <t<> 	>ru   c                D   |j                   |j                  }}ddlm} t	        ||      s3|j
                  r'd| j                  |      d| j                  |      dS | j                  |      }d|v rd|d| j                  |      dS |d| j                  |      dS )Nr   )r  rE  rF  ro   r   r  )rC  rH  r  r  r  r  r  )r   r  rC  rH  r  base_strs         rs   _print_MatPowzLatexPrinter._print_MatPow2  s    IItxxc/$-$2D2D/3{{4/@.2kk#.>@ @ {{4(Hh2:DKK<LMM$,dkk#.>??ru   c                B    | j                  || j                  d         S )Nr   r  )r  r   r  s     rs   _print_MatrixSymbolz LatexPrinter._print_MatrixSymbol?  s(    !!$dnn/ ! ! 	!ru   c                .    | j                   d   dk(  rdS dS )Nr   r   0z
\mathbf{0}r   )r   Zs     rs   _print_ZeroMatrixzLatexPrinter._print_ZeroMatrixC  (    nn #*+s 	>0=	>ru   c                .    | j                   d   dk(  rdS dS )Nr   r   1z
\mathbf{1}r#  )r   Os     rs   _print_OneMatrixzLatexPrinter._print_OneMatrixG  r&  ru   c                .    | j                   d   dk(  rdS dS )Nr   r   z
\mathbb{I}z
\mathbf{I}r#  )r   r  s     rs   _print_IdentityzLatexPrinter._print_IdentityK  s(     $! #*!+} 	>0=	>ru   c                H    | j                  |j                  d         }d|z  S )Nr   zP_{%s}r  )r   Pperm_strs      rs   _print_PermutationMatrixz%LatexPrinter._print_PermutationMatrixO  s#    ;;qvvay)(""ru   c           
     >   |j                         dk(  r| j                  |d         S | j                  d   }|?| j                  d   dk(  rd}n*|j                         dk(  s|j                  d   dk  rd	}nd
}d}|j	                  d|      }|d
k(  r(|j	                  ddd|j                  d   z  z   dz         }| j                  d   r,| j                  d   }| j
                  |   }d|z   |z   dz   |z   }|j                         dk(  r|dz  S t        |j                         dz         D cg c]  }g  }}|j                  D cg c]  }t        t        |             }}t        j                  | D ]  }	|d   j                  | j                  ||	                d}
t        |j                         dz
  dd      D ]  }t        ||dz            |j                  |   k  r o|
r*||   j                  dj                  ||dz                   nT||   j                  |dj                  ||dz            z         t        ||dz            dk(  rd||   d   z   dz   ||   d<   |
 }
g ||dz   <     |d   d   }|j                         dz  dk(  r||z  }|S c c}w c c}w )Nr   rp   r   r   r   r  rj  r  r  r  r  r  r  r   r   r  r   r  r  r   rk  Tr}  r  r  r  r  )rankr  r   shaper   r   r  r  	itertoolsproductr-  r  rO  )r   r  r   	block_strr  r  r   	level_strshape_rangesouter_ievenback_outer_ir  s                rs   _print_NDimArrayzLatexPrinter._print_NDimArrayS  s   99;!;;tBx((..+?~~f%1'IIK1$$**R.B*>&G%G7	%%j':	g!))$c$**Q-6G0G%0OPI>>+&"nn[9J**:6K :-	9!"$/0I 99;!r>!27		a2H%IQb%I	%I04

;1U1X;; ((,7 	/GbM  T']!;<D %diik!mR < /ya01DJJ|4LLl+22Il1n$=>@ l+22!UZZ	,q.0I%JKM9\!^45:6?%l3B778:D7E	,/3x,.	,q.)/	/$ A,q/99;?a')G3 &J;s   *	JJc                Z   | j                  |      }d }d }|D ]  }|j                  }||v s|r
||k(  r|dz  }||k7  r||dz  }|j                  r|dz  }n|dz  }|| j                  |j                  d         z  }||v r|dz  }|| j                  ||         z  }d}nd}|} ||dz  }|S )	Nrl  ro   z{}^{z{}_{r   rW  TF)r  is_upr@  )	r   rP  r:  	index_mapr  last_valenceprev_mapindexnew_valences	            rs   _printer_tensor_indicesz$LatexPrinter._printer_tensor_indices  s    ++d# 	'E++K)# K/3{*+sNG;;v%Gv%Gt{{5::a=11G	!34;;y'788 &L'	'( #sNGru   c                    |j                   d   j                   d   }|j                         }| j                  ||i       S r  )r@  get_indicesrD  )r   r  rP  r:  s       rs   _print_TensorzLatexPrinter._print_Tensor  s=    yy|  #""$++D'2>>ru   c                    |j                   j                  d   j                  d   }|j                   j                         }|j                  }| j	                  |||      S r  )r  r@  rF  r?  rD  )r   r  rP  r:  r?  s        rs   _print_TensorElementz!LatexPrinter._print_TensorElement  sO    yy~~a %%a())'')NN	++D'9EEru   c                    |j                         \  }}|dj                  |D cg c]  }| j                  |t        |             c}      z   S c c}w r  )!_get_args_for_traditional_printerrO  r  r    )r   r  r  r@  r<   s        rs   _print_TensMulzLatexPrinter._print_TensMul  sO    ;;=
dbggAEF#TsJt$45F
 
 	
Fs   "A
c           	         g }|j                   }|D ],  }|j                  | j                  |t        |                   . |j	                          dj                  |      }|j                  dd      }|S )Nr^  z+ -r  )r@  r-  r  r    r,  rO  r   )r   r  r  r@  r-  rr   s         rs   _print_TensAddzLatexPrinter._print_TensAdd  sh    yy 	=AHHT&&q*T*:;<	=	JJqMIIeT"ru   c                h    d|j                   rdndd| j                  |j                  d         dS )Nz{}r   rw  r   r   ro   )r>  r  r@  r  s     rs   _print_TensorIndexzLatexPrinter._print_TensorIndex  s.    ::C3&KK		!%
 	
ru   c                   t        |j                        dk(  rGd| j                  |j                  d         d| j                  |j                  t
        d   d      dS dt        |j                        dd	j                  |j                  D cg c]  }d
| j                  |      z   c}      d| j                  |j                  t
        d   d      dS c c}w )Nrk  z\frac{\partial}{\partial {r   rE  r
   Fro   z\frac{\partial^{r   z\partial {%s}r  )r  r  r  r  r  r!   rO  r   r  r   s      rs   _print_PartialDerivativez%LatexPrinter._print_PartialDerivative  s    t~~!#DNN1-.!!$))Z->F  $ DNN#T^^T*T[[^;TU!!$))Z->F Ts   Cc                8    | j                  |j                        S r  )r  rP  r  s     rs   _print_ArraySymbolzLatexPrinter._print_ArraySymbol  s    {{499%%ru   c                    d| j                  |j                  t        d   d      ddj                  |j                  D cg c]  }| j                  |        c}      dS c c}w )Nz{{r  Tr  rK  r  )r  rP  r!   rO  r:  r  rR  s      rs   _print_ArrayElementz LatexPrinter._print_ArrayElement  sU    diiF);TBIIDLLAq$++a.)*ABD 	DAs    A#c                     y)Nz
\mathbb{U}rp   r  s     rs   _print_UniversalSetz LatexPrinter._print_UniversalSet      ru   c                    |!d| j                  |j                  d         z  S d| j                  |j                  d         d|dS )Nz$\operatorname{frac}{\left(%s\right)}r   z\operatorname{frac}{\left(z
\right)}^{ro   r  rG  s      rs   _print_fraczLatexPrinter._print_frac  sK    ;:T[[ST=VVV  KK		!-s4 4ru   c           
     ^   | j                   d   dk(  rd}n | j                   d   dk(  rd}nt        d      t        |      dk(  r&| j                  | j	                  |d         |z         S | j                  |d	z   j                  |D cg c]  }| j	                  |       c}            S c c}w )
Nr   r  ;r   rl  Unknown Decimal Separatorrk  r   z \  )r   r   r  r  r  rO  )r   r  sepr   s       rs   _print_tuplezLatexPrinter._print_tuple  s    >>-.'9C^^/0H<C899t9>**4;;tAw+?#+EFF**w$$d%Cdkk!n%CDF F%Cs   B*c                ~    |j                   D cg c]  }| j                  |       }}dj                  |      S c c}w )Nr  r@  r  rO  r   r  r  elementss       rs   _print_TensorProductz!LatexPrinter._print_TensorProduct  s7    ,0II6qDKKN66  ** 7   :c                ~    |j                   D cg c]  }| j                  |       }}dj                  |      S c c}w )N \wedge rc  rd  s       rs   _print_WedgeProductz LatexPrinter._print_WedgeProduct  s7    ,0II6qDKKN66)) 7rg  c                $    | j                  |      S r  )ra  r  s     rs   _print_TuplezLatexPrinter._print_Tuple  s      &&ru   c           	     8   | j                   d   dk(  r1ddj                  |D cg c]  }| j                  |       c}      z  S | j                   d   dk(  r1ddj                  |D cg c]  }| j                  |       c}      z  S t        d      c c}w c c}w )Nr   r  z\left[ %s\right]z; \  r   , \  r_  )r   rO  r  r   rR  s      rs   _print_listzLatexPrinter._print_list  s    >>-.'9&t<!t{{1~<=> >^^/0H<&t<!t{{1~<=> > 899 = =s   B
&B
c                    t        |j                         t              }g }|D ];  }||   }|j                  | j	                  |      d| j	                  |             = ddj                  |      z  S )Nr"  z : z\left\{ %s\right\}rn  )r  keysr   r-  r  rO  )r   r   rq  r*  r#  vals         rs   _print_dictzLatexPrinter._print_dict  sm    affh$45 	KCC&CLLdkk#&6C8HIJ	K %x}}U';;;ru   c                $    | j                  |      S r  )rs  r  s     rs   _print_DictzLatexPrinter._print_Dict  s    %%ru   c                6   t        |j                        dk(  s|j                  d   dk(  r"d| j                  |j                  d         z  }nAd| j                  |j                  d         d| j                  |j                  d         d}|r	d|d|d	}|S )
Nrk  r   z\delta\left(%s\right)z\delta^{\left( z \right)}\left( r  rE  rF  ro   r  r  s       rs   _print_DiracDeltazLatexPrinter._print_DiracDelta  s    tyy>Q$))A,!"3*T[[1-FFC #4 DIIaL)4;;tyy|+DFC-0#6C
ru   c                    | j                  |j                  d   |j                  d   z
        }| j                  |j                  d         }d|d|d}|d|d|d	|d}|S )
Nr   rk  r  z{\left\langle z \right\rangle}^{ro   z{\left({\langle z \rangle}^{z}\right)}^{r  )r   r  rH  shiftr  r  s         rs   _print_SingularityFunctionz'LatexPrinter._print_SingularityFunction#  s\    DIIaL499Q<78DIIaL)9>F?FKUTWXC
ru   c                p     dj                   fd|j                  D              }d|z  }|r	d|d|d}|S )NrK  c              3  @   K   | ]  }j                  |        y wr  rR  r,  r<   r   s     rs   r.  z0LatexPrinter._print_Heaviside.<locals>.<genexpr>,  s     As$++c*Ar0  z\theta\left(%s\right)rE  rF  ro   )rO  pargs)r   r  rH  r~  r  s   `    rs   _print_HeavisidezLatexPrinter._print_Heaviside+  s7    		AdjjAA&.-0#6C
ru   c                   | j                  |j                  d         }| j                  |j                  d         }|j                  d   j                  r#|j                  d   j                  r
d|d|d}n	d|d|d}|	d|d|d}|S )	Nr   rk  z\delta_{r   ro   rK  rE  rF  )r  r@  r  )r   r  rH  r   r   r  s         rs   _print_KroneckerDeltaz"LatexPrinter._print_KroneckerDelta2  sx    KK		!%KK		!%99Q<DIIaL$8$8'(!,C()1-C?-0#6C
ru   c                    t        | j                  |j                        }t        d |j                  D              rddj	                  |      z  }nddj	                  |      z  }|r	d|d|d}|S )Nc              3  4   K   | ]  }|j                     y wr  )r  )r,  r-  s     rs   r.  z1LatexPrinter._print_LeviCivita.<locals>.<genexpr>?  s     ,Qqyy,s   z\varepsilon_{%s}r   rK  rE  rF  ro   )r9  r  r@  rj  rO  )r   r  rH  r:  r  s        rs   _print_LeviCivitazLatexPrinter._print_LeviCivita=  s`    dkk499-,$)),,%(99C%		'(::C-0#6C
ru   c                f   t        |d      r"d| j                  |j                               z   S t        |d      r=d| j                  |j                        z   dz   | j                  |j                        z   S t        |d      rd| j                  |j                        z   S | j                  d       S )N
as_booleanz\text{Domain: }set \in rl  z\text{Domain on })r  r  r  rl  r  )r   r   s     rs   _print_RandomDomainz LatexPrinter._print_RandomDomainG  s    1l#%ALLN(CCCQ&QYY)??(JKK&' (Q	"'$++aii*@@@;;t$$ru   c                Z    t        |j                  t              }| j                  |      S )Nr"  )r  r@  r   
_print_setr   rr   r*  s      rs   _print_FiniteSetzLatexPrinter._print_FiniteSetR  s"    qvv#34u%%ru   c                *   t        |t              }| j                  d   dk(  r*dj                  t	        | j
                  |            }d|z  S | j                  d   dk(  r*dj                  t	        | j
                  |            }d|z  S t        d      )	Nr"  r   r  r  r   rK  r_  \left\{%s\right\})r  r   r   rO  r9  r  r   r  s      rs   r  zLatexPrinter._print_setV  s    q./>>-.'9IIc$++u56E
 $e++	 ^^/0H<IIc$++u56E $e++ 899ru   c                     fd}t               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}nkj                  Xj                  dk  dk(  rt              }nAj                  r't              }t        |      t        |      d   f}n |       S  |       S ddj                   fd	|D              z   d
z   S )Nc                    j                   d   dk(  rVj                   d   dk(  rj                  j                   d         } ndj                  fdj                   D              } n^j                   d   dk(  r(dj                  fdj                   d d D              } n$dj                  fdj                   D              } d|  d	S )
Nr   r  rk  rK  c              3  @   K   | ]  }j                  |        y wr  rR  r}  s     rs   r.  zKLatexPrinter._print_Range.<locals>._print_symbolic_range.<locals>.<genexpr>j       $H#T[[%5$Hr0  c              3  @   K   | ]  }j                  |        y wr  rR  r}  s     rs   r.  zKLatexPrinter._print_Range.<locals>._print_symbolic_range.<locals>.<genexpr>m  s     $L#T[[%5$Lr0  c              3  @   K   | ]  }j                  |        y wr  rR  r}  s     rs   r.  zKLatexPrinter._print_Range.<locals>._print_symbolic_range.<locals>.<genexpr>o  r  r0  z\text{Range}\left(rn  rc  )contrr   r   s    rs   _print_symbolic_rangez8LatexPrinter._print_Range.<locals>._print_symbolic_ranged  s    vvayA~66!9>;;qvvay1D99$H$HHD66!9>99$L$LLD99$H$HHD+D6:;ru   rj  r   rk  rb  T\left\{rK  c              3  L   K   | ]  }|urj                  |      nd   ywz\ldotsNrR  r,  eldotsr   s     rs   r.  z,LatexPrinter._print_Range.<locals>.<genexpr>  %     _PRbn4;;r?)K_   !$\right\})objectstartis_infinitestopstepis_positiveiternextis_emptyrp  r  is_iterablerO  )r   rr   r  printsetitr  s   ``   @rs   _print_RangezLatexPrinter._print_Rangec  s2   	< x77166#5#5vv!!Q4/Ar4/WW  QrUQVV^QrU2HVVaBBxb4/HZZ#
t# 8!W8T"XtQrU:,..(**

_V^__` 	ru   c           
        t        |j                        dk(  r|F|d| j                  |j                  d         d|d| j                  |j                  d         dS |d| j                  |j                  d         d| j                  |j                  d         dS |d| j                  |j                  d         d}||d	|d}|S )
Nr  rf  r   rg  r#  rk  rn  ro   r  r  )r   r  letterrH  r  s        rs   __print_number_polynomialz&LatexPrinter.__print_number_polynomial  s    tyy>Q9? KK		!5s KK		!57 7 17DIIaL14;;tyy|3LN N #DKK		!$=>? #S)C
ru   c                (    | j                  |d|      S NB&_LatexPrinter__print_number_polynomialrG  s      rs   _print_bernoullizLatexPrinter._print_bernoulli      --dC==ru   c                (    | j                  |d|      S )NGr  rG  s      rs   _print_genocchizLatexPrinter._print_genocchi  r  ru   c                Z    t        |j                        dk(  rd j                  |j                  d         d j                  |j                  d         d}ddj                   fd|j                  d	   D              z  }||d
|d|}|S ||z   }|S  j	                  |d|      S )Nr%  zB_{r   rK  rk  ro   r_  c              3  @   K   | ]  }j                  |        y wr  rR  )r,  r  r   s     rs   r.  z+LatexPrinter._print_bell.<locals>.<genexpr>  s#      3C/1 48;;r? 3Cr0  r  r  r  )r  r@  r  rO  r  )r   r  rH  tex1tex2r  s   `     rs   _print_bellzLatexPrinter._print_bell  s    tyy>Q$(KK		!$= $DIIaL 9;D%

 3C59YYq\3C )C CD&*C6 J TkJ--dC==ru   c                (    | j                  |d|      S NFr  rG  s      rs   _print_fibonaccizLatexPrinter._print_fibonacci  r  ru   c                \    d| j                  |j                  d         z  }||d|d}|S )NzL_{%s}r   r  ro   r  r  s       rs   _print_lucaszLatexPrinter._print_lucas  1    $++diil33? #S)C
ru   c                (    | j                  |d|      S )NTr  rG  s      rs   _print_tribonaccizLatexPrinter._print_tribonacci  r  ru   c                    |!d| j                  |j                  d         z  S d|d| j                  |j                  d         dS )Nz\mu\left(%s\right)r   z\mu^{r#  rn  r  rG  s      rs   _print_mobiuszLatexPrinter._print_mobius  sD    ;(4;;tyy|+DDD -0$++diil2KLLru   c           
     T    t               t        |j                  j                        dkD  s"t        |j                  j                        dkD  rvd j                  |j                        d j                  |j                  d         d j                  |j                        d j                  |j                        d	S |j                  t        j                  u rY|j                  }|j                  |dz
        |j                  |dz
        |j                  |d	z
        |j                  |      f}nM|j                  t        j                  u s|j                  d
kD  r|d d
 }|j                         nt        |      }ddj                   fd|D              z   dz   S )Nr   r  z
\right\}_{rW  rg  ro   r%  r  rk  rb  r  rK  c              3  L   K   | ]  }|urj                  |      nd   ywr  rR  r  s     rs   r.  z1LatexPrinter._print_SeqFormula.<locals>.<genexpr>  r  r  r  )r  r  r  free_symbolsr  r  formular  r   rq  coeffrp  lengthr-  r  rO  )r   rr   r  r  r  s   `   @rs   _print_SeqFormulazLatexPrinter._print_SeqFormula  sH   xqww##$q(C0C0C,Dq,HAII&AKKN+AGG$AFF#	  77a(((66DaggdQh/1Bq)1774=:HVVqzz!QXX\!uHOOD!QxH

_V^__` 	ru   c                2   |j                   |j                  k(  rd| j                  |j                         z  S |j                  rd}nd}|j                  rd}nd}d|| j                  |j                         d| j                  |j                        d|S )	Nr  r   r   r   r   r  rK  r  )r  endr  	left_open
right_open)r   r   leftrights       rs   _print_IntervalzLatexPrinter._print_Interval  s    77aee'$++agg*>>> {{|| $++agg.AEE0BEK Kru   c                x    d| j                  |j                        d| j                  |j                        dS )Nz\left\langle rK  z\right\rangle)r  r   r   r   r   s     rs   _print_AccumulationBoundsz&LatexPrinter._print_AccumulationBounds  s+    QUU#T[[%79 	9ru   c                    t        |      }|j                  D cg c]  }| j                  ||       }}dj                  |      S c c}w )Nz \cup r   r@  r  rO  r   ur  r   args_strs        rs   _print_UnionzLatexPrinter._print_Union  E    %a(89?1D%%a.??~~h'' @   Ac                    t        |      }|j                  D cg c]  }| j                  ||       }}dj                  |      S c c}w )Nz \setminus r  r  s        rs   _print_ComplementzLatexPrinter._print_Complement  G    %a(89?1D%%a.??""8,, @r  c                    t        |      }|j                  D cg c]  }| j                  ||       }}dj                  |      S c c}w )Nz \cap r  r  s        rs   _print_Intersectionz LatexPrinter._print_Intersection  r  r  c                    t        |      }|j                  D cg c]  }| j                  ||       }}dj                  |      S c c}w )Nz \triangle r  r  s        rs   _print_SymmetricDifferencez'LatexPrinter._print_SymmetricDifference  r  r  c                0    t        |      t        |j                        dk\  rMt        |j                        s8 j	                  |j                  d         dt        |j                        z  z   S dj                   fd|j                  D              S )Nrk  r   z^{%d}r   c              3  B   K   | ]  }j                  |        y wr  )r  )r,  r  r  r   s     rs   r.  z1LatexPrinter._print_ProductSet.<locals>.<genexpr>	  s#       <-0Dc4( <s   )r   r  setsr$   r  rO  )r   r  r  s   ` @rs   _print_ProductSetzLatexPrinter._print_ProductSet	  sy    %a(qvv;!K$7$$QVVAY5#aff+8MMM  <45FF < < 	<ru   c                     y)Nz	\emptysetrp   rV  s     rs   _print_EmptySetzLatexPrinter._print_EmptySet	  s    ru   c                     y)Nz
\mathbb{N}rp   r   r  s     rs   _print_NaturalszLatexPrinter._print_Naturals	  rZ  ru   c                     y)Nz\mathbb{N}_0rp   r  s     rs   _print_Naturals0zLatexPrinter._print_Naturals0	  s    ru   c                     yNz
\mathbb{Z}rp   r  s     rs   _print_IntegerszLatexPrinter._print_Integers	  rZ  ru   c                     yNz
\mathbb{Q}rp   r  s     rs   _print_RationalszLatexPrinter._print_Rationals	  rZ  ru   c                     yNz
\mathbb{R}rp   r  s     rs   _print_RealszLatexPrinter._print_Reals	  rZ  ru   c                     yNz
\mathbb{C}rp   r  s     rs   _print_ComplexeszLatexPrinter._print_Complexes	  rZ  ru   c                     |j                   j                  }|j                   j                  } fdt        ||j                        D        }dj                  d |D              }d j                  |      d|dS )Nc              3  h   K   | ])  \  }}j                  |      j                  |      f + y wr  rR  )r,  r-  r  r   s      rs   r.  z/LatexPrinter._print_ImageSet.<locals>.<genexpr>#	  s*     RDAqAA/Rs   /2rK  c              3  &   K   | ]	  }d |z    yw)	%s \in %sNrp   )r,  xys     rs   r.  z/LatexPrinter._print_ImageSet.<locals>.<genexpr>$	  s     ;<",;s   r  \; \middle|\; r  )rX   r  	signaturerY  	base_setsrO  r  )r   rr   r  sigxysxinyss   `     rs   _print_ImageSetzLatexPrinter._print_ImageSet 	  s\    ww||ggRCQ[[<QR

;s;;7;{{47H%PPru   c           
        dj                  t        |j                        D cg c]  }| j                  |       c}      }|j                  t
        j                  u r"d|d| j                  |j                        dS d|d|d| j                  |j                        d| j                  |j                        d	S c c}w )NrK  r  r  	 \right\}r  ri  )rO  r   r%  r  base_setr   UniversalSet	conditionr   rr   r  
vars_prints       rs   _print_ConditionSetz LatexPrinter._print_ConditionSet'	  s    YYE!%%LISC 0IJ
::'T[[57 7 (
 KK

#KK$	& 	&  Js   Cc                `    | j                  |j                  d         }dj                  |      S )Nr   z\mathcal{{P}}\left({}\right)r  r@  r   )r   r  	arg_prints      rs   _print_PowerSetzLatexPrinter._print_PowerSet3	  s)    KK		!-	.55i@@ru   c                    dj                  |j                  D cg c]  }| j                  |       c}      }d| j                  |j                        d|d| j                  |j                        dS c c}w )NrK  r  r  r  r  )rO  r  r  r  r  r  s       rs   _print_ComplexRegionz!LatexPrinter._print_ComplexRegion7	  s[    YYAKKHSC 0HI
KKKK! 	!  Is   A7c                F     dt         fd|j                  D              z  S )Nr  c              3  @   K   | ]  }j                  |        y wr  rR  )r,  r  r   s     rs   r.  z/LatexPrinter._print_Contains.<locals>.<genexpr>?	  s     #CqDKKN#Cr0  )r  r@  rV  s   ` rs   _print_ContainszLatexPrinter._print_Contains>	  s    e#CAFF#CCCCru   c                   |j                   j                  t        j                  u rA|j                  j                  t        j                  u r| j                  |j                        S | j                  |j                               dz   S )Nz	 + \ldots)	rb  r  r   rB  bnr  a0re  truncater  s     rs   _print_FourierSeriesz!LatexPrinter._print_FourierSeriesA	  sV    44<<166!addllaff&<;;qtt$$qzz|,|;;ru   c                8    | j                  |j                        S r  )re  infiniter  s     rs   _print_FormalPowerSeriesz%LatexPrinter._print_FormalPowerSeriesF	  s    qzz**ru   c                     d|j                   z  S )Nz\mathbb{F}_{%s})modr  s     rs   _print_FiniteFieldzLatexPrinter._print_FiniteFieldI	  s    !DHH,,ru   c                     yr  rp   r  s     rs   _print_IntegerRingzLatexPrinter._print_IntegerRingL	  rZ  ru   c                     yr  rp   r  s     rs   _print_RationalFieldz!LatexPrinter._print_RationalFieldO	  rZ  ru   c                     yr  rp   r  s     rs   _print_RealFieldzLatexPrinter._print_RealFieldR	  rZ  ru   c                     yr  rp   r  s     rs   _print_ComplexFieldz LatexPrinter._print_ComplexFieldU	  rZ  ru   c                    | j                  |j                        }dj                  t        | j                   |j                              }|d|dS )NrK  r  r  r  domainrO  r9  rl  r   r  r5  rl  s       rs   _print_PolynomialRingz"LatexPrinter._print_PolynomialRingX	  <    T[[)))CT\\:;'-w77ru   c                    | j                  |j                        }dj                  t        | j                   |j                              }|d|dS )NrK  rE  rn  r4  r6  s       rs   _print_FractionFieldz!LatexPrinter._print_FractionField]	  r8  ru   c                    | j                  |j                        }dj                  t        | j                   |j                              }d}|j
                  sd}||d|dS )NrK  r   zS_<^{-1}r  r  )r  r5  rO  r9  rl  is_Poly)r   r  r5  rl  invs        rs   _print_PolynomialRingBasez&LatexPrinter._print_PolynomialRingBaseb	  sO    T[[)))CT\\:;||C),fg>>ru   c           	     p   |j                   j                  }g }|j                         D ]P  \  }}d}t        |      D ]]  \  }}|dkD  s|dk(  r"|| j	                  |j
                  |         z  }3|| j	                  t        |j
                  |   |            z  }_ |j                  r)|rd| j	                  |      z  }	nq| j	                  |      }	n_|rL|t        j                  u r|j                  d|g       |t        j                  u r|j                  d|g       | j	                  |      }	|s|	}
n|	dz   |z   }
|
j                  d      r|j                  d|
dd  g       >|j                  d|
g       S |d   dv r!|j                  d      }|dk(  rd|d   z   |d<   dj                  |      }t        t!        | j                  |j
                              }d	| j	                  |j#                               z  }d
j                  |g|z   |gz         }|t$        v rd|d|d}|S d|d|d}|S )Nr   r   rk  r_  r  r$  r   )r$  r  z	domain=%srK  r    {\left(z	 \right)}rx  z	}{\left( )rM  rN  rb  ra  r  genspowr!  r   r  extendr  r  poprO  r  r9  
get_domainrz  )r   polyr  rb  monomr  s_monomr   rH  s_coeffs_termmodifierr  rA  r5  r@  r  s                    rs   _print_PolyzLatexPrinter._print_Polyj	  s    nn%% JJL "	,LE5G#E* G37ax4;;tyy|#<<4;;s499Q</E#FFG ||04;;u3EEG"kk%0G~c7^4 -c7^4 ++e,  30  %c6!":./c6]+E"	,H 8z!yy|H3q>axxCTYY/0t{{4??+<==yy$$&12**/2D9C 
 + >A$GC
ru   c                    |j                   j                  }|dk(  rd}| j                  |j                        }|j                  }|t
        v rd|||fz  S d|||fz  S )NComplexRootOfCRootOfz\%s {\left(%s, %d\right)}z'\operatorname{%s} {\left(%s, %d\right)})rM  rN  r  r  rB  rz  )r   r;   r  r  rB  s        rs   _print_ComplexRootOfz!LatexPrinter._print_ComplexRootOf	  sq    nn%%/!C{{499%

**/3e2DDD=dAFAH H Hru   c                b   |j                   j                  }| j                  |j                        g}|j                  t
        j                  ur*|j                  | j                  |j                               |t        v rd|ddj                  |      dS d|ddj                  |      dS )Nr   r@  rK  r  rx  z	} {\left()
rM  rN  r  r  funr   IdentityFunctionr-  rz  rO  )r   r  r  r@  s       rs   _print_RootSumzLatexPrinter._print_RootSum	  s    nn%%DII&'881---KKDHH-.**/2DIIdODD + >A=AYYt_N Nru   c                     y)N\omegarp   r  s     rs   _print_OrdinalOmegaz LatexPrinter._print_OrdinalOmega	  s    ru   c                    |j                   \  }}|dk7  r(|dk7  rdj                  ||      S dj                  |      S |dk7  rdj                  |      S y)Nrk  z{} \omega^{{{}}}z	{} \omegaz\omega^{{{}}}rV  )r@  r   )r   r  rH  muls       rs   _print_OmegaPowerzLatexPrinter._print_OmegaPower	  s\    99S!8ax*11#s;;#**3//ax'..s33 ru   c                |    dj                  |j                  D cg c]  }| j                  |       c}      S c c}w Nr^  )rO  r@  r  rA  s      rs   _print_OrdinalzLatexPrinter._print_Ordinal	  s,    zztyyA4;;s+ABBAs   9c                P    | j                   d   }|j                  | t        d|      S )Nr   z	{%s}^{%d})r   rs  r!   )r   rF  r   s      rs   _print_PolyElementzLatexPrinter._print_PolyElement	  s&    ^^$67
xxj+zBBru   c                    |j                   dk(  r| j                  |j                        S | j                  |j                        }| j                  |j                         }d|d|dS )Nrk  r  r  ro   )r  r  r  )r   r:   r  r  s       rs   _print_FracElementzLatexPrinter._print_FracElement	  sO    ::?;;tzz**KK

+EKK

+E',e44ru   c                    t        |j                        dk(  r|j                  d   d fn|j                  \  }}d| j                  |      z  }||d|d}||d| j                  |      d}|S )Nrk  r   zE_{%s}r  ro   rE  rn  r  )r   r  rH  r  r-  r  s         rs   _print_eulerzLatexPrinter._print_euler	  sj    '*499~':		!d#		1$++a.(? #S)C=*-t{{1~>C
ru   c                \    d| j                  |j                  d         z  }||d|d}|S )NzC_{%s}r   r  ro   r  r  s       rs   _print_catalanzLatexPrinter._print_catalan	  r  ru   c           
         dj                  ||rdnd| j                  |j                  d         | j                  |j                  d         | j                  |j                  d               S )Nz5\mathcal{{{}}}{}_{{{}}}\left[{}\right]\left({}\right)z^{-1}r   rk  r   r  r   r  r@  )r   r  rr   inverses       rs   _print_UnifiedTransformz$LatexPrinter._print_UnifiedTransform	  s    GNNq]dRYjlnrnynyz~  {D  {D  EF  {G  oH  JN  JU  JU  VZ  V_  V_  `a  Vb  Jc  ei  ep  ep  qu  qz  qz  {|  q}  e~    	ru   c                &    | j                  |d      S )NMri  r  s     rs   _print_MellinTransformz#LatexPrinter._print_MellinTransform	      ++D#66ru   c                (    | j                  |dd      S )Nrk  Trl  r  s     rs   _print_InverseMellinTransformz*LatexPrinter._print_InverseMellinTransform	      ++D#t<<ru   c                &    | j                  |d      S )NLrl  r  s     rs   _print_LaplaceTransformz$LatexPrinter._print_LaplaceTransform	  rn  ru   c                (    | j                  |dd      S )Nrs  Trl  r  s     rs   _print_InverseLaplaceTransformz+LatexPrinter._print_InverseLaplaceTransform	  rq  ru   c                &    | j                  |d      S r  rl  r  s     rs   _print_FourierTransformz$LatexPrinter._print_FourierTransform	  rn  ru   c                (    | j                  |dd      S )Nr  Trl  r  s     rs   _print_InverseFourierTransformz+LatexPrinter._print_InverseFourierTransform	  rq  ru   c                &    | j                  |d      S )NSINrl  r  s     rs   _print_SineTransformz!LatexPrinter._print_SineTransform	      ++D%88ru   c                (    | j                  |dd      S )Nr|  Trl  r  s     rs   _print_InverseSineTransformz(LatexPrinter._print_InverseSineTransform
      ++D%>>ru   c                &    | j                  |d      S )NCOSrl  r  s     rs   _print_CosineTransformz#LatexPrinter._print_CosineTransform
  r~  ru   c                (    | j                  |dd      S )Nr  Trl  r  s     rs   _print_InverseCosineTransformz*LatexPrinter._print_InverseCosineTransform
  r  ru   c                    	 |j                   *| j                  |j                   j                  |            S 	 | j                  t	        |            S # t        $ r Y %w xY wr  )ringr  to_sympyr   reprr   r  s     rs   
_print_DMPzLatexPrinter._print_DMP
  s[    	vv!{{166??1#566 "
 {{47##  		s   5A 	AAc                $    | j                  |      S r  )r  r  s     rs   
_print_DMFzLatexPrinter._print_DMF
  s    q!!ru   c                J    | j                  t        |j                              S r  )r  r   rP  )r   r  s     rs   _print_ObjectzLatexPrinter._print_Object
  s    {{6&++.//ru   c                    | j                  |j                  d         }|d|dnd}t        |j                        dk(  rd|d|d}|S | j                  |j                  d         }d	j                  |||      }|S )
Nr   r  ro   r   rk  WrE  rn  zW{0}_{{{1}}}\left({2}\right))r  r@  r  r   )r   r  rH  arg0resultarg1s         rs   _print_LambertWzLatexPrinter._print_LambertW
  sx    {{499Q<(#&?#tyy>Q.148F  ;;tyy|,D5<<S$MFru   c                \    dj                  | j                  |j                  d               S )Nz!\operatorname{{E}}\left[{}\right]r   rg  r  s     rs   _print_ExpectationzLatexPrinter._print_Expectation$
  %    3::4;;tyyQR|;TUUru   c                \    dj                  | j                  |j                  d               S )Nz#\operatorname{{Var}}\left({}\right)r   rg  r  s     rs   _print_VariancezLatexPrinter._print_Variance'
  s%    5<<T[[ST=VWWru   c                j     dj                  dj                   fd|j                  D                    S )Nz#\operatorname{{Cov}}\left({}\right)rK  c              3  @   K   | ]  }j                  |        y wr  rR  r}  s     rs   r.  z1LatexPrinter._print_Covariance.<locals>.<genexpr>+
  s     Fm\_t{{SVGWFmr0  )r   rO  r@  r  s   ` rs   _print_CovariancezLatexPrinter._print_Covariance*
  s*    5<<TYYFmcgclclFm=mnnru   c                \    dj                  | j                  |j                  d               S )Nz!\operatorname{{P}}\left({}\right)r   rg  r  s     rs   _print_ProbabilityzLatexPrinter._print_Probability-
  r  ru   c                |    | j                  |j                        }| j                  |j                        }|d|S )Nr  )r  r5  codomain)r   morphismr5  r  s       rs   _print_MorphismzLatexPrinter._print_Morphism0
  s3    X__-;;x001&,h77ru   c                    | j                  |j                        | j                  |j                        }}d|d|dS )Nr  r  ro   )r  rN  den)r   r  rN  r  s       rs   _print_TransferFunctionz$LatexPrinter._print_TransferFunction5
  s0    ;;txx($++dhh*?S#&,,ru   c                r     t        j                        } fd}dj                  t        ||            S )Nc                <    j                  | t              d      S r  )r  r   )r-  r  r   s    rs   rt   z,LatexPrinter._print_Series.<locals>.<lambda>;
  s    4,,Q0Ft0L,13 ru   r   )r  r@  rO  r9  )r   r  r@  r  s   ``  rs   _print_SerieszLatexPrinter._print_Series9
  s-    DII3xxFD)**ru   c                     ddl m t        j                        d d d   } fd}dj	                  t        ||            S )Nr   )MIMOParallelrj  c                v    t        |       rj                  | t              d      S j                  |       S r  )r  r  r   r  )r-  r  r  r   s    rs   rt   z0LatexPrinter._print_MIMOSeries.<locals>.<lambda>B
  s@    7A!\7R  ,,Q0Ft0L-24 X\XcXcdeXf ru   z\cdot)sympy.physics.control.ltir  r  r@  rO  r9  )r   r  r@  r  r  s   ``  @rs   _print_MIMOSerieszLatexPrinter._print_MIMOSeries?
  s:    :DIItt$g}}S.//ru   c                `    dj                  t        | j                  |j                              S r\  rO  r9  r  r@  r  s     rs   _print_ParallelzLatexPrinter._print_ParallelF
       zz#dkk499566ru   c                `    dj                  t        | j                  |j                              S r\  r  r  s     rs   _print_MIMOParallelz LatexPrinter._print_MIMOParallelI
  r  ru   c           	        ddl m}m} |j                   |dd|j                        }}t        ||      rt        |j                        n|g}t        |j                  |      rt        |j                  j                        n|j                  g}|}t        ||      r!t        |j                  |      r |g || }	nt        ||      rBt        |j                  |      r,|j                  |k(  r || }	nx| |g ||j                   f}	nat        ||      r+t        |j                  |      r||k(  r || }	n4 ||g| }	n*||k(  r || }	n|j                  |k(  r || }	n
 |g || }	| j                  |      }
| j                  |      }| j                  |	      }|j                  dk(  rdnd}d|
d|d	|d	|d
	S )Nr   )TransferFunctionSeriesrk  rj  r  r$  r  r  r   ro   )sympy.physics.controlr  r  sys1r  r  r  r@  sys2r  r  )r   r  r  r  rN  tfnum_arg_listden_arg_list
den_term_1
den_term_2r  denom_1denom_2_signs                 rs   _print_FeedbackzLatexPrinter._print_FeedbackL
  s   B))-aDHH=R)3C)@tCHH~setyy&) DIINN+04		{ 	
c6"z$))V'D===JV$DII?O)PyyB#\2
!A!Atyy!AA
-.:dii3Pby#\2
#C7,7
by#\2
b#\2
#A\ALA
C ++j)++j)yyBC).HHru   c                    ddl m} | j                   ||j                  |j                              }| j                  |j                        }|j
                  dk(  rdnd}d|d|d|S )	Nr   )
MIMOSeriesrj  r  r$  z\left(I_{\tau} r   z\right)^{-1} \cdot )r  r  r  r  r  r  )r   r  r  inv_matr  r  s         rs   _print_MIMOFeedbackz LatexPrinter._print_MIMOFeedbackp
  sR    4++jDII>?{{499%yyBC?DgtTTru   c                B    | j                  |j                        }d|z  S )Nz%s_\tau)r  	_expr_matr  s      rs   _print_TransferFunctionMatrixz*LatexPrinter._print_TransferFunctionMatrixw
  s    kk$..)Cru   c                b    dj                  |j                  j                  |j                        S )Nz\text{{{}}}_{{{}}})r   rM  rN  r  r  s     rs   
_print_DFTzLatexPrinter._print_DFT{
  s#    $++DNN,C,CTVVLLru   c                z    | j                  t        |j                              }| j                  |      }|d|S )Nr  )r  r   rP  r  )r   r  pretty_namepretty_morphisms       rs   _print_NamedMorphismz!LatexPrinter._print_NamedMorphism
  s4    kk&"78..x8%77ru   c                h    ddl m} | j                   ||j                  |j                  d            S )Nr   )NamedMorphismid)sympy.categoriesr  r  r5  r  )r   r  r  s      rs   _print_IdentityMorphismz$LatexPrinter._print_IdentityMorphism
  s0    2((OOX..*6 7 	7ru   c                    |j                   D cg c]&  }| j                  t        |j                              ( }}|j	                          dj                  |      dz   }| j                  |      }||z   S c c}w )Nz\circ r  )r+  r  r   rP  reverserO  r  )r   r  	componentcomponent_names_listcomponent_namesr  s         rs   _print_CompositeMorphismz%LatexPrinter._print_CompositeMorphism
  s~     .6-@-@ B ) !%F9>>,B C  B  B$$&#..)=>D..x800 Bs   +A6c                h    dj                  | j                  t        |j                                    S Nr  )r   r  r   rP  )r   r  s     rs   _print_CategoryzLatexPrinter._print_Category
  s%    &&t{{6(--3H'IJJru   c                    |j                   s| j                  t        j                        S | j                  |j                         }|j                  r!|d| j                  |j                        z  z  }|S )Nz\Longrightarrow %s)premisesr  r   EmptySetconclusions)r   diagramlatex_results      rs   _print_DiagramzLatexPrinter._print_Diagram
  sg    ;;qzz**{{7#3#341 KK(;(;<= =L ru   c                B   dd|j                   z  z  }t        |j                        D ]o  }t        |j                         D ]9  }|||f   r|t        |||f         z  }|dz  }||j                   dz
  k7  s5|dz  }; ||j                  dz
  k7  r|dz  }|dz  }q |dz  }|S )	Nz\begin{array}{%s}
r   r   rk  & r  
z\end{array}
)widthr  heightlatex)r   gridr  r   r   s        rs   _print_DiagramGridzLatexPrinter._print_DiagramGrid
  s    -tzz1ABt{{# 
	!A4::& )1: E$q!t*$55L#

Q& D(L) DKK!O#&D L
	! 	((ru   c                    dj                  | j                  |j                        | j                  |j                              S )Nz{{{}}}^{{{}}})r   r  r  r2  r   rk  s     rs   _print_FreeModulezLatexPrinter._print_FreeModule
  s/    %%dkk!&&&94;;qvv;NOOru   c                V     dj                  dj                   fd|D                    S )N\left[ {} \right]rl  c              3  L   K   | ]  }d j                  |      z   dz     ywr   ro   NrR  r,  r-  r   s     rs   r.  z8LatexPrinter._print_FreeModuleElement.<locals>.<genexpr>
  s(      43+,C$++a. 3&43r  )r   rO  )r   r  s   ` rs   _print_FreeModuleElementz%LatexPrinter._print_FreeModuleElement
  s.    #**388 430143 ,3 4 	4ru   c                "   |j                   D cg c]:  }|D cg c],  }| j                  |j                  j                  |            . c}< }}}d d dj	                  fd|D              }dj                  |      S c c}w c c}}w )Nc                    d| z   dz   S )Nr   ro   rp   rM   s    rs   rt   z/LatexPrinter._print_SubModule.<locals>.<lambda>
  s    $(T/ ru   c                    d| z   dz   S )Nz\left[ z \right]rp   r  s    rs   rt   z/LatexPrinter._print_SubModule.<locals>.<lambda>
  s    :>K7 ru   rl  c           	   3  j   K   | ]*  }  d j                  fd|D                           , yw)rl  c              3  .   K   | ]  } |        y wr  rp   )r,  r-  curlys     rs   r.  z:LatexPrinter._print_SubModule.<locals>.<genexpr>.<genexpr>
  s     3HE!H3Hs   N)rO  )r,  gr  squares     rs   r.  z0LatexPrinter._print_SubModule.<locals>.<genexpr>
  s*     YqeF3883Ha3H+H$IJYs   03\left\langle {} \right\rangle)rA  r  r  r  rO  r   )r   r  r  r-  rA  
gens_latexr  r   s         @@rs   _print_SubModulezLatexPrinter._print_SubModule
  ss    FGffM!<QQVV__Q/0<MM)7XXYTXYY
/66zBB	 =Ms   	B1BBBc           	         dj                  |j                  D cg c]  }d| j                  |      z   dz    c}      }dj                  |      S c c}w )Nrl  r   ro   r  )rO  rA  r  r   )r   r  r  r  s       rs   _print_SubQuotientModulez%LatexPrinter._print_SubQuotientModule
  sH    XX166JasT[[^3c9JK
/66zBB Ks   Ac                     |j                   j                  D cg c]  \  }|j                  j                  |      ! }}dj	                   fd|D              }dj                  |      S c c}w )Nrl  c              3  L   K   | ]  }d j                  |      z   dz     ywr  rR  r  s     rs   r.  z=LatexPrinter._print_ModuleImplementedIdeal.<locals>.<genexpr>
  s#     GQcDKKN2S8Gr  r  )_modulerA  r  r  rO  r   )r   r  r-  rA  r  s   `    rs   _print_ModuleImplementedIdealz*LatexPrinter._print_ModuleImplementedIdeal
  sW    ./iinn=s"==XXG$GG
/66zBB >s   $A+c                    |j                   D cg c]  }| j                  |t        d   d       }}|d   gt        |dd  d      D cg c]  \  }}|dz   |z    c}}z   }dj	                  |      S c c}w c c}}w )	Nr
   Tr  r   rk  ijkr   r^  )r@  r  r!   rY  rO  )r   r  r   rr   r   r  s         rs   _print_QuaternionzLatexPrinter._print_Quaternion
  s     ii! q*U"3DA ! !qTF#aeU*;<$!QaeAg<<zz!}!<s   "A3
A8c                    dj                  | j                  |j                        | j                  |j                              S Nz\frac{{{}}}{{{}}})r   r  r  
base_ideal)r   Rs     rs   _print_QuotientRingz LatexPrinter._print_QuotientRing
  s4    #**4;;qvv+>Q\\*, 	,ru   c                    | j                  |j                  j                  |            }dj                  || j                  |j                  j                              S )N{{{}}} + {{{}}})r  r  r  r   r  )r   r-  x_latexs      rs   _print_QuotientRingElementz'LatexPrinter._print_QuotientRingElement
  sH    ++affooa01!((QVV../1 	1ru   c                B    |j                   D cg c]'  }|j                  j                  j                  |      ) }}dj	                  dj                   fd|D                    }dj	                  | j                  |j                  j                              S c c}w )Nr  rl  c              3  L   K   | ]  }d j                  |      z   dz     ywr  rR  r  s     rs   r.  z<LatexPrinter._print_QuotientModuleElement.<locals>.<genexpr>
  s(      :6+,C$++a. 3&:6r  r  )datamoduler  r  r   rO  r  killed_module)r   r  r-  r  
data_latexs   `    rs   _print_QuotientModuleElementz)LatexPrinter._print_QuotientModuleElement
  s    3466:a&&q)::)00 :604:6 26 7
!((QXX3346 	6 ;s   ,Bc                    dj                  | j                  |j                        | j                  |j                              S r  )r   r  rC  r  r  s     rs   _print_QuotientModulez"LatexPrinter._print_QuotientModule
  s4    #**4;;qvv+>Q__-/ 	/ru   c                    dj                  | j                  |j                               | j                  |j                        | j                  |j                              S )Nz{{{}}} : {{{}}} \to {{{}}})r   r  _sympy_matrixr5  r  )r   r  s     rs   _print_MatrixHomomorphismz&LatexPrinter._print_MatrixHomomorphism
  sF    ,33DKK@Q4RKK!4;;qzz#:< 	<ru   c                ^   |j                   j                   }d|v r|g g }}}nJt        |      \  }}}t        |      }|D cg c]  }t        |       }}|D cg c]  }t        |       }}d|z  }|r|ddj                  |      z  z  }|r|ddj                  |      z  z  }|S c c}w c c}w )Nr   rU  rh  r   r8  )rP  r   r  rO  )r   manifoldr  rP  r  rZ  r  r   s           rs   _print_ManifoldzLatexPrinter._print_Manifold
  s    ##&=!'R$&D!0!8D&$T?D067in7F7.23sIcN3D3d"Gchhv...DGchhtn,,D 83s    B%B*c                x    d| j                  |j                        d| j                  |j                        dS )N\text{r  ro   )r  rP  r#  )r   patchs     rs   _print_PatchzLatexPrinter._print_Patch  s'    $(KK

$;T[[=XYYru   c                    d| j                  |j                        d| j                  |j                  j                        d| j                  |j                        dS )Nr&  z	}^{\text{z}}_{ro   )r  rP  r'  r#  )r   coordsyss     rs   _print_CoordSystemzLatexPrinter._print_CoordSystem  sC    KK&HNN4G4G(H$++V^VgVgJh
 	
ru   c                >    d| j                  |j                        z  S )Nz\mathbb{\nabla}_{%s})r  _wrt)r   cvds     rs   _print_CovarDerivativeOpz%LatexPrinter._print_CovarDerivativeOp
  s    &SXX)>>>ru   c                    |j                   j                  |j                     j                  }dj	                  | j                  t        |                  S r  
_coord_sysrl  _indexrP  r   r  r   r   fieldr  s      rs   _print_BaseScalarFieldz#LatexPrinter._print_BaseScalarField  s@    !!))%,,7<<&&t{{6&>'BCCru   c                    |j                   j                  |j                     j                  }dj	                  | j                  t        |                  S )Nz\partial_{{{}}}r1  r4  s      rs   _print_BaseVectorFieldz#LatexPrinter._print_BaseVectorField  s@    !!))%,,7<<!((VF^)DEEru   c                "   |j                   }t        |d      rV|j                  j                  |j                     j
                  }dj                  | j                  t        |                  S | j                  |      }dj                  |      S )Nr2  z\operatorname{{d}}{}z!\operatorname{{d}}\left({}\right))	_form_fieldr  r2  rl  r3  rP  r   r  r   )r   diffr5  r  s       rs   _print_Differentialz LatexPrinter._print_Differential  st      5,'%%--ell;@@F*11$++fVn2MNN[['F7>>vFFru   c                `    | j                  |j                  d         }dj                  |      S )Nr   z"\operatorname{{tr}}\left({}\right)r  )r   r  contentss      rs   	_print_TrzLatexPrinter._print_Tr  s)    ;;qvvay)4;;HEEru   c                    |%d| j                  |j                  d         d|dS d| j                  |j                  d         z  S )Nz\left(\phi\left(r   \right)\right)^{ro   z\phi\left(%s\right)r  rG  s      rs   _print_totientzLatexPrinter._print_totient#  sC    ?TYYq\*C1 1%DIIaL(AAAru   c                    |%d| j                  |j                  d         d|dS d| j                  |j                  d         z  S )Nz\left(\lambda\left(r   rA  ro   z\lambda\left(%s\right)r  rG  s      rs   _print_reduced_totientz#LatexPrinter._print_reduced_totient)  sC    ?TYYq\*C1 1(4;;tyy|+DDDru   c           	        t        |j                        dk(  r?dt        t        | j                  |j                  d   |j                  d   f            z  }n!d| j	                  |j                  d         z  }|d|d|S d|z  S )	Nr  _%s\left(%s\right)rk  r   r_  z\sigma^{ro   z\sigma%sri  r  s       rs   _print_divisor_sigmaz!LatexPrinter._print_divisor_sigma/  s    tyy>Q'%DKK151tyy|0L1N +O OC %t{{499Q<'@@C?'*C00S  ru   c           	        t        |j                        dk(  r?dt        t        | j                  |j                  d   |j                  d   f            z  }n!d| j	                  |j                  d         z  }|d|d|S d|z  S )	Nr  rF  rk  r   r_  z
\sigma^*^{ro   z
\sigma^*%sri  r  s       rs   _print_udivisor_sigmaz"LatexPrinter._print_udivisor_sigma9  s    tyy>Q'%DKK151tyy|0L1N +O OC %t{{499Q<'@@C?),c22s""ru   c                    |%d| j                  |j                  d         d|dS d| j                  |j                  d         z  S )Nz\left(\nu\left(r   rA  ro   z\nu\left(%s\right)r  rG  s      rs   _print_primenuzLatexPrinter._print_primenuC  sC    ?TYYq\*C1 1$t{{499Q<'@@@ru   c                    |%d| j                  |j                  d         d|dS d| j                  |j                  d         z  S )Nz\left(\Omega\left(r   rA  ro   z\Omega\left(%s\right)r  rG  s      rs   _print_primeomegazLatexPrinter._print_primeomegaI  sC    ?TYYq\*C1 1'$++diil*CCCru   c                ,    t        |j                        S r  )rs  rP  r  s     rs   
_print_StrzLatexPrinter._print_StrO  s    166{ru   c                6    | j                  t        |            S r  )r  r   r  s     rs   _print_floatzLatexPrinter._print_floatR  s    {{5;''ru   c                    t        |      S r  rs  r  s     rs   
_print_intzLatexPrinter._print_intU      4yru   c                    t        |      S r  rS  r  s     rs   
_print_mpzzLatexPrinter._print_mpzX  rU  ru   c                    t        |      S r  rS  r  s     rs   
_print_mpqzLatexPrinter._print_mpq[  rU  ru   c                    t        |      S r  rS  r  s     rs   _print_fmpzzLatexPrinter._print_fmpz^  rU  ru   c                    t        |      S r  rS  r  s     rs   _print_fmpqzLatexPrinter._print_fmpqa  rU  ru   c                \    dj                  t        t        |j                                    S )Nz"\operatorname{{Q}}_{{\text{{{}}}}})r   r   rs  rP  r  s     rs   _print_PredicatezLatexPrinter._print_Predicated  s     4;;LTYY<XYYru   c                    |j                   }|j                  }| j                  |      }dj                  |D cg c]  }| j                  |       c}      }|d|dS c c}w )NrK  r   r   )r  	argumentsr  rO  )r   r  predr@  
pred_latexr  
args_latexs          rs   _print_AppliedPredicatez$LatexPrinter._print_AppliedPredicateg  sS    }}~~[[&
YY=1A=>
%z22  >s   A c                >    t         |   |      }dt        |      z  S )Nz\mathtt{\text{%s}})superemptyPrinterr   )r   r  rr   rM  s      rs   rh  zLatexPrinter.emptyPrintern  s!    G &$|A66ru   r  r  )FF)r  bool)r  rs  )rW  z!bool | BooleanTrue | BooleanFalse)r  r   )r  r   )r  rs  r  rs  )r  z'BasisDependent')r  rs  r  rs  )r  r   r  rs  r  )r%  rs  r  rs  r  )FN)r   )r  r   )r  rs  r  rs  )r  r&   )r?  dict)F(A  rN  
__module____qualname__printmethodr   __annotations__r   r  r  r  r   r  r  r#  r;  r>  r  r   rI  rR  rX  _print_BooleanTrue_print_BooleanFalser[  re  rv  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r6  r<  r?  rC  rO  r`  rn  ru  r}  r  r  r  propertyr  r  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  r  r  r  r  r  r  _print_gammar  r	  r  r  r  r  r  r  r  r!  r'  r)  r-  r0  r3  r6  r8  r:  r<  r?  rA  rC  rG  rI  rN  rS  rV  rY  r_  re  rg  rj  rl  rn  rq  rv  ry  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  _print_RandomSymbolrL  r  r  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r   r%  r*  r,  r0  r<  rD  rG  rI  rL  rN  rP  rS  rU  rW  rY  r\  ra  rf  rj  rl  ro  rs  ru  rw  rz  r  r  r  r  r  r  _print_frozensetr  r  r  r  r  r  r  r  r  r  _print_SeqPer_print_SeqAdd_print_SeqMulr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r$  r'  r*  r,  r.  r0  r2  r7  r:  r>  rL  rP  rT  rW  rZ  r]  r_  ra  rc  re  ri  rm  rp  rt  rv  rx  rz  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  _print_IDFTr  r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r!  r$  r(  r+  r/  r6  r8  r<  r?  rB  rD  rG  rI  rK  rM  rO  rQ  rT  rW  rY  r[  r]  r_  re  rh  __classcell__)rM  s   @rs   r   r      s   K)U)E) 	e) 	4	)
 	-) 	) 	u) 	4) 	S) 	4) 	) 	d) 	) 	) 	)  	G!)" 	##)$ %"!3)~ 8;fz,-%EK.>3/  %% & 9BJ<NNMMIIqf/-+<Z&")&&<'@BE"/H4@J)X0
 , ,0
- 87J	++	7203DF)+  	 "	/[<%%; (L1:  ++"777777====-42288	 !+@QGGSS'' A (,J(*+,5
J($G7&/"GA>A>@!>>>#5n8?
F

&D
4F+*':<&		%&, "(T>>>>>M
. &M%M%MK$9(
-
(
-
<Q
&A!D<
+-8
8
?7r
HN!CC57=7=7=9?9?$"0VXoV8
-+077"IHU MK8
7
	1K
$P4
CCC
,
1
6/
<&Z

?DFGF
BE!#AD(Z37 7ru   r   c           
        t         j                  |       }|r|S | j                         t        v rd| j                         z   S | t        v rd| z   S t        t        j                         t        d      D ]_  }| j                         j                  |      s#t        |       t        |      kD  s;t        |   t        | dt        |                    c S  | S )a  
    Check for a modifier ending the string.  If present, convert the
    modifier to latex and translate the rest recursively.

    Given a description of a Greek letter or other special character,
    return the appropriate latex.

    Let everything else pass as given.

    >>> from sympy.printing.latex import translate
    >>> translate('alphahatdotprime')
    "{\\dot{\\hat{\\alpha}}}'"
    r   T)r#  r  N)tex_greek_dictionaryr   r  greek_letters_setother_symbolsr  r   rq  r  r  r  )rr   r  r#  s      rs   r  r  u  s     
"
"1
%C

	
'	'aggi	
m	ax -,,.CF 	DCwwy!!#&3q6CH+<$S))AjCyM*BCC	D ru   c                6    t        |      j                  |       S )a%  Convert the given expression to LaTeX string representation.

    Parameters
    ==========
    full_prec: boolean, optional
        If set to True, a floating point number is printed with full precision.
    fold_frac_powers : boolean, optional
        Emit ``^{p/q}`` instead of ``^{\frac{p}{q}}`` for fractional powers.
    fold_func_brackets : boolean, optional
        Fold function brackets where applicable.
    fold_short_frac : boolean, optional
        Emit ``p / q`` instead of ``\frac{p}{q}`` when the denominator is
        simple enough (at most two terms and no powers). The default value is
        ``True`` for inline mode, ``False`` otherwise.
    inv_trig_style : string, optional
        How inverse trig functions should be displayed. Can be one of
        ``'abbreviated'``, ``'full'``, or ``'power'``. Defaults to
        ``'abbreviated'``.
    itex : boolean, optional
        Specifies if itex-specific syntax is used, including emitting
        ``$$...$$``.
    ln_notation : boolean, optional
        If set to ``True``, ``\ln`` is used instead of default ``\log``.
    long_frac_ratio : float or None, optional
        The allowed ratio of the width of the numerator to the width of the
        denominator before the printer breaks off long fractions. If ``None``
        (the default value), long fractions are not broken up.
    mat_delim : string, optional
        The delimiter to wrap around matrices. Can be one of ``'['``, ``'('``,
        or the empty string ``''``. Defaults to ``'['``.
    mat_str : string, optional
        Which matrix environment string to emit. ``'smallmatrix'``,
        ``'matrix'``, ``'array'``, etc. Defaults to ``'smallmatrix'`` for
        inline mode, ``'matrix'`` for matrices of no more than 10 columns, and
        ``'array'`` otherwise.
    mode: string, optional
        Specifies how the generated code will be delimited. ``mode`` can be one
        of ``'plain'``, ``'inline'``, ``'equation'`` or ``'equation*'``.  If
        ``mode`` is set to ``'plain'``, then the resulting code will not be
        delimited at all (this is the default). If ``mode`` is set to
        ``'inline'`` then inline LaTeX ``$...$`` will be used. If ``mode`` is
        set to ``'equation'`` or ``'equation*'``, the resulting code will be
        enclosed in the ``equation`` or ``equation*`` environment (remember to
        import ``amsmath`` for ``equation*``), unless the ``itex`` option is
        set. In the latter case, the ``$$...$$`` syntax is used.
    mul_symbol : string or None, optional
        The symbol to use for multiplication. Can be one of ``None``,
        ``'ldot'``, ``'dot'``, or ``'times'``.
    order: string, optional
        Any of the supported monomial orderings (currently ``'lex'``,
        ``'grlex'``, or ``'grevlex'``), ``'old'``, and ``'none'``. This
        parameter does nothing for `~.Mul` objects. Setting order to ``'old'``
        uses the compatibility ordering for ``~.Add`` defined in Printer. For
        very large expressions, set the ``order`` keyword to ``'none'`` if
        speed is a concern.
    symbol_names : dictionary of strings mapped to symbols, optional
        Dictionary of symbols and the custom strings they should be emitted as.
    root_notation : boolean, optional
        If set to ``False``, exponents of the form 1/n are printed in fractonal
        form. Default is ``True``, to print exponent in root form.
    mat_symbol_style : string, optional
        Can be either ``'plain'`` (default) or ``'bold'``. If set to
        ``'bold'``, a `~.MatrixSymbol` A will be printed as ``\mathbf{A}``,
        otherwise as ``A``.
    imaginary_unit : string, optional
        String to use for the imaginary unit. Defined options are ``'i'``
        (default) and ``'j'``. Adding ``r`` or ``t`` in front gives ``\mathrm``
        or ``\text``, so ``'ri'`` leads to ``\mathrm{i}`` which gives
        `\mathrm{i}`.
    gothic_re_im : boolean, optional
        If set to ``True``, `\Re` and `\Im` is used for ``re`` and ``im``, respectively.
        The default is ``False`` leading to `\operatorname{re}` and `\operatorname{im}`.
    decimal_separator : string, optional
        Specifies what separator to use to separate the whole and fractional parts of a
        floating point number as in `2.5` for the default, ``period`` or `2{,}5`
        when ``comma`` is specified. Lists, sets, and tuple are printed with semicolon
        separating the elements when ``comma`` is chosen. For example, [1; 2; 3] when
        ``comma`` is chosen and [1,2,3] for when ``period`` is chosen.
    parenthesize_super : boolean, optional
        If set to ``False``, superscripted expressions will not be parenthesized when
        powered. Default is ``True``, which parenthesizes the expression when powered.
    min: Integer or None, optional
        Sets the lower bound for the exponent to print floating point numbers in
        fixed-point format.
    max: Integer or None, optional
        Sets the upper bound for the exponent to print floating point numbers in
        fixed-point format.
    diff_operator: string, optional
        String to use for differential operator. Default is ``'d'``, to print in italic
        form. ``'rd'``, ``'td'`` are shortcuts for ``\mathrm{d}`` and ``\text{d}``.
    adjoint_style: string, optional
        String to use for the adjoint symbol. Defined options are ``'dagger'``
        (default),``'star'``, and ``'hermitian'``.

    Notes
    =====

    Not using a print statement for printing, results in double backslashes for
    latex commands since that's the way Python escapes backslashes in strings.

    >>> from sympy import latex, Rational
    >>> from sympy.abc import tau
    >>> latex((2*tau)**Rational(7,2))
    '8 \\sqrt{2} \\tau^{\\frac{7}{2}}'
    >>> print(latex((2*tau)**Rational(7,2)))
    8 \sqrt{2} \tau^{\frac{7}{2}}

    Examples
    ========

    >>> from sympy import latex, pi, sin, asin, Integral, Matrix, Rational, log
    >>> from sympy.abc import x, y, mu, r, tau

    Basic usage:

    >>> print(latex((2*tau)**Rational(7,2)))
    8 \sqrt{2} \tau^{\frac{7}{2}}

    ``mode`` and ``itex`` options:

    >>> print(latex((2*mu)**Rational(7,2), mode='plain'))
    8 \sqrt{2} \mu^{\frac{7}{2}}
    >>> print(latex((2*tau)**Rational(7,2), mode='inline'))
    $8 \sqrt{2} \tau^{7 / 2}$
    >>> print(latex((2*mu)**Rational(7,2), mode='equation*'))
    \begin{equation*}8 \sqrt{2} \mu^{\frac{7}{2}}\end{equation*}
    >>> print(latex((2*mu)**Rational(7,2), mode='equation'))
    \begin{equation}8 \sqrt{2} \mu^{\frac{7}{2}}\end{equation}
    >>> print(latex((2*mu)**Rational(7,2), mode='equation', itex=True))
    $$8 \sqrt{2} \mu^{\frac{7}{2}}$$
    >>> print(latex((2*mu)**Rational(7,2), mode='plain'))
    8 \sqrt{2} \mu^{\frac{7}{2}}
    >>> print(latex((2*tau)**Rational(7,2), mode='inline'))
    $8 \sqrt{2} \tau^{7 / 2}$
    >>> print(latex((2*mu)**Rational(7,2), mode='equation*'))
    \begin{equation*}8 \sqrt{2} \mu^{\frac{7}{2}}\end{equation*}
    >>> print(latex((2*mu)**Rational(7,2), mode='equation'))
    \begin{equation}8 \sqrt{2} \mu^{\frac{7}{2}}\end{equation}
    >>> print(latex((2*mu)**Rational(7,2), mode='equation', itex=True))
    $$8 \sqrt{2} \mu^{\frac{7}{2}}$$

    Fraction options:

    >>> print(latex((2*tau)**Rational(7,2), fold_frac_powers=True))
    8 \sqrt{2} \tau^{7/2}
    >>> print(latex((2*tau)**sin(Rational(7,2))))
    \left(2 \tau\right)^{\sin{\left(\frac{7}{2} \right)}}
    >>> print(latex((2*tau)**sin(Rational(7,2)), fold_func_brackets=True))
    \left(2 \tau\right)^{\sin {\frac{7}{2}}}
    >>> print(latex(3*x**2/y))
    \frac{3 x^{2}}{y}
    >>> print(latex(3*x**2/y, fold_short_frac=True))
    3 x^{2} / y
    >>> print(latex(Integral(r, r)/2/pi, long_frac_ratio=2))
    \frac{\int r\, dr}{2 \pi}
    >>> print(latex(Integral(r, r)/2/pi, long_frac_ratio=0))
    \frac{1}{2 \pi} \int r\, dr

    Multiplication options:

    >>> print(latex((2*tau)**sin(Rational(7,2)), mul_symbol="times"))
    \left(2 \times \tau\right)^{\sin{\left(\frac{7}{2} \right)}}

    Trig options:

    >>> print(latex(asin(Rational(7,2))))
    \operatorname{asin}{\left(\frac{7}{2} \right)}
    >>> print(latex(asin(Rational(7,2)), inv_trig_style="full"))
    \arcsin{\left(\frac{7}{2} \right)}
    >>> print(latex(asin(Rational(7,2)), inv_trig_style="power"))
    \sin^{-1}{\left(\frac{7}{2} \right)}

    Matrix options:

    >>> print(latex(Matrix(2, 1, [x, y])))
    \left[\begin{matrix}x\\y\end{matrix}\right]
    >>> print(latex(Matrix(2, 1, [x, y]), mat_str = "array"))
    \left[\begin{array}{c}x\\y\end{array}\right]
    >>> print(latex(Matrix(2, 1, [x, y]), mat_delim="("))
    \left(\begin{matrix}x\\y\end{matrix}\right)

    Custom printing of symbols:

    >>> print(latex(x**2, symbol_names={x: 'x_i'}))
    x_i^{2}

    Logarithms:

    >>> print(latex(log(10)))
    \log{\left(10 \right)}
    >>> print(latex(log(10), ln_notation=True))
    \ln{\left(10 \right)}

    ``latex()`` also supports the builtin container types :class:`list`,
    :class:`tuple`, and :class:`dict`:

    >>> print(latex([2/x, y], mode='inline'))
    $\left[ 2 / x, \  y\right]$

    Unsupported types are rendered as monospaced plaintext:

    >>> print(latex(int))
    \mathtt{\text{<class 'int'>}}
    >>> print(latex("plain % text"))
    \mathtt{\text{plain \% text}}

    See :ref:`printer_method_example` for an example of how to override
    this behavior for your own types by implementing ``_latex``.

    .. versionchanged:: 1.7.0
        Unsupported types no longer have their ``str`` representation treated as valid latex.

    )r   r  r  r   s     rs   r  r    s    n !))$//ru   c                .    t        t        | fi |       y)z`Prints LaTeX representation of the given expression. Takes the same
    settings as ``latex()``.N)printr  r  s     rs   print_latexr  n  s     
%
!
!"ru   c           
        t        di |}|dk(  rd}d}d}	d}
d}n:|dk(  rd}d}d}	d	}
d}n*|d
k(  rd}d}d}	d}
d}nt        dj                  |            d}|rd}|j                         }t	        |      }d}t        |      D ]  }||   }d}d}d}||kD  r	|rd}nd}d}||k(  r||dz
  k  r||	z   dz   dz   }nd}|j                         d   dk(  rd|z  }d}|dk(  r>|dk(  rd}|dj                  |j                  |       |||j                  |      |      z  }n&|dj                  |||j                  |      |      z  }|dz  } ||
z  }|S )a  
    This function generates a LaTeX equation with a multiline right-hand side
    in an ``align*``, ``eqnarray`` or ``IEEEeqnarray`` environment.

    Parameters
    ==========

    lhs : Expr
        Left-hand side of equation

    rhs : Expr
        Right-hand side of equation

    terms_per_line : integer, optional
        Number of terms per line to print. Default is 1.

    environment : "string", optional
        Which LaTeX wnvironment to use for the output. Options are "align*"
        (default), "eqnarray", and "IEEEeqnarray".

    use_dots : boolean, optional
        If ``True``, ``\\dots`` is added to the end of each line. Default is ``False``.

    Examples
    ========

    >>> from sympy import multiline_latex, symbols, sin, cos, exp, log, I
    >>> x, y, alpha = symbols('x y alpha')
    >>> expr = sin(alpha*y) + exp(I*alpha) - cos(log(y))
    >>> print(multiline_latex(x, expr))
    \begin{align*}
    x = & e^{i \alpha} \\
    & + \sin{\left(\alpha y \right)} \\
    & - \cos{\left(\log{\left(y \right)} \right)}
    \end{align*}

    Using at most two terms per line:
    >>> print(multiline_latex(x, expr, 2))
    \begin{align*}
    x = & e^{i \alpha} + \sin{\left(\alpha y \right)} \\
    & - \cos{\left(\log{\left(y \right)} \right)}
    \end{align*}

    Using ``eqnarray`` and dots:
    >>> print(multiline_latex(x, expr, terms_per_line=2, environment="eqnarray", use_dots=True))
    \begin{eqnarray}
    x & = & e^{i \alpha} + \sin{\left(\alpha y \right)} \dots\nonumber\\
    & & - \cos{\left(\log{\left(y \right)} \right)}
    \end{eqnarray}

    Using ``IEEEeqnarray``:
    >>> print(multiline_latex(x, expr, environment="IEEEeqnarray"))
    \begin{IEEEeqnarray}{rCl}
    x & = & e^{i \alpha} \nonumber\\
    & & + \sin{\left(\alpha y \right)} \nonumber\\
    & & - \cos{\left(\log{\left(y \right)} \right)}
    \end{IEEEeqnarray}

    Notes
    =====

    All optional parameters from ``latex`` can also be used.

    eqnarrayz\begin{eqnarray}
z& = &z	\nonumberz
\end{eqnarray}TIEEEeqnarrayz\begin{IEEEeqnarray}{rCl}
z
\end{IEEEeqnarray}align*z\begin{align*}
z= &r   z
\end{align*}FzUnknown environment: {}z\dotsrk  r  z& & r  r  r  r   rj  r$  z{:s} {:s}{:s} {:s} {:s}z{:s}{:s} {:s} {:s}rp   )r   r   r   as_ordered_termsr  r  r  r  )r  r  terms_per_lineenvironmentuse_dotsr   r  r  
first_termnonumberend_termdoubleetr  rb  n_terms
term_countr   rc  
term_startterm_endr  s                        rs   multiline_latexr  u  s   F 	 x Aj +
&		&4
*		 )
%299+FGGD  "E%jGJ7^ Qx
&#
!
J'719}(?U2T9""$Q'2-d7DD6s{077		#"D!))D/8E EF +22:t		$3 3Fa
=> hFMru   )rr   rs  r  rs  )rk  r  F)J__doc__
__future__r   typingr   r   r   r4  
sympy.corer   r   r	   r
   r   r   r   r   sympy.core.alphabetsr   sympy.core.containersr   sympy.core.functionr   r   r   sympy.core.operationsr   sympy.core.powerr   sympy.core.sortingr   sympy.core.sympifyr   r  r   r   r   sympy.printing.precedencer   sympy.printing.printerr   r   sympy.printing.conventionsr   r   r    r!   mpmath.libmp.libmpfr"   r#   r  sympy.utilities.iterablesr$   r%   r8   sympy.tensor.arrayr&   sympy.vector.basisdependentr'   rz  r}  r  r   rn  	frozensetr~  compiler  r   r   r  r  r  r  rp   ru   rs   <module>r     s   # / /  D D D ' ' B B )   / + ? ? = : H < B 7 	,: %]%
M% Y% Y	%
 }% M% 
=% Y% M% ]% j% 	-% 	-% 	&% s%  }!%" 	&#%$ 
=%%& Y'%( 
=)%* {+%, 
7-%. 
=/%0 
71%2 Y3%4 Z5%6 Z7%8 
79%: 
=;%< .=%> ?%@ jA%B YC%D jE%F I% N,2.2 *2 (	2
 &2 
$2 (2 (2 (2 (2 (2 
$2 
$2 
$2 !2  
!2$ ,%2& 	
*'2( )(*09--72. < f%  BJJ~BJJ'( d+77 d+7NW> V0 V0r#~ru   