
    \h             	         % S r SSKJr  SSKJrJrJr  SSKrSSKJ	r	J
r
JrJrJrJrJrJr  SSKJr  SSKJr  SSKJrJrJr  SS	KJr  SS
KJr  SSKJr  SSKJ r   SSK!J"r"J#r#J$r$  SSK%J&r&  SSK'J(r(J)r)  SSK*J+r+J,r,  SSK%J-r-J.r.  SSK/J0r0J1r2  SSK3J4r4J5r5  SSK6r6\(       a  SSK7J8r8  SSK9J:r:  / SQr;0 SS_SS_SS_SS_SS _S!S"_S#S$_S%S&_S'S(_S)S*_S+S,_S-S._S/S0_S1S2_S3S4_S5S6_S7S8_0 S9S:_S;S<_S=S>_S?S@_SASB_SCSD_SESF_SGSH_SISJ_SKS,_SLSM_SNSD_SOSP_SQSR_SSST_SUSV_SWSX_ESYSZS[.Er<1 S\kr=0 S]S^ _S_S` _SaSb _ScSd _SeSf _SgSh _SiSj _SkSl _SmSn _SoSp _SqSr _SsSt _SuSv _SwSx _SySz _S{S| _S}S~ _S S S S S S S S.Er>S\?S'   \@" \5      rA\6R                  " S5      \6R                  " S5      4rCSS jrD " S S\(5      rESS jrF\)" \E5      S 5       rGS rHSS jrIg)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                    SU -   S-   $ )Nz
\mathring{} ss    L/var/www/auris/envauris/lib/python3.13/site-packages/sympy/printing/latex.py<lambda>rt   [   s    -/$.    ddddotc                    SU -   S-   $ )Nz\ddddot{ro   rp   rq   s    rs   rt   rt   \   s    Ad*ru   dddotc                    SU -   S-   $ )Nz\dddot{ro   rp   rq   s    rs   rt   rt   ]       z!|D(ru   ddotc                    SU -   S-   $ )Nz\ddot{ro   rp   rq   s    rs   rt   rt   ^   s    ik$&ru   dotc                    SU -   S-   $ )Nz\dot{ro   rp   rq   s    rs   rt   rt   _       XaZ_ru   checkc                    SU -   S-   $ )Nz\check{ro   rp   rq   s    rs   rt   rt   `   rz   ru   brevec                    SU -   S-   $ )Nz\breve{ro   rp   rq   s    rs   rt   rt   a   rz   ru   acutec                    SU -   S-   $ )Nz\acute{ro   rp   rq   s    rs   rt   rt   b   rz   ru   gravec                    SU -   S-   $ )Nz\grave{ro   rp   rq   s    rs   rt   rt   c   rz   ru   tildec                    SU -   S-   $ )Nz\tilde{ro   rp   rq   s    rs   rt   rt   d   rz   ru   hatc                    SU -   S-   $ )Nz\hat{ro   rp   rq   s    rs   rt   rt   e   r   ru   barc                    SU -   S-   $ )Nz\bar{ro   rp   rq   s    rs   rt   rt   f   r   ru   vecc                    SU -   S-   $ )Nz\vec{ro   rp   rq   s    rs   rt   rt   g   r   ru   primec                    SU -   S-   $ N{z}'rp   rq   s    rs   rt   rt   h   s    s1uTzru   prmc                    SU -   S-   $ r   rp   rq   s    rs   rt   rt   i   s    SU4Zru   boldc                    SU -   S-   $ Nz\boldsymbol{ro   rp   rq   s    rs   rt   rt   k   s    oa',ru   bmc                    SU -   S-   $ r   rp   rq   s    rs   rt   rt   l   s    OA%d*ru   c                    SU -   S-   $ )Nz	\mathcal{ro   rp   rq   s    rs   rt   rt   m       \!^D(ru   c                    SU -   S-   $ )Nz	\mathscr{ro   rp   rq   s    rs   rt   rt   n   r   ru   c                    SU -   S-   $ )Nz
\mathfrak{ro   rp   rq   s    rs   rt   rt   o   s    mAod*ru   c                    SU -   S-   $ )Nz\left\|{z	}\right\|rp   rq   s    rs   rt   rt   q   s    k!mL0ru   c                    SU -   S-   $ )Nz\left\langle{z}\right\ranglerp   rq   s    rs   rt   rt   r   s    %a'(99ru   c                    SU -   S-   $ Nz\left|{z}\right|rp   rq   s    rs   rt   rt   s       Z\+-ru   c                    SU -   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                    U R                  SS5      n S H  nU R                  USU-   5      n M     U R                  SS5      n U R                  SS5      n U $ )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      sZ     	
		$)*AIIa" 			#)*A			#*+AHru   c                  X  ^  \ rS rSr% Sr0 SS_SS_SS_SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS_S0 _SS_SS_SS_SSSSSSSSSS.	ErS\S '   GSRS! jrGSSS" jrGSSS# jr	GSTGSSS$ jjr
S% rGSSS& jrGSUS' jrGSUS( jrGSTGSUS) jjrGSUS* jrGSUS+ jrGSUS, jrGSVS- jrS. rGSWS/ jr\r\rS0 rGSRS1 jrS2 rS3 rS4 rS5 rS6 rS7 rS8 r S9 r!S: r"S; r#GSXS< jr$S= r%S> r&GSYS? jr'GSZS@ jr(SA r)SB r*SC r+GS[SD jr,SE r-SF r.SG r/SH r0SI r1SJ r2SK r3GS\SL jr4GSRGS]SM jjr5SN r6SO r7\8SP 5       r9SQ r:SR r;SS r<GSRGSSST jjr=\==r>r?GSRSU jr@GSRSV jrAGSRSW jrBGSRSX jrCGSRSY jrDGSRSZ jrES[ rFS\ rGS] rHS^ rIS_ rJGSRS` jrKGSRSa jrLGSRSb jrMGSRSc jrNGSRSd jrOGSRSe jrPGSRSf jrQGSRSg jrRGSRSh jrSGSRSi jrTGSRSj jrUGS^Sk jrVGSRSl jrWGSRSm jrXGSRSn jrYGSRGSSSo jjrZ\Zr[GSRSp jr\GSRSq jr]GSRSr jr^GSRSs jr_GSRSt jr`GSRSu jraGSRSv jrbGSRSw jrcGSRSx jrdGSRSy jreGS_Sz jrfGSSS{ jrgGSRS| jrhGSRS} jriGSRS~ jrjGSRS jrkGSRS jrlGSRS jrmGSRS jrnGSRS jroGSRS jrpGSRS jrqGS`GSSS jjrrGS`GSSS jjrsGSRS jrtGSRS jruGSRS jrvGSRS jrwGSRS jrxGSRS jryGSRS jrzGSRS jr{GSRS jr|GSRS jr}GSRS jr~GSRS jrGSRS jrGSRS jrGSRS jrGSRS jrGSRS jrGSRS jrGSRS jrGSRS jrGSRS jrGSRS jrGSaS jrGSRS jrGSRS jrGSRS jrGSRS jrS rS rGSbGScS jjr\rGSdS jrGSbGSeS jjrS rS rS rS rS rS rS rS rS rS rS rS rS rGSRS jrS rS rS rS rS rS rS rS rS rGSfS jrGSgS jrS rS rS rS rS rS rS rS rS rGSRS jrS rS rS rS rS rS rS rGSRS jrGSRS jrGSRS jrGSRS jrGSRS jrS rS rS r\rS rGSRS jrGSRS jrGSRS jrGSRS jrGSRS jrGSRS jrGSRS jrGSRS jrS r\r\r\rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rGS  rGS rGS rGS rGS rGS rGS rGS rGS rGSRGS	 jrGSRGS
 jrGShGS jrGS rGS rGS rGS Gr GS GrGS GrGS GrGS GrGS GrGS GrGS GrGS GrGS Gr	GSRGS jGr
GS GrGS GrGS GrGS GrGS GrGS GrGS  GrGS! GrGS" GrGS# GrGS$ GrGS% GrGS& GrGS' GrG\GrGS( GrGS) GrGS* GrGS+ GrGS, GrGS- GrGS. Gr GS/ Gr!GS0 Gr"GS1 Gr#GS2 Gr$GS3 Gr%GS4 Gr&GS5 Gr'GS6 Gr(GS7 Gr)GS8 Gr*GS9 Gr+GS: Gr,GS; Gr-GS< Gr.GS= Gr/GS> Gr0GS? Gr1GS@ Gr2GSRGSA jGr3GSRGSB jGr4GSRGSC jGr5GSRGSD jGr6GSRGSE jGr7GSRGSF jGr8GSG Gr9GSH Gr:GSI Gr;GSJ Gr<GSK Gr=GSL Gr>GSM Gr?GSN Gr@GSO GrAU 4GSP jGrBGSQGrCU =GrD$ (i  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_styledisable_split_super_subzdict[str, Any]_default_settingsc                   [         R                  " X5        SU R                  ;   a"  / SQnU R                  S   U;  a  [        S5      eU R                  S   c"  U R                  S   S:X  a  SU R                  S'   SSS	S
S.n X0R                  S      U R                  S'    X0R                  S   =(       d    S   U R                  S'   SSS.U l        SSSSSSSS.nU R                  S   nUR                  XU5      U R                  S'   SSSSS .nU R                  S!   nUR                  Xw5      U R                  S"'   g ! [         a    U R                  S   U R                  S'    Nf = f! [         aT    U R                  S   R                  5       S;   a  US   U R                  S'    NU R                  S   U R                  S'    Nf = f)#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   LatexPrinter.__init__   s   (T^^#(K~~f%[8  "= > > >>+,4v&(204DNN,-  	
	- !=> NN-.

	1 !=!FG NN56 "%3/  
 NN#34	1E1I1I)1_-. 	
 70C0G0G0e,-I  	-|, NN-.	-  	1|,224BC %U+ 9: NN<0 9:	1s*   D? "'E+ ?&E('E(+=G	*G	G	c                $    SR                  U5      $ )Nz\left({}\right)formatr   rr   s     rs   _add_parensLatexPrinter._add_parens   s    !((++ru   c                $    SR                  U5      $ )Nz\left( {}\right)r  r  s     rs   _add_parens_lspaceLatexPrinter._add_parens_lspace   s    "))!,,ru   c                    [        U5      nU(       a'  U(       a   U R                  U R                  U5      5      $ XR:  d  U(       d%  XR::  a   U R                  U R                  U5      5      $ U R                  U5      $ N)r   r  _print)r   itemlevelis_negstrictprec_vals         rs   parenthesizeLatexPrinter.parenthesize   sa    )$/f##DKK$566v83D##DKK$566;;t$$ru   c                ~    SU;   a6  U R                   S   (       a  U R                  U5      $ SR                  U5      $ U$ )zt
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   LatexPrinter.parenthesize_super   s=     !8~~23''**q))ru   c                    [         R                  " X5      nU R                  S   S:X  a  U$ U R                  S   S:X  a  SU-  $ U R                  S   (       a  SU-  $ U R                  S   nSU< SU< S	U< S3$ )
Nr   r   r   z$%s$r   z$$%s$$z\begin{ro   z\end{)r   doprintr   )r   exprtexenv_strs       rs   r  LatexPrinter.doprint
  sr    ood)>>&!W,J^^F#x/S= ^^F#s?"nnV,G.5sGDDru   c                    UR                   =(       a    UR                  =(       d:    UR                  =(       a'    U[        R                  L=(       a    UR
                  SL (       + $ )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_bracketsLatexPrinter._needs_brackets  sT     __<)<)< J I$amm*C +H.2.>.>%.GK 	Kru   c                   U R                  U5      (       d  gUR                  (       a  U R                  U5      (       d  gUR                  (       a  U R	                  U5      (       d  gUR
                  (       d  UR                  (       a  gg)aX  
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_brackets%LatexPrinter._needs_function_brackets!  sc     ##D)) {{4#5#5d#;#;T%7%7%=%= 0 0ru   c                  ^ SSK Jn  SSKJn  SSKJn  TR                  (       a  U(       d  TR                  5       (       a  gO)[        T5      [        S   :  a  gTR                  (       a  gTR                  (       a  g[        U4S j[        4 5       5      (       a  gU(       d  [        U4S jXdU4 5       5      (       a  gg	)
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  F   >#    U  H  nTR                  U5      v   M     g 7fr  has.0xr  s     rs   	<genexpr>3LatexPrinter._needs_mul_brackets.<locals>.<genexpr>O       +Fqtxx{{F   !c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr  r3  r5  s     rs   r8  r9  R  s     B)AADHHQKK)Ar;  F)sympy.concrete.productsr/  sympy.concrete.summationsr0  sympy.integrals.integralsr1  r&  could_extract_minus_signr   r!   is_Relationalis_Piecewiseanyr	   )r   r  firstlastr/  r0  r1  s    `     rs   _needs_mul_brackets LatexPrinter._needs_mul_brackets8  s     	416;;T::<<#D)Ju,==+SF+++B(S)ABBBru   c                   ^ TR                   (       a  g[        U4S j[        4 5       5      (       a  gTR                  (       a  gg)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  F   >#    U  H  nTR                  U5      v   M     g 7fr  r3  r5  s     rs   r8  3LatexPrinter._needs_add_brackets.<locals>.<genexpr>_  r:  r;  F)rA  rC  r	   r*  r"  s    `rs   _needs_add_brackets LatexPrinter._needs_add_bracketsW  s4     +SF+++;;ru   c                P    UR                    H  nUR                  (       d  M    g   g)NFT)argsr+  r   r  r<   s      rs   r'  LatexPrinter._mul_is_cleane  s!    99C  ru   c                B    U R                  UR                  5      (       + $ r  )r#  baser"  s     rs   r)  LatexPrinter._pow_is_cleank  s    ''		222ru   c                "    Ub  SU< SU< S3$ U$ )N\left(	\right)^{ro   rp   r   r  exps      rs   _do_exponentLatexPrinter._do_exponentn  s    ?.2C88Kru   c                4   U R                  UR                  R                  5      nUR                  (       aM  UR                   Vs/ s H  o0R	                  U5      PM     nnSnUR                  USR                  U5      5      $ SR                  U5      $ s  snf )Nz"\operatorname{{{}}}\left({}\right), z\text{{{}}})_deal_with_super_sub	__class____name__rN  r  r  join)r   r  namerM   lsrr   s         rs   _print_BasicLatexPrinter._print_Basict  su    (()@)@A99*.))4)Q++a.)B45A88D$))B-00!((..	 5s   Bc                    SU-  $ N	\text{%s}rp   r   es     rs   _print_boolLatexPrinter._print_bool}      aru   c                    SU-  $ rf  rp   rh  s     rs   _print_NoneTypeLatexPrinter._print_NoneType  rl  ru   c                   U R                  XS9nSn[        U5       H_  u  pVUS:X  a  O#UR                  5       (       a	  US-  nU* nOUS-  nU R                  U5      nU R	                  U5      (       a  SU-  nXG-  nMa     U$ )N)r   r   r    -  + \left(%s\right))_as_ordered_terms	enumerater@  r  rK  )r   r  r   termsr  r   termterm_texs           rs   
_print_AddLatexPrinter._print_Add  s    &&t&9 'GAAv..00uuu{{4(H''---8OC ( 
ru   c                L   SSK Jn  UR                  S:X  a  gU" U5      nUR                  nUR                  nUR                  S   US-
  :X  a	  X4S-
  //-   nSnU H!  nU[        U5      R                  SS5      -  nM#     UR                  S	S
5      nUR                  SS5      nU$ )Nr   Permutation\left( \right)   r   ,r   r   \left( r   \right)) sympy.combinatorics.permutationsr}  sizecyclic_form
array_formstrr   )r   r  r}  	expr_permsizrx  r   s          rs   _print_CycleLatexPrinter._print_Cycle  s    @99>$4 $$	ii??2#')!AgYK/IAAsE22H ##C4##C4ru   c                   SSK Jn  SSKJn  UR                  nUb  U" SU S3SSSS	9  OU R
                  R                  S
S5      nU(       a  U R                  U5      $ UR                  S:X  a  gUR                   Vs/ s H  oPR                  U5      PM     nn[        [        U5      5       Vs/ s H  oPR                  U5      PM     nnSR                  U5      nSR                  U5      n	SR                  X45      n
SU
-  $ s  snf s  snf )Nr   r|  )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   Tr~   &  \\ z \begin{pmatrix} %s \end{pmatrix})r  r}  sympy.utilities.exceptionsr  print_cyclicr   r   r  r  r  r  rangelenr`  )r   r  r}  r  r   r<   lowerupperrow1row2mats              rs   _print_Permutation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   =D/D	c                p    UR                   u  p#SU R                  U5      < SU R                  U5      < S3$ )Nz\sigma_{z}(r   rN  r  )r   r  permvars       rs   _print_AppliedPermutation&LatexPrinter._print_AppliedPermutation  s,    II	c%)[[%6C8HIIru   c                D   [        UR                  5      nU R                  S   (       a  SOSnSU R                  ;   a  U R                  S   OS nSU R                  ;   a  U R                  S   OS n[        UR                  X#XES9nU R                  S   nSU;   aS  UR                  S5      u  pU	S	   S
:X  a  U	SS  n	U R                  S   S:X  a  UR                  SS5      nU< U< SU	< S3$ US:X  a  gUS:X  a  gU R                  S   S:X  a  UR                  SS5      nU$ )Nr   FTr   r   )strip_zeros	min_fixed	max_fixedr   ri  r   +r  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mantrX  s
             rs   _print_FloatLatexPrinter._print_Float  s   $**%4$','>dnnU#D(-(?t~~e$Ttzz3Sa NN#=>	(?"..-KT1v}!"g~~12g=||C.%)9c::~~12g=#++C6Oru   c                    UR                   nUR                  nU R                  U[        S   5      < SU R                  U[        S   5      < 3$ )Nr
   r   _expr1_expr2r  r!   r   r  vec1vec2s       rs   _print_CrossLatexPrinter._print_Cross  sJ    {{{{"&"3"3D*U:K"L"&"3"3D*U:K"LN 	Nru   c                R    UR                   nSU R                  U[        S   5      -  $ )Nz\nabla\times %sr
   _exprr  r!   r   r  r   s      rs   _print_CurlLatexPrinter._print_Curl  s(    jj!D$5$5c:e;L$MMMru   c                R    UR                   nSU R                  U[        S   5      -  $ )Nz\nabla\cdot %sr
   r  r  s      rs   _print_DivergenceLatexPrinter._print_Divergence  s(    jj 4#4#4S*U:K#LLLru   c                    UR                   nUR                  nU R                  U[        S   5      < SU R                  U[        S   5      < 3$ )Nr
   r   r  r  s       rs   
_print_DotLatexPrinter._print_Dot  sJ    {{{{!%!2!24E9J!K!%!2!24E9J!KM 	Mru   c                R    UR                   nSU R                  U[        S   5      -  $ )Nz	\nabla %sr
   r  r   r  funcs      rs   _print_GradientLatexPrinter._print_Gradient   (    zzd//j6GHHHru   c                R    UR                   nSU R                  U[        S   5      -  $ )Nz	\Delta %sr
   r  r  s      rs   _print_LaplacianLatexPrinter._print_Laplacian  r  ru   c                *  ^ ^^^ SSK Jn  T R                  S   mT R                  S   mSUU 4S jjnSUU U4S jjm[        U[        5      (       aD  UR
                  nUS   [        R                  L d  [        S USS   5       5      (       a  T" U5      $ S	nUR                  5       (       a  U* nS
nUR                  (       a  US-  nSnOSnU" USS9u  pxU[        R                  L a%  [        SSS	S9UR
                  ;  a  Xc" U5      -  nGOU" U5      n	U" U5      n
[        U
R                  5       5      nT R                  S   nT R                  S   (       a=  US::  a7  SU
;  a1  T R                  US	S9(       a  USU	< SU
< 3-  nGO~Xi< SU
< 3-  nGOqUGb_  [        U	R                  5       5      X-  :  Ga?  T R                  USS9(       a  USU
< ST< SU	< S3-  nGO$UR                  (       a  [        R                  n[        R                  nUR
                   Hk  nT R                  US	S9(       dI  [        U" X-  5      R                  5       5      X-  :  d"  UR                   UR                   s=L a  S	L a	  O  OX-  nMg  X-  nMm     T R                  USS9(       a#  USU" U5      < SU
< ST< SU" U5      < S3	-  nO@USU" U5      < SU
< ST< U" U5      < 3-  nOUSU
< ST< U	< 3-  nOUSU	< SU
< S3-  nU(       a  US-  nU$ ) Nr   )fractionr   r   c                  > U R                   (       d  [        TR                  U 5      5      $ TR                  S;  a  U R	                  5       nO[        U R                  5      n[        US SS9u  p#[        US SS9u  pBT" X4-   U-   5      $ )N)oldnonec                    [        U S5      =(       d    [        U S5      =(       d-    [        U [        5      =(       a    [        U R                  S5      $ )N_scale_factoris_physical_constant)hasattr
isinstancer   rR  r7  s    rs   rt   :LatexPrinter._print_Mul.<locals>.convert.<locals>.<lambda>  sE    ?8S8yW^_`bxWy 8H)!S1  G&qvv/EF8Hru   T)binaryc                    [        U S5      $ )Nr  )r  r  s    rs   rt   r    s    ?8Sru   )r&  r  r  r   as_ordered_factorslistrN  r%   )r  rN  unitsnonunitsprefixesconvert_argsr   s        rs   convert(LatexPrinter._print_Mul.<locals>.convert  s    ;;4;;t,--::_4224D		?D #'t .HPT#V #'u.S\`"a#H$7%$?@@ru   c           	       > S=p[        U 5       H  u  p4TR                  U5      n[        US5      (       d  [        US5      (       dy  TR                  XCS:H  U[	        U 5      S-
  :H  S9(       a  SU-  n[
        S   R                  U5      (       a#  [
        S   R                  U5      (       a  UT-  nOU(       a  UT-  nOU(       a  UT-  nX-  nUnM     U$ )Nr   r  r  r   r  )rD  rE  rs  )ru  r  r  rF  r  _between_two_numbers_psearchmatch)	rN  _texlast_term_texr   rw  rx  	numbersepr   r  s	         rs   r  -LatexPrinter._print_Mul.<locals>.convert_args  s    #%%D$T?;;t,o66'$H^:_:_//!V673t9q=6H 0 K#5#@.q188GG.q177AA	)	)I%D  (# +$ Kru   c              3  B   #    U  H  n[        U[        5      v   M     g 7fr  )r  r   )r6  r<   s     rs   r8  *LatexPrinter._print_Mul.<locals>.<genexpr>;  s     &S(3z#v'>'>(s   r  F- r   Tr   )exactr  )evaluater   r      r   )rE  rU  z
\right) / z / z	\frac{1}{ro   r  \frac{}{r   returnr  )sympy.simplifyr  r   r  r
   rN  r   OnerC  r@  r*  r   r  r  rF  r&  is_commutative)r   r  r  r  rN  include_parensr  numerdenomsnumersdenomldenomratioabr7  r  r  r  s   `               @@@rs   
_print_MulLatexPrinter._print_Mul  s   +(:;	(BC		A 	A 	 	8 dC  99DAw!%%3&S$qr(&S#S#S#D))((**5DC{{s
!%CD1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 #GACL$6$6$8 9EL H!"!1!1Q5E5E!N!NFAFA ( ///=&qz69gaj J J &qz69gaj J J &)VLLC66::3JC
ru   c                    UR                   (       a-  U R                  UR                  5       R                  5       5      $ U R                  UR                  5       5      $ r  )
is_aliasedr  as_polyas_exprr"  s     rs   _print_AlgebraicNumber#LatexPrinter._print_AlgebraicNumber{  s<    ??;;t||~55788;;t||~..ru   c                    U R                  UR                  5      nUR                  (       a  SU S3$ U R                  UR                  R	                  5       5      nSU SU S3$ )NrU  r  r\  )r  pis_inertalphar  )r   r  r  r  s       rs   _print_PrimeIdealLatexPrinter._print_PrimeIdeal  sZ    KK==QCw''DJJ..012eWG,,ru   c                   UR                   R                  (       Ga|  UR                   R                  nUR                   R                  n[	        U5      S:X  a  US:w  a~  U R
                  S   (       aj  U R                  UR                  5      nUS:X  a  SU-  nO!U R
                  S   (       a  SX44-  nOSX44-  nUR                   R                  (       a  SU-  $ U$ U R
                  S	   (       a  US:w  a  U R                  UR                  [        S
   5      nUR                  R                  (       a  U R                  U5      nUR                  R                  (       a!  U R                  UR                  U< SU< 3S9$ U< SU< SU< S3$ UR                   R                  (       a  UR                  R                  (       a  UR                  S:X  a  UR                  < SUR                   < S3$ UR                  R                  (       az  UR                  R                  nUR                  R                  nXg-  [	        U5      :X  a=  UR                   S:X  a  SU< SU< S3$ SU< SU< S[	        UR                   5      < S3$ U R                  U5      $ UR                  R                  (       a3  U R                  UR                  U R                  UR                   5      S9$ SnU R!                  X5      $ )Nr  r   r  z	\sqrt{%s}r   z\root{%d}{%s}z\sqrt[%d]{%s}z\frac{1}{%s}r   r   /rX  ^{ro   r  z\frac{1}{\frac{r  }}z\frac{1}{(\frac{z})^{z%s^{%s})rX  r!  r  qr   r   r  rR  is_negativer  r!   	is_Symbolr   r+  r  r  _helper_print_standard_power)r   r  r  r  rR  r  base_pbase_qs           rs   
_print_PowLatexPrinter._print_Pow  s)   88XXZZAXXZZA1v{qAv$..*I{{499-6&-C^^F+*aY6C*aY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;;ru   c                   U R                  UR                  5      nU R                  UR                  [        S   5      nUR                  R
                  (       a  U R                  U5      nOUR                  R                  (       a  SU-  nOl[        UR                  [        5      (       aM  UR                  S5      (       a7  [        R                  " SU5      (       a  UR                  S5      (       a  USS nX$U4-  $ )Nr   z{%s}rU  z\\left\(\\d?d?dotr     i)r  rX  r  rR  r!   r   r   is_Floatr  r   
startswithr8   r  endswith)r   r  templaterX  rR  s        rs   r!  )LatexPrinter._helper_print_standard_power  s    kk$((#   Ju,=>99**40DYYT>DJ//	**-t44j))2;D+%%ru   c                >    U R                  UR                  S   5      $ Nr   r  rN  r"  s     rs   _print_UnevaluatedExpr#LatexPrinter._print_UnevaluatedExpr  s    {{499Q<((ru   c           
       ^  [        UR                  5      S:X  a<  S[        UR                  S    Vs/ s H  nT R                  U5      PM     sn5      -  nO?U 4S jnS[        R                  SUR                   Vs/ s H
  oT" U5      PM     sn5      -  n[        UR                  [        5      (       a#  UST R                  UR                  5      -  -  nU$ UT R                  UR                  5      -  nU$ s  snf s  snf )Nr  z\sum_{%s=%s}^{%s} r   c           	        > S[        U S   U S   U S   4 Vs/ s H  nTR                  U5      PM     sn5      -  $ s  snf Nz%s \leq %s \leq %sr  r   r  tupler  lrr   r   s     rs   _format_ineq-LatexPrinter._print_Sum.<locals>._format_ineq  I    ,AaD!A$!3EF3Ea4;;q>3EFGH HF   <
z\sum_{\substack{%s}} \\rs  	r  limitsr6  r  r  r`  r  functionr   r   r  r   r  r9  r8  s   `     rs   
_print_SumLatexPrinter._print_Sum  s    t{{q 't{{1~>~!t{{1~~>?@CH +4;;!G;a,q/;!GHIC dmmS))%DMM(BBBC 
 4;;t}}--C
 ? "H   C8
<C=c           
       ^  [        UR                  5      S:X  a<  S[        UR                  S    Vs/ s H  nT R                  U5      PM     sn5      -  nO?U 4S jnS[        R                  SUR                   Vs/ s H
  oT" U5      PM     sn5      -  n[        UR                  [        5      (       a#  UST R                  UR                  5      -  -  nU$ UT R                  UR                  5      -  nU$ s  snf s  snf )Nr  z\prod_{%s=%s}^{%s} r   c           	        > S[        U S   U S   U S   4 Vs/ s H  nTR                  U5      PM     sn5      -  $ s  snf r4  r5  r7  s     rs   r9  1LatexPrinter._print_Product.<locals>._format_ineq  r;  r<  z\prod_{\substack{%s}} r=  rs  r>  rA  s   `     rs   _print_ProductLatexPrinter._print_Product  s    t{{q (t{{1~>~!t{{1~~>?@CH ,4;;!G;a,q/;!GHIC dmmS))%DMM(BBBC 
 4;;t}}--C
 ? "HrD  c                   SSK Jn  / nXR                  :X  a  UR                  R                  $ [	        X5      (       a  UR                  5       R                  5       nOSU4/nU H  u  pV[        UR                  R                  5       5      nUR                  S S9  U H  u  pU	S:X  a   UR                  SUR                  -   5        M+  U	S:X  a   UR                  SUR                  -   5        MQ  S	U R                  U	5      -   S
-   n
UR                  SU
-   UR                  -   5        M     M     SR                  U5      nUS   S:w  a  USS  nU$ USS  nU$ )Nr   )Vectorc                (    U S   R                  5       $ r.  )__str__r  s    rs   rt   4LatexPrinter._print_BasisDependent.<locals>.<lambda>  s    !A$,,.ru   keyr  rr  r  rq  rU  r  r   -   )sympy.vectorrK  zero_latex_formr  separateitemsr  
componentssortappendr  r`  )r   r  rK  o1rW  systemvect
inneritemskvarg_stroutstrs               rs   _print_BasisDependent"LatexPrinter._print_BasisDependent  s3   '9999(((d##MMO))+EYKE!LFdoo3356JOO 8O9"6IIeamm34"WIIeamm34'$++a.8:EGIIego=> # " ''"+!9ABZF  ABZFru   c                    U R                  UR                  5      nSU-   S-   SSR                  [        U R                   UR                  5      5      -  -   nU$ )Nr   ro   _{%s}r  )r  rR  r`  mapindices)r   r  tex_baser  s       rs   _print_IndexedLatexPrinter._print_Indexed  sP    ;;tyy)(l3wT\\**,  , ,
ru   c                8    U R                  UR                  5      $ r  )r  labelr"  s     rs   _print_IndexedBaseLatexPrinter._print_IndexedBase  s    {{4::&&ru   c                X   U R                  UR                  5      nUR                  b  U R                  UR                  5      nUR                  b  U R                  UR                  5      nOU R                  [        R
                  5      nSR                  XCS9nSR                  X%S9$ U$ )Nz%{lower}\mathrel{{..}}\nobreak {upper})r  r  z{{{label}}}_{{{interval}}})rm  interval)r  rm  r  r  r   Zeror  )r   r  rm  r  r  rq  s         rs   
_print_IdxLatexPrinter._print_Idx  s    DJJ'::!KK

+Ezz%DJJ/AFF+@GG! H 2H/66 7 4 4 ru   c           	        [        UR                  5      (       a  SnOU R                  S   nSnSn[        UR                  5       Hh  u  pVXF-  nUS:X  a  X2< SU R                  U5      < 3-  nM+  X2< SU R                  U R                  U5      5      < SU R                  U5      < S3-  nMj     US:X  a  S	U< S
U< S3nOS	U< SU R                  U5      < SU< S3n[        S UR                   5       5      (       a*  U< SU R                  UR                  [        S   SSS9< 3$ U< SU R                  UR                  [        S   SSS9< 3$ )Nz\partialr   r   r   r  r   r  ro   r  r  }}{c              3  @   #    U  H  oR                  5       v   M     g 7fr  r@  r6  r   s     rs   r8  1LatexPrinter._print_Derivative.<locals>.<genexpr>;  s     ?Y))++Y   r
   Tr  r  F)r   r  r   reversedvariable_countr  r   rC  rN  r  r!   )r   r  diff_symbolr  dimr7  nums          rs   _print_DerivativeLatexPrinter._print_Derivative%  sN   DII&&%K..)>?Kt223FAJCax;A??(,(?(?A(O(,C(8: : 4 !8&137C  ,7C8H#NC?TYY???"D$5$5dii2<U2C9=9= %6 %? @ @
  1 1$))2<U2C9>9= !2 !? @ 	@ru   c                   ^  UR                   u  p#nT R                  U5      nU 4S jU 5       nU 4S jU 5       nSR                  S [        Xg5       5       5      nSU< SU< S3$ )Nc              3  F   >#    U  H  nTR                  U5      v   M     g 7fr  r  r6  ri  r   s     rs   r8  +LatexPrinter._print_Subs.<locals>.<genexpr>I       1ST[[^^Sr;  c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr  r  r  s     rs   r8  r  J  r  r;  z\\ c              3  <   #    U  H  oS    S-   US   -   v   M     g7f)r   =r  Nrp   )r6  ri  s     rs   r8  r  K  s$      !B'@!aD3J1'@s   z\left. z \right|_{\substack{ z }})rN  r  r`  zip)	r   subsr  r  new
latex_expr	latex_old	latex_new
latex_subss	   `        rs   _print_SubsLatexPrinter._print_SubsF  sg    3[[&
1S1	1S1	[[ !B'*9'@!B B
9C9CE 	Eru   c           
        S/ p2U R                   S   n[        UR                  5      S::  ax  [        S UR                   5       5      (       aW  SS[        UR                  5      S-
  -  -   S-   nUR                   Vs/ s H  nS	U< U R	                  US
   5      < 3PM      nnO[        UR                  5       H  nUS
   nUS-  n[        U5      S:  a  U R                   S   S:w  a  U R                   S   (       d  US-  n[        U5      S:X  a2  USU R	                  US   5      < SU R	                  US   5      < S3-  n[        U5      S:X  a  USU R	                  US   5      -  -  nUR                  S
S	U< U R	                  U5      < 35        M     U< SU R                  UR                  [        S   [        S UR                   5       5      SS9< SR                  U5      < 3$ s  snf )Nr   r      c              3  >   #    U  H  n[        U5      S :H  v   M     g7f)r  N)r  )r6  lims     rs   r8  /LatexPrinter._print_Integral.<locals>.<genexpr>U  s     (N+3SQ+s   z\ir   r  ntz\, r   z\intr   r   r   z\limitsrR  _{}^{r  ro   ^{%s}r   r
   c              3  @   #    U  H  oR                  5       v   M     g 7fr  rx  ry  s     rs   r8  r  p  s     >oen`a?Y?Y?[?[enr{  Tr|  )r   r  r?  allr  r}  insertr  r@  r!   rC  rN  r`  )r   r  r  symbolsr  symbolr  s          rs   _print_IntegralLatexPrinter._print_IntegralP  s   2Wnn%:; t{{q S(N$++(N%N%N #s4;;/!344t;C%)[[2%06 &1$++fQi2HI%0  2G  ,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 -" !$"3"3DMM4>u4E;>>oeienen>o;o;? #4 #A  WWW-	/ 	/+2s   <%G-c                   UR                   u  p#pESU R                  U5      -  n[        U5      S:X  d$  U[        R                  [        R
                  4;   a  USU R                  U5      -  -  nO*X`R                  U5      < SU R                  U5      < S3-  n[        U[        5      (       a  U< SU R                  U5      < S3$ U< SU R                  U5      < 3$ )	Nz\lim_{%s \to z+-z%s}r   ro   rU  r  r   )rN  r  r  r   InfinityNegativeInfinityr  r   )r   r  ri  zz0dirr  s          rs   _print_LimitLatexPrinter._print_Limitt  s    		bQ/s8trajj!2D2D%EE6DKKO++CBS1ABBCa!!+.A??"DKKN33ru   c                   U R                  U5      nUR                  S5      nUR                  S5      nU[        ;   a  SU-  nU$ [        U5      S:X  d"  UR	                  S5      (       d  US:X  d  US:X  a  UnU$ US:  a*  US:  a$  SUS[        X25       < S	U[        X25      S < 3nU$ US:  a  SUSU < S	XS < 3nU$ US:  a  SUSU < S	XS < 3nU$ S
U-  nU$ )a;  
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\%sr  r   r   \operatorname{Nro   z\operatorname{%s})r]  findaccepted_latex_functionsr  r)  r   )r   r  superscriptidxsubscriptidxra  s        rs   _hprint_FunctionLatexPrinter._hprint_Function  s!    ((.3yy~++D=D$ # Y!^tt448I^_`M`D   !lQ&6:#l:;\9:;=   !#.))+  !,'')
  ,d2ru   c                   UR                   R                  n[        U SU-   5      (       a*  [        U[        5      (       d  [        U SU-   5      " X5      $ UR                   Vs/ s H  n[        U R                  U5      5      PM     nnU R                  S   nSnU R                  S   =(       a8    [        U5      S:H  =(       a#    U R                  UR                  S   5      (       + n/ SQn	X9;   a3  US:X  a  O,US	:X  a  US
   S:X  a  SOSUSS -   nOUS:X  a  USS nSnUb  SnU(       a  U[        ;   a  SU-  n
OGSU-  n
OAUb-  U R                  U5      nU R                  U5      nU< SU< S3n
OU R                  U5      n
U(       a  U[        ;   a  U
S-  n
OU
S-  n
OU
S-  n
U(       a  Ub  U
SU-  -  n
U
SR                  U5      -  $ s  snf )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   r  r   )asinacosatanacscasecacotasinhacoshatanhacschasechacothr   fullr  hararcNpowerTz\%s^{-1}z\operatorname{%s}^{-1}r  ro   z {%s}%s{\left(%s \right)}r  r  )r  r_  r  r  r   getattrrN  r  r  r   r  r,  r  r  r   r`  )r   r  rX  r  r<   rN  r   inv_trig_power_casecan_fold_bracketsinv_trig_tablera  func_texs               rs   _print_FunctionLatexPrinter._print_Function  s    yy!!4T)**t\224T!124==59YY?YcCC()YD? "^^,<=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   #$G
c                6    U R                  [        U5      5      $ r  )r  r  r"  s     rs   _print_UndefinedFunction%LatexPrinter._print_UndefinedFunction  s    $$SY//ru   c                |    SU R                  UR                  5      < SU R                  UR                  5      < S3$ )Nr   z}_{\circ}\left({z}\right))r  r@  r  r"  s     rs   _print_ElementwiseApplyFunction,LatexPrinter._print_ElementwiseApplyFunction  s,    KK&KK		"
 	
ru   c                ^    SSK Jn  SSKJnJn  SSKJn  SSKJn  SSK	J
n  USUSUS	US
USUS0$ )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_classes&LatexPrinter._special_function_classes  s;    KM?F?		I)I*, 	,ru   c                    U R                    H@  n[        X5      (       d  M  UR                  UR                  :X  d  M1  U R                   U   s  $    U R                  [	        U5      5      $ r  )r  
issubclassr_  r  r  )r   r  clss      rs   _print_FunctionClass!LatexPrinter._print_FunctionClass  sT    11C$$$#,,)F55c:: 2 $$SY//ru   c                    UR                   u  p![        U5      S:X  a  U R                  US   5      nOU R                  [        U5      5      nSU< SU R                  U5      < S3nU$ )Nr  r   r  z	 \mapsto  \right))rN  r  r  r6  )r   r  r  r  s       rs   _print_LambdaLatexPrinter._print_Lambda  sV    		w<1kk'!*-Gkk%.1G18$++d:KL
ru   c                    g)Nz\left( x \mapsto x \right)rp   r"  s     rs   _print_IdentityFunction$LatexPrinter._print_IdentityFunction  s    ,ru   c                   [        UR                  [        S9nU Vs/ s H  nSU R                  U5      -  PM     nnS[	        UR
                  5      R                  5       < SSR                  U5      < S3nUb
  U< SU< S3$ U$ s  snf )	NrO  r  r   rU  r\  r  r  ro   )sortedrN  r   r  r  r  r  r`  )r   r  rX  rN  r  texargsr  s          rs   _hprint_variadic_function&LatexPrinter._hprint_variadic_function  sy    dii%56=ABT654;;v..TB'*499~';';'='+yy'9;?!$c**J Cs   Bc                b    SU R                  UR                  S   5      -  nUb
  U< SU< S3$ U$ )Nz\left\lfloor{%s}\right\rfloorr   r  ro   r/  r   r  rX  r  s       rs   _print_floorLatexPrinter._print_floor&  s2    .TYYq\1JJ?!$c**Jru   c                b    SU R                  UR                  S   5      -  nUb
  U< SU< S3$ U$ )Nz\left\lceil{%s}\right\rceilr   r  ro   r/  r  s       rs   _print_ceilingLatexPrinter._print_ceiling.  s2    ,t{{499Q</HH?!$c**Jru   c                    U R                   S   (       d"  SU R                  UR                  S   5      -  nO!SU R                  UR                  S   5      -  nUb
  U< SU< S3$ U$ )Nr   z\log{\left(%s \right)}r   z\ln{\left(%s \right)}r  ro   )r   r  rN  r  s       rs   
_print_logLatexPrinter._print_log6  sY    ~~m,+dkk$))A,.GGC*T[[1-FFC?!$c**Jru   c                b    SU R                  UR                  S   5      -  nUb
  U< SU< S3$ U$ )N\left|{%s}\right|r   r  ro   r/  r  s       rs   
_print_AbsLatexPrinter._print_AbsA  s2    "T[[1%>>?!$c**Jru   c                
   U R                   S   (       a*  SU R                  UR                  S   [        S   5      -  nO5SR	                  U R                  UR                  S   [        S   5      5      nU R                  X25      $ )Nr   z\Re{%s}r   Atomz\operatorname{{re}}{{{}}}r   r  rN  r!   r  rY  r  s       rs   	_print_reLatexPrinter._print_reI  p    >>.)t001z&?QRRC.55d6G6G		RSV`agVh6ijC  **ru   c                
   U R                   S   (       a*  SU R                  UR                  S   [        S   5      -  nO5SR	                  U R                  UR                  S   [        S   5      5      nU R                  X25      $ )Nr   z\Im{%s}r   r  z\operatorname{{im}}{{{}}}r  r  s       rs   	_print_imLatexPrinter._print_imQ  r  ru   c                   SSK JnJn  [        UR                  S   U5      (       a  U R                  UR                  S   S5      $ [        UR                  S   U5      (       a  U R                  UR                  S   S5      $ UR                  S   R                  (       a!  SU R                  UR                  S   5      -  $ SU R                  UR                  S   5      -  $ )Nr   )
EquivalentImpliesz\not\Leftrightarrowz\not\Rightarrowz\neg \left(%s\right)z\neg %s)	sympy.logic.boolalgr  r  r  rN  _print_Equivalent_print_Implies
is_Booleanr  )r   ri  r  r  s       rs   
_print_NotLatexPrinter._print_NotY  s    =affQi,,))!&&)5KLLaffQi))&&qvvay2DEEFF1I  *T[[-CCCAFF1I 666ru   c                x   US   nUR                   (       a&  UR                  (       d  SU R                  U5      -  nOSU R                  U5      -  nUSS   H`  nUR                   (       a0  UR                  (       d  USU< SU R                  U5      < S3-  nMD  USU< SU R                  U5      < 3-  nMb     U$ )Nr   rs  r  r  r   z \left(r  )r  is_Notr  )r   rN  charr<   r  s        rs   _print_LogOpLatexPrinter._print_LogOpd  s    1g>>#**$t{{3'77C$++c**C8C~~cjjt{{37GHHD$++c*:;;	  
ru   c                V    [        UR                  [        S9nU R                  US5      $ )NrO  z\wedger  rN  r   r  r   ri  rN  s      rs   
_print_AndLatexPrinter._print_Ands  s&    aff"23  y11ru   c                V    [        UR                  [        S9nU R                  US5      $ )NrO  z\veer  r  s      rs   	_print_OrLatexPrinter._print_Orw  s&    aff"23  w//ru   c                V    [        UR                  [        S9nU R                  US5      $ )NrO  z\veebarr  r  s      rs   
_print_XorLatexPrinter._print_Xor{  s&    aff"23  z22ru   c                L    U R                  UR                  U=(       d    S5      $ )Nz\Rightarrow)r  rN  )r   ri  altchars      rs   r  LatexPrinter._print_Implies  s      )BNCCru   c                f    [        UR                  [        S9nU R                  X2=(       d    S5      $ )NrO  z\Leftrightarrowr  )r   ri  r)  rN  s       rs   r  LatexPrinter._print_Equivalent  s*    aff"23  'D2DEEru   c                b    SU R                  UR                  S   5      -  nUb
  U< SU< S3$ U$ )Nz\overline{%s}r   r  ro   r/  r  s       rs   _print_conjugateLatexPrinter._print_conjugate  s2    TYYq\!::?!$c**Jru   c                x    SnSU R                  UR                  S   5      -  nUb  U< SU< SU< 3$ U< U< 3$ )Nz\operatorname{polar\_lift}r  r   r  ro   r/  )r   r  rX  r  r<   s        rs   _print_polar_liftLatexPrinter._print_polar_lift  s?    ,#dkk$))A,&???#'c22"C((ru   c                f    SU R                  UR                  S   5      -  nU R                  X25      $ )Nze^{%s}r   )r  rN  rY  r  s       rs   _print_ExpBaseLatexPrinter._print_ExpBase  s0     $++diil33  **ru   c                    g)Nri  rp   rW  s      rs   _print_Exp1LatexPrinter._print_Exp1  s    ru   c                h    SU R                  UR                  S   5      -  nUb
  SU< SU< 3$ SU-  $ )Nrs  r   zK^{ro   zK%sr/  r  s       rs   _print_elliptic_kLatexPrinter._print_elliptic_k  s7     4;;tyy|#<<?"%s++C<ru   c                    SU R                  UR                  S   5      < SU R                  UR                  S   5      < S3nUb
  SU< SU< 3$ SU-  $ )	NrU  r   	\middle| r  r  zF^{ro   zF%sr/  r  s       rs   _print_elliptic_fLatexPrinter._print_elliptic_f  sK    [[1&DIIaL(AC?"%s++C<ru   c                "   [        UR                  5      S:X  aD  SU R                  UR                  S   5      < SU R                  UR                  S   5      < S3nO!SU R                  UR                  S   5      -  nUb
  SU< S	U< 3$ S
U-  $ )Nr  rU  r   r=  r  r  rs  zE^{ro   zE%sr  rN  r  r  s       rs   _print_elliptic_eLatexPrinter._print_elliptic_e  sx    tyy>QTYYq\*DKK		!,EGC %t{{499Q<'@@C?"%s++C<ru   c           	        [        UR                  5      S:X  ad  SU R                  UR                  S   5      < SU R                  UR                  S   5      < SU R                  UR                  S   5      < S3nOCSU R                  UR                  S   5      < SU R                  UR                  S   5      < S3nUb
  S	U< S
U< 3$ SU-  $ )NrR  rU  r   ; r  r=  r  r  z\Pi^{ro   z\Pi%srA  r  s       rs   _print_elliptic_piLatexPrinter._print_elliptic_pi  s    tyy>QTYYq\*DKK		!,ETYYq\*,C  TYYq\*DKK		!,EGC?$'--c>!ru   c                    UR                   S   n[        UR                   5      S:X  a  UR                   S   OUR                   S   nSU SU S3nUb
  SU< SU< 3$ SU-  $ )	Nr   r  rU  r\  r  z\operatorname{B}^{ro   z\operatorname{B}%s)rN  r  )r   r  rX  r7  yr  s         rs   _print_betaLatexPrinter._print_beta  sd    IIaL		Na/DIIaLTYYq\s"QCw'?14c::(3..ru   c           
         UR                    Vs/ s H  o@R                  U5      PM     nnSUS   < SUS   < S3nUb  SU< SUS   < SUS	   < S
U< SU< 3
$ SU< SUS   < SUS	   < SU< 3$ s  snf )NrU  r   r\  r  r  r  z}_{(r  rR  z)}^{ro   z)}r  )r   r  rX  operatorr<   largsr  s          rs   _print_betaincLatexPrinter._print_betainc  s~    -1YY7YcS!Y7(-a%(;?=EuQxQVWXQY[^`cdd  9A%(ERSHVYZZ 8s   A3c                "    U R                  XSS9$ )NI)rM  )rO  rW  s      rs   _print_betainc_regularized'LatexPrinter._print_betainc_regularized  s    ""4s";;ru   c                    SU R                  UR                  S   5      < SU R                  UR                  S   5      < S3nUb
  SU< SU< 3$ SU-  $ )	NrU  r   r\  r  r  z\Gamma^{ro   z\Gamma%sr/  r  s       rs   _print_uppergammaLatexPrinter._print_uppergamma  O    (,DIIaL(A(,DIIaL(AC ?'*C00$$ru   c                    SU R                  UR                  S   5      < SU R                  UR                  S   5      < S3nUb
  SU< SU< 3$ SU-  $ )	NrU  r   r\  r  r  z\gamma^{ro   \gamma%sr/  r  s       rs   _print_lowergammaLatexPrinter._print_lowergamma  rX  ru   c                    SU R                  UR                  S   5      -  nUb&  U R                  UR                  5      < SU< SU< 3$ U R                  UR                  5      < U< 3$ Nrs  r   r  ro   )r  rN  r  r  s       rs   _hprint_one_arg_func!LatexPrinter._hprint_one_arg_func  sT     4;;tyy|#<<?#';;tyy#93DD"kk$))4c::ru   c                h    SU R                  UR                  S   5      -  nUb
  SU< SU< 3$ SU-  $ )Nrs  r   z\operatorname{Chi}^{ro   z\operatorname{Chi}%sr/  r  s       rs   
_print_ChiLatexPrinter._print_Chi  s8     4;;tyy|#<<?36<<*S00ru   c                    SU R                  UR                  S   5      -  nU R                  UR                  S   5      nUb  SU< SU< SU< 3$ SU< SU< 3$ )Nrs  r  r   z\operatorname{E}_{r  ro   r/  )r   r  rX  r  nus        rs   _print_expintLatexPrinter._print_expint  sW     4;;tyy|#<<[[1&?68#sCC  24S99ru   c                h    SU R                  UR                  S   5      -  nUb
  SU< SU< 3$ SU-  $ )Nrs  r   zS^{ro   zS%sr/  r  s       rs   _print_fresnelsLatexPrinter._print_fresnels  7     4;;tyy|#<<?"%s++C<ru   c                h    SU R                  UR                  S   5      -  nUb
  SU< SU< 3$ SU-  $ )Nrs  r   zC^{ro   zC%sr/  r  s       rs   _print_fresnelcLatexPrinter._print_fresnelc  rk  ru   c                t    SU R                  UR                  S   [        S   5      -  nUb  SU< SU< S3$ U$ )Nz!%sr   FuncrU  rV  ro   r  rN  r!   r  s       rs   _print_subfactorial LatexPrinter._print_subfactorial  s;    t((1z&7IJJ?.1377Jru   c                r    SU R                  UR                  S   [        S   5      -  nUb
  U< SU< S3$ U$ )Nz%s!r   rp  r  ro   rq  r  s       rs   _print_factorialLatexPrinter._print_factorial#  s;    t((1z&7IJJ?!$c**Jru   c                r    SU R                  UR                  S   [        S   5      -  nUb
  U< SU< S3$ U$ )Nz%s!!r   rp  r  ro   rq  r  s       rs   _print_factorial2LatexPrinter._print_factorial2+  s;    ))$))A,
68JKK?!$c**Jru   c                    SU R                  UR                  S   5      < SU R                  UR                  S   5      < S3nUb
  U< SU< S3$ U$ )Nz{\binom{r   r  r  r  r  ro   r/  r  s       rs   _print_binomialLatexPrinter._print_binomial3  sI    %)[[1%>%)[[1%>@ ?!$c**Jru   c                    UR                   u  p4SU R                  U[        S   5      -  nSU< SU R                  U5      < S3nU R	                  Xb5      $ )Nr  rp  r   	}^{\left(\right)}rN  r  r!   r  rY  )r   r  rX  nr_  rR  r  s          rs   _print_RisingFactorial#LatexPrinter._print_RisingFactorial<  sL    yyt((Jv,>??+/Q@  **ru   c                    UR                   u  p4SU R                  U[        S   5      -  nSU R                  U5      < SU< S3nU R	                  Xb5      $ )Nr  rp  z{\left(z
\right)}_{ro   r  )r   r  rX  r  r_  subr  s          rs   _print_FallingFactorial$LatexPrinter._print_FallingFactorialD  sL    yyd'':f+=>>+/;;q>3?  **ru   c                   SU-  nSnUb"  UR                  S5      S:X  a  U< SU< S3nOSnU< SU R                  UR                  5      < S	U R                  UR                  5      < S
3nU(       a  U R	                  XB5      nU$ )Nr  Fr   r  r  ro   Tr  }\left(r  )r  r  r   argumentrY  )r   r  rX  symr  need_exps         rs   _hprint_BesselBaseLatexPrinter._hprint_BesselBaseL  sx    sm?xx}"$'-+.DJJ0G+/;;t}}+EG ##C-C
ru   c                    U(       d  gSnUS S  H  nUSU R                  U5      -  -  nM     X R                  US   5      -  nU$ )Nr   r  z%s, r  )r   r   rr   r   s       rs   _hprint_vecLatexPrinter._hprint_vec]  sN    SbA$++a.((A 	[[R!!ru   c                &    U R                  XS5      $ )NJr  rW  s      rs   _print_besseljLatexPrinter._print_besseljf      &&t#66ru   c                &    U R                  XS5      $ )NrR  r  rW  s      rs   _print_besseliLatexPrinter._print_besselii  r  ru   c                &    U R                  XS5      $ )NKr  rW  s      rs   _print_besselkLatexPrinter._print_besselkl  r  ru   c                &    U R                  XS5      $ )NYr  rW  s      rs   _print_besselyLatexPrinter._print_besselyo  r  ru   c                &    U R                  XS5      $ )NrI  r  rW  s      rs   	_print_ynLatexPrinter._print_ynr  r  ru   c                &    U R                  XS5      $ )Nr   r  rW  s      rs   	_print_jnLatexPrinter._print_jnu  r  ru   c                &    U R                  XS5      $ )NzH^{(1)}r  rW  s      rs   _print_hankel1LatexPrinter._print_hankel1x      &&t)<<ru   c                &    U R                  XS5      $ )NzH^{(2)}r  rW  s      rs   _print_hankel2LatexPrinter._print_hankel2{  r  ru   c                &    U R                  XS5      $ )Nzh^{(1)}r  rW  s      rs   
_print_hn1LatexPrinter._print_hn1~  r  ru   c                &    U R                  XS5      $ )Nzh^{(2)}r  rW  s      rs   
_print_hn2LatexPrinter._print_hn2  r  ru   c                t    SU R                  UR                  S   5      -  nUb  U< SU< SU< 3$ U< U< 3$ r^  r/  r   r  rX  notationr  s        rs   _hprint_airyLatexPrinter._hprint_airy  s:     4;;tyy|#<<?#+S#66&,,ru   c                x    SU R                  UR                  S   5      -  nUb  SU< SU< SU< 3$ U< SU< 3$ )Nrs  r   r   z
^\prime}^{ro   z^\primer/  r  s        rs   _hprint_airy_primeLatexPrinter._hprint_airy_prime  s:     4;;tyy|#<<?,4c3??%-s33ru   c                &    U R                  XS5      $ NAir  rW  s      rs   _print_airyaiLatexPrinter._print_airyai        D11ru   c                &    U R                  XS5      $ NBir  rW  s      rs   _print_airybiLatexPrinter._print_airybi  r  ru   c                &    U R                  XS5      $ r  r  rW  s      rs   _print_airyaiprimeLatexPrinter._print_airyaiprime      &&t$77ru   c                &    U R                  XS5      $ r  r  rW  s      rs   _print_airybiprimeLatexPrinter._print_airybiprime  r  ru   c                n   SU R                  [        UR                  5      5      < SU R                  [        UR                  5      5      < SU R	                  UR                  5      < SU R	                  UR                  5      < SU R                  UR
                  5      < S3nUb  SU< SU< S	3nU$ )
Nz{{}_{z}F_{}\left(\begin{matrix} r  z \end{matrix}\middle| {
} \right)}r   r  ro   )r  r  apbqr  r  r  s       rs   _print_hyperLatexPrinter._print_hyper  s{     [[TWW&CL(Atww')9)9$'')Bkk$--(	* ?"%s+C
ru   c                z   SU R                  [        UR                  5      5      < SU R                  [        UR                  5      5      < SU R                  [        UR                  5      5      < SU R                  [        UR
                  5      5      < SU R                  UR
                  5      < SU R                  UR                  5      < SU R                  UR                  5      < SU R                  UR                  5      < SU R                  UR                  5      < S3nUb  S	U< SU< S
3nU$ )Nz{G_{r\  r  r  r   \\z \end{matrix} \middle| {r  r   ro   )
r  r  r  r  r   anr  aotherbotherr  r  s       rs   _print_meijerg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                h    SU R                  UR                  S   5      -  nUb
  SU< SU< 3$ SU-  $ )Nrs  r   z\eta^{ro   z\eta%sr/  r  s       rs   _print_dirichlet_eta!LatexPrinter._print_dirichlet_eta  s7     4;;tyy|#<<?%(#..3ru   c                    [        UR                  5      S:X  a-  S[        [        U R                  UR                  5      5      -  nO!SU R	                  UR                  S   5      -  nUb
  SU< SU< 3$ SU-  $ )Nr  z\left(%s, %s\right)rs  r   z\zeta^{ro   z\zeta%sr  rN  r6  rg  r  r  s       rs   _print_zetaLatexPrinter._print_zeta  sf    tyy>Q(5T[[$))1L+MMC$t{{499Q<'@@C?&)3//Cru   c                    [        UR                  5      S:X  a-  S[        [        U R                  UR                  5      5      -  nO!SU R	                  UR                  S   5      -  nUb  SU< SU< S3$ SU-  $ )	Nr  z_{%s}\left(%s\right)rf  r   r  r  ro   rZ  r  r  s       rs   _print_stieltjesLatexPrinter._print_stieltjes  sf    tyy>Q)E#dkk4992M,NNCT[[166C?'*C00S  ru   c                ~    S[        [        U R                  UR                  5      5      -  nUc  SU-  $ SU< SU< 3$ )Nz\left(%s, %s, %s\right)z\Phi%sz\Phi^{ro   )r6  rg  r  rN  r  s       rs   _print_lerchphiLatexPrinter._print_lerchphi  s?    (5T[[$))1L+MM;s?" !$c**ru   c                    [        U R                  UR                  5      u  p4SU-  nUc
  SU< SU< 3$ SU< SU< SU< 3$ )Nrs  z\operatorname{Li}_{ro   r  rg  r  rN  )r   r  rX  rr   r  r  s         rs   _print_polylogLatexPrinter._print_polylog  sD    4;;		* 1$;23S99 34c3??ru   c           	         [        U R                  UR                  5      u  p4pVSU< SU< SU< SU< S3	nUb  SU-   SU-  -   nU$ )NP_{r~  r  \right)}\left(r  rU  \right)^{%s}r  )r   r  rX  r  r	  r
  r7  r  s           rs   _print_jacobiLatexPrinter._print_jacobi  sG    dii0
a?@!QJ?c/Os$;;C
ru   c                    [        U R                  UR                  5      u  p4nSU< SU< SU< S3nUb  SU-   SU-  -   nU$ )NzC_{r~  r  r  rU  r  r  r   r  rX  r  r	  r7  r  s          rs   _print_gegenbauerLatexPrinter._print_gegenbauer  C    dkk499-a<=q!D?c/Os$;;C
ru   c                |    [        U R                  UR                  5      u  p4SU< SU< S3nUb  SU-   SU-  -   nU$ )NzT_{r  r  rU  r  r  r   r  rX  r  r7  r  s         rs   _print_chebyshevtLatexPrinter._print_chebyshevt  A    4;;		*1*+Q/?c/Os$;;C
ru   c                |    [        U R                  UR                  5      u  p4SU< SU< S3nUb  SU-   SU-  -   nU$ )NzU_{r  r  rU  r  r  r  s         rs   _print_chebyshevuLatexPrinter._print_chebyshevu  r   ru   c                |    [        U R                  UR                  5      u  p4SU< SU< S3nUb  SU-   SU-  -   nU$ )Nr  r  r  rU  r  r  r  s         rs   _print_legendreLatexPrinter._print_legendre  r   ru   c                    [        U R                  UR                  5      u  p4nSU< SU< SU< S3nUb  SU-   SU-  -   nU$ )Nr  r~  r  r  rU  r  r  r  s          rs   _print_assoc_legendre"LatexPrinter._print_assoc_legendre   r  ru   c                |    [        U R                  UR                  5      u  p4SU< SU< S3nUb  SU-   SU-  -   nU$ )NzH_{r  r  rU  r  r  r  s         rs   _print_hermiteLatexPrinter._print_hermite  r   ru   c                |    [        U R                  UR                  5      u  p4SU< SU< S3nUb  SU-   SU-  -   nU$ )NL_{r  r  rU  r  r  r  s         rs   _print_laguerreLatexPrinter._print_laguerre  r   ru   c                    [        U R                  UR                  5      u  p4nSU< SU< SU< S3nUb  SU-   SU-  -   nU$ )Nr  r~  r  r  rU  r  r  r  s          rs   _print_assoc_laguerre"LatexPrinter._print_assoc_laguerre  r  ru   c           	         [        U R                  UR                  5      u  p4pVSU< SU< SU< SU< S3	nUb  SU-   SU-  -   nU$ )NzY_{r  r  r  r  rU  r  r  r   r  rX  r  mthetaphir  s           rs   
_print_YnmLatexPrinter._print_Ynm  H    t{{DII6eS23QsC?c/Os$;;C
ru   c           	         [        U R                  UR                  5      u  p4pVSU< SU< SU< SU< S3	nUb  SU-   SU-  -   nU$ )NzZ_{r  r  r  r  rU  r  r  r  s           rs   
_print_ZnmLatexPrinter._print_Znm#  r  ru   c           
         [        U R                  U5      u  pVnU(       a  SOSnU(       d  SOSU-  nU< U< SU< SU< SU< SU< 3
$ )Nz	^{\prime}r   r  rU  r\  r  )rg  r  )	r   	characterrN  r   rX  r	  r  r  sups	            rs   __print_mathieu_functions&LatexPrinter.__print_mathieu_functions*  s?    dkk4(a#lb33<c1aCPPru   c                8    U R                  SUR                  US9$ )NCr  &_LatexPrinter__print_mathieu_functionsrN  rW  s      rs   _print_mathieucLatexPrinter._print_mathieuc0      --c499#-FFru   c                8    U R                  SUR                  US9$ )Nr   r  r&  rW  s      rs   _print_mathieusLatexPrinter._print_mathieus3  r*  ru   c                :    U R                  SUR                  SUS9$ )Nr%  Tr   rX  r&  rW  s      rs   _print_mathieucprime!LatexPrinter._print_mathieucprime6       --c499Dc-RRru   c                :    U R                  SUR                  SUS9$ )Nr   Tr/  r&  rW  s      rs   _print_mathieusprime!LatexPrinter._print_mathieusprime9  r2  ru   c                
   UR                   S:w  aY  SnUR                  nUR                  S:  a  SnU* nU R                  S   (       a  SX#UR                   4-  $ SX#UR                   4-  $ U R                  UR                  5      $ )Nr  r   r   r  r   z	%s%d / %dz%s\frac{%d}{%d})r  r  r   r  )r   r  signr  s       rs   _print_RationalLatexPrinter._print_Rational<  sz    66Q;DAvvzB~~/0#t&777%$&&(999;;tvv&&ru   c                r   U R                  UR                  5      nUR                  (       a!  [        S UR                   5       5      (       d  [	        UR
                  5      S:  a  US-  n[	        UR
                  5      S:  a  X R                  UR
                  5      -  nO1UR
                  (       a   X R                  UR
                  S   5      -  nUS-  n[	        UR                  5      S:  a"  X R                  UR                  5      -  nSU-  $ X R                  UR                  S   5      -  nSU-  $ )Nc              3  F   #    U  H  o[         R                  :g  v   M     g 7fr  )r   rr  )r6  r  s     rs   r8  ,LatexPrinter._print_Order.<locals>.<genexpr>K  s     >:a166k:s   !r  rE  r   \rightarrow zO\left(%s\right))r  r  pointrC  r  	variables)r   r  rr   s      rs   _print_OrderLatexPrinter._print_OrderI  s    KK		"::#>4::>>>t~~"IA4>>"Q&[[00[[!233 A4::"[[,, #Q&& [[A//"Q&&ru   c                |    U R                   S   R                  U5      nUb  U$ U R                  UR                  US9$ )Nr   style)r   r   r]  ra  )r   r  rD  ra  s       rs   _print_SymbolLatexPrinter._print_SymbolY  s@    NN>266t<K((%(@@ru   c                L   Ub  SU;   a  U/ / 4$ U R                   S   (       a&  UR                  SS5      R                  SS5      / / p2nO[        U5      u  pn[        U5      nU Vs/ s H  n[        U5      PM     nnU Vs/ s H  n[        U5      PM     nnXU4$ s  snf s  snf )Nr   r   r  z\_r   z\^)r   r   r   	translate)r   ra  supersr  r!  r  s         rs   _split_super_subLatexPrinter._split_super_subb  s    <3$;"b>!^^56"&,,sE":"B"B3"NPRTV$D$!0!6D$,23FS)C.F3*./$3	#$/d## 4/s   &BB!c                    U R                  U5      u  p4nUS:X  a  SR                  U5      nU(       a  USSR                  U5      -  -  nU(       a  USSR                  U5      -  -  nU$ )Nr   \mathbf{{{}}}r  r   rf  )rJ  r  r`  )r   stringrD  ra  rI  r  s         rs   r]  !LatexPrinter._deal_with_super_subn  sl    !226:d F?#**40D Gchhv...DGchhtn,,Dru   c                    U R                   S   (       a  SnSnOSnSnSUUSSS	S
.nU R                  UR                  5      < SXAR                     < SU R                  UR                  5      < 3$ )Nr   z\gtz\lt><r  z\geqz\leqz\neq)z==rQ  rR  z>=z<=z!=r   )r   r  lhsrel_oprhs)r   r  gtltcharmaps        rs   _print_RelationalLatexPrinter._print_Relational}  st    >>&!BBBB 
 "[[2$[[14;;txx3HJ 	Jru   c           	     J   UR                   S S  VVs/ s H,  u  p#U R                  U5      < SU R                  U5      < 3PM.     nnnUR                   S   R                  [        :X  a;  UR	                  SU R                  UR                   S   R
                  5      -  5        OdUR	                  U R                  UR                   S   R
                  5      < SU R                  UR                   S   R                  5      < 35        SnUSR                  U5      -  $ s  snnf )Nr  z & \text{for}\: z%s & \text{otherwise}z\begin{cases} %s \end{cases}r  )rN  r  condr   rZ  r  r`  )r   r  ri  r   ecpairsr  s         rs   _print_PiecewiseLatexPrinter._print_Piecewise  s    #yy"~/-tq /3kk!ndkk!nM- 	 /99R=%NN3;;tyy}'9'9:; < NN KK		"(:(:; KK		"(:(:;= > .V[[)))/s   3Dc                   / n[        UR                  5       HH  nUR                  SR                  XS S 24    Vs/ s H  o@R	                  U5      PM     sn5      5        MJ     U R
                  S   nUc-  U R
                  S   S:X  a  SnOUR                  S:*  SL a  SnOS	nS
nUR                  SU5      nUS	:X  a%  UR                  SSSUR                  -  -   S-   5      nUSR                  U5      -  $ s  snf )Nr  r   r   r   smallmatrix
   Tmatrixarray \begin{%MATSTR%}%s\end{%MATSTR%}%MATSTR%r  r   r   }%sr=  )r  rowsrZ  r`  r  r   colsr   )r   r  linesliner   r   out_strs          rs   _print_matrix_contents#LatexPrinter._print_matrix_contents  s    $))$DLLT']$K][[^]$KLM % ..+?~~f%1'IIO,&G%G5//*g6goodC#dii-,?%,GHGE***! %Ls   C6c                    U R                  U5      nU R                  S   (       a,  U R                  S   nU R                  U   nSU-   U-   S-   U-   nU$ )Nr   \left\right)rm  r   r   )r   r  rl  
left_delimright_delims        rs   _print_MatrixBaseLatexPrinter._print_MatrixBase  s`    --d3>>+&4J**:6K+g5 "-.Gru   c                    U R                  UR                  [        S   SS9nU R                  UR                  5       SU R                  UR
                  5       3nSU SU S3$ )Nr  Tr  r  r   }_{ro   )r  parentr!   r  r   r   )r   r  matrix_part
index_parts       rs   _print_MatrixElement!LatexPrinter._print_MatrixElement  sd    ''Z5GPT'UDFF+,Adkk$&&.A-BC
K=j\44ru   c                  ^  U 4S jnT R                  UR                  [        S   SS9S-   U" UR                  UR                  R                  5      -   S-   U" UR
                  UR                  R                  5      -   S-   $ )Nc                   > [        U 5      n U S   S:X  a  U S	 U S   S:X  a  S U S'   U S   U:X  a  S U S'   SR                  U4S jU  5       5      $ )Nr  r  r   :c              3  N   >#    U  H  ob  TR                  U5      OSv   M     g 7fNr   r  )r6  xir   s     rs   r8  FLatexPrinter._print_MatrixSlice.<locals>.latexslice.<locals>.<genexpr>  s"     RPQ"~DKKO2EPQs   "%)r  r`  )r7  r  r   s     rs   
latexslice3LatexPrinter._print_MatrixSlice.<locals>.latexslice  s\    QAtqyaDtqy!ts{!88RPQRRRru   r  Trw  \left[r\  \right])r  ry  r!   rowslicerh  colsliceri  )r   r  r  s   `  rs   _print_MatrixSliceLatexPrinter._print_MatrixSlice  s    	S !!$++z&/A$!OR[[4==$++*:*:;<>BC4==$++*:*:;<>HI 	Jru   c                8    U R                  UR                  5      $ r  )r  blocksr"  s     rs   _print_BlockMatrixLatexPrinter._print_BlockMatrix  s    {{4;;''ru   c                   UR                   nSSKJnJn  [	        X#5      (       d5  [	        X$5      (       d%  UR
                  (       a  SU R                  U5      -  $ U R                  U[        U5      S5      nSU;   a  SU-  $ SU-  $ )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_TransposeLatexPrinter._print_Transpose  sv    hh<3--3,,1B1B)DKK,<<<!!#'=d'CTJAax-11!|#ru   c                B    UR                   nSU R                  U5      -  $ )Nz!\operatorname{tr}\left(%s \right))r<   r  r   r  r  s      rs   _print_TraceLatexPrinter._print_Trace  s    hh3dkk#6FFFru   c                x   SSSS.nUR                  U R                  S   S5      nUR                  nSSKJnJn  [        XE5      (       d;  [        XF5      (       d+  UR                  (       a  SU R                  U5      < S	U< S
3$ U R                  U[        U5      S5      nSU;   a  SU< S	U< S
3$ U< SU< S
3$ )Nz\daggerz\astz
\mathsf{H})r   star	hermitianr   r   r  rU  rV  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_AdjointLatexPrinter._print_Adjoint  s    # &

 '**4>>/+JJWhh<3--3,,1B1B1B.2kk#.>NN!!#'=d'CTJAax23]CC%&66ru   c                  ^ ^^ SSK Jm  UUU 4S jn[        TR                  5      nTR	                  5       (       a5  US   S:X  a  USS  nO	US   * US'   SSR                  [        X#5      5      -   $ SR                  [        X#5      5      $ )Nr   )MatMulc                   > [        U [        5      (       a"  [        U T5      (       d  TR                  U 5      $ TR                  U [	        T5      S5      $ NF)r  r
   r  r  r   )r7  r  r  r   s    rs   rt   ,LatexPrinter._print_MatMul.<locals>.<lambda>  sK    Z3-?-?
STV\H]H]4;;q> Fa!7!=uEFru   r  r  r  r   )sympyr  r  rN  r@  r`  rg  )r   r  parensrN  r  s   ``  @rs   _print_MatMulLatexPrinter._print_MatMul  s~     F DII((**Aw"}ABx7(Q#((3v#455588C-..ru   c                ~    [        U5      nUR                  u  p4U R                  X25       SU R                  XB5       3$ )Nr   )r   rN  r  )r   r  r  leftrights        rs   _print_DotProductLatexPrinter._print_DotProduct  s@    &t,ii$$T12'$:K:KE:Y9Z[[ru   c                    UR                   nUR                  (       aH  SSKJn  [	        X#5      (       a  SU R                  UR                  5      -  $ SU R                  U5      -  $ SU R                  U5      -  $ )Nr   )r  r  )r<   r  &sympy.matrices.expressions.blockmatrixr  r  rm  r  r  )r   r  r  r  s       rs   _print_DeterminantLatexPrinter._print_Determinant  sf    hhJ#+++d.I.I#**.UUU'$++c*:::#d&A&A#&FFFru   c           	     P   UbU  SU R                  UR                  S   [        S   SS9< SU R                  UR                  S   [        S   SS9< SU< S	3$ U R                  UR                  S   [        S   SS9< SU R                  UR                  S   [        S   SS9< 3$ )
NrU  r   r
   Trw  z \bmod r  rV  ro   rq  rW  s      rs   
_print_ModLatexPrinter._print_Mod  s    ?""499Q<E1B*. # 0""499Q<E1B*. # 0  "&!2!2499Q<3=e3D:> "3 "@ "&!2!2499Q<3=e3D:> "3 "@A 	Aru   c                   ^^ UR                   n[        S   mU R                  mSR                  UU4S jU 5       5      $ )Nr   z \circ c              3  4   >#    U  H  nT" UTS S9v   M     g7fTrw  Nrp   r6  r<   r  precs     rs   r8  6LatexPrinter._print_HadamardProduct.<locals>.<genexpr>,       <tVCd+t   rN  r!   r  r`  r   r  rN  r  r  s      @@rs   _print_HadamardProduct#LatexPrinter._print_HadamardProduct&  s:    yy% ""<t<> 	>ru   c                n    [        UR                  5      [        S   :  a  SnOSnU R                  X5      $ )Nr
   z%s^{\circ \left({%s}\right)}z%s^{\circ {%s}})r   rX  r!   r!  )r   r  r+  s      rs   _print_HadamardPower!LatexPrinter._print_HadamardPower.  s3    !$((+j.??6H)H00@@ru   c                   ^^ UR                   n[        S   mU R                  mSR                  UU4S jU 5       5      $ )Nr   	 \otimes c              3  4   >#    U  H  nT" UTS S9v   M     g7fr  rp   r  s     rs   r8  7LatexPrinter._print_KroneckerProduct.<locals>.<genexpr>;  r  r  r  r  s      @@rs   _print_KroneckerProduct$LatexPrinter._print_KroneckerProduct5  s<    yy% ""  <t<> 	>ru   c                d   UR                   UR                  p2SSKJn  [	        X$5      (       d:  UR
                  (       a)  SU R                  U5      < SU R                  U5      < S3$ U R                  U5      nSU;   a  SU< SU R                  U5      < S3$ U< SU R                  U5      < S3$ )Nr   )r  rU  rV  ro   r   r  )rR  rX  r  r  r  r  r  )r   r  rR  rX  r  base_strs         rs   _print_MatPowLatexPrinter._print_MatPow=  s    IItxxc/$--$2D2D2D/3{{4/@.2kk#.>@ @ {{4(Hh2:DKK<LMM$,dkk#.>??ru   c                :    U R                  XR                  S   S9$ )Nr   rC  )rE  r   r"  s     rs   _print_MatrixSymbol LatexPrinter._print_MatrixSymbolJ  s&    !!$nn/ ! ! 	!ru   c                0    U R                   S   S:X  a  S$ S$ )Nr   r   0z
\mathbf{0}r   )r   Zs     rs   _print_ZeroMatrixLatexPrinter._print_ZeroMatrixN  (    nn #*+s 	>0=	>ru   c                0    U R                   S   S:X  a  S$ S$ )Nr   r   1z
\mathbf{1}r  )r   Os     rs   _print_OneMatrixLatexPrinter._print_OneMatrixR  r  ru   c                0    U R                   S   S:X  a  S$ S$ )Nr   r   z
\mathbb{I}z
\mathbf{I}r  )r   rR  s     rs   _print_IdentityLatexPrinter._print_IdentityV  s(     $! #*!+} 	>0=	>ru   c                H    U R                  UR                  S   5      nSU-  $ )Nr   zP_{%s}r/  )r   Pperm_strs      rs   _print_PermutationMatrix%LatexPrinter._print_PermutationMatrixZ  s#    ;;qvvay)(""ru   c           
     t   UR                  5       S:X  a  U R                  US   5      $ U R                  S   nUcB  U R                  S   S:X  a  SnO,UR                  5       S:X  d  UR                  S   S::  a  S	nOS
nSnUR	                  SU5      nUS
:X  a(  UR	                  SSSUR                  S   -  -   S-   5      nU R                  S   (       a,  U R                  S   nU R
                  U   nSU-   U-   S-   U-   nUR                  5       S:X  a  US-  $ [        UR                  5       S-   5       Vs/ s H  n/ PM     nnUR                   Vs/ s H  n[        [        U5      5      PM     nn[        R                  " U6  GH  n	US   R                  U R                  X   5      5        Sn
[        UR                  5       S-
  SS5       H  n[        X{S-      5      UR                  U   :  a    Mp  U
(       a(  X{   R                  SR                  X{S-      5      5        OPX{   R                  USR                  X{S-      5      -  5        [        X{S-      5      S:X  a  SX{   S   -   S-   X{   S'   U
(       + n
/ X{S-   '   M     GM     US   S   nUR                  5       S-  S:X  a  X<-  nU$ s  snf s  snf )Nr   rp   r   r   r   ra  r  rb  rc  rd  re  rf  r  r   r   rg  r   rp  rq  r   r  Tr  r=  r  r  r  )rankr  r   shaper   r   r  r  	itertoolsproductrZ  r  r`  )r   r  r   	block_strrr  rs  r   	level_strshape_rangesouter_ievenback_outer_irl  s                rs   _print_NDimArrayLatexPrinter._print_NDimArray^  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%I2HQb2H	%I04

;
1U1X
; ((,7GbM  T]!;<D %diik!mR <ya01DJJ|4LL+22I1n$=>@ +22!UZZ	q.0I%JKM9!^45:6?%3B778:D7E	/3x,.	q.) != 8$ A,q/99;?a)G3 &J;s   6J0J5c                t   U R                  U5      nS nS nU H  nUR                  nXs;   d  U(       a
  XX:X  a  US-  nXX:w  a$  Ub  US-  nUR                  (       a  US-  nOUS-  nX@R                  UR                  S   5      -  nXs;   a  US-  nX@R                  X7   5      -  nSnOSnUnM     Ub  US-  nU$ )	Nr  ro   z{}^{z{}_{r   r  TF)r  is_uprN  )	r   ra  rh  	index_maprl  last_valenceprev_mapindexnew_valences	            rs   _printer_tensor_indices$LatexPrinter._printer_tensor_indices  s    ++d#E++K# /3*+sNG;;v%Gv%G{{5::a=11G!3;;y'788 &L' ( #sNGru   c                ~    UR                   S   R                   S   nUR                  5       nU R                  X#0 5      $ r.  )rN  get_indicesr  )r   r  ra  rh  s       rs   _print_TensorLatexPrinter._print_Tensor  s;    yy|  #""$++D2>>ru   c                    UR                   R                  S   R                  S   nUR                   R                  5       nUR                  nU R	                  X#U5      $ r.  )r  rN  r  r  r  )r   r  ra  rh  r  s        rs   _print_TensorElement!LatexPrinter._print_TensorElement  sM    yy~~a %%a())'')NN	++D9EEru   c                    UR                  5       u  p#USR                  U Vs/ s H  o@R                  U[        U5      5      PM     sn5      -   $ s  snf r  )!_get_args_for_traditional_printerr`  r  r    )r   r  r7  rN  r<   s        rs   _print_TensMulLatexPrinter._print_TensMul  sO    ;;=
bggAEF#sJt$45F
 
 	
Fs   $A
c           	         / nUR                   nU H-  nUR                  U R                  U[        U5      5      5        M/     UR	                  5         SR                  U5      nUR                  SS5      nU$ )Nrr  z+ -r  )rN  rZ  r  r    rY  r`  r   )r   r  r	  rN  r7  rr   s         rs   _print_TensAddLatexPrinter._print_TensAdd  sc    yyAHHT&&q*T*:;< 	JJqMIIeT"ru   c                v    SUR                   (       a  SOS< SU R                  UR                  S   5      < S3$ )Nz{}r   r  r   r   ro   )r  r  rN  r"  s     rs   _print_TensorIndexLatexPrinter._print_TensorIndex  s.    ::C3&KK		!%
 	
ru   c                   [        UR                  5      S:X  aI  SU R                  UR                  S   5      < SU R                  UR                  [
        S   S5      < S3$ S[        UR                  5      < SS	R                  UR                   Vs/ s H  nS
U R                  U5      -  PM     sn5      < SU R                  UR                  [
        S   S5      < S3$ s  snf )Nr  z\frac{\partial}{\partial {r   rv  r
   Fro   z\frac{\partial^{r   z\partial {%s}r  )r  r?  r  r  r  r!   r`  r   r  r   s      rs   _print_PartialDerivative%LatexPrinter._print_PartialDerivative  s    t~~!#DNN1-.!!$))Z->F  $ DNN#T^^T^*T[[^;^TU!!$))Z->F Ts   C#c                8    U R                  UR                  5      $ r  )r  ra  r"  s     rs   _print_ArraySymbolLatexPrinter._print_ArraySymbol  s    {{499%%ru   c                    SU R                  UR                  [        S   S5      < SSR                  UR                   Vs/ s H  o R                  U5       PM     sn5      < S3$ s  snf )Nz{{rp  Trx  r\  r  )r  ra  r!   r`  rh  r  r  s      rs   _print_ArrayElement LatexPrinter._print_ArrayElement  sW    diiF);TBIIDLLALq++a.)*LABD 	DAs   A'c                    g)Nz
\mathbb{U}rp   r"  s     rs   _print_UniversalSet LatexPrinter._print_UniversalSet      ru   c                    Uc!  SU R                  UR                  S   5      -  $ SU R                  UR                  S   5      < SU< S3$ )Nz$\operatorname{frac}{\left(%s\right)}r   z\operatorname{frac}{\left(z
\right)}^{ro   r/  rW  s      rs   _print_fracLatexPrinter._print_frac  sK    ;:T[[ST=VVV  KK		!-s4 4ru   c           
     h   U R                   S   S:X  a  SnO!U R                   S   S:X  a  SnO[        S5      e[        U5      S:X  a&  U R                  U R	                  US   5      U-   5      $ U R                  US	-   R                  U Vs/ s H  o0R	                  U5      PM     sn5      5      $ s  snf )
Nr   r  ;r   r  Unknown Decimal Separatorr  r   z \  )r   r   r  r  r  r`  )r   r  sepr   s       rs   _print_tupleLatexPrinter._print_tuple  s    >>-.'9C^^/0H<C899t9>**4;;tAw+?#+EFF**w$$d%Cdkk!nd%CDF F%Cs   
B/c                    UR                    Vs/ s H  o R                  U5      PM     nnSR                  U5      $ s  snf )Nr  rN  r  r`  r   r  r	  elementss       rs   _print_TensorProduct!LatexPrinter._print_TensorProduct  s6    ,0II6IqKKNI6  ** 7   <c                    UR                    Vs/ s H  o R                  U5      PM     nnSR                  U5      $ s  snf )N \wedge r'  r(  s       rs   _print_WedgeProduct LatexPrinter._print_WedgeProduct  s6    ,0II6IqKKNI6)) 7r,  c                $    U R                  U5      $ r  )r$  r"  s     rs   _print_TupleLatexPrinter._print_Tuple	  s      &&ru   c           	     D   U R                   S   S:X  a3  SSR                  U Vs/ s H  o R                  U5      PM     sn5      -  $ U R                   S   S:X  a3  SSR                  U Vs/ s H  o R                  U5      PM     sn5      -  $ [        S5      es  snf s  snf )Nr   r  z\left[ %s\right]z; \  r   , \  r"  )r   r`  r  r   r  s      rs   _print_listLatexPrinter._print_list  s    >>-.'9&t<t!{{1~t<=> >^^/0H<&t<t!{{1~t<=> > 899 = =s   B
*B
c                    [        UR                  5       [        S9n/ nU H=  nX   nUR                  U R	                  U5      < SU R	                  U5      < 35        M?     SSR                  U5      -  $ )NrO  z : z\left\{ %s\right\}r5  )r  keysr   rZ  r  r`  )r   r   r9  rW  rP  vals         rs   _print_dictLatexPrinter._print_dict  sd    affh$45C&CLLdkk#&6C8HIJ  %x}}U';;;ru   c                $    U R                  U5      $ r  )r;  r"  s     rs   _print_DictLatexPrinter._print_Dict!  s    %%ru   c                L   [        UR                  5      S:X  d  UR                  S   S:X  a"  SU R                  UR                  S   5      -  nOCSU R                  UR                  S   5      < SU R                  UR                  S   5      < S3nU(       a  SU< SU< S	3nU$ )
Nr  r   z\delta\left(%s\right)z\delta^{\left( z \right)}\left( r  rU  rV  ro   rA  r  s       rs   _print_DiracDeltaLatexPrinter._print_DiracDelta$  s    tyy>Q$))A,!"3*T[[1-FFC #4 DIIaL)4;;tyy|+DFC-0#6C
ru   c                    U R                  UR                  S   UR                  S   -
  5      nU R                  UR                  S   5      nSU< SU< S3nUb  SU< SU< S	U< S3nU$ )
Nr   r  r  z{\left\langle z \right\rangle}^{ro   z{\left({\langle z \rangle}^{z}\right)}^{r/  )r   r  rX  shiftr  r  s         rs   _print_SingularityFunction'LatexPrinter._print_SingularityFunction.  s\    DIIaL499Q<78DIIaL)9>F?FKUTWXC
ru   c                   ^  SR                  U 4S jUR                   5       5      nSU-  nU(       a  SU< SU< S3nU$ )Nr\  c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr  r  r6  r<   r   s     rs   r8  0LatexPrinter._print_Heaviside.<locals>.<genexpr>7  s     Ajs$++c**jr;  z\theta\left(%s\right)rU  rV  ro   )r`  pargs)r   r  rX  rK  r  s   `    rs   _print_HeavisideLatexPrinter._print_Heaviside6  s7    		AdjjAA&.-0#6C
ru   c                @   U R                  UR                  S   5      nU R                  UR                  S   5      nUR                  S   R                  (       a*  UR                  S   R                  (       a  SU< SU< S3nOSU< SU< S3nUb  SU< SU< S3nU$ )	Nr   r  z\delta_{r   ro   r\  rU  rV  )r  rN  r  )r   r  rX  r   r   r  s         rs   _print_KroneckerDelta"LatexPrinter._print_KroneckerDelta=  s{    KK		!%KK		!%99Q<DIIaL$8$8$8'(!,C()1-C?-0#6C
ru   c                    [        U R                  UR                  5      n[        S UR                   5       5      (       a  SSR	                  U5      -  nOSSR	                  U5      -  nU(       a  SU< SU< S3nU$ )Nc              3  8   #    U  H  oR                   v   M     g 7fr  )r  )r6  r7  s     rs   r8  1LatexPrinter._print_LeviCivita.<locals>.<genexpr>J  s     ,)Qyy)s   z\varepsilon_{%s}r   r\  rU  rV  ro   )rg  r  rN  r  r`  )r   r  rX  rh  r  s        rs   _print_LeviCivitaLatexPrinter._print_LeviCivitaH  sc    dkk499-,$)),,,%(99C%		'(::C-0#6C
ru   c                   [        US5      (       a"  SU R                  UR                  5       5      -   $ [        US5      (       a=  SU R                  UR                  5      -   S-   U R                  UR                  5      -   $ [        US5      (       a  SU R                  UR                  5      -   $ U R                  S 5      $ )N
as_booleanz\text{Domain: }set \in r  z\text{Domain on })r  r  rW  r  rX  )r   r   s     rs   _print_RandomDomain LatexPrinter._print_RandomDomainR  s    1l##%ALLN(CCCQ&QYY)??(JKK&' (Q	""'$++aii*@@@;;t$$ru   c                T    [        UR                  [        S9nU R                  U5      $ )NrO  )r  rN  r   
_print_setr   rr   rW  s      rs   _print_FiniteSetLatexPrinter._print_FiniteSet]  s"    qvv#34u%%ru   c                (   [        U[        S9nU R                  S   S:X  a*  SR                  [	        U R
                  U5      5      nSU-  $ U R                  S   S:X  a*  SR                  [	        U R
                  U5      5      nSU-  $ [        S5      e)	NrO  r   r  rE  r   r\  r"  \left\{%s\right\})r  r   r   r`  rg  r  r   r^  s      rs   r]  LatexPrinter._print_seta  s    q./>>-.'9IIc$++u56E
 $e++	 ^^/0H<IIc$++u56E $e++ 899ru   c                  ^ ^^ UU 4S jn[        5       mTR                  R                  (       aF  TR                  R                  (       a+  TR                  R
                  (       a  TSSST4nOTSSST4nOTR                  R                  (       a  TTS   TR                  -
  TS   4nOTR                  R                  (       a#  [        T5      n[        U5      [        U5      T4nOrTR                  b^  TR                  S:  S:X  a  [        T5      nOFTR                  (       a'  [        T5      n[        U5      [        U5      TTS   4nOU" 5       $ U" 5       $ SSR                  UU 4S	 jU 5       5      -   S
-   $ )Nc                   > TR                   S   S:X  aX  TR                   S   S:X  a  TR                  TR                   S   5      n OSR                  U4S jTR                    5       5      n OaTR                   S   S:X  a)  SR                  U4S jTR                   S S  5       5      n O%SR                  U4S jTR                    5       5      n SU  S	3$ )
Nr   r  r  r\  c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr  r  rI  s     rs   r8  KLatexPrinter._print_Range.<locals>._print_symbolic_range.<locals>.<genexpr>u       $H#T[[%5%5r;  c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr  r  rI  s     rs   r8  rg  x  s     $L#T[[%5%5r;  c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr  r  rI  s     rs   r8  rg  z  rh  r;  z\text{Range}\left(r  r'  )contrr   r   s    rs   _print_symbolic_range8LatexPrinter._print_Range.<locals>._print_symbolic_rangeo  s    vvayA~66!9>;;qvvay1D99$H$HHD66!9>99$L$LLD99$H$HHD+D6:;ru   r  r   r  r  T\left\{r\  c              3  R   >#    U  H  oTLa  TR                  U5      OS v   M     g7fz\ldotsNr  r6  eldotsr   s     rs   r8  ,LatexPrinter._print_Range.<locals>.<genexpr>  %     _V^PRn4;;r?)KV^   $'\right\})objectstartis_infinitestopstepis_positiveiternextis_emptyr  r6  is_iterabler`  )r   rr   rl  printsetitrs  s   ``   @rs   _print_RangeLatexPrinter._print_Rangen  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           
        [        UR                  5      S:X  a  UbJ  U< SU R                  UR                  S   5      < SU< SU R                  UR                  S   5      < S3$ U< SU R                  UR                  S   5      < SU R                  UR                  S   5      < S3$ U< SU R                  UR                  S   5      < S3nUb
  U< S	U< S3nU$ )
Nr  r  r   r  r  r  r  ro   r  rA  )r   r  letterrX  r  s        rs   __print_number_polynomial&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                (    U R                  USU5      $ NB&_LatexPrinter__print_number_polynomialrW  s      rs   _print_bernoulliLatexPrinter._print_bernoulli      --dC==ru   c                (    U R                  USU5      $ )NGr  rW  s      rs   _print_genocchiLatexPrinter._print_genocchi  r  ru   c                h  ^  [        UR                  5      S:X  a  ST R                  UR                  S   5      < ST R                  UR                  S   5      < S3nSSR                  U 4S jUR                  S	    5       5      -  nUb  U< S
U< SU< 3nU$ X4-   nU$ T R	                  USU5      $ )NrR  zB_{r   r\  r  ro   rs  c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr  r  )r6  rr  r   s     rs   r8  +LatexPrinter._print_bell.<locals>.<genexpr>  s#      3C5Ar 48;;r??5Ar;  r  r  r  )r  rN  r  r`  r  )r   r  rX  tex1tex2r  s   `     rs   _print_bellLatexPrinter._print_bell  s    tyy>Q$(KK		!$= $DIIaL 9;D%

 3C59YYq\3C )C CD&*C6 J kJ--dC==ru   c                (    U R                  USU5      $ NFr  rW  s      rs   _print_fibonacciLatexPrinter._print_fibonacci  r  ru   c                b    SU R                  UR                  S   5      -  nUb
  U< SU< S3nU$ )NzL_{%s}r   r  ro   r/  r  s       rs   _print_lucasLatexPrinter._print_lucas  1    $++diil33? #S)C
ru   c                (    U R                  USU5      $ )NTr  rW  s      rs   _print_tribonacciLatexPrinter._print_tribonacci  r  ru   c                    Uc!  SU R                  UR                  S   5      -  $ SU< SU R                  UR                  S   5      < S3$ )Nz\mu\left(%s\right)r   z\mu^{r  r  r/  rW  s      rs   _print_mobiusLatexPrinter._print_mobius  sD    ;(4;;tyy|+DDD -0$++diil2KLLru   c           
     h  ^ ^ [        5       m[        UR                  R                  5      S:  d#  [        UR                  R                  5      S:  az  ST R                  UR                  5      < ST R                  UR                  S   5      < ST R                  UR                  5      < ST R                  UR                  5      < S3	$ UR                  [        R                  L aY  UR                  nTUR                  US-
  5      UR                  US-
  5      UR                  US	-
  5      UR                  U5      4nOOUR                  [        R                  L d  UR                  S
:  a  US S
 nUR                  T5        O[        U5      nSSR                  UU 4S jU 5       5      -   S-   $ )Nr   rn  z
\right\}_{r  r  ro   rR  r  r  r  r  r\  c              3  R   >#    U  H  oTLa  TR                  U5      OS v   M     g7frp  r  rq  s     rs   r8  1LatexPrinter._print_SeqFormula.<locals>.<genexpr>  ru  rv  r  )rx  r  ry  free_symbolsr{  r  formular?  r   r  coeffr  lengthrZ  r6  r`  )r   rr   r{  r  rs  s   `   @rs   _print_SeqFormula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                P   UR                   UR                  :X  a  SU R                  UR                   5      -  $ UR                  (       a  SnOSnUR                  (       a  SnOSnSU< U R                  UR                   5      < SU R                  UR                  5      < SU< 3$ )	Nrb  r   r   r   r   rp  r\  rq  )ry  endr  	left_open
right_open)r   r   r  r  s       rs   _print_IntervalLatexPrinter._print_Interval  s    77aee'$++agg*>>> {{|| $++agg.AEE0BEK Kru   c                |    SU R                  UR                  5      < SU R                  UR                  5      < S3$ )Nz\left\langle r\  z\right\rangle)r  r   r   r   r   s     rs   _print_AccumulationBounds&LatexPrinter._print_AccumulationBounds  s+    QUU#T[[%79 	9ru   c                    [        U5      nUR                   Vs/ s H  o0R                  X25      PM     nnSR                  U5      $ s  snf )Nz \cup r   rN  r  r`  r   ur  r   args_strs        rs   _print_UnionLatexPrinter._print_Union  B    %a(89?1%%a.?~~h'' @   Ac                    [        U5      nUR                   Vs/ s H  o0R                  X25      PM     nnSR                  U5      $ s  snf )Nz \setminus r  r  s        rs   _print_ComplementLatexPrinter._print_Complement 	  D    %a(89?1%%a.?""8,, @r  c                    [        U5      nUR                   Vs/ s H  o0R                  X25      PM     nnSR                  U5      $ s  snf )Nz \cap r  r  s        rs   _print_Intersection LatexPrinter._print_Intersection	  r  r  c                    [        U5      nUR                   Vs/ s H  o0R                  X25      PM     nnSR                  U5      $ s  snf )Nz \triangle r  r  s        rs   _print_SymmetricDifference'LatexPrinter._print_SymmetricDifference
	  r  r  c                >  ^ ^ [        U5      m[        UR                  5      S:  aR  [        UR                  5      (       d8  T R	                  UR                  S   T5      S[        UR                  5      -  -   $ SR                  UU 4S jUR                   5       5      $ )Nr  r   z^{%d}r   c              3  H   >#    U  H  nTR                  UT5      v   M     g 7fr  )r  )r6  rX  r  r   s     rs   r8  1LatexPrinter._print_ProductSet.<locals>.<genexpr>	  s$       <4:SDc4((Fs   ")r   r  setsr$   r  r`  )r   r  r  s   ` @rs   _print_ProductSetLatexPrinter._print_ProductSet	  s|    %a(qvv;!K$7$7$$QVVAY5#aff+8MMM  <45FF < < 	<ru   c                    g)Nz	\emptysetrp   rh  s     rs   _print_EmptySetLatexPrinter._print_EmptySet	  s    ru   c                    g)Nz
\mathbb{N}rp   r   r  s     rs   _print_NaturalsLatexPrinter._print_Naturals	  r  ru   c                    g)Nz\mathbb{N}_0rp   r  s     rs   _print_Naturals0LatexPrinter._print_Naturals0	  s    ru   c                    gNz
\mathbb{Z}rp   r  s     rs   _print_IntegersLatexPrinter._print_Integers	  r  ru   c                    gNz
\mathbb{Q}rp   r  s     rs   _print_RationalsLatexPrinter._print_Rationals"	  r  ru   c                    gNz
\mathbb{R}rp   r  s     rs   _print_RealsLatexPrinter._print_Reals%	  r  ru   c                    gNz
\mathbb{C}rp   r  s     rs   _print_ComplexesLatexPrinter._print_Complexes(	  r  ru   c                   ^  UR                   R                  nUR                   R                  nU 4S j[        X1R                  5       5       nSR                  S U 5       5      nST R                  U5      < SU< S3$ )Nc              3  l   >#    U  H)  u  pTR                  U5      TR                  U5      4v   M+     g 7fr  r  )r6  r7  rI  r   s      rs   r8  /LatexPrinter._print_ImageSet.<locals>.<genexpr>.	  s*     R<QDAAA/<Qs   14r\  c              3  ,   #    U  H
  nS U-  v   M     g7f)	%s \in %sNrp   )r6  xys     rs   r8  r  /	  s     ;s<",ss   rn  \; \middle|\; rw  )rX   r  	signaturer  	base_setsr`  r  )r   rr   r  sigxysxinyss   `     rs   _print_ImageSetLatexPrinter._print_ImageSet+	  sZ    ww||ggRC[[<QR

;s;;7;{{47H%PPru   c           
        SR                  [        UR                  5       Vs/ s H  o R                  U5      PM     sn5      nUR                  [
        R                  L a$  SU< SU R                  UR                  5      < S3$ SU< SU< SU R                  UR                  5      < SU R                  UR                  5      < S3	$ s  snf )Nr\  rn  r  	 \right\}rY  r.  )r`  r   r  r  base_setr   UniversalSet	conditionr   rr   r  
vars_prints       rs   _print_ConditionSet LatexPrinter._print_ConditionSet2	  s    YYE!%%LILSC 0LIJ
::'T[[57 7 (
 KK

#KK$	& 	&  Js   C
c                `    U R                  UR                  S   5      nSR                  U5      $ )Nr   z\mathcal{{P}}\left({}\right)r  rN  r  )r   r  	arg_prints      rs   _print_PowerSetLatexPrinter._print_PowerSet>	  s)    KK		!-	.55i@@ru   c                   SR                  UR                   Vs/ s H  o R                  U5      PM     sn5      nSU R                  UR                  5      < SU< SU R                  UR                  5      < S3$ s  snf )Nr\  rn  r  rY  r  )r`  r?  r  r  r  r  s       rs   _print_ComplexRegion!LatexPrinter._print_ComplexRegionB	  s]    YYAKKHKSC 0KHI
KKKK! 	!  Is   A<c                H   ^  S[        U 4S jUR                   5       5      -  $ )Nr  c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr  r  )r6  r	  r   s     rs   r8  /LatexPrinter._print_Contains.<locals>.<genexpr>J	  s     #CFqDKKNNFr;  )r6  rN  rh  s   ` rs   _print_ContainsLatexPrinter._print_ContainsI	  s    e#CAFF#CCCCru   c                   UR                   R                  [        R                  L aB  UR                  R                  [        R                  L a  U R                  UR                  5      $ U R                  UR                  5       5      S-   $ )Nz	 + \ldots)	r  r  r   rr  bnr  a0ry  truncater  s     rs   _print_FourierSeries!LatexPrinter._print_FourierSeriesL	  sV    44<<166!addllaff&<;;qtt$$qzz|,|;;ru   c                8    U R                  UR                  5      $ r  )ry  infiniter  s     rs   _print_FormalPowerSeries%LatexPrinter._print_FormalPowerSeriesQ	  s    qzz**ru   c                     SUR                   -  $ )Nz\mathbb{F}_{%s})modr"  s     rs   _print_FiniteFieldLatexPrinter._print_FiniteFieldT	  s    !DHH,,ru   c                    gr  rp   r"  s     rs   _print_IntegerRingLatexPrinter._print_IntegerRingW	  r  ru   c                    gr  rp   r"  s     rs   _print_RationalField!LatexPrinter._print_RationalFieldZ	  r  ru   c                    gr  rp   r"  s     rs   _print_RealFieldLatexPrinter._print_RealField]	  r  ru   c                    gr  rp   r"  s     rs   _print_ComplexField LatexPrinter._print_ComplexField`	  r  ru   c                    U R                  UR                  5      nSR                  [        U R                   UR                  5      5      nU< SU< S3$ )Nr\  r  r  r  domainr`  rg  r  r   r  r3  r  s       rs   _print_PolynomialRing"LatexPrinter._print_PolynomialRingc	  <    T[[)))CT\\:;'-w77ru   c                    U R                  UR                  5      nSR                  [        U R                   UR                  5      5      nU< SU< S3$ )Nr\  rU  r  r2  r4  s       rs   _print_FractionField!LatexPrinter._print_FractionFieldh	  r7  ru   c                    U R                  UR                  5      nSR                  [        U R                   UR                  5      5      nSnUR
                  (       d  SnU< U< SU< S3$ )Nr\  r   zS_<^{-1}r  r  )r  r3  r`  rg  r  is_Poly)r   r  r3  r  invs        rs   _print_PolynomialRingBase&LatexPrinter._print_PolynomialRingBasem	  sO    T[[)))CT\\:;||C),fg>>ru   c           	        UR                   R                  n/ nUR                  5        GHr  u  pESn[        U5       H_  u  pxUS:  d  M  US:X  a"  X`R	                  UR
                  U   5      -  nM5  X`R	                  [        UR
                  U   U5      5      -  nMa     UR                  (       a.  U(       a  SU R	                  U5      -  n	O{U R	                  U5      n	OiU(       aQ  U[        R                  L a  UR                  SU/5        M  U[        R                  L a  UR                  SU/5        GM  U R	                  U5      n	U(       d  U	n
OU	S-   U-   n
U
R                  S5      (       a  UR                  SU
SS  /5        GM_  UR                  SU
/5        GMu     US   S;   a"  UR                  S5      nUS:X  a  SUS   -   US'   SR                  U5      n[        [!        U R                  UR
                  5      5      nS	U R	                  UR#                  5       5      -  nS
R                  U/U-   U/-   5      nU[$        ;   a  SU< SU< S3nU$ SU< SU< S3nU$ )Nr   r   r  rs  r  rQ  r   )rQ  r  z	domain=%sr\  r    {\left(z	 \right)}r  z	}{\left( )r^  r_  rv  ru  r  genspowr*  r   r   extendr   r)  popr`  r  rg  
get_domainr  )r   polyr  rv  monomr  s_monomr   rX  s_coeffs_termmodifierr  rB  r3  rN  r  s                    rs   _print_PolyLatexPrinter._print_Polyu	  s   nn%% JJLLEG#E*7ax;;tyy|#<<;;s499Q</E#FF + ||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                    UR                   R                  nUS:X  a  SnU R                  UR                  5      nUR                  nU[
        ;   a  SX#U4-  $ SX#U4-  $ )NComplexRootOfCRootOfz\%s {\left(%s, %d\right)}z'\operatorname{%s} {\left(%s, %d\right)})r^  r_  r  r  r  r  )r   r;   r  r  r  s        rs   _print_ComplexRootOf!LatexPrinter._print_ComplexRootOf	  sm    nn%%/!C{{499%

**/3e2DDD=AFAH H Hru   c                p   UR                   R                  nU R                  UR                  5      /nUR                  [
        R                  La*  UR                  U R                  UR                  5      5        U[        ;   a  SU< SSR                  U5      < S3$ SU< SSR                  U5      < S3$ )Nr   rA  r\  r  r  z	} {\left()
r^  r_  r  r  funr   IdentityFunctionrZ  r  r`  )r   r  r  rN  s       rs   _print_RootSumLatexPrinter._print_RootSum	  s    nn%%DII&'881---KKDHH-.**/2DIIdODD + >A=AYYt_N Nru   c                    g)N\omegarp   r"  s     rs   _print_OrdinalOmega LatexPrinter._print_OrdinalOmega	  s    ru   c                    UR                   u  p#US:w  a(  US:w  a  SR                  X25      $ SR                  U5      $ US:w  a  SR                  U5      $ g)Nr  z{} \omega^{{{}}}z	{} \omegaz\omega^{{{}}}rZ  )rN  r  )r   r  rX  muls       rs   _print_OmegaPowerLatexPrinter._print_OmegaPower	  sX    99!8ax*11#;;#**3//ax'..s33 ru   c                    SR                  UR                   Vs/ s H  o R                  U5      PM     sn5      $ s  snf Nrr  )r`  rN  r  rO  s      rs   _print_OrdinalLatexPrinter._print_Ordinal	  s.    zztyyAy;;s+yABBAs   ;c                P    U R                   S   nUR                  U [        SU5      $ )Nr   z	{%s}^{%d})r   r  r!   )r   rG  r   s      rs   _print_PolyElementLatexPrinter._print_PolyElement	  s&    ^^$67
xxj+zBBru   c                    UR                   S:X  a  U R                  UR                  5      $ U R                  UR                  5      nU R                  UR                   5      nSU< SU< S3$ )Nr  r  r  ro   )r  r  r  )r   r:   r  r  s       rs   _print_FracElementLatexPrinter._print_FracElement	  sO    ::?;;tzz**KK

+EKK

+E',e44ru   c                    [        UR                  5      S:X  a  UR                  S   S 4OUR                  u  p4SU R                  U5      -  nUb
  U< SU< S3nUb  U< SU R                  U5      < S3nU$ )Nr  r   zE_{%s}r  ro   rU  r  rA  )r   r  rX  r  r7  r  s         rs   _print_eulerLatexPrinter._print_euler	  sh    '*499~':		!d#		$++a.(? #S)C=*-t{{1~>C
ru   c                b    SU R                  UR                  S   5      -  nUb
  U< SU< S3nU$ )NzC_{%s}r   r  ro   r/  r  s       rs   _print_catalanLatexPrinter._print_catalan	  r  ru   c           
         SR                  X#(       a  SOSU R                  UR                  S   5      U R                  UR                  S   5      U R                  UR                  S   5      5      $ )Nz5\mathcal{{{}}}{}_{{{}}}\left[{}\right]\left({}\right)z^{-1}r   r  r   r  r  r  rN  )r   r  rr   inverses       rs   _print_UnifiedTransform$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                &    U R                  US5      $ )NMrt  r"  s     rs   _print_MellinTransform#LatexPrinter._print_MellinTransform	      ++D#66ru   c                (    U R                  USS5      $ )Nrw  Trx  r"  s     rs   _print_InverseMellinTransform*LatexPrinter._print_InverseMellinTransform	      ++D#t<<ru   c                &    U R                  US5      $ )NLrx  r"  s     rs   _print_LaplaceTransform$LatexPrinter._print_LaplaceTransform	  r{  ru   c                (    U R                  USS5      $ )Nr  Trx  r"  s     rs   _print_InverseLaplaceTransform+LatexPrinter._print_InverseLaplaceTransform
  r  ru   c                &    U R                  US5      $ r  rx  r"  s     rs   _print_FourierTransform$LatexPrinter._print_FourierTransform
  r{  ru   c                (    U R                  USS5      $ )Nr  Trx  r"  s     rs   _print_InverseFourierTransform+LatexPrinter._print_InverseFourierTransform
  r  ru   c                &    U R                  US5      $ )NSINrx  r"  s     rs   _print_SineTransform!LatexPrinter._print_SineTransform

      ++D%88ru   c                (    U R                  USS5      $ )Nr  Trx  r"  s     rs   _print_InverseSineTransform(LatexPrinter._print_InverseSineTransform
      ++D%>>ru   c                &    U R                  US5      $ )NCOSrx  r"  s     rs   _print_CosineTransform#LatexPrinter._print_CosineTransform
  r  ru   c                (    U R                  USS5      $ )Nr  Trx  r"  s     rs   _print_InverseCosineTransform*LatexPrinter._print_InverseCosineTransform
  r  ru   c                     UR                   b*  U R                  UR                   R                  U5      5      $  U R                  [	        U5      5      $ ! [         a     N&f = fr  )ringr  to_sympyr   reprr   r  s     rs   
_print_DMPLatexPrinter._print_DMP
  s[    	vv!{{166??1#566 "
 {{47##  		s   6A 
A! A!c                $    U R                  U5      $ r  )r  r  s     rs   
_print_DMFLatexPrinter._print_DMF
  s    q!!ru   c                J    U R                  [        UR                  5      5      $ r  )r  r   ra  )r   rx  s     rs   _print_ObjectLatexPrinter._print_Object"
  s    {{6&++.//ru   c                   U R                  UR                  S   5      nUb  SU< S3OSn[        UR                  5      S:X  a  SU< SU< S3nU$ U R                  UR                  S   5      nS	R                  X%U5      nU$ )
Nr   r  ro   r   r  WrU  r  zW{0}_{{{1}}}\left({2}\right))r  rN  r  r  )r   r  rX  arg0resultarg1s         rs   _print_LambertWLatexPrinter._print_LambertW%
  sv    {{499Q<(#&?#tyy>Q.148F  ;;tyy|,D5<<SMFru   c                \    SR                  U R                  UR                  S   5      5      $ )Nz!\operatorname{{E}}\left[{}\right]r   rr  r"  s     rs   _print_ExpectationLatexPrinter._print_Expectation/
  %    3::4;;tyyQR|;TUUru   c                \    SR                  U R                  UR                  S   5      5      $ )Nz#\operatorname{{Var}}\left({}\right)r   rr  r"  s     rs   _print_VarianceLatexPrinter._print_Variance2
  s%    5<<T[[ST=VWWru   c                l   ^  SR                  SR                  U 4S jUR                   5       5      5      $ )Nz#\operatorname{{Cov}}\left({}\right)r\  c              3  F   >#    U  H  nTR                  U5      v   M     g 7fr  r  rI  s     rs   r8  1LatexPrinter._print_Covariance.<locals>.<genexpr>6
  s!     Fmcl\_t{{SVGWGWclr;  )r  r`  rN  r"  s   ` rs   _print_CovarianceLatexPrinter._print_Covariance5
  s*    5<<TYYFmcgclclFm=mnnru   c                \    SR                  U R                  UR                  S   5      5      $ )Nz!\operatorname{{P}}\left({}\right)r   rr  r"  s     rs   _print_ProbabilityLatexPrinter._print_Probability8
  r  ru   c                    U R                  UR                  5      nU R                  UR                  5      nU< SU< 3$ )Nr=  )r  r3  codomain)r   morphismr3  r  s       rs   _print_MorphismLatexPrinter._print_Morphism;
  s3    X__-;;x001&,h77ru   c                    U R                  UR                  5      U R                  UR                  5      p2SU< SU< S3$ )Nr  r  ro   )r  r  den)r   r  r  r  s       rs   _print_TransferFunction$LatexPrinter._print_TransferFunction@
  s.    ;;txx($++dhh*?S#&,,ru   c                r   ^ ^ [        TR                  5      nUU 4S jnSR                  [        X25      5      $ )Nc                <   > TR                  U [        T5      S5      $ r  )r  r   )r7  r  r   s    rs   rt   ,LatexPrinter._print_Series.<locals>.<lambda>F
  s    4,,Q0Ft0L,13ru   r   )r  rN  r`  rg  )r   r  rN  r  s   ``  rs   _print_SeriesLatexPrinter._print_SeriesD
  s+    DII3xxF)**ru   c                   ^ ^^ SSK Jm  [        TR                  5      S S S2   nUUU 4S jnSR	                  [        X25      5      $ )Nr   )MIMOParallelr  c                   > [        U T5      (       a  TR                  U [        T5      S5      $ TR                  U 5      $ r  )r  r  r   r  )r7  r  r  r   s    rs   rt   0LatexPrinter._print_MIMOSeries.<locals>.<lambda>M
  sH    7A!\7R7R  ,,Q0Ft0L-24 gX\XcXcdeXfgru   z\cdot)sympy.physics.control.ltir  r  rN  r`  rg  )r   r  rN  r  r  s   ``  @rs   _print_MIMOSeriesLatexPrinter._print_MIMOSeriesJ
  s8    :DIItt$g}}S.//ru   c                `    SR                  [        U R                  UR                  5      5      $ rb  r`  rg  r  rN  r"  s     rs   _print_ParallelLatexPrinter._print_ParallelQ
       zz#dkk499566ru   c                `    SR                  [        U R                  UR                  5      5      $ rb  r  r"  s     rs   _print_MIMOParallel LatexPrinter._print_MIMOParallelT
  r  ru   c           	        SSK JnJn  UR                  U" SSUR                  5      pT[        XC5      (       a  [        UR                  5      OU/n[        UR                  U5      (       a  [        UR                  R                  5      OUR                  /nUn[        XC5      (       a&  [        UR                  U5      (       a  U" / UQUQ76 n	O[        XC5      (       aG  [        UR                  U5      (       a,  UR                  U:X  a  U" U6 n	OXS" / UQUR                  P76 4n	Ok[        XB5      (       a0  [        UR                  U5      (       a  XE:X  a  U" U6 n	O5U" U/UQ76 n	O+XE:X  a  U" U6 n	O UR                  U:X  a  U" U6 n	O
U" / UQUQ76 n	U R                  U5      n
U R                  U5      nU R                  U	5      nUR                  S:X  a  SOSnSU
< SU< S	U< S	U< S
3	$ )Nr   )TransferFunctionSeriesr  r  r  rQ  r  r  r   ro   )sympy.physics.controlr  r  sys1r  r  r  rN  sys2r  r7  )r   r  r  r  r  tfnum_arg_listden_arg_list
den_term_1
den_term_2r  denom_1denom_2_signs                 rs   _print_FeedbackLatexPrinter._print_FeedbackW
  s   B))-aDHH=R)3C)@)@tCHH~setyy&)) DIINN+04		{ 	
c""z$))V'D'D===J$$DII?O)P)PyyB#\2
!A!Atyy!AA
..:dii3P3Py#\2
#C7,7
y#\2
b#\2
#A\ALA
C ++j)++j)yyBC).HHru   c                    SSK Jn  U R                  U" UR                  UR                  5      5      nU R                  UR                  5      nUR
                  S:X  a  SOSnSU< SU< SU< 3$ )	Nr   )
MIMOSeriesr  r  rQ  z\left(I_{\tau} r   z\right)^{-1} \cdot )r  r  r  r  r  r7  )r   r  r  inv_matr  r  s         rs   _print_MIMOFeedback LatexPrinter._print_MIMOFeedback{
  sR    4++jDII>?{{499%yyBC?DgtTTru   c                B    U R                  UR                  5      nSU-  $ )Nz%s_\tau)r  	_expr_matr  s      rs   _print_TransferFunctionMatrix*LatexPrinter._print_TransferFunctionMatrix
  s    kk$..)Cru   c                b    SR                  UR                  R                  UR                  5      $ )Nz\text{{{}}}_{{{}}})r  r^  r_  r  r"  s     rs   
_print_DFTLatexPrinter._print_DFT
  s#    $++DNN,C,CTVVLLru   c                ~    U R                  [        UR                  5      5      nU R                  U5      nU< SU< 3$ )Nr  )r  r   ra  r  )r   r  pretty_namepretty_morphisms       rs   _print_NamedMorphism!LatexPrinter._print_NamedMorphism
  s4    kk&"78..x8%77ru   c                h    SSK Jn  U R                  U" UR                  UR                  S5      5      $ )Nr   )NamedMorphismid)sympy.categoriesr  r  r3  r  )r   r  r  s      rs   _print_IdentityMorphism$LatexPrinter._print_IdentityMorphism
  s0    2((OOX..*6 7 	7ru   c                    UR                    Vs/ s H'  nU R                  [        UR                  5      5      PM)     nnUR	                  5         SR                  U5      S-   nU R                  U5      nXE-   $ s  snf )Nz\circ r  )rX  r  r   ra  reverser`  r  )r   r  	componentcomponent_names_listcomponent_namesr  s         rs   _print_CompositeMorphism%LatexPrinter._print_CompositeMorphism
  s}     .6-@-@ B-@	 !%F9>>,B C-@ 	  B$$&#..)=>D..x800 Bs   .A8c                h    SR                  U R                  [        UR                  5      5      5      $ NrM  )r  r  r   ra  )r   r  s     rs   _print_CategoryLatexPrinter._print_Category
  s%    &&t{{6(--3H'IJJru   c                    UR                   (       d  U R                  [        R                  5      $ U R                  UR                   5      nUR                  (       a!  USU R                  UR                  5      -  -  nU$ )Nz\Longrightarrow %s)premisesr  r   EmptySetconclusions)r   diagramlatex_results      rs   _print_DiagramLatexPrinter._print_Diagram
  sg    ;;qzz**{{7#3#341 KK(;(;<= =L ru   c                R   SSUR                   -  -  n[        UR                  5       Hv  n[        UR                   5       H>  nXU4   (       a  U[        XU4   5      -  nUS-  nXAR                   S-
  :w  d  M9  US-  nM@     X1R                  S-
  :w  a  US-  nUS-  nMx     US-  nU$ )	Nz\begin{array}{%s}
r   r   r  & r=  
z\end{array}
)widthr  heightlatex)r   gridr  r   r   s        rs   _print_DiagramGridLatexPrinter._print_DiagramGrid
  s    -tzz1ABt{{#A4::&1: E$!t*$55L#

Q& D(L ' KK!O#&D L $ 	((ru   c                    SR                  U R                  UR                  5      U R                  UR                  5      5      $ )Nz{{{}}}^{{{}}})r  r  r  r  r   rw  s     rs   _print_FreeModuleLatexPrinter._print_FreeModule
  s/    %%dkk!&&&94;;qvv;NOOru   c                X   ^  SR                  SR                  U 4S jU 5       5      5      $ )N\left[ {} \right]r  c              3  R   >#    U  H  nS TR                  U5      -   S-   v   M     g7fr   ro   Nr  r6  r7  r   s     rs   r8  8LatexPrinter._print_FreeModuleElement.<locals>.<genexpr>
  s&      43011C$++a. 3&rv  )r  r`  )r   r  s   ` rs   _print_FreeModuleElement%LatexPrinter._print_FreeModuleElement
  s.    #**388 430143 ,3 4 	4ru   c                ,  ^^ UR                    VVs/ s H<  o" Vs/ s H,  o0R                  UR                  R                  U5      5      PM.     snPM>     nnnS mS mSR	                  UU4S jU 5       5      nSR                  U5      $ s  snf s  snnf )Nc                    SU -   S-   $ )Nr   ro   rp   rM   s    rs   rt   /LatexPrinter._print_SubModule.<locals>.<lambda>
  s    $(T/ru   c                    SU -   S-   $ )Nz\left[ z \right]rp   r.  s    rs   rt   r/  
  s    :>K7ru   r  c           	   3  r   >#    U  H,  nT" T" S R                  U4S jU 5       5      5      5      v   M.     g7f)r  c              3  4   >#    U  H  nT" U5      v   M     g 7fr  rp   )r6  r7  curlys     rs   r8  :LatexPrinter._print_SubModule.<locals>.<genexpr>.<genexpr>
  s     3HaE!HHar  N)r`  )r6  gr3  squares     rs   r8  0LatexPrinter._print_SubModule.<locals>.<genexpr>
  s/     YTXqeF3883Ha3H+H$IJJTXs   47\left\langle {} \right\rangle)rB  r  r  r  r`  r  )r   r  r5  r7  rB  
gens_latexr3  r6  s         @@rs   _print_SubModuleLatexPrinter._print_SubModule
  sv    FGffMf!<!QQVV__Q/0!<fM)7XXYTXYY
/66zBB	 =Ms   	B3BBBc           	         SR                  UR                   Vs/ s H  nSU R                  U5      -   S-   PM     sn5      nSR                  U5      $ s  snf )Nr  r   ro   r8  )r`  rB  r  r  )r   r  r5  r9  s       rs   _print_SubQuotientModule%LatexPrinter._print_SubQuotientModule
  sL    XX166J6asT[[^3c96JK
/66zBB Ks   !Ac                   ^  UR                   R                   Vs/ s H  u  o!R                  R                  U5      PM!     nnSR	                  U 4S jU 5       5      nSR                  U5      $ s  snf )Nr  c              3  R   >#    U  H  nS TR                  U5      -   S-   v   M     g7fr'  r  r(  s     rs   r8  =LatexPrinter._print_ModuleImplementedIdeal.<locals>.<genexpr>
  s#     G$QcDKKN2S8$rv  r8  )_modulerB  r  r  r`  r  )r   r  r7  rB  r9  s   `    rs   _print_ModuleImplementedIdeal*LatexPrinter._print_ModuleImplementedIdeal
  sV    ./iinn=ns"n=XXG$GG
/66zBB >s   &A.c           	         UR                    Vs/ s H  nU R                  U[        S   SS9PM     nnUS   /[        USS  S5       VVs/ s H  u  p$US-   U-   PM     snn-   nSR	                  U5      $ s  snf s  snnf )	Nr
   Trw  r   r  ijkr   rr  )rN  r  r!   r  r`  )r   r  r   rr   r   r	  s         rs   _print_QuaternionLatexPrinter._print_Quaternion
  s     ii! q*U"3DA 	
 !qTF#aeU*;<*;$!aeAg*;<<zz!}!<s   "A5
A:c                    SR                  U R                  UR                  5      U R                  UR                  5      5      $ Nz\frac{{{}}}{{{}}})r  r  r  
base_ideal)r   Rs     rs   _print_QuotientRing LatexPrinter._print_QuotientRing
  s4    #**4;;qvv+>Q\\*, 	,ru   c                    U R                  UR                  R                  U5      5      nSR                  UU R                  UR                  R                  5      5      $ )N{{{}}} + {{{}}})r  r  r  r  rK  )r   r7  x_latexs      rs   _print_QuotientRingElement'LatexPrinter._print_QuotientRingElement
  sH    ++affooa01!((QVV../1 	1ru   c                H  ^  UR                    Vs/ s H'  o!R                  R                  R                  U5      PM)     nnSR	                  SR                  U 4S jU 5       5      5      nSR	                  UT R                  UR                  R                  5      5      $ s  snf )Nr%  r  c              3  R   >#    U  H  nS TR                  U5      -   S-   v   M     g7fr'  r  r(  s     rs   r8  <LatexPrinter._print_QuotientModuleElement.<locals>.<genexpr>
  s&      :6041C$++a. 3&rv  rP  )datamoduler  r  r  r`  r  killed_module)r   r  r7  rW  
data_latexs   `    rs   _print_QuotientModuleElement)LatexPrinter._print_QuotientModuleElement
  s    3466:6a&&q)6:)00 :604:6 26 7
!((QXX3346 	6 ;s   .Bc                    SR                  U R                  UR                  5      U R                  UR                  5      5      $ rJ  )r  r  rR  rY  r!  s     rs   _print_QuotientModule"LatexPrinter._print_QuotientModule
  s4    #**4;;qvv+>Q__-/ 	/ru   c                    SR                  U R                  UR                  5       5      U R                  UR                  5      U R                  UR                  5      5      $ )Nz{{{}}} : {{{}}} \to {{{}}})r  r  _sympy_matrixr3  r  )r   r  s     rs   _print_MatrixHomomorphism&LatexPrinter._print_MatrixHomomorphism
  sF    ,33DKK@Q4RKK!4;;qzz#:< 	<ru   c                    U R                  UR                  R                  5      u  p#nSU-  nU(       a  USSR                  U5      -  -  nU(       a  USSR                  U5      -  -  nU$ )Nrg  r  r   rf  )rJ  ra  r`  )r   manifoldra  rI  r  s        rs   _print_ManifoldLatexPrinter._print_Manifold
  se    !228==3E3EFdd"Gchhv...DGchhtn,,Dru   c                |    SU R                  UR                  5      < SU R                  UR                  5      < S3$ )N\text{rx  ro   )r  ra  re  )r   patchs     rs   _print_PatchLatexPrinter._print_Patch  s'    $(KK

$;T[[=XYYru   c                    SU R                  UR                  5      < SU R                  UR                  R                  5      < SU R                  UR                  5      < S3$ )Nri  z	}^{\text{z}}_{ro   )r  ra  rj  re  )r   coordsyss     rs   _print_CoordSystemLatexPrinter._print_CoordSystem  sC    KK&HNN4G4G(H$++V^VgVgJh
 	
ru   c                >    SU R                  UR                  5      -  $ )Nz\mathbb{\nabla}_{%s})r  _wrt)r   cvds     rs   _print_CovarDerivativeOp%LatexPrinter._print_CovarDerivativeOp  s    &SXX)>>>ru   c                    UR                   R                  UR                     R                  nSR	                  U R                  [        U5      5      5      $ r  
_coord_sysr  _indexra  r  r  r   r   fieldrN  s      rs   _print_BaseScalarField#LatexPrinter._print_BaseScalarField  s@    !!))%,,7<<&&t{{6&>'BCCru   c                    UR                   R                  UR                     R                  nSR	                  U R                  [        U5      5      5      $ )Nz\partial_{{{}}}rw  rz  s      rs   _print_BaseVectorField#LatexPrinter._print_BaseVectorField  s@    !!))%,,7<<!((VF^)DEEru   c                ,   UR                   n[        US5      (       aV  UR                  R                  UR                     R
                  nSR                  U R                  [        U5      5      5      $ U R                  U5      nSR                  U5      $ )Nrx  z\operatorname{{d}}{}z!\operatorname{{d}}\left({}\right))	_form_fieldr  rx  r  ry  ra  r  r  r   )r   diffr{  rN  s       rs   _print_Differential LatexPrinter._print_Differential  sw      5,''%%--ell;@@F*11$++fVn2MNN[['F7>>vFFru   c                `    U R                  UR                  S   5      nSR                  U5      $ )Nr   z"\operatorname{{tr}}\left({}\right)r  )r   r  contentss      rs   	_print_TrLatexPrinter._print_Tr!  s)    ;;qvvay)4;;HEEru   c                    Ub'  SU R                  UR                  S   5      < SU< S3$ SU R                  UR                  S   5      -  $ )Nz\left(\phi\left(r   \right)\right)^{ro   z\phi\left(%s\right)r/  rW  s      rs   _print_totientLatexPrinter._print_totient&  sC    ?TYYq\*C1 1%DIIaL(AAAru   c                    Ub'  SU R                  UR                  S   5      < SU< S3$ SU R                  UR                  S   5      -  $ )Nz\left(\lambda\left(r   r  ro   z\lambda\left(%s\right)r/  rW  s      rs   _print_reduced_totient#LatexPrinter._print_reduced_totient,  sC    ?TYYq\*C1 1(4;;tyy|+DDDru   c           	        [        UR                  5      S:X  a?  S[        [        U R                  UR                  S   UR                  S   45      5      -  nO!SU R	                  UR                  S   5      -  nUb
  SU< SU< 3$ SU-  $ )	Nr  _%s\left(%s\right)r  r   rs  z\sigma^{ro   z\sigma%sr  r  s       rs   _print_divisor_sigma!LatexPrinter._print_divisor_sigma2  s    tyy>Q'%DKK151tyy|0L1N +O OC %t{{499Q<'@@C?'*C00S  ru   c           	        [        UR                  5      S:X  a?  S[        [        U R                  UR                  S   UR                  S   45      5      -  nO!SU R	                  UR                  S   5      -  nUb
  SU< SU< 3$ SU-  $ )	Nr  r  r  r   rs  z
\sigma^*^{ro   z
\sigma^*%sr  r  s       rs   _print_udivisor_sigma"LatexPrinter._print_udivisor_sigma<  s    tyy>Q'%DKK151tyy|0L1N +O OC %t{{499Q<'@@C?),c22s""ru   c                    Ub'  SU R                  UR                  S   5      < SU< S3$ SU R                  UR                  S   5      -  $ )Nz\left(\nu\left(r   r  ro   z\nu\left(%s\right)r/  rW  s      rs   _print_primenuLatexPrinter._print_primenuF  sC    ?TYYq\*C1 1$t{{499Q<'@@@ru   c                    Ub'  SU R                  UR                  S   5      < SU< S3$ SU R                  UR                  S   5      -  $ )Nz\left(\Omega\left(r   r  ro   z\Omega\left(%s\right)r/  rW  s      rs   _print_primeomegaLatexPrinter._print_primeomegaL  sC    ?TYYq\*C1 1'$++diil*CCCru   c                ,    [        UR                  5      $ r  )r  ra  r  s     rs   
_print_StrLatexPrinter._print_StrR  s    166{ru   c                6    U R                  [        U5      5      $ r  )r  r   r"  s     rs   _print_floatLatexPrinter._print_floatU  s    {{5;''ru   c                    [        U5      $ r  r  r"  s     rs   
_print_intLatexPrinter._print_intX      4yru   c                    [        U5      $ r  r  r"  s     rs   
_print_mpzLatexPrinter._print_mpz[  r  ru   c                    [        U5      $ r  r  r"  s     rs   
_print_mpqLatexPrinter._print_mpq^  r  ru   c                    [        U5      $ r  r  r"  s     rs   _print_fmpzLatexPrinter._print_fmpza  r  ru   c                    [        U5      $ r  r  r"  s     rs   _print_fmpqLatexPrinter._print_fmpqd  r  ru   c                \    SR                  [        [        UR                  5      5      5      $ )Nz"\operatorname{{Q}}_{{\text{{{}}}}})r  r   r  ra  r"  s     rs   _print_PredicateLatexPrinter._print_Predicateg  s     4;;LTYY<XYYru   c                    UR                   nUR                  nU R                  U5      nSR                  U Vs/ s H  oPR                  U5      PM     sn5      nU< SU< S3$ s  snf )Nr\  r   r   )r@  	argumentsr  r`  )r   r  predrN  
pred_latexr	  
args_latexs          rs   _print_AppliedPredicate$LatexPrinter._print_AppliedPredicatej  sU    }}~~[[&
YY=1A=>
%z22  >s   A$c                >   > [         TU ]  U5      nS[        U5      -  $ )Nz\mathtt{\text{%s}})superemptyPrinterr   )r   r  rr   r^  s      rs   r  LatexPrinter.emptyPrinterq  s!    G &$|A66ru   )r   r  r  )FF)r  bool)r  r  )ri  z!bool | BooleanTrue | BooleanFalse)r  r   )r  r   )r+  r  r  r  )r  z'BasisDependent')r  r  r  r  )r  r   r  r  r  )r  r  r  r  r  )FN)r   )r  r   )ra  r  r  z tuple[str, list[str], list[str]])rN  r  r  r  )r  r&   )r  dict)F(E  r_  
__module____qualname____firstlineno__printmethodr   __annotations__r   r  r  r  r   r  r#  r,  rF  rK  r'  r)  rY  rc  rj  _print_BooleanTrue_print_BooleanFalsern  ry  r  r  r  r  r  r  r  r  r  r  r  r  r  r$  r!  r0  rB  rH  rc  rj  rn  rs  r  r  r  r  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.  r1  r4  r7  r:  r>  rB  rF  rJ  rO  rS  rV  r[  r_  _print_gammarb  rf  ri  rm  rr  ru  rx  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r'  r(  r,  r0  r4  r8  r@  rE  _print_RandomSymbolrJ  r]  rY  r^  rm  rt  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r
  r  r  r  r  r  r  r$  r*  r/  r2  r6  r;  r>  rA  rE  rL  rO  rT  rZ  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)  r,  r/  r5  r9  r>  rM  rR  rW  r[  r_  rc  rf  ri  rl  ro  rt  ry  r}  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  _print_IDFTr  r  r	  r  r  r  r"  r*  r:  r=  rC  rG  rM  rR  r[  r^  rb  rf  rk  ro  rt  r|  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  __static_attributes____classcell__)r^  s   @rs   r   r      s   K)U)E) 	e) 	4	)
 	-) 	) 	u) 	4) 	S) 	4) 	) 	d) 	) 	) 	)  	G!)" 	##)$ %"!#(5)~ :;fz,-% %EK. >3/  %% & 9BJ<NNMMIIqf/-+<Z&")&&<'@BE"/H4@J) J)X0
 , ,0
-  87J	++	7203DF)+  	 "	/[<%%; ; (L1:  ++"777777====- -4 42288	 !+@QGGSS'' A 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 7 7ru   r   c           
        [         R                  U 5      nU(       a  U$ U R                  5       [        ;   a  SU R                  5       -   $ U [        ;   a  SU -   $ [        [        R                  5       [        SS9 Hh  nU R                  5       R                  U5      (       d  M)  [        U 5      [        U5      :  d  MC  [        U   " [        U S[        U5      *  5      5      s  $    U $ )aj  
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)rP  r  N)tex_greek_dictionaryr   r  greek_letters_setother_symbolsr  r   r9  r  r*  rH  )rr   r  rP  s      rs   rH  rH  x  s     
"
"1
%C

	
'	'aggi	
m	ax -,,.CFCwwy!!#&&3q6CH+<$S))AjCyM*BCC G ru   c                6    [        U5      R                  U 5      $ )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                .    [        [        U 40 UD65        g)z\Prints LaTeX representation of the given expression. Takes the same
settings as ``latex()``.N)printr  r  s     rs   print_latexr  q  s     
%
!
!"ru   c           
        [        S0 UD6nUS:X  a  SnSnSn	Sn
SnO<US:X  a  SnSnSn	S	n
SnO+US
:X  a  SnSnSn	Sn
SnO[        SR                  U5      5      eSnU(       a  SnUR                  5       n[	        U5      nSn[        U5       H  nUU   nSnSnSnX:  a  U(       a  SnOSnSnX:X  a  UUS-
  :  a  X-   S-   S-   nOSnUR                  5       S   S:X  a  SU-  nSnUS:X  a?  US:X  a  SnUSR                  UR                  U 5      UUUR                  U5      U5      -  nO&USR                  UUUR                  U5      U5      -  nUS-  nM     Xz-  nU$ )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\dotsr  r  z& & r  r=  r  r   r  rQ  z{:s} {:s}{:s} {:s} {:s}z{:s}{:s} {:s} {:s}rp   )r   r   r  as_ordered_termsr  r  r  r  )rS  rU  terms_per_lineenvironmentuse_dotsr   r8  r  
first_termnonumberend_termdoubleetrs  rv  n_terms
term_countr   rw  
term_startterm_endr7  s                        rs   multiline_latexr  x  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
= > FMru   )rr   r  r  r  )r  r  F)J__doc__
__future__r   typingr   r   r   r  
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'   r  r  r  r   r  	frozensetr  compiler  r   r   rH  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%  JJ~JJ'( g+77 g+7TW> V0 V0r#~ru   