� ��g��� ��UdZddlmZddlmZmZmZddlZddlm Z m Z m Z m Z m Z mZmZmZddlmZddlmZddlmZmZmZdd lmZdd lmZdd lmZdd lm Z dd l!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(m)Z)ddl*m+Z+m,Z,ddl%m-Z-m.Z.ddl/m0Z0m1Z2ddl3m4Z4m5Z5ddl6Z6er ddl7m8Z8ddl9m:Z:gd�Z;idd�dd�dd�dd�dd �d!d"�d#d$�d%d&�d'd(�d)d*�d+d,�d-d.�d/d0�d1d2�d3d4�d5d6�d7d8�id9d:�d;d<�d=d>�d?d@�dAdB�dCdD�dEdF�dGdH�dIdJ�dKd,�dLdM�dNdD�dOdP�dQdR�dSdT�dUdV�dWdX��dYdZd[��Z<hd\�Z=id]d^��d_d`��dadb��dcdd��dedf��dgdh��didj��dkdl��dmdn��dodp��dqdr��dsdt��dudv��dwdx��dydz��d{d|��d}d~��d�d��d��d��d��d��d��d���Z>d�e?d�<e@e��ZAe6jBd���e6jBd���fZCd�d��ZDGd��d�e(��ZEd�d��ZFe)eE��d����ZGd��ZHd�d��ZIdS)�zC A Printer which converts an expression into its LaTeX equivalent. �)� annotations)�Any�Callable� TYPE_CHECKINGN)�Add�Float�Mod�Mul�Number�S�Symbol�Expr)�greeks)�Tuple)�Function� AppliedUndef� Derivative)�AssocOp)�Pow)�default_sort_key)� SympifyError)�true� BooleanTrue� BooleanFalse)�precedence_traditional)�Printer�print_function)�split_super_sub�requires_partial)� precedence� PRECEDENCE)� prec_to_dps�to_str)� has_variety�sift)� NDimArray)�BasisDependent)�arcsin�arccos�arctan�sin�cos�tan�sinh�cosh�tanh�sqrt�ln�log�sec�csc�cot�coth�re�im�frac�root�arg�Alphaz \mathrm{A}�Betaz \mathrm{B}�Gamma�\Gamma�Deltaz\Delta�Epsilonz \mathrm{E}�Zetaz \mathrm{Z}�Etaz \mathrm{H}�Thetaz\Theta�Iotaz \mathrm{I}�Kappaz \mathrm{K}�Lambdaz\Lambda�Muz \mathrm{M}�Nuz \mathrm{N}�Xiz\Xi�omicron�o�Omicronz \mathrm{O}�Piz\Pi�Rhoz \mathrm{P}�Sigmaz\Sigma�Tauz \mathrm{T}�Upsilonz\Upsilon�Phiz\Phi�Chiz \mathrm{X}�Psiz\Psi�Omegaz\Omega�lamdaz\lambda�Lamda�khiz\chi�Khi� varepsilonz \varepsilon�varkappaz \varkappa�varphiz\varphi�varpiz\varpi�varrhoz\varrhoz \varsigmaz \vartheta)�varsigma�vartheta> �wp�ell�eth�mho�beth�hbar�aleph�gimel�daleth�hslash�mathringc��d|zdzS)Nz \mathring{�}���ss �d/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/printing/latex.py�<lambda>rt[s��-��/�$�.���ddddotc��d|zdzS)Nz\ddddot{rorprqs rsrtrt\s�� �A� �d�*�ru�dddotc��d|zdzS)Nz\dddot{rorprqs rsrtrt]���z�!�|�D�(�ru�ddotc��d|zdzS)Nz\ddot{rorprqs rsrtrt^s��i��k�$�&�ru�dotc��d|zdzS)Nz\dot{rorprqs rsrtrt_���X�a�Z��_�ru�checkc��d|zdzS)Nz\check{rorprqs rsrtrt`rzru�brevec��d|zdzS)Nz\breve{rorprqs rsrtrtarzru�acutec��d|zdzS)Nz\acute{rorprqs rsrtrtbrzru�gravec��d|zdzS)Nz\grave{rorprqs rsrtrtcrzru�tildec��d|zdzS)Nz\tilde{rorprqs rsrtrtdrzru�hatc��d|zdzS)Nz\hat{rorprqs rsrtrterru�barc��d|zdzS)Nz\bar{rorprqs rsrtrtfrru�vecc��d|zdzS)Nz\vec{rorprqs rsrtrtgrru�primec��d|zdzS�N�{z}'rprqs rsrtrths��s�1�u�T�z�ru�prmc��d|zdzSr�rprqs rsrtrtis��S��U�4�Z�ru�boldc��d|zdzS�Nz \boldsymbol{rorprqs rsrtrtks��o�a�'��,�ru�bmc��d|zdzSr�rprqs rsrtrtls��O�A�%�d�*�ruc��d|zdzS)Nz \mathcal{rorprqs rsrtrtm���\�!�^�D�(�ruc��d|zdzS)Nz \mathscr{rorprqs rsrtrtnr�ruc��d|zdzS)Nz \mathfrak{rorprqs rsrtrtos��m�A�o�d�*�ruc��d|zdzS)Nz\left\|{z }\right\|rprqs rsrtrtqs��k�!�m�L�0�ruc��d|zdzS)Nz \left\langle{z}\right\ranglerprqs rsrtrtrs��%�a�'�(9�9�ruc��d|zdzS�Nz\left|{z}\right|rprqs rsrtrts���Z��\�+�-�ruc��d|zdzSr�rprqs rsrtrttr�ru)�cal�scr�frak�norm�avg�abs�magzdict[str, Callable[[str], str]]� modifier_dictz [0-9][} ]*$z(\d|\\frac{\d+}{\d+})rr�str�returnc���|�dd��}dD]}|�|d|z��}�|�dd��}|�dd��}|S)z� Escape a string such that latex interprets it as plaintext. We cannot use verbatim easily with mathjax, so escaping is easier. Rules from https://tex.stackexchange.com/a/34586/41112. �\z\textbackslashz&%$#_{}�~z\textasciitilde�^z\textasciicircum)�replace)rr�cs rs� latex_escaper�sm�� � � �$�)�*�*�A� �#�#�� �I�I�a���� "� "��� � � �#�)�*�*�A� � � �#�*�+�+�A� �Hruc �P ��eZdZUdZidd�dd�dd�dd�dd �d d�d d�d d�d d�dd�dd�dd�dd�di�dd�dd�dd�ddddddddd��Zded<�dbd �Z�dcd#�Z�dcd$�Z�dd�dcd%�Z d&�Z �dcd'�Z �ded)�Z �ded*�Z �dd�ded+�Z�ded,�Z�ded-�Z�ded.�Z�dfd0�Zd1�Z�dgd4�ZeZeZd5�Z�dbd6�Zd7�Zd8�Zd9�Zd:�Zd;�Zd<�Zd=�Zd>�Z d?�Z!d@�Z"�dhdB�Z#dC�Z$dD�Z%�didF�Z&�djdH�Z'dI�Z(dJ�Z)dK�Z*�dkdM�Z+dN�Z,dO�Z-dP�Z.dQ�Z/dR�Z0dS�Z1dT�Z2�dldV�Z3�db�dmdX�Z4dY�Z5dZ�Z6e7d[���Z8d\�Z9d]�Z:d^�Z;�db�dcd_�Z<e<xZ=Z>�dbd`�Z?�dbda�Z@�dbdb�ZA�dbdc�ZB�dbdd�ZC�dbde�ZDdf�ZEdg�ZFdh�ZGdi�ZHdj�ZI�dbdk�ZJ�dbdl�ZK�dbdm�ZL�dbdn�ZM�dbdo�ZN�dbdp�ZO�dbdq�ZP�dbdr�ZQ�dbds�ZR�dbdt�ZS�dbdu�ZT�dndw�ZU�dbdx�ZV�dbdy�ZW�dbdz�ZX�db�dcd{�ZYeYZZ�dbd|�Z[�dbd}�Z\�dbd~�Z]�dbd�Z^�dbd��Z_�dbd��Z`�dbd��Za�dbd��Zb�dbd��Zc�dbd��Zd�dod��Ze�dcd��Zf�dbd��Zg�dbd��Zh�dbd��Zi�dbd��Zj�dbd��Zk�dbd��Zl�dbd��Zm�dbd��Zn�dbd��Zo�dbd��Zp�dp�dcd��Zq�dp�dcd��Zr�dbd��Zs�dbd��Zt�dbd��Zu�dbd��Zv�dbd��Zw�dbd��Zx�dbd��Zy�dbd��Zz�dbd��Z{�dbd��Z|�dbd��Z}�dbd��Z~�dbd��Z�dbd��Z��dbd��Z��dbd��Z��dbd��Z��dbd��Z��dbd��Z��dbd��Z��dbd��Z��dbd��Z��dqd��Z��dbd��Z��dbd��Z��dbd��Z��dbd��Z�d��Z�d��Z��dr�dsd��Z�e�Z��dr�dtd��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d„Z��dbdÄZ�dĄZ�dńZ�dƄZ�dDŽZ�dȄZ�dɄZ�dʄZ�d˄Z�d̄Z��dud΄Z��dvdфZ�d҄Z�dӄZ�dԄZ�dՄZ�dքZ�dׄZ�d؄Z�dلZ�dڄZ��dbdۄZ�d܄Z�d݄Z�dބZ�d߄Z�d��Z�d�Z�d�Z��dbd�Z��dbd�Z��dbd�Z��dbd�Z��dbd�Z�d�Z�d�Z�d�Z�e�Z�d�ZŐdbd�ZƐdbd�Zǐdbd�ZȐdbd�Zɐdbd��Zʐdbd�Zːdbd�Z̐dbd�Z�d�Z�e�Z�e�Z�e�Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Z�d��Zܐd�Zݐd�Zސd�Zߐd�Z��d�Z�d�Z�d�Z�d�Z�d�Z�d �Z�d �Z�d �Z�d �Z�d �Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z�d�Z��d�Z��d�Z��db�d�Z��db�d�Z��dw�d�Z��d�Z��d�Z��d�Z��d �Z��d!�Z��d"�Z��d#��Z�d$��Z�d%��Z�d&��Z�d'��Z�d(��Z�d)��Z�db�d*��Z�d+��Z�d,��Z �d-��Z �d.��Z �d/��Z �d0��Z �d1��Z�d2��Z�d3��Z�d4��Z�d5��Z�d6��Z�d7��Z�d8��Z�e�Z�d9��Z�d:��Z�d;��Z�d<��Z�d=��Z�d>��Z�d?��Z�d@��Z�dA��Z�dB��Z �dC��Z!�dD��Z"�dE��Z#�dF��Z$�dG��Z%�dH��Z&�dI��Z'�dJ��Z(�dK��Z)�dL��Z*�dM��Z+�dN��Z,�dO��Z-�dP��Z.�dQ��Z/�db�dR��Z0�db�dS��Z1�db�dT��Z2�db�dU��Z3�db�dV��Z4�db�dW��Z5�dX��Z6�dY��Z7�dZ��Z8�d[��Z9�d\��Z:�d]��Z;�d^��Z<�d_��Z=�d`��Z>�f�da��Z?�x�Z@S(x� 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_stylezdict[str, Any]�_default_settingsc�6�tj||��d|jvr"gd�}|jd|vrtd���|jd�|jddkr d|jd<ddd d d �} ||jd |jd <n%#t$r|jd |jd <YnwxYw ||jd pd|jd<nW#t$rJ|jd ���dvr|d|jd<n|jd |jd<YnwxYwddd�|_dddddddd�}|jd}|�||��|jd<ddddd �}|jd!}|�||��|jd"<dS)#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 rsr�zLatexPrinter.__init__�sP�����x�(�(�(� �T�^� #� #�(�(�(�K��~�f�%�[�8�8� �"=�>�>�>� �>�+� ,� 4���v�&�(�2�2�04�D�N�,� -���� �  � ��  -� ��� �!=�>� �N�-� .� .��� -� -� -���|�,� �N�-� .� .� .� -���� 1� ��� �!=�!F��G� �N�5� 6� 6��� 1� 1� 1���|�,�2�2�4�4�B�C�C�%�U�+���9�:�:��N�<�0���9�:���  1����"%�3�/�/���������� � ���N�#3�4� �1E�1I�1I�)�U^�1_�1_���-�.�����  � �� ���7� �0C�0G�0G� �Wd�0e�0e���,�-�-�-s%�1B � B/�.B/�3C�AD%�$D%r�r�c�,�d�|��S)Nz\left({}\right)��format�r�rrs rs� _add_parenszLatexPrinter._add_parens�s��!�(�(��+�+�+ruc�,�d�|��S)Nz\left( {}\right)rrs rs�_add_parens_lspacezLatexPrinter._add_parens_lspace�s��"�)�)�!�,�,�,ruc��t|��}|r*|r(|�|�|����S||ks|s.||kr(|�|�|����S|�|��S�N)rr�_print)r��item�level�is_neg�strict�prec_vals rs� parenthesizezLatexPrinter.parenthesize�s���)�$�/�/�� � 7�f� 7��#�#�D�K�K��$5�$5�6�6� 6� �u� � �v� �8�u�3D�3D��#�#�D�K�K��$5�$5�6�6� 6��;�;�t�$�$� $ruc�|�d|vr7|jdr|�|��Sd�|��S|S)z� Protect superscripts in s If the parenthesize_super option is set, protect with parentheses, else wrap in braces. r�r�z{{{}}})r�rrrs rsr�zLatexPrinter.parenthesize_super�sH�� �!�8�8��~�2�3� *��'�'��*�*�*����q�)�)�)��ruc���tj||��}|jddkr|S|jddkrd|zS|jdrd|zS|jd}d|�d|�d |�d�S) Nr�r�r�z$%s$r�z$$%s$$z\begin{roz\end{)r�doprintr�)r��expr�tex�env_strs rsrzLatexPrinter.doprint s����o�d�D�)�)�� �>�&� !�W� ,� ,��J� �^�F� #�x� /� /��S�=� � �^�F� #� E��s�?� "��n�V�,�G�G�.5�g�g�s�s�s�G�G�G�D� Dru�boolc�\�|jr|jp|jo|tjuo|jdu S)z� Returns True if the expression needs to be wrapped in brackets when printed, False otherwise. For example: a + b => True; a => False; 10 => False; -10 => True. F)� is_Integer�is_nonnegative�is_Atomr � NegativeOne� is_Rational�r�rs rs�_needs_bracketszLatexPrinter._needs_bracketssH�� �_�<��)<�J�� �I�$�a�m�*C�+H�.2�.>�%�.G�K� Kruc���|�|��sdS|jr|�|��sdS|jr|�|��sdS|js|jrdSdS)a� Returns True if the expression needs to be wrapped in brackets when passed as an argument to a function, False otherwise. This is a more liberal version of _needs_brackets, in that many expressions which need to be wrapped in brackets when added/subtracted/raised to a power do not need them when passed to a function. Such an example is a*b. FT)r�is_Mul� _mul_is_clean�is_Pow� _pow_is_clean�is_Add� is_Functionrs rs�_needs_function_bracketsz%LatexPrinter._needs_function_brackets s����#�#�D�)�)� ��5��{� �4�#5�#5�d�#;�#;� ��t��� �T�%7�%7��%=�%=� ��t��� �� 0� ��t��uruc�Z��ddlm}ddlm}ddlm}�jr|s����rdSn)t���tdkrdS�j rdS�j rdSt�fd�tfD����rdS|s t�fd�|||fD����rdSd S) 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 c3�B�K�|]}��|��V��dSr��has��.0�xrs �rs� <genexpr>z3LatexPrinter._needs_mul_brackets.<locals>.<genexpr>N�-�����+�+�q�t�x�x��{�{�+�+�+�+�+�+ruc3�B�K�|]}��|��V��dSrr,r.s �rsr1z3LatexPrinter._needs_mul_brackets.<locals>.<genexpr>Qs-�����B�B�A�D�H�H�Q�K�K�B�B�B�B�B�BruF)�sympy.concrete.productsr(�sympy.concrete.summationsr)�sympy.integrals.integralsr*r �could_extract_minus_signrr!� is_Relational� is_Piecewise�anyr )r�r�first�lastr(r)r*s ` rs�_needs_mul_bracketsz LatexPrinter._needs_mul_brackets7s ��� 4�3�3�3�3�3�1�1�1�1�1�1�6�6�6�6�6�6� �;� �� �T�:�:�<�<� ��t�� #�D� )� )�J�u�,=� =� =��4� � � ��4� � � ��4� �+�+�+�+�S�F�+�+�+� +� +� ��4�� ��B�B�B�B�(�G�S�)A�B�B�B�B�B� ��4��uruc�r���jrdSt�fd�tfD����rdS�jrdSdS)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. Tc3�B�K�|]}��|��V��dSrr,r.s �rsr1z3LatexPrinter._needs_add_brackets.<locals>.<genexpr>^r2ruF)r8r:r r$rs `rs�_needs_add_bracketsz LatexPrinter._needs_add_bracketsVsU��� � � ��4� �+�+�+�+�S�F�+�+�+� +� +� ��4� �;� ��4��uruc�.�|jD] }|jrdS� dS)NFT)�argsr%)r�rr<s rsr!zLatexPrinter._mul_is_cleands.���9� � �C��� ��u�u� ��truc�8�|�|j�� Sr)r�basers rsr#zLatexPrinter._pow_is_cleanjs���'�'�� �2�2�2�2rurc��|� d|�d|�d�S|S)N�\left(� \right)^{rorp�r�r�exps rs� _do_exponentzLatexPrinter._do_exponentms!�� �?�?�.2�d�d�C�C�C�8� 8��Kruc������|jj��}|jr>�fd�|jD��}d}|�|d�|����Sd�|��S)Nc�:��g|]}��|����Srp�r )r/rMr�s �rs� <listcomp>z-LatexPrinter._print_Basic.<locals>.<listcomp>vs#���4�4�4�Q�$�+�+�a�.�.�4�4�4ruz"\operatorname{{{}}}\left({}\right)�, z \text{{{}}})�_deal_with_super_sub� __class__�__name__rBr�join)r�r�name�lsrrs` rs� _print_BasiczLatexPrinter._print_Basicssw����(�(���)@�A�A�� �9� /�4�4�4�4�$�)�4�4�4�B�5�A��8�8�D�$�)�)�B�-�-�0�0� 0�!�(�(��.�.� .ru�e�!bool | BooleanTrue | BooleanFalsec� �d|zS�N� \text{%s}rp�r�rWs rs� _print_boolzLatexPrinter._print_bool|� ���a��ruc� �d|zSrZrpr\s rs�_print_NoneTypezLatexPrinter._print_NoneType�r^ruc��|�||���}d}t|��D]b\}}|dkrn"|���r |dz }| }n|dz }|�|��}|�|��rd|z}||z }�c|S)N)r�r�r� - � + �\left(%s\right))�_as_ordered_terms� enumerater7r r@)r�rr��termsrr��term�term_texs rs� _print_AddzLatexPrinter._print_Add�s����&�&�t�5�&�9�9���� ��'�'� � �G�A�t��A�v�v���.�.�0�0� ��u� ���u����u� ���{�{�4�(�(�H��'�'��-�-� 9�-��8�� �8�O�C�C�� ruc�L�ddlm}|jdkrdS||��}|j}|j}|jd|dz kr ||dz ggz}d}|D](}|t |���dd��z }�)|�d d ��}|�d d ��}|S) Nr�� Permutation�\left( \right)������r��,r�r��\left( r��\right))� sympy.combinatorics.permutationsrm�size� cyclic_form� array_formr�r�)r�rrm� expr_perm�sizrir�s rs� _print_CyclezLatexPrinter._print_Cycle�s���@�@�@�@�@�@� �9��>�>�$�$��{�4� � ���$� ��i�� �?�2� �#��'� )� )�!�c�A�g�Y�K�/�I���� 3� 3�A� ��A�����s�E�2�2� 2�H�H��#�#�C��4�4���#�#�C��4�4���ruc����ddlm}ddlm}|j}|�|d|�d�ddd� ��n�j�d d ��}|r��|��S|jdkrd S�fd �|j D��}�fd�tt|����D��}d� |��}d� |��}d� ||f��} d| zS)Nrrl)�sympy_deprecation_warningzw Setting Permutation.print_cyclic is deprecated. Instead use init_printing(perm_cyclic=z). z1.6z#deprecated-permutation-print_cyclic�)�deprecated_since_version�active_deprecations_target� stacklevelr�Trnc�:��g|]}��|����SrprM�r/r<r�s �rsrNz3LatexPrinter._print_Permutation.<locals>.<listcomp>�s%���=�=�=�c����S�!�!�=�=�=ruc�:��g|]}��|����SrprMr�s �rsrNz3LatexPrinter._print_Permutation.<locals>.<listcomp>�s%���?�?�?�c����S�!�!�?�?�?ru� & � \\ z \begin{pmatrix} %s \end{pmatrix}) rtrm�sympy.utilities.exceptionsr|� print_cyclicr�r�rzrurw�range�lenrS) r�rrmr|r��lower�upper�row1�row2�mats ` rs�_print_PermutationzLatexPrinter._print_Permutation�s@���@�@�@�@�@�@�H�H�H�H�H�H�!�.� � � "� %� %��+6����*/�+P�� � � � � ��.�,�,�]�D�A�A�K� � +��$�$�T�*�*� *� �9��>�>�$�$�=�=�=�=�T�_�=�=�=��?�?�?�?�U�3�u�:�:�->�->�?�?�?���z�z�%� � ���z�z�%� � ���l�l�D�$�<�(�(��2�S�8�8ruc�t�|j\}}d|�|���d|�|���d�S)Nz\sigma_{z}(r�)rBr )r�r�perm�vars rs�_print_AppliedPermutationz&LatexPrinter._print_AppliedPermutation�s>���I� ��c�c�%)�[�[��%6�%6�%6�%6�� � �C�8H�8H�8H�8H�I�Iruc�0�t|j��}|jdrdnd}d|jvr |jdnd}d|jvr |jdnd}t|j||||���}|jd}d|vr_|�d��\}} | d d kr | d d�} |jd d kr|�dd��}|�|�d| �d�S|dkrdS|dkrdS|jd d kr|�dd��}|S)Nr�FTr�r�)� strip_zeros� min_fixed� max_fixedr�rWr�+rpr��comma�.z{,}z10^{roz+infz\inftyz-infz- \infty)r"�_precr�� mlib_to_str�_mpf_�splitr�) r�r�dpsr��low�high�str_real� separator�mantrIs rs� _print_FloatzLatexPrinter._print_Float�sL���$�*�%�%���� �4�>���$��',���'>�'>�d�n�U�#�#�D��(-���(?�(?�t�~�e�$�$�T���t�z�3�E�S�\`�a�a�a���N�#=�>� � �(�?�?�"�.�.��-�-�K�T�3��1�v��}�}��!�"�"�g���~�1�2�g�=�=��|�|�C��.�.��%)�T�9�9�9�c�c�c�:� :� �� � ��9� �� � ��;��~�1�2�g�=�=�#�+�+�C��6�6���Oruc��|j}|j}|�|td���d|�|td����S)Nr r���_expr1�_expr2rr!�r�r�vec1�vec2s rs� _print_CrosszLatexPrinter._print_Cross�sU���{���{��"&�"3�"3�D�*�U�:K�"L�"L�"L�"L�"&�"3�"3�D�*�U�:K�"L�"L�"L�N� Nruc�X�|j}d|�|td��zS)Nz\nabla\times %sr ��_exprrr!�r�rr�s rs� _print_CurlzLatexPrinter._print_Curl�s)���j��!�D�$5�$5�c�:�e�;L�$M�$M�M�Mruc�X�|j}d|�|td��zS)Nz\nabla\cdot %sr r�r�s rs�_print_DivergencezLatexPrinter._print_Divergence�s)���j�� �4�#4�#4�S�*�U�:K�#L�#L�L�Lruc��|j}|j}|�|td���d|�|td����S)Nr r�r�r�s rs� _print_DotzLatexPrinter._print_Dot�sU���{���{��!%�!2�!2�4��E�9J�!K�!K�!K�!K�!%�!2�!2�4��E�9J�!K�!K�!K�M� Mruc�X�|j}d|�|td��zS)Nz \nabla %sr r��r�r�funcs rs�_print_GradientzLatexPrinter._print_Gradient��)���z���d�/�/��j��6G�H�H�H�Hruc�X�|j}d|�|td��zS)Nz \Delta %sr r�r�s rs�_print_LaplacianzLatexPrinter._print_Laplacianr�rurc �������ddlm}�jd��jd�d!��fd� }d!���fd� �t|t��rG|j}|dt jus!td �|d d�D����r �|��Sd }|� ��r| }d }|j r|d z }d}nd}||d���\}}|t jur)td dd ���|jvr|||��z }�n�||��} ||��} t| � ����} �jd} �jdr:| dkr4d| vr0��|d ���r |d| �d| ��z }�nn|| �d| ��z }�nb| ��St| � ����| | zk�r*��|d���r|d| �d��d| �d�z }�n|jr�t j} t j}|jD]n}��|d ���sJt|| |z��� ����| | zks|j|jcxurd ur nn||z}�i| |z} �o��|d���r%|d|| ���d| �d��d||���d� z }n=|d|| ���d| �d��||����z }n|d| �d��| ��z }n |d| �d| �d�z }|r|d z }|S)"Nr)�fractionr�r�r�r�c�4��|js"t��|����S�jdvr|���}nt |j��}t|d�d���\}}t|d�d���\}}�||z|z��S)N)�old�nonec��t|d��p9t|d��p)t|t��ot|jd��S)N� _scale_factor�is_physical_constant)�hasattr� isinstancerrD�r0s rsrtz:LatexPrinter._print_Mul.<locals>.convert.<locals>.<lambda>sN����?�8S�8S�8y�W^�_`�bx�Wy�Wy�8H�)�!�S�1�1� G�&�q�v�/E�F�F�ruT)�binaryc�"�t|d��S)Nr�)r�r�s rsrtz:LatexPrinter._print_Mul.<locals>.convert.<locals>.<lambda>s����?�8S�8S�ru)r r�r r��as_ordered_factors�listrBr%)rrB�units�nonunits�prefixes� convert_argsr�s ��rs�convertz(LatexPrinter._print_Mul.<locals>.convert s�����;� A��4�;�;�t�,�,�-�-�-��:�_�4�4��2�2�4�4�D�D��� �?�?�D�#'�t�.H�.H�PT�#V�#V�#V���x�#'�u�.S�.S�\`�"a�"a�"a���%�#�|�H�x�$7�%�$?�@�@�@ruc ����dx}}t|��D]�\}}��|��}t|d��s�t|d��s���||dk|t |��dz k���rd|z}t d�|��r&t d�|��r|�z }n|r|�z }n|r|�z }||z }|}��|S)Nr�r�r�rrp)r;r<rd)rfr r�r=r��_between_two_numbers_p�search�match) rB�_tex� last_term_texr�rhri� numbersepr�r�s ���rsr�z-LatexPrinter._print_Mul.<locals>.convert_argss���#%� %�D�=�$�T�?�?� )� )���4��;�;�t�,�,����o�6�6� &�'�$�H^�:_�:_� &��/�/��Q�!�V�67�3�t�9�9�q�=�6H�0�K�K�A�#5��#@��.�q�1�8�8��G�G�*�.�q�1�7�7��A�A�*�� �)����*�� �)����&��I�%�D��� �� (� � ��Kruc3�@K�|]}t|t��V��dSr)r�r )r/r<s rsr1z*LatexPrinter._print_Mul.<locals>.<genexpr>:s,����&S�&S�3�z�#�v�'>�'>�&S�&S�&S�&S�&S�&SrurpF�- r�Tr�)�exactro)�evaluater�r��r�)r<rFz \right) / z / z \frac{1}{rors�\frac{�}{r��r�r�)�sympy.simplifyr�r�r�r rBr �Oner:r7r$rr�r�r=r �is_commutative)r�rr�r�rB�include_parensr�numer�denom�snumer�sdenom�ldenom�ratio�a�br0r�r�r�s` @@@rs� _print_MulzLatexPrinter._print_Muls$������+�+�+�+�+�+���(:�;� ���(B�C� � A� A� A� A� A� A� A�  � � � � � � � �8 �d�C� � � *��9�D��A�w�!�%���3�&S�&S�$�q�r�r�(�&S�&S�&S�#S�#S��#�|�D�)�)�)��� � (� (� *� *� ��5�D��C��{� &��s� ��!%����C��x��D�1�1�1� ��u� �A�E�>�>�c�!�R�%�8�8�8�� �I�I� �7�7�4�=�=� �C�C��W�U�^�^�F��W�U�^�^�F�������(�(�F��N�#4�5�E��~�/�0�! ;�V�q�[�[��v�%�%��+�+�E��+�>�>�9��C�f�f�f�f�f�E�E�C�C�������8�8�C�C��"��� � ���'�'�%��,�6�6��+�+�E��+�=�=�M��C�!�6�6�9�9�9�f�f�f�6�6�C�C��\�M���A���A�"�Z�#�#���3�3�A�E�3�B�B�#� #�G�G�A�a�C�L�L�$6�$6�$8�$8� 9� 9�E�&�L� H� H�!"�!1�Q�5E�!N�!N�!N�!N��!N�!N�!N�!N�!N���F�A�A���F�A�A��/�/���/�=�=�J���&�w�q�z�z�z�z�6�6�6�9�9�9�g�g�a�j�j�j�j� J�J�����&�w�q�z�z�z�z�6�6�6�9�9�g�g�a�j�j�j� J�J����C�&�&�&�)�)�V�V�L�L�C�C���6�6�6�6�6�6�:�:�� � � �3�J�C�� ruc���|jr9|�|��������S|�|�����Sr)� is_aliasedr �as_poly�as_exprrs rs�_print_AlgebraicNumberz#LatexPrinter._print_AlgebraicNumberzsL�� �?� /��;�;�t�|�|�~�~�5�5�7�7�8�8� 8��;�;�t�|�|�~�~�.�.� .ruc��|�|j��}|jrd|�d�S|�|j�����}d|�d|�d�S)NrFrsrO)r �p�is_inert�alphar�)r�rr�r�s rs�_print_PrimeIdealzLatexPrinter._print_PrimeIdeal�sh�� �K�K��� � �� �=� (�'�Q�'�'�'� '�� � �D�J�.�.�0�0�1�1��,��,�,�e�,�,�,�,rurc��|jj�r�|jj}|jj}t |��dkrh|dkrb|jdrU|�|j��}|dkrd|z}n|jdrd||fz}nd||fz}|jjrd|zS|S|jd r�|dkr|� |jtd ��}|jj r|� |��}|jj r!|�|j|�d |��� ��S|�d |�d |�d�S|jjr�|jjr�|jdkr|j�d |j�d�S|jjr`|jj}|jj}||zt |��kr2|jdkr d|�d|�d�Sd|�d|�dt |j���d�S|�|��S|jj r4|�|j|�|j��� ��Sd}|�||��S)Nrpr�r�z \sqrt{%s}r�z \root{%d}{%s}z \sqrt[%d]{%s}z \frac{1}{%s}r�r�/�rI�^{roroz\frac{1}{\frac{r��}}z\frac{1}{(\frac{z})^{z%s^{%s})rIrr��qr�r�r rD� is_negativerr!� is_Symbolr�r%r�r��_helper_print_standard_power)r�rr�r�rDr�base_p�base_qs rs� _print_PowzLatexPrinter._print_Pow�sx�� �8� �% -��X�Z�A��X�Z�A��1�v�v��{�{�q�A�v�v�$�.��*I�v��{�{�4�9�-�-����6�6�&��-�C�C��^�F�+�7�*�a��Y�6�C�C�*�a��Y�6�C��8�'��*�S�0�0��J��� 2�3� -��Q����(�(���J�u�4E�F�F���9�&�9��2�2�4�8�8�D��9�(�H��;�;�t�y����A�A�6F�;�G�G�G�(,���a�a�a����3�3���%� -�$�)�*B� -��9��>�>�)-����D�H�H�H�=�=��9�(�g�"&�)�+�F�"&�)�+�F����#�f�+�+�5�5��8�r�>�>�>�AG������#P�P�*�IO���PV�PV�PV�X[�\`�\d�Xe�Xe�Xe�Xe�#f�f����t�,�,�,� �9� � E��;�;�t�y�d�k�k�$�(�.C�.C�;�D�D� D����0�0��s�;�;�;ru�templatec��|�|j��}|�|jtd��}|jjr|�|��}nu|jjrd|z}nct|jt��rI|� d��r4tj d|��r|� d��r |dd�}|||fzS)Nrz{%s}rFz\\left\(\\d?d?dotrs�i����)r rIrrDr!r�r��is_Floatr�r� startswithr8r��endswith)r�rrrIrDs rsrz)LatexPrinter._helper_print_standard_power�s����k�k�$�(�#�#��� � ���J�u�,=�>�>�� �9� � ��*�*�4�0�0�D�D� �Y� � ��T�>�D�D����J�/�/� ���� �*�*� ���-�t�4�4� �� � �j�)�)� � ��2��;�D��4��+�%�%ruc�B�|�|jd��S�Nr�r rBrs rs�_print_UnevaluatedExprz#LatexPrinter._print_UnevaluatedExpr�s���{�{�4�9�Q�<�(�(�(ruc����t|j��dkr*dt�fd�|jdD����z}n4�fd��dt�d�fd�|jD����z}t |jt��r!|d ��|j��zz }n|��|j��z }|S) Nrpz\sum_{%s=%s}^{%s} c�:��g|]}��|����SrprM�r/r�r�s �rsrNz+LatexPrinter._print_Sum.<locals>.<listcomp>��#���>�>�>�!�t�{�{�1�~�~�>�>�>rurc�j��dt�fd�|d|d|dfD����zS)N�%s \leq %s \leq %sc�:��g|]}��|����SrprM�r/rrr�s �rsrNzALatexPrinter._print_Sum.<locals>._format_ineq.<locals>.<listcomp>��#���F�F�F�a�4�;�;�q�>�>�F�F�Frurprr���tuple��lr�s �rs� _format_ineqz-LatexPrinter._print_Sum.<locals>._format_ineq��E���,��F�F�F�F�A�a�D�!�A�$��!��3E�F�F�F�G�G�H�Hruz\sum_{\substack{%s}} �\\c�&��g|] }�|����Srprp�r/rrs �rsrNz+LatexPrinter._print_Sum.<locals>.<listcomp>��!���!G�!G�!G�a�,�,�q�/�/�!G�!G�!Grurd� r��limitsrr�rSr��functionrr �r�rrrs` @rs� _print_SumzLatexPrinter._print_Sum�s����� �t�{� � �q� � �'��>�>�>�>�t�{�1�~�>�>�>�?�?�@�C�C� H� H� H� H� H�+�����!G�!G�!G�!G�4�;�!G�!G�!G�H�H�I�C� �d�m�S� )� )� .� �%�� � �D�M�(B�(B�B� B�C�C� �4�;�;�t�}�-�-� -�C�� ruc����t|j��dkr*dt�fd�|jdD����z}n4�fd��dt�d�fd�|jD����z}t |jt��r!|d ��|j��zz }n|��|j��z }|S) Nrpz\prod_{%s=%s}^{%s} c�:��g|]}��|����SrprMrs �rsrNz/LatexPrinter._print_Product.<locals>.<listcomp>�rrurc�j��dt�fd�|d|d|dfD����zS)Nrc�:��g|]}��|����SrprMrs �rsrNzELatexPrinter._print_Product.<locals>._format_ineq.<locals>.<listcomp>�rrurprr�rrs �rsrz1LatexPrinter._print_Product.<locals>._format_ineq�rruz\prod_{\substack{%s}} rc�&��g|] }�|����Srprprs �rsrNz/LatexPrinter._print_Product.<locals>.<listcomp>�r rurdr!r$s` @rs�_print_ProductzLatexPrinter._print_Product�s����� �t�{� � �q� � �(��>�>�>�>�t�{�1�~�>�>�>�?�?�@�C�C� H� H� H� H� H�,�����!G�!G�!G�!G�4�;�!G�!G�!G�H�H�I�C� �d�m�S� )� )� .� �%�� � �D�M�(B�(B�B� B�C�C� �4�;�;�t�}�-�-� -�C�� ru�'BasisDependent'c���ddlm}g}||jkr |jjSt ||��r'|������}nd|fg}|D]�\}}t|j�����}|� d����|D]�\}} | dkr|� d|jz���)| dkr|� d|jz���Md |� | ��zd z} |� d| z|jz������d � |��} | dd kr | d d�} n | dd�} | S)Nr)�Vectorc�6�|d���Sr )�__str__r�s rsrtz4LatexPrinter._print_BasisDependent.<locals>.<lambda>�s��!�A�$�,�,�.�.�ru��keyrprcrorbrFrsr��-�) � sympy.vectorr.�zero� _latex_formr��separate�itemsr�� components�sort�appendr rS) r�rr.�o1r9�system�vect� inneritems�k�v�arg_str�outstrs rs�_print_BasisDependentz"LatexPrinter._print_BasisDependent�s���'�'�'�'�'�'��� �4�9� � ��9�(� (� �d�F� #� #� ��M�M�O�O�)�)�+�+�E�E���Y�K�E�!� ?� ?�L�F�D��d�o�3�3�5�5�6�6�J� �O�O� 8� 8�O� 9� 9� 9�"� ?� ?���1���6�6��I�I�e�a�m�3�4�4�4�4��"�W�W��I�I�e�a�m�3�4�4�4�4�'�$�+�+�a�.�.�8�:�E�G��I�I�e�g�o�� �=�>�>�>�>� ?��'�'�"�+�+�� �!�9�� � ��A�B�B�Z�F�F��A�B�B�Z�F�� ruc��|�|j��}d|zdzdd�t|j|j����zz}|S)Nr�ro�_{%s}rq)r rDrS�map�indices)r�r�tex_basers rs�_print_IndexedzLatexPrinter._print_Indexed sU���;�;�t�y�)�)���(�l�3��w���� �� �T�\� *� *�*,�*,� ,�,��� ruc�6�|�|j��Sr)r �labelrs rs�_print_IndexedBasezLatexPrinter._print_IndexedBases���{�{�4�:�&�&�&ruc�Z�|�|j��}|j��|�|j��}|j�|�|j��}n|�tj��}d�||���}d�||���S|S)Nz%{lower}\mathrel{{..}}\nobreak {upper})r�r�z{{{label}}}_{{{interval}}})rM�interval)r rMr�r�r �Zeror)r�rrMr�r�rPs rs� _print_IdxzLatexPrinter._print_Idxs���� � �D�J�'�'�� �:� !��K�K�� �+�+�E��z�%�� � �D�J�/�/���� � �A�F�+�+��@�G�G�!�5�H�2�2�H�/�6�6��(�7�4�4� 4�� ruc ��t|j��rd}n |jd}d}d}t|j��D]u\}}||z }|dkr||�d|�|����z }�.||�d|�|�|�����d|�|���d�z }�v|dkr d |�d |�d�}nd |�d|�|���d |�d�}td �|jD����r.|�d|� |jtd dd�����S|�d|� |jtd dd�����S)Nz\partialr�r�rrpr�r�ror�r��}}{c3�>K�|]}|���V��dSr�r7�r/r�s rsr1z1LatexPrinter._print_Derivative.<locals>.<genexpr>:s.����?�?��q�)�)�+�+�?�?�?�?�?�?rur T�r r F) rrr��reversed�variable_countr r�r:rBrr!)r�r� diff_symbolr�dimr0�nums rs�_print_DerivativezLatexPrinter._print_Derivative$s��� �D�I� &� &� @�%�K�K��.�)>�?�K������t�2�3�3� :� :�F�A�s� �3�J�C��a�x�x��;�;�;�� � �A����?�?���� � � �(,�(?�(?�� � �A���(O�(O�(O�(O�(,� � �C�(8�(8�(8�(8�:�:��� �!�8�8�8�&1�k�k�3�3�3�7�C�C� �,7�;�;�� � �C�8H�8H�8H�8H�#�#�#�N�C� �?�?�T�Y�?�?�?� ?� ?� @�"�s�s�D�$5�$5�d�i�2<�U�2C�9=�9=�%6�%?�%?�%?�@� @� �3�3�� 1� 1�$�)�2<�U�2C�9>�9=�!2�!?�!?�!?�@� @ruc����|j\}}}��|��}�fd�|D��}�fd�|D��}d�d�t||��D����}d|�d|�d�S)Nc3�B�K�|]}��|��V��dSrrM�r/rWr�s �rsr1z+LatexPrinter._print_Subs.<locals>.<genexpr>H�-�����1�1��T�[�[��^�^�1�1�1�1�1�1ruc3�B�K�|]}��|��V��dSrrMras �rsr1z+LatexPrinter._print_Subs.<locals>.<genexpr>Irbruz\\ c3�>K�|]}|ddz|dzV��dS)r�=rpNrp)r/rWs rsr1z+LatexPrinter._print_Subs.<locals>.<genexpr>JsL����!B�!B�"#�A�a�D�3�J��1�� �!B�!B�!B�!B�!B�!Bruz\left. z \right|_{\substack{ z }})rBr rS�zip) r��subsrr��new� latex_expr� latex_old� latex_new� latex_subss ` rs� _print_SubszLatexPrinter._print_SubsEs��������c�3��[�[��&�&� �1�1�1�1�S�1�1�1� �1�1�1�1�S�1�1�1� ��[�[�!B�!B�'*�9�i�'@�'@�!B�!B�!B�B�B� � �9C���9C���E� Eruc �����dg}}�jd�t|j��dkrTtd�|jD����r6ddt|j��dz zzdz}��fd �|jD��}�n t |j��D]�}|d }|d z }t|��dkr��jd d kr�jds|dz }t|��dkr>|d��|d���d��|d���d�z }t|��dkr!|d��|d��zz }|�d d����|��������|�d��|jtdtd�|j D����d����d� |����S)Nr�r��c3�<K�|]}t|��dkV��dS)rpN)r�)r/�lims rsr1z/LatexPrinter._print_Integral.<locals>.<genexpr>Ts,����(N�(N�3��S���Q��(N�(N�(N�(N�(N�(Nruz\ir�rp�ntc�P��g|]"}d����|d������#S)�\, rrM)r/�symbolr[r�s ��rsrNz0LatexPrinter._print_Integral.<locals>.<listcomp>XsE���2�2�2�!�6�&1�[�$�+�+�f�Q�i�2H�2H�2H�I�2�2�2rurz\intr�r�r�z\limitsr4�_{�}^{r�ro�^{%s}rtr�r c3�>K�|]}|���V��dSrrVrWs rsr1z/LatexPrinter._print_Integral.<locals>.<genexpr>os/����>o�>o�`a�q�?Y�?Y�?[�?[�>o�>o�>o�>o�>o�>oruTrX) r�r�r"�allrYr �insertrr#r!r:rBrS)r�rr�symbolsrqrur[s` @rs�_print_IntegralzLatexPrinter._print_IntegralOs/�����2�W���n�%:�;� � �t�{� � �q� � �S�(N�(N�$�+�(N�(N�(N�%N�%N� ��#�s�4�;�/�/�!�3�4�4�t�;�C�2�2�2�2�2�%)�[�2�2�2�G�G� �� �,�,� S� S���Q����w����s�8�8�a�<�<��~�f�-��9�9�$(�N�6�$:�:��z�)���3�x�x�1�}�}���t�{�{�3�q�6�/B�/B�/B�/B�/3�{�{�3�q�6�/B�/B�/B�/B� D�D���3�x�x�1�}�}��w�$�+�+�c�!�f�*=�*=�>�>�����q�q� � �T�[�[��=P�=P�=P�"Q�R�R�R�R� �S�S�$�"3�"3�D�M�4>�u�4E�;>�>o�>o�ei�en�>o�>o�>o�;o�;o�;?�#4�#A�#A�#A� �W�W�W�-�-�-� /� /ruc���|j\}}}}d|�|��z}t|��dks|tjtjfvr|d|�|��zz }n1||�|���d|�|���d�z }t |t��r|�d|�|���d�S|�d|�|����S) Nz \lim_{%s \to z+-z%s}r�rorFrsr�)rBr r�r �Infinity�NegativeInfinityr�r)r�rrW�z�z0�dirrs rs� _print_LimitzLatexPrinter._print_Limitss���� � ��1�b�#�����Q���/�� �s�8�8�t� � �r�a�j�!�2D�%E�E�E� �6�D�K�K��O�O�+� +�C�C� �� � �B��������S�1A�1A�1A�1A�B� B�C� �a�� !� !� 4�+.�3�3�� � �A�����?� ?�"�s�s�D�K�K��N�N�N�3� 3rur�c��|�|��}|�d��}|�d��}|tvrd|z}n�t|��dks!|�d��s |dks|dkr|}n�|dkr;|dkr5d|dt ||����d |t ||��d���}nC|dkrd|d|��d ||d���}n$|dkrd|d|��d ||d���}nd |z}|S) ak Logic to decide how to render a function to latex - if it is a recognized latex name, use the appropriate latex command - if it is a single letter, excluding sub- and superscripts, just use that letter - if it is a longer name, then put \operatorname{} around it and be mindful of undercores in the name r��_z\%srpr�r�\operatorname{Nroz\operatorname{%s})rP�find�accepted_latex_functionsr�rr�)r�r��superscriptidx� subscriptidxrTs rs�_hprint_FunctionzLatexPrinter._hprint_Function�sf���(�(��.�.�����3�����y�y��~�~� � �+� +� +��D�=�D�D� ��Y�Y�!�^�^�t���t�4�4�^� ��8I�8I�^�_`�M`�M`��D�D���!�!�l�Q�&6�&6�&6��:�#�l�>�:�:�:�;�;�;���\�.�9�9�:�:�;�;�=��� �!�#�#�#���.��)�)�)�����)�)�+�����!�!�!���,��'�'�'�����'�'�)���,�d�2��� rurc�<��|jj}t�d|z��r2t|t��st �d|z��||��S�fd�|jD��}�jd}d}�jdo3t|��dko �� |jd�� }gd�}||vr?|d krn8|d kr|d d krd nd|dd�z}n|dkr|dd�}d}|�d}|r|tvrd|z} nPd|z} nJ|�3�� |��} �� | ��} | �d|�d�} n�� |��} |r|tvr| dz } n | dz } n| dz } |r |�| d|zz } | d� |��zS)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_c�T��g|]$}t��|������%Srp)r�r r�s �rsrNz0LatexPrinter._print_Function.<locals>.<listcomp>�s-���?�?�?�c�C�� � �C�(�(�)�)�?�?�?rur�Fr�rpr) �asin�acos�atan�acsc�asec�acot�asinh�acosh�atanh�acsch�asech�acothr��fullro�h�ar�arcN�powerTz\%s^{-1}z\operatorname{%s}^{-1}r�roz {%s}�%s�{\left(%s \right)}rxrq)r�rRr�r�r�getattrrBr�r�r&r�r�r�rS) r�rrIr�rBr��inv_trig_power_case�can_fold_brackets�inv_trig_tablerT�func_texs ` rs�_print_FunctionzLatexPrinter._print_Function�s7����y�!�� �4��T�)� *� *�= )��t�\�2�2�= )�2�7�4��T�!1�2�2�4��=�=� =�?�?�?�?�T�Y�?�?�?�D�"�^�,<�=�N�"'� � $��/C� D�!@��D� � �Q��!@��1�1�$�)�A�,�?�?�?� ����N��~�%�%�!�]�2�2��#�v�-�-�$(��H��O�O�D�D��$�q�r�r�(�J�D�D�#�w�.�.�����8�D�*.�'���,1�)�"� 3��3�3�3�&��-�D�D�4�t�;�D�D����0�0��6�6���2�2�8�<�<��%-�X�X�s�s�s�3����,�,�T�2�2�� � .��3�3�3��H�$�D�D��E�M�D�D��-�-��"� '�s����3��&���#�(�(�4�.�.�(� (ruc�F�|�t|����Sr)r�r�rs rs�_print_UndefinedFunctionz%LatexPrinter._print_UndefinedFunction�s���$�$�S��Y�Y�/�/�/ruc�t�d|�|j���d|�|j���d�S)Nr�z}_{\circ}\left({z}\right))r r#rrs rs�_print_ElementwiseApplyFunctionz,LatexPrinter._print_ElementwiseApplyFunction�s<��� �K�K�� � &� &� &� &� �K�K�� � "� "� "� "� � ruc �^�ddlm}ddlm}m}ddlm}ddlm}ddl m }|d|d|d |d |d|d iS) Nr)�KroneckerDelta)�gamma� lowergamma)�beta)� DiracDelta)rUz\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�rUs rs�_special_function_classesz&LatexPrinter._special_function_classes�s���K�K�K�K�K�K�M�M�M�M�M�M�M�M�?�?�?�?�?�?�F�F�F�F�F�F�?�?�?�?�?�?�� �� ��I��)��I��*� ,� ,ruc��|jD]1}t||��r|j|jkr|j|cS�2|�t |����Sr)r�� issubclassrRr�r�)r�r�clss rs�_print_FunctionClassz!LatexPrinter._print_FunctionClasssc���1� ;� ;�C��$��$�$� ;���#�,�)F�)F��5�c�:�:�:�:���$�$�S��Y�Y�/�/�/ruc���|j\}}t|��dkr|�|d��}n"|�t|����}d|�d|�|���d�}|S)Nrprrrz \mapsto � \right))rBr�r r)r�rr|rs rs� _print_LambdazLatexPrinter._print_Lambda sr��� � ��� �w�<�<�1� � ��k�k�'�!�*�-�-�G�G��k�k�%��.�.�1�1�G��18���$�+�+�d�:K�:K�:K�:K�L��� ruc��dS)Nz\left( x \mapsto x \right)rprs rs�_print_IdentityFunctionz$LatexPrinter._print_IdentityFunctions��,�,ruc����t|jt���}�fd�|D��}dt|j������dd�|���d�}|�|�d|�d�S|S) Nr1c�@��g|]}d��|��z��S)r�rM)r/rur�s �rsrNz:LatexPrinter._hprint_variadic_function.<locals>.<listcomp>s*���B�B�B�6�5�4�;�;�v�.�.�.�B�B�Brur�rFrOrsr�ro)�sortedrBrr�r�r�rS)r�rrIrB�texargsrs` rs�_hprint_variadic_functionz&LatexPrinter._hprint_variadic_functions�����d�i�%5�6�6�6��B�B�B�B�T�B�B�B���'*�4�9�~�~�';�';�'=�'=�'=�'=�'+�y�y��'9�'9�'9�'9�;�� �?�!$���c�c�c�*� *��Jruc�`�d|�|jd��z}|�|�d|�d�S|S)Nz\left\lfloor{%s}\right\rfloorrr�ror �r�rrIrs rs� _print_floorzLatexPrinter._print_floor%s;��.����T�Y�q�\�1J�1J�J�� �?�!$���c�c�c�*� *��Jruc�`�d|�|jd��z}|�|�d|�d�S|S)Nz\left\lceil{%s}\right\rceilrr�ror r�s rs�_print_ceilingzLatexPrinter._print_ceiling-s;��,�t�{�{�4�9�Q�<�/H�/H�H�� �?�!$���c�c�c�*� *��Jruc���|jds$d|�|jd��z}n#d|�|jd��z}|�|�d|�d�S|S)Nr�z\log{\left(%s \right)}rz\ln{\left(%s \right)}r�ro)r�r rBr�s rs� _print_logzLatexPrinter._print_log5si���~�m�,� G�+�d�k�k�$�)�A�,�.G�.G�G�C�C�*�T�[�[���1��-F�-F�F�C� �?�!$���c�c�c�*� *��Jruc�`�d|�|jd��z}|�|�d|�d�S|S)N�\left|{%s}\right|rr�ror r�s rs� _print_AbszLatexPrinter._print_Abs@s;��"�T�[�[���1��%>�%>�>�� �?�!$���c�c�c�*� *��Jruc�&�|jdr0d|�|jdtd��z}n?d�|�|jdtd����}|�||��S)Nr�z\Re{%s}r�Atomz\operatorname{{re}}{{{}}}�r�rrBr!rrJr�s rs� _print_rezLatexPrinter._print_reH��� �>�.� )� k��t�0�0���1��z�&�?Q�R�R�R�C�C�.�5�5�d�6G�6G�� �RS� �V`�ag�Vh�6i�6i�j�j�C�� � ��c�*�*�*ruc�&�|jdr0d|�|jdtd��z}n?d�|�|jdtd����}|�||��S)Nr�z\Im{%s}rr�z\operatorname{{im}}{{{}}}r�r�s rs� _print_imzLatexPrinter._print_imPr�ruc��ddlm}m}t|jd|��r!|�|jdd��St|jd|��r!|�|jdd��S|jdjr#d|�|jd��zSd|�|jd��zS)Nr)� Equivalent�Impliesz\not\Leftrightarrowz\not\Rightarrowz\neg \left(%s\right)z\neg %s) �sympy.logic.boolalgr�r�r�rB�_print_Equivalent�_print_Implies� is_Booleanr )r�rWr�r�s rs� _print_NotzLatexPrinter._print_NotXs���=�=�=�=�=�=�=�=� �a�f�Q�i�� ,� ,� M��)�)�!�&��)�5K�L�L� L� �a�f�Q�i�� )� )� F��&�&�q�v�a�y�2D�E�E� E� �F�1�I� � 7�*�T�[�[�����-C�-C�C� C��� � �A�F�1�I� 6� 6�6� 6ruc�F�|d}|jr |jsd|�|��z}nd|�|��z}|dd�D]N}|jr'|js |d|�d|�|���d�z }�0|d|�d|�|����z }�O|S)Nrrdr�rpr�z \left(rs)r��is_Notr )r�rB�charr<rs rs� _print_LogOpzLatexPrinter._print_LogOpcs����1�g�� �>� +�#�*� +�$�t�{�{�3�'7�'7�7�C�C��$�+�+�c�*�*�*�C�����8� <� <�C��~� <�c�j� <������t�{�{�3�7G�7G�7G�7G�H�H�����D�D�D�$�+�+�c�*:�*:�*:�;�;���� ruc�d�t|jt���}|�|d��S)Nr1z\wedge�r�rBrr��r�rWrBs rs� _print_AndzLatexPrinter._print_Andrs-���a�f�"2�3�3�3��� � ��y�1�1�1ruc�d�t|jt���}|�|d��S)Nr1z\veer�r�s rs� _print_OrzLatexPrinter._print_Orvs-���a�f�"2�3�3�3��� � ��w�/�/�/ruc�d�t|jt���}|�|d��S)Nr1z\veebarr�r�s rs� _print_XorzLatexPrinter._print_Xorzs-���a�f�"2�3�3�3��� � ��z�2�2�2ruc�<�|�|j|pd��S)Nz \Rightarrow)r�rB)r�rW�altchars rsr�zLatexPrinter._print_Implies~s��� � ����)B�N�C�C�Cruc�h�t|jt���}|�||pd��S)Nr1z\Leftrightarrowr�)r�rWr�rBs rsr�zLatexPrinter._print_Equivalent�s3���a�f�"2�3�3�3��� � ��w�'D�2D�E�E�Eruc�`�d|�|jd��z}|�|�d|�d�S|S)Nz \overline{%s}rr�ror r�s rs�_print_conjugatezLatexPrinter._print_conjugate�s;������T�Y�q�\�!:�!:�:�� �?�!$���c�c�c�*� *��Jruc�p�d}d|�|jd��z}|� |�d|�d|��S|�|��S)Nz\operatorname{polar\_lift}r�rr�ror )r�rrIr�r<s rs�_print_polar_liftzLatexPrinter._print_polar_lift�sN��,��#�d�k�k�$�)�A�,�&?�&?�?�� �?�#'�4�4����c�c�2� 2�"�d�C�C�(� (ruc�t�d|�|jd��z}|�||��S)Nze^{%s}r)r rBrJr�s rs�_print_ExpBasezLatexPrinter._print_ExpBase�s6���$�+�+�d�i��l�3�3�3��� � ��c�*�*�*ruc��dS)NrWrprHs rs� _print_Exp1zLatexPrinter._print_Exp1�s���sruc�f�d|�|jd��z}|�d|�d|��Sd|zS)NrdrzK^{rozK%sr r�s rs�_print_elliptic_kzLatexPrinter._print_elliptic_k�s@�� �4�;�;�t�y��|�#<�#<�<�� �?�?�"%�#�#�s�s�+� +��C�<� ruc��d|�|jd���d|�|jd���d�}|�d|�d|��Sd|zS) NrFr� \middle| rprszF^{rozF%sr r�s rs�_print_elliptic_fzLatexPrinter._print_elliptic_f�sc��� �[�[���1�� &� &� &� &�� � �D�I�a�L�(A�(A�(A�(A�C�� �?�?�"%�#�#�s�s�+� +��C�<� ruc�"�t|j��dkrFd|�|jd���d|�|jd���d�}n#d|�|jd��z}|�d|�d |��Sd |zS) Nr�rFrr�rprsrdzE^{rozE%s�r�rBr r�s rs�_print_elliptic_ezLatexPrinter._print_elliptic_e�s��� �t�y�>�>�Q� � � ����T�Y�q�\�*�*�*�*�D�K�K�� �!� �,E�,E�,E�,E�G�C�C�%�t�{�{�4�9�Q�<�'@�'@�@�C� �?�?�"%�#�#�s�s�+� +��C�<� ruc ��t|j��dkrgd|�|jd���d|�|jd���d|�|jd���d�}nEd|�|jd���d|�|jd���d�}|�d |�d |��Sd |zS) Nr4rFr�; rpr�r�rsz\Pi^{roz\Pi%sr�r�s rs�_print_elliptic_pizLatexPrinter._print_elliptic_pi�s��� �t�y�>�>�Q� � � ����T�Y�q�\�*�*�*�*�D�K�K�� �!� �,E�,E�,E�,E����T�Y�q�\�*�*�*�*�,�C�C� � ���T�Y�q�\�*�*�*�*�D�K�K�� �!� �,E�,E�,E�,E�G�C� �?�?�$'�C�C���-� -��c�>� !ruc��|jd}t|j��dkr |jdn |jd}d|�d|�d�}|�d|�d|��Sd|zS) NrrprFrOrsz\operatorname{B}^{roz\operatorname{B}%s)rBr�)r�rrIr0�yrs rs� _print_betazLatexPrinter._print_beta�so�� �I�a�L���� �N�N�a�/�/�D�I�a�L�L�T�Y�q�\��'��'�'�Q�'�'�'�� �?�?�14���c�c�:� :�(�3�.� .ru�Bc �����fd�|jD��}d|d�d|d�d�}|�d|�d|d �d|d �d |�d |�� Sd|�d|d �d|d �d |��S)Nc�:��g|]}��|����SrprMr�s �rsrNz/LatexPrinter._print_betainc.<locals>.<listcomp>�s%���7�7�7�c����S�!�!�7�7�7rurFrrOrprsr�z}_{(r�r4z)}^{roz)})rB)r�rrI�operator�largsrs` rs�_print_betainczLatexPrinter._print_betainc�s����7�7�7�7�T�Y�7�7�7���(-�a����%��(�(�(�;�� �?�?�=E�X�X�u�Q�x�x�x�QV�WX�QY�QY�QY�[^�[^�[^�`c�`c�d� d� �9A���%��(�(�(�E�RS�H�H�H�VY�VY�Z� Zruc�2�|�||d���S)N�I)r )r rHs rs�_print_betainc_regularizedz'LatexPrinter._print_betainc_regularized�s���"�"�4��s�"�;�;�;ruc��d|�|jd���d|�|jd���d�}|�d|�d|��Sd|zS) NrFrrOrprsz\Gamma^{roz\Gamma%sr r�s rs�_print_uppergammazLatexPrinter._print_uppergamma��g���(,� � �D�I�a�L�(A�(A�(A�(A�(,� � �D�I�a�L�(A�(A�(A�(A�C�� �?�?�'*�s�s�C�C�0� 0���$� $ruc��d|�|jd���d|�|jd���d�}|�d|�d|��Sd|zS) NrFrrOrprsz\gamma^{ro�\gamma%sr r�s rs�_print_lowergammazLatexPrinter._print_lowergamma�rruc���d|�|jd��z}|�"|�|j���d|�d|��S|�|j���|��S�Nrdrr�ro)r rBr�r�s rs�_hprint_one_arg_funcz!LatexPrinter._hprint_one_arg_func�sh�� �4�;�;�t�y��|�#<�#<�<�� �?�#'�;�;�t�y�#9�#9�#9�#9�3�3�3���D� D�"�k�k�$�)�4�4�4�c�c�:� :ruc�f�d|�|jd��z}|�d|�d|��Sd|zS)Nrdrz\operatorname{Chi}^{roz\operatorname{Chi}%sr r�s rs� _print_ChizLatexPrinter._print_Chi�sA�� �4�;�;�t�y��|�#<�#<�<�� �?�?�36�3�3���<� <�*�S�0� 0ruc��d|�|jd��z}|�|jd��}|� d|�d|�d|��Sd|�d|��S)Nrdrprz\operatorname{E}_{rwror )r�rrIr�nus rs� _print_expintzLatexPrinter._print_expintsk�� �4�;�;�t�y��|�#<�#<�<�� �[�[���1�� &� &�� �?�?�68�b�b�#�#�#�s�s�C� C� �24���S�S�9� 9ruc�f�d|�|jd��z}|�d|�d|��Sd|zS)NrdrzS^{rozS%sr r�s rs�_print_fresnelszLatexPrinter._print_fresnels �@�� �4�;�;�t�y��|�#<�#<�<�� �?�?�"%�#�#�s�s�+� +��C�<� ruc�f�d|�|jd��z}|�d|�d|��Sd|zS)NrdrzC^{rozC%sr r�s rs�_print_fresnelczLatexPrinter._print_fresnelcrruc�z�d|�|jdtd��z}|� d|�d|�d�S|S)Nz!%sr�FuncrFrGro�rrBr!r�s rs�_print_subfactorialz LatexPrinter._print_subfactorialsF���t�(�(���1��z�&�7I�J�J�J�� �?�?�.1�c�c�3�3�3�7� 7��Jruc�x�d|�|jdtd��z}|�|�d|�d�S|S)Nz%s!rr#r�ror$r�s rs�_print_factorialzLatexPrinter._print_factorial"sD���t�(�(���1��z�&�7I�J�J�J�� �?�!$���c�c�c�*� *��Jruc�x�d|�|jdtd��z}|�|�d|�d�S|S)Nz%s!!rr#r�ror$r�s rs�_print_factorial2zLatexPrinter._print_factorial2*sD����)�)�$�)�A�,� �6�8J�K�K�K�� �?�!$���c�c�c�*� *��Jruc��d|�|jd���d|�|jd���d�}|�|�d|�d�S|S)Nz{\binom{rr�rpr�r�ror r�s rs�_print_binomialzLatexPrinter._print_binomial2sa���%)�[�[���1��%>�%>�%>�%>�%)�[�[���1��%>�%>�%>�%>�@�� �?�!$���c�c�c�*� *��Jruc���|j\}}d|�|td��z}d|�d|�|���d�}|�||��S)Nr�r#r�� }^{\left(�\right)}�rBrr!r rJ)r�rrI�nrArDrs rs�_print_RisingFactorialz#LatexPrinter._print_RisingFactorial;s`���y���1��t�(�(��J�v�,>�?�?�?���+/�4�4����Q�����@��� � ��c�*�*�*ruc���|j\}}d|�|td��z}d|�|���d|�d�}|�||��S)Nr�r#z{\left(z \right)}_{ror/)r�rrIr0rA�subrs rs�_print_FallingFactorialz$LatexPrinter._print_FallingFactorialCs`���y���1��d�'�'��:�f�+=�>�>�>���+/�;�;�q�>�>�>�>�3�3�3�?��� � ��c�*�*�*ru�symc��d|z}d}|�$|�d��dkr |�d|�d�}nd}|�d|�|j���d |�|j���d �}|r|�||��}|S) Nr�Fr�ror�roTrv�}\left(rs)r�r r��argumentrJ)r�rrIr5r�need_exps rs�_hprint_BesselBasezLatexPrinter._hprint_BesselBaseKs����s�m���� �?��x�x��}�}��"�"�$'�C�C����-�����+.�3�3�� � �D�J�0G�0G�0G�0G�+/�;�;�t�}�+E�+E�+E�+E�G�� � .��#�#�C��-�-�C�� ruc��|sdSd}|dd�D]}|d|�|��zz }�||�|d��z }|S)Nr�roz%s, rM)r�r�rrr�s rs� _hprint_veczLatexPrinter._hprint_vec\se��� ��2� ���S�b�S�� )� )�A� ��$�+�+�a�.�.�(� (�A�A� �T�[�[��R�� !� !�!���ruc�0�|�||d��S)N�J�r:rHs rs�_print_besseljzLatexPrinter._print_besselje����&�&�t�S�#�6�6�6ruc�0�|�||d��S)Nr r?rHs rs�_print_besselizLatexPrinter._print_besselihrAruc�0�|�||d��S)N�Kr?rHs rs�_print_besselkzLatexPrinter._print_besselkkrAruc�0�|�||d��S)N�Yr?rHs rs�_print_besselyzLatexPrinter._print_besselynrAruc�0�|�||d��S)Nrr?rHs rs� _print_ynzLatexPrinter._print_ynqrAruc�0�|�||d��S)Nr�r?rHs rs� _print_jnzLatexPrinter._print_jntrAruc�0�|�||d��S)NzH^{(1)}r?rHs rs�_print_hankel1zLatexPrinter._print_hankel1w����&�&�t�S�)�<�<�<ruc�0�|�||d��S)NzH^{(2)}r?rHs rs�_print_hankel2zLatexPrinter._print_hankel2zrPruc�0�|�||d��S)Nzh^{(1)}r?rHs rs� _print_hn1zLatexPrinter._print_hn1}rPruc�0�|�||d��S)Nzh^{(2)}r?rHs rs� _print_hn2zLatexPrinter._print_hn2�rPrur�c�l�d|�|jd��z}|� |�d|�d|��S|�|��Srr �r�rrI�notationrs rs� _hprint_airyzLatexPrinter._hprint_airy�sI�� �4�;�;�t�y��|�#<�#<�<�� �?�#+�8�8�S�S�S�#�#�6� 6�&�h���,� ,ruc�p�d|�|jd��z}|� d|�d|�d|��S|�d|��S)Nrdrr�z ^\prime}^{roz^\primer rXs rs�_hprint_airy_primezLatexPrinter._hprint_airy_prime�sM�� �4�;�;�t�y��|�#<�#<�<�� �?�?�,4�H�H�c�c�c�3�3�?� ?�%-�X�X�s�s�3� 3ruc�0�|�||d��S�N�Ai�rZrHs rs� _print_airyaizLatexPrinter._print_airyai����� � ��s�D�1�1�1ruc�0�|�||d��S�N�Bir`rHs rs� _print_airybizLatexPrinter._print_airybi�rbruc�0�|�||d��Sr^�r\rHs rs�_print_airyaiprimezLatexPrinter._print_airyaiprime�����&�&�t�S�$�7�7�7ruc�0�|�||d��SrdrhrHs rs�_print_airybiprimezLatexPrinter._print_airybiprime�rjruc �d�d|�t|j�����d|�t|j�����d|�|j���d|�|j���d|�|j���d� }|� d|�d|�d �}|S) Nz{{}_{z}F_{�}\left(\begin{matrix} r�z \end{matrix}\middle| {� } \right)}r�rwro)r r��ap�bqr<r8r�s rs� _print_hyperzLatexPrinter._print_hyper�s�����[�[��T�W��� &� &� &� &�� � �C���L�L�(A�(A�(A�(A����t�w�'�'�'�'��)9�)9�$�'�)B�)B�)B�)B��k�k�$�-�(�(�(�(� *�� �?�?�"%�#�#�s�s�s�+�C�� ruc�p�d|�t|j�����d|�t|j�����d|�t|j�����d|�t|j�����d|�|j���d|�|j���d|�|j���d|�|j���d|�|j ���d�}|� d |�d|�d �}|S) Nz{G_{rOrwrnr�� \\z \end{matrix} \middle| {ror�ro) r r�rprqr��anr<�aother�botherr8r�s rs�_print_meijergzLatexPrinter._print_meijerg�s����[�[��T�W��� &� &� &� &�� � �C���L�L�(A�(A�(A�(A��k�k�#�d�g�,�,�'�'�'�'����S���\�\�)B�)B�)B�)B����t�w�'�'�'�'��)9�)9�$�+�)F�)F�)F�)F����t�w�'�'�'�'��)9�)9�$�+�)F�)F�)F�)F��k�k�$�-�(�(�(�(� *�� �?�?�"%�#�#�s�s�s�+�C�� ruc�f�d|�|jd��z}|�d|�d|��Sd|zS)Nrdrz\eta^{roz\eta%sr r�s rs�_print_dirichlet_etaz!LatexPrinter._print_dirichlet_eta�s@�� �4�;�;�t�y��|�#<�#<�<�� �?�?�%(�S�S�#�#�.� .��3��ruc���t|j��dkr+dtt|j|j����z}n#d|�|jd��z}|�d|�d|��Sd|zS)Nr�z\left(%s, %s\right)rdrz\zeta^{roz\zeta%s�r�rBrrHr r�s rs� _print_zetazLatexPrinter._print_zeta�sv�� �t�y�>�>�Q� � �(�5��T�[�$�)�1L�1L�+M�+M�M�C�C�$�t�{�{�4�9�Q�<�'@�'@�@�C� �?�?�&)�c�c�3�3�/� /��C��ruc���t|j��dkr+dtt|j|j����z}n#d|�|jd��z}|� d|�d|�d�Sd|zS) Nr�z_{%s}\left(%s\right)rGrr�r�rorr|r�s rs�_print_stieltjeszLatexPrinter._print_stieltjes�sx�� �t�y�>�>�Q� � �)�E�#�d�k�4�9�2M�2M�,N�,N�N�C�C��T�[�[���1��6�6�6�C� �?�?�'*�s�s�C�C�C�0� 0��S� � ruc�t�dtt|j|j����z}|�d|zSd|�d|��S)Nz\left(%s, %s, %s\right)z\Phi%sz\Phi^{ro)rrHr rBr�s rs�_print_lerchphizLatexPrinter._print_lerchphi�sG��(�5��T�[�$�)�1L�1L�+M�+M�M�� �;��s�?� "� �!$���c�c�*�*ruc�p�t|j|j��\}}d|z}|�d|�d|��Sd|�d|�d|��S)Nrdz\operatorname{Li}_{rorw�rHr rB)r�rrIrrr�rs rs�_print_polylogzLatexPrinter._print_polylog�sW���4�;�� �*�*���1� �1�$�� �;�;�23�!�!�S�S�9� 9� �34�1�1�c�c�c�3�3�?�?ruc �|�t|j|j��\}}}}d|�d|�d|�d|�d� }|� d|zd|zz}|S)N�P_{r-rq�\right)}\left(rsrF� \right)^{%s}r�)r�rrIr0r�r�r0rs rs� _print_jacobizLatexPrinter._print_jacobi�sZ�����d�i�0�0� ��1�a���?@�q�q�!�!�!�Q�Q�Q����J�� �?��c�/�O�s�$;�;�C�� ruc�t�t|j|j��\}}}d|�d|�d|�d�}|� d|zd|zz}|S)NzC_{r-r�rsrFr�r��r�rrIr0r�r0rs rs�_print_gegenbauerzLatexPrinter._print_gegenbauer��R���d�k�4�9�-�-���1�a�a�<=�A�A�q�q�q�!�!�!�D�� �?��c�/�O�s�$;�;�C�� ruc�l�t|j|j��\}}d|�d|�d�}|� d|zd|zz}|S)NzT_{r7rsrFr�r��r�rrIr0r0rs rs�_print_chebyshevtzLatexPrinter._print_chebyshevt��J���4�;�� �*�*���1�1�*+�!�!�Q�Q�Q�/�� �?��c�/�O�s�$;�;�C�� ruc�l�t|j|j��\}}d|�d|�d�}|� d|zd|zz}|S)NzU_{r7rsrFr�r�r�s rs�_print_chebyshevuzLatexPrinter._print_chebyshevu�r�ruc�l�t|j|j��\}}d|�d|�d�}|� d|zd|zz}|S)Nr�r7rsrFr�r�r�s rs�_print_legendrezLatexPrinter._print_legendre�r�ruc�t�t|j|j��\}}}d|�d|�d|�d�}|� d|zd|zz}|S)Nr�r-r�rsrFr�r�r�s rs�_print_assoc_legendrez"LatexPrinter._print_assoc_legendre�r�ruc�l�t|j|j��\}}d|�d|�d�}|� d|zd|zz}|S)NzH_{r7rsrFr�r�r�s rs�_print_hermitezLatexPrinter._print_hermiter�ruc�l�t|j|j��\}}d|�d|�d�}|� d|zd|zz}|S)N�L_{r7rsrFr�r�r�s rs�_print_laguerrezLatexPrinter._print_laguerre r�ruc�t�t|j|j��\}}}d|�d|�d|�d�}|� d|zd|zz}|S)Nr�r-r�rsrFr�r�r�s rs�_print_assoc_laguerrez"LatexPrinter._print_assoc_laguerrer�ruc �|�t|j|j��\}}}}d|�d|�d|�d|�d� }|� d|zd|zz}|S)NzY_{rwr7rqrsrFr�r��r�rrIr0�m�theta�phirs rs� _print_YnmzLatexPrinter._print_Ynm�[���t�{�D�I�6�6���1�e�S�S�23�!�!�Q�Q�Q����s�s�s�C�� �?��c�/�O�s�$;�;�C�� ruc �|�t|j|j��\}}}}d|�d|�d|�d|�d� }|� d|zd|zz}|S)NzZ_{rwr7rqrsrFr�r�r�s rs� _print_ZnmzLatexPrinter._print_Znm"r�ruc �v�t|j|��\}}}|rdnd}|sdnd|z}|�|�d|�d|�d|�d|�� S)Nz ^{\prime}r�rxrFrOrs)rHr ) r�� characterrBr�rIr�r�r��sups rs�__print_mathieu_functionsz&LatexPrinter.__print_mathieu_functions)s`���d�k�4�(�(���1�a�#�+�l�l����.�b�b��3���3<�9�c�c�c�1�1�1�a�a�a����C�C�P�Pruc�<�|�d|j|���S)N�Cr���&_LatexPrinter__print_mathieu_functionsrBrHs rs�_print_mathieuczLatexPrinter._print_mathieuc/����-�-�c�4�9�#�-�F�F�Fruc�<�|�d|j|���S)Nr r�r�rHs rs�_print_mathieuszLatexPrinter._print_mathieus2r�ruc�>�|�d|jd|���S)Nr�T�r�rIr�rHs rs�_print_mathieucprimez!LatexPrinter._print_mathieucprime5�!���-�-�c�4�9�D�c�-�R�R�Rruc�>�|�d|jd|���S)Nr Tr�r�rHs rs�_print_mathieusprimez!LatexPrinter._print_mathieusprime8r�ruc���|jdkr@d}|j}|jdkrd}| }|jdr d|||jfzSd|||jfzS|�|j��S)Nrpr�rr�r�z %s%d / %dz%s\frac{%d}{%d})r�r�r�r )r�r�signr�s rs�_print_RationalzLatexPrinter._print_Rational;s|�� �6�Q�;�;��D���A��v��z�z����B���~�/�0� 8�#�t�Q���&7�7�7�%��q�$�&�(9�9� 9��;�;�t�v�&�&� &ruc�@�|�|j��}|jrtd�|jD����st |j��dkr�|dz }t |j��dkr||�|j��z }n*|jr#||�|jd��z }|dz }t |j��dkr||�|j��z }n#||�|jd��z }d|zS)Nc3�6K�|]}|tjkV��dSr)r rQ)r/r�s rsr1z,LatexPrinter._print_Order.<locals>.<genexpr>Js(����>�>�a�a�1�6�k�>�>�>�>�>�>rurprr� \rightarrow zO\left(%s\right))r r�pointr:r�� variables)r�rrrs rs� _print_OrderzLatexPrinter._print_OrderHs�� �K�K�� � "� "�� �:� 0�#�>�>�4�:�>�>�>�>�>� 0� �t�~� � �� "� "� ��I�A��4�>�"�"�Q�&�&��T�[�[���0�0�0����� 4��T�[�[����!2�3�3�3�� �� �A��4�:����"�"��T�[�[���,�,�,����T�[�[���A��/�/�/��"�Q�&�&rur c��|jd�|��}|�|S|�|j|���S)Nr���style)r�r�rPrT)r�rr�rTs rs� _print_SymbolzLatexPrinter._print_SymbolXsB���N�>�2�6�6�t�<�<�� � ��K��(�(���%�(�@�@�@ru�stringc�:�d|vr|gg}}}n:t|��\}}}t|��}d�|D��}d�|D��}|dkrd�|��}|r|dd�|��zz }|r|dd�|��zz }|S) Nr�c�,�g|]}t|����Srp�� translate�r/r�s rsrNz5LatexPrinter._deal_with_super_sub.<locals>.<listcomp>h���7�7�7��i��n�n�7�7�7ruc�,�g|]}t|����Srpr��r/r3s rsrNz5LatexPrinter._deal_with_super_sub.<locals>.<listcomp>i���3�3�3�s�I�c�N�N�3�3�3rur�� \mathbf{{{}}}rxr�rG)rr�rrS)r�r�r�rT�supersrgs rsrPz!LatexPrinter._deal_with_super_subas��� �&�=�=�!'��R�$�&�D�D�!0��!8�!8� �D�&�$��T�?�?�D�7�7��7�7�7�F�3�3�d�3�3�3�D� �F�?�?�#�*�*�4�0�0�D� � /� �G�c�h�h�v�.�.�.� .�D� � -� �G�c�h�h�t�n�n�,� ,�D�� ruc���|jdrd}d}nd}d}d||ddd d �}|�|j���d ||j�d |�|j����S) Nr�z\gtz\lt�>�<rez\geqz\leqz\neq)z==r�r�z>=z<=z!=r�)r�r �lhs�rel_op�rhs)r�r�gt�lt�charmaps rs�_print_RelationalzLatexPrinter._print_Relationalws��� �>�&� !� ��B��B�B��B��B�������  � ��"�[�[���2�2�2�2�$�T�[�1�1�1�4�;�;�t�x�3H�3H�3H�J� Jruc�����fd�|jdd�D��}|jdjtkr<|�d��|jdj��z��n`|���|jdj���d��|jdj������d}|d�|��zS)Nc�p��g|]2\}}��|���d��|������3S)� & \text{for}\: rM)r/rWr�r�s �rsrNz1LatexPrinter._print_Piecewise.<locals>.<listcomp>�sL���/�/�/��q�!�/3�k�k�!�n�n�n�n�d�k�k�!�n�n�n�M�/�/�/ruroz%s & \text{otherwise}r�z\begin{cases} %s \end{cases}rt)rB�condrr<r rrS)r�r�ecpairsrs` rs�_print_PiecewisezLatexPrinter._print_Piecewise�s����/�/�/�/�#�y��"��~�/�/�/�� �9�R�=� �� %� %� �N�N�3��;�;�t�y��}�'9�:�:�;� <� <� <� <� �N�N� �K�K�� �"� �(:�;�;�;�;� �K�K�� �"� �(:�;�;�;�=� >� >� >�.���V�[�[��)�)�)�)ruc ����g}t|j��D]@}|�d��fd�||dd�fD�������A�jd}|�&�jddkrd}n|jdkdurd }nd }d }|�d |��}|d kr$|�d dd|jzzdz��}|d�|��zS)Nr�c�:��g|]}��|����SrprMrs �rsrNz7LatexPrinter._print_matrix_contents.<locals>.<listcomp>�s#���$K�$K�$K��T�[�[��^�^�$K�$K�$Krur�r�r�� smallmatrix� T�matrix�array� \begin{%MATSTR%}%s\end{%MATSTR%}�%MATSTR%r�r�r��}%sr)r��rowsr<rSr��colsr�)r�r�lines�liner��out_strs` rs�_print_matrix_contentsz#LatexPrinter._print_matrix_contents�s ������$�)�$�$� N� N�D� �L�L����$K�$K�$K�$K�T�$����'�]�$K�$K�$K�L�L� M� M� M� M��.��+�� �?��~�f�%��1�1�'����I��O��,�,�&�G�G�%�G�5���/�/�*�g�6�6�� �g� � ��o�o�d�C�#�d�i�-�,?�%�,G�H�H�G�����E�*�*�*�*ruc��|�|��}|jdr(|jd}|j|}d|z|zdz|z}|S)Nr��\left�\right)r�r�r�)r�rr�� left_delim� right_delims rs�_print_MatrixBasezLatexPrinter._print_MatrixBase�sa���-�-�d�3�3�� �>�+� &� .��� �4�J��*�:�6�K���+�g�5�� �"-�.�G��ruc���|�|jtdd���}|�|j���d|�|j����}d|�d|�d�S)Nr�T�r rqr��}_{ro)r�parentr!r r�r�)r�r� matrix_part� index_parts rs�_print_MatrixElementz!LatexPrinter._print_MatrixElement�sl���'�'�� �Z��5G�PT�'�U�U� �� � �D�F�+�+�C�C�d�k�k�$�&�.A�.A�C�C� �4�K�4�4�j�4�4�4�4ruc�����fd�}��|jtdd���dz||j|jj��zdz||j|jj��zdzS)Nc����t|��}|ddkr|d=|ddkrd|d<|d|krd|d<d��fd�|D����S)Nr�rpr�:c3�J�K�|]}|���|��ndV��dS�Nr�rM)r/�xir�s �rsr1zFLatexPrinter._print_MatrixSlice.<locals>.latexslice.<locals>.<genexpr>�s5�����R�R�"�r�~�D�K�K��O�O�O�2�R�R�R�R�R�Rru)r�rS)r0r\r�s �rs� latexslicez3LatexPrinter._print_MatrixSlice.<locals>.latexslice�sv����Q���A���t�q�y�y��a�D���t�q�y�y���!����t�s�{�{���!���8�8�R�R�R�R�PQ�R�R�R�R�R� Rrur�Tr��\left[rO�\right])rr�r!�rowslicer��colslicer�)r�rrs` rs�_print_MatrixSlicezLatexPrinter._print_MatrixSlice�s���� S� S� S� S� S��!�!�$�+�z�&�/A�$�!�O�O�R[�[�� �4�=�$�+�*:�;�;�<�>B�C�� �4�=�$�+�*:�;�;�<�>H�I� Jruc�6�|�|j��Sr)r �blocksrs rs�_print_BlockMatrixzLatexPrinter._print_BlockMatrix�s���{�{�4�;�'�'�'ruc��|j}ddlm}m}t ||��s/t ||��s|jrd|�|��zS|�|t|��d��}d|vrd|zSd|zS)Nr�� MatrixSymbol� BlockMatrixz\left(%s\right)^{T}Tr�z%s^{T}) r<�sympy.matricesrrr�� is_MatrixExprr rr)r�rr�rrrrs rs�_print_TransposezLatexPrinter._print_Transpose�s����h��<�<�<�<�<�<�<�<��3� �-�-� $��3� �,�,� $�14�1B� $�)�D�K�K��,<�,<�<� <��!�!�#�'=�d�'C�'C�T�J�J�A��a�x�x�-��1�1��!�|�#ruc�@�|j}d|�|��zS)Nz!\operatorname{tr}\left(%s \right))r<r �r�rr�s rs� _print_TracezLatexPrinter._print_Trace�s ���h��3�d�k�k�#�6F�6F�F�Fruc�f�dddd�}|�|jdd��}|j}ddlm}m}t ||��s3t ||��s#|jrd|�|���d |�d �S|� |t|��d ��}d |vr d|�d |�d �S|�d |�d �S)Nz\daggerz\astz \mathsf{H})r��star� hermitianr�rrrFrGroTr�r�) r�r�r<rrrr�rr rr)r�r�style_to_latexr�r�rrrrs rs�_print_AdjointzLatexPrinter._print_Adjoint�s���#� �&� � �� '�*�*�4�>�/�+J�J�W�W� ��h��<�<�<�<�<�<�<�<��3� �-�-� 7��3� �,�,� 7�14�1B� 7� 7�.2�k�k�#�.>�.>�.>�.>� � � �N� N��!�!�#�'=�d�'C�'C�T�J�J�A��a�x�x�x�23�!�!�]�]�]�C�C�%&�Q�Q� � � �6�6ruc�J����ddlm����fd�}t�j��}����rI|ddkr |dd�}n |d |d<dd�t ||����zSd�t ||����S)Nr)�MatMulc����t|t��r%t|���s��|��n#��|t ���d��S�NF)r�r r rr)r0rrr�s ���rsrtz,LatexPrinter._print_MatMul.<locals>.<lambda>�sZ���Z��3�-?�-?�F� �ST�V\�H]�H]�F�4�;�;�q�>�>�>� � � �a�!7��!=�!=�u� E� E�rurorpr�r�)�sympyrr�rBr7rSrH)r�r�parensrBrs`` @rs� _print_MatMulzLatexPrinter._print_MatMul�s������ � � � � � �F�F�F�F�F�F���D�I���� � (� (� *� *� /��A�w�"�}�}��A�B�B�x�����7�(��Q���#�(�(�3�v�t�#4�#4�5�5�5� 5��8�8�C���-�-�.�.� .ruc���|j}|jrKddlm}t ||��rd|�|j��zSd|�|��zSd|�|��zS)Nr)rr�)r<r�&sympy.matrices.expressions.blockmatrixrr�r�r r )r�rr�rs rs�_print_DeterminantzLatexPrinter._print_Determinants����h�� � � ;� J� J� J� J� J� J��#�{�+�+� V�+�d�.I�.I�#�*�.U�.U�U�U�'�$�+�+�c�*:�*:�:� :�#�d�&A�&A�#�&F�&F�F�Fruc��|�dd|�|jdtdd����d|�|jdtdd����d|�d �S|�|jdtdd����d|�|jdtdd�����S) NrFrr Tr�z \bmod rprGror$rHs rs� _print_ModzLatexPrinter._print_Mod s��� �?�?��"�"�4�9�Q�<��E�1B�*.�#�0�0�0�0��"�"�4�9�Q�<��E�1B�*.�#�0�0�0�0���� � � "&�!2�!2�4�9�Q�<�3=�e�3D�:>�"3�"@�"@�"@�"@�"&�!2�!2�4�9�Q�<�3=�e�3D�:>�"3�"@�"@�"@�A� Aruc����|j}td�|j�d���fd�|D����S)Nrz \circ c3�4�K�|]}�|�d���V��dS�Tr�Nrp�r/r<r"�precs ��rsr1z6LatexPrinter._print_HadamardProduct.<locals>.<genexpr>!�4����� <� <��V�V�C��d� +� +� +� <� <� <� <� <� <ru�rBr!rrS�r�rrBr"r-s @@rs�_print_HadamardProductz#LatexPrinter._print_HadamardProductsM�����y���%� ���"����� <� <� <� <� <�t� <� <� <�>�>� >ruc�~�t|j��tdkrd}nd}|�||��S)Nr z%s^{\circ \left({%s}\right)}z%s^{\circ {%s}})rrIr!r)r�rrs rs�_print_HadamardPowerz!LatexPrinter._print_HadamardPower#s>�� !�$�(� +� +�j��.?� ?� ?�6�H�H�)�H��0�0��x�@�@�@ruc����|j}td�|j�d���fd�|D����S)Nr� \otimes c3�4�K�|]}�|�d���V��dSr+rpr,s ��rsr1z7LatexPrinter._print_KroneckerProduct.<locals>.<genexpr>0r.rur/r0s @@rs�_print_KroneckerProductz$LatexPrinter._print_KroneckerProduct*sO�����y���%� ���"��� � � <� <� <� <� <�t� <� <� <�>�>� >ruc�V�|j|j}}ddlm}t ||��s6|jr/d|�|���d|�|���d�S|�|��}d|vrd|�d|�|���d�S|�d|�|���d�S)Nr)rrFrGror�r�)rDrIrrr�rr )r�rrDrIr�base_strs rs� _print_MatPowzLatexPrinter._print_MatPow2s����I�t�x�c��/�/�/�/�/�/��$� �-�-� @�$�2D� @� @�/3�{�{�4�/@�/@�/@�/@�.2�k�k�#�.>�.>�.>�.>�@� @��{�{�4�(�(�H��h����2:�(�(�D�K�K��<L�<L�<L�<L�M�M�$,�H�H�d�k�k�#�.>�.>�.>�.>�?�?ruc�F�|�||jd���S)Nr�r�)r�r�rs rs�_print_MatrixSymbolz LatexPrinter._print_MatrixSymbol?s+���!�!�$�d�n� �/ �!�!�!� !ruc�,�|jddkrdndS)Nr�r��0z \mathbf{0}�r�)r��Zs rs�_print_ZeroMatrixzLatexPrinter._print_ZeroMatrixC�(���n� � �#*�+�+�s�s�0=� >ruc�,�|jddkrdndS)Nr�r��1z \mathbf{1}r?)r��Os rs�_print_OneMatrixzLatexPrinter._print_OneMatrixGrBruc�,�|jddkrdndS)Nr�r�z \mathbb{I}z \mathbf{I}r?)r�r s rs�_print_IdentityzLatexPrinter._print_IdentityKs(�� $�� �! �#*�!+�!+�}�}�0=� >ruc�L�|�|jd��}d|zS)NrzP_{%s}r )r��P�perm_strs rs�_print_PermutationMatrixz%LatexPrinter._print_PermutationMatrixOs$���;�;�q�v�a�y�)�)���(�"�"rur&c ���|���dkr|�|d��S|jd}|�B|jddkrd}n.|���dks|jddkrd }nd }d }|�d |��}|d kr*|�d dd|jdzzdz��}|jdr(|jd}|j|}d|z|zdz|z}|���dkr|dzSd�t |���dz��D��}d�|jD��}tj|�D�]C}|d� |�||����d} t |���dz dd��D]�} t|| dz��|j| krn�| r8|| � d� || dz����ns|| � |d� || dz��z��t|| dz��dkrd|| dzdz|| d<| } g|| dz<���E|dd} |���dzdkr|| z} | S)Nrrpr�r�r�r�ror�r�r�r�r�r�r�r�r�r�r�r�r�c��g|]}g��SrprprWs rsrNz1LatexPrinter._print_NDimArray.<locals>.<listcomp>os��%I�%I�%I�Q�b�%I�%I�%Irurpc�F�g|]}tt|������Srp)r�r�rWs rsrNz1LatexPrinter._print_NDimArray.<locals>.<listcomp>ps$��;�;�;�1��U�1�X�X���;�;�;ruTr�rrrr�) �rankr r��shaper�r�r�� itertools�productr<r�rS) r�rr�� block_strr�r�� level_str� shape_ranges�outer_i�even� back_outer_ir�s rs�_print_NDimArrayzLatexPrinter._print_NDimArraySs �� �9�9�;�;�!� � ��;�;�t�B�x�(�(� (��.��+�� �?��~�f�%��1�1�'����I�I�K�K�1�$�$�$�*�R�.�B�*>�*>�&�G�G�%�G�7� ��%�%�j�'�:�:� � �g� � �!�)�)�$��c�$�*�Q�-�6G�0G�%�0O�P�P�I� �>�+� &� 0�"�n�[�9�J��*�:�6�K� �:�-� �9�!�"�$/�0�I� �9�9�;�;�!� � ��r�>� !�%I�%I�%�� � � � �a��2H�2H�%I�%I�%I� �;�;�� �;�;�;� � �(�,�7� /� /�G� �b�M� � ����T�'�]�!;�!;� <� <� <��D� %�d�i�i�k�k�!�m�R�� <� <� /� /� ��y��a��0�1�1�D�J�|�4L�L�L��E��E��l�+�2�2�� � �I�l�1�n�$=�>�>�@�@�@�@��l�+�2�2�!�U�Z�Z� �,�q�.�0I�%J�%J�K�M�M�M��9�\�!�^�4�5�5��:�:�6?�%�l�3�B�7�78�:D�7E� �,�/��3��x��,.� �,�q�.�)�)���A�,�q�/�� �9�9�;�;��?�a� � ��'�)�G��ru� index_map�dictc�`�|�|��}d}d}|D]�}|j}||vs|r ||kr|dz }||kr|�|dz }|jr|dz }n|dz }||�|jd��z }||vr&|dz }||�||��z }d}nd}|}��|�|dz }|S) Nrqroz{}^{z{}_{rreTF)r �is_uprB) r�rTrIr[r�� last_valence�prev_map�index� new_valences rs�_printer_tensor_indicesz$LatexPrinter._printer_tensor_indices�s���+�+�d�#�#��� ���� '� '�E��+�K��)�#�#��#� �K�/�/��3����{�*�*��+��s�N�G��;�&��v�%�G�G��v�%�G� �t�{�{�5�:�a�=�1�1� 1�G�� �!�!��3����4�;�;�y��'7�8�8�8����� ��&�L�L� � #� �s�N�G��ruc��|jdjd}|���}|�||i��Sr )rB� get_indicesrc)r�rrTrIs rs� _print_TensorzLatexPrinter._print_Tensor�s>���y��|� ��#���"�"�$�$���+�+�D�'�2�>�>�>ruc��|jjdjd}|j���}|j}|�|||��Sr )rrBrer[rc)r�rrTrIr[s rs�_print_TensorElementz!LatexPrinter._print_TensorElement�sJ���y�~�a� �%�a�(���)�'�'�)�)���N� ��+�+�D�'�9�E�E�Eruc�~�������\}}|d���fd�|D����zS)Nr�c�V��g|]%}��|t�������&Srp)rr )r/r<rr�s ��rsrNz/LatexPrinter._print_TensMul.<locals>.<listcomp>�s1��� F� F� F�#�T� � �s�J�t�$4�$4� 5� 5� F� F� Fru)�!_get_args_for_traditional_printerrS)r�rr�rBs`` rs�_print_TensMulzLatexPrinter._print_TensMul�sP�����;�;�=�=� ��d��b�g�g� F� F� F� F� F�� F� F� F� � � � ruc � �g}|j}|D]8}|�|�|t|�������9|���d�|��}|�dd��}|S)Nrcz+ -r�)rBr<rr r;rSr�)r�rr�rBr0rrs rs�_print_TensAddzLatexPrinter._print_TensAdd�s~�� ���y��� =� =�A� �H�H�T�&�&�q�*�T�*:�*:�;�;� <� <� <� <� ������ �J�J�q�M�M�� �I�I�e�T� "� "���ruc�b�d|jrdnd�d|�|jd���d�S)Nz{}r�r�r�rro)r^r rBrs rs�_print_TensorIndexzLatexPrinter._print_TensorIndex�s=����:� &�C�C�3� &� &� �K�K�� �!� � %� %� %� %� � ruc ���t|j��dkrLd��|jd���d��|jt dd���d�Sdt|j���dd ��fd �|jD�����d ��|jt dd���d�S) Nrpz\frac{\partial}{\partial {rrTr Froz\frac{\partial^{r�c�@��g|]}d��|��z��S)z \partial {%s}rMrs �rsrNz9LatexPrinter._print_PartialDerivative.<locals>.<listcomp>�s)���T�T�T��*�T�[�[��^�^�;�T�T�Trur�)r�r�r rrr!rSrs` rs�_print_PartialDerivativez%LatexPrinter._print_PartialDerivative�s���� �t�~� � �!� #� #� #�� � �D�N�1�-�.�.�.�.��!�!�$�)�Z��->��F�F�F�F�� � $��D�N�#�#�#�#����T�T�T�T�T�^�T�T�T�U�U�U�U��!�!�$�)�Z��->��F�F�F�F�� ruc�6�|�|j��Sr)r rTrs rs�_print_ArraySymbolzLatexPrinter._print_ArraySymbol�s���{�{�4�9�%�%�%ruc���d��|jtdd���dd��fd�|jD�����d�S)Nz{{r#Tr�rOc�<��g|]}��|�����SrprMrs �rsrNz4LatexPrinter._print_ArrayElement.<locals>.<listcomp>�s&���A�A�A�q�$�+�+�a�.�.�*�A�A�Arur�)rrTr!rSrIrs` rs�_print_ArrayElementz LatexPrinter._print_ArrayElement�s_���� � � �d�i��F�);�T� B� B� B� B� �I�I�A�A�A�A�D�L�A�A�A� B� B� B� B�D� Druc��dS)Nz \mathbb{U}rprs rs�_print_UniversalSetz LatexPrinter._print_UniversalSet�����}ruc��|�#d|�|jd��zSd|�|jd���d|�d�S)Nz$\operatorname{frac}{\left(%s\right)}rz\operatorname{frac}{\left(z \right)}^{ror rHs rs� _print_fraczLatexPrinter._print_frac�sW�� �;�:�T�[�[���ST��=V�=V�V� V� ��K�K�� �!� �-�-�-�-�s�s�s�4� 4ruc�h���jddkrd}n#�jddkrd}ntd���t|��dkr1����|d��|z��S��|d z��fd �|D������S) Nr�r��;r�rq�Unknown Decimal Separatorrprz \ c�:��g|]}��|����SrprMrs �rsrNz-LatexPrinter._print_tuple.<locals>.<listcomp>�s#���%C�%C�%C��d�k�k�!�n�n�%C�%C�%Cru)r�r�r�rr rS)r�r�seps` rs� _print_tuplezLatexPrinter._print_tuple�s���� �>�-� .�'� 9� 9��C�C� �^�/� 0�H� <� <��C�C��8�9�9� 9� �t�9�9��>�>��*�*�4�;�;�t�A�w�+?�+?�#�+E�F�F� F��*�*��w��$�$�%C�%C�%C�%C�d�%C�%C�%C�D�D�F�F� Fruc�T���fd�|jD��}d�|��S)Nc�:��g|]}��|����SrprM�r/r�r�s �rsrNz5LatexPrinter._print_TensorProduct.<locals>.<listcomp>��#���6�6�6�q�D�K�K��N�N�6�6�6rur5�rBrS�r�r�elementss` rs�_print_TensorProductz!LatexPrinter._print_TensorProduct�s2���6�6�6�6�D�I�6�6�6��� � ��*�*�*ruc�T���fd�|jD��}d�|��S)Nc�:��g|]}��|����SrprMr�s �rsrNz4LatexPrinter._print_WedgeProduct.<locals>.<listcomp>�r�ru� \wedge r�r�s` rs�_print_WedgeProductz LatexPrinter._print_WedgeProduct�s2���6�6�6�6�D�I�6�6�6������)�)�)ruc�,�|�|��Sr)r�rs rs� _print_TuplezLatexPrinter._print_Tuple�s��� � ��&�&�&ruc�����jddkr$dd��fd�|D����zS�jddkr$dd��fd�|D����zStd ���) Nr�r�z\left[ %s\right]z; \ c�:��g|]}��|����SrprMrs �rsrNz,LatexPrinter._print_list.<locals>.<listcomp>�#���<�<�<�!�t�{�{�1�~�~�<�<�<rur��, \ c�:��g|]}��|����SrprMrs �rsrNz,LatexPrinter._print_list.<locals>.<listcomp>r�rur�)r�rSr�rs` rs� _print_listzLatexPrinter._print_lists���� �>�-� .�'� 9� 9�&�� � �<�<�<�<�t�<�<�<�=�=�>� >� �^�/� 0�H� <� <�&�� � �<�<�<�<�t�<�<�<�=�=�>� >��8�9�9� 9ruc� �t|���t���}g}|D]J}||}|�|�|���d|�|�������Kdd�|��zS)Nr1z : z\left\{ %s\right\}r�)r��keysrr<r rS)r�r�r�r9r2�vals rs� _print_dictzLatexPrinter._print_dict s����a�f�f�h�h�$4�5�5�5����� K� K�C��C�&�C� �L�L�d�k�k�#�&6�&6�&6�&6�� � �C�8H�8H�8H�I� J� J� J� J�$�x�}�}�U�';�';�;�;ruc�,�|�|��Sr)r�rs rs� _print_DictzLatexPrinter._print_Dicts������%�%�%ruc�@�t|j��dks|jddkr$d|�|jd��z}nEd|�|jd���d|�|jd���d�}|r d|�d|�d �}|S) Nrprz\delta\left(%s\right)z\delta^{\left( z \right)}\left( r�rFrGror�r�s rs�_print_DiracDeltazLatexPrinter._print_DiracDeltas��� �t�y�>�>�Q� � �$�)�A�,�!�"3�"3�*�T�[�[���1��-F�-F�F�C�C�#4�� � �D�I�a�L�)�)�)�)�4�;�;�t�y��|�+D�+D�+D�+D�F�C� � 7� 7�-0�S�S�#�#�#�6�C�� ruc���|�|jd|jdz ��}|�|jd��}d|�d|�d�}|� d|�d|�d |�d�}|S) Nrrpr�z{\left\langle z \right\rangle}^{roz{\left({\langle z \rangle}^{z }\right)}^{r )r�rrI�shiftr�rs rs�_print_SingularityFunctionz'LatexPrinter._print_SingularityFunction#sv��� � �D�I�a�L�4�9�Q�<�7�8�8��� � �D�I�a�L�)�)���9>������F�� �?�?�FK�e�e�U�U�U�TW�TW�TW�X�C�� ruc�t��d��fd�|jD����}d|z}|r d|�d|�d�}|S)NrOc3�B�K�|]}��|��V��dSrrMr�s �rsr1z0LatexPrinter._print_Heaviside.<locals>.<genexpr>,s/�����A�A�s�$�+�+�c�*�*�A�A�A�A�A�Aruz\theta\left(%s\right)rFrGro)rS�pargs)r�rrIr�rs` rs�_print_HeavisidezLatexPrinter._print_Heaviside+sY���� � �A�A�A�A�d�j�A�A�A�A�A��&��.�� � 7� 7�-0�S�S�#�#�#�6�C�� ruc� �|�|jd��}|�|jd��}|jdjr|jdjr d|�d|�d�}n d|�d|�d�}|� d|�d|�d�}|S) Nrrpz\delta_{r�rorOrFrG)r rBr)r�rrIr�r�rs rs�_print_KroneckerDeltaz"LatexPrinter._print_KroneckerDelta2s��� �K�K�� �!� � %� %�� �K�K�� �!� � %� %�� �9�Q�<� � .�D�I�a�L�$8� .� .�'(�q�q�!�!�!�,�C�C��()���1�1�1�-�C� �?�?�-0�S�S�#�#�#�6�C�� ruc���t|j|j��}td�|jD����rdd�|��z}ndd�|��z}|r d|�d|�d�}|S)Nc3�$K�|] }|jV�� dSr)r)r/r0s rsr1z1LatexPrinter._print_LeviCivita.<locals>.<genexpr>?s$����,�,�Q�q�y�,�,�,�,�,�,ruz\varepsilon_{%s}r�rOrFrGro)rHr rBrzrS)r�rrIrIrs rs�_print_LeviCivitazLatexPrinter._print_LeviCivita=s����d�k�4�9�-�-�� �,�,�$�)�,�,�,� ,� ,� ;�%�����(9�(9�9�C�C�%�� � �'�(:�(:�:�C� � 7� 7�-0�S�S�#�#�#�6�C�� ruc��t|d��r*d|�|�����zSt|d��r;d|�|j��zdz|�|j��zSt|d��rd|�|j��zS|�d��S)N� as_booleanz\text{Domain: }�set� \in r|z\text{Domain on })r�r r�r|r�)r�r�s rs�_print_RandomDomainz LatexPrinter._print_RandomDomainGs��� �1�l� #� #� %�%�� � �A�L�L�N�N�(C�(C�C� C� �Q�� � � %�&����Q�Y�)?�)?�?�(�J��K�K���&�&�'� (� �Q� � "� "� %�'�$�+�+�a�i�*@�*@�@� @��;�;�t�$�$� $ruc�b�t|jt���}|�|��S)Nr1)r�rBr� _print_set�r�rrr9s rs�_print_FiniteSetzLatexPrinter._print_FiniteSetRs)���q�v�#3�4�4�4�����u�%�%�%ruc�>�t|t���}|jddkr)d�t |j|����}nI|jddkr)d�t |j|����}nt d���d|zS) Nr1r�r�rr�rOr��\left\{%s\right\})r�rr�rSrHr r�r�s rsr�zLatexPrinter._print_setVs����q�.�/�/�/�� �>�-� .�'� 9� 9��I�I�c�$�+�u�5�5�6�6�E�E� �^�/� 0�H� <� <��I�I�c�$�+�u�5�5�6�6�E�E��8�9�9� 9�#�e�+�+ruc�������fd�}t����jjr(�jjr�jjr�ddd�f}n��ddd�f}n؉jjr��d�jz �df}n��jjr/t ���}t|��t|���f}nw�j�f�j dkdkrt���}nQ�j r6t ���}t|��t|����df}n|��S|��Sdd� ��fd �|D����zd zS) Nc����jddkrY�jddkr!���jd��}n�d��fd��jD����}nf�jddkr/d��fd��jdd�D����}n&d��fd��jD����}d|�d �S) Nrr�rprOc3�B�K�|]}��|��V��dSrrMr�s �rsr1zKLatexPrinter._print_Range.<locals>._print_symbolic_range.<locals>.<genexpr>j�/�����$H�$H�#�T�[�[��%5�%5�$H�$H�$H�$H�$H�$Hruc3�B�K�|]}��|��V��dSrrMr�s �rsr1zKLatexPrinter._print_Range.<locals>._print_symbolic_range.<locals>.<genexpr>ms/�����$L�$L�#�T�[�[��%5�%5�$L�$L�$L�$L�$L�$Lruc3�B�K�|]}��|��V��dSrrMr�s �rsr1zKLatexPrinter._print_Range.<locals>._print_symbolic_range.<locals>.<genexpr>or�ruz\text{Range}\left(rs)rBr rS)�contrrr�s ��rs�_print_symbolic_rangez8LatexPrinter._print_Range.<locals>._print_symbolic_rangeds�����v�a�y�A�~�~��6�!�9��>�>��;�;�q�v�a�y�1�1�D�D��9�9�$H�$H�$H�$H���$H�$H�$H�H�H�D�D��6�!�9��>�>��9�9�$L�$L�$L�$L�������$L�$L�$L�L�L�D�D��9�9�$H�$H�$H�$H���$H�$H�$H�H�H�D�:�D�:�:�:� ;rurorrproT�\left\{rOc3�N�K�|]}|�ur��|��ndV�� dS�z\ldotsNrM�r/�el�dotsr�s ��rsr1z,LatexPrinter._print_Range.<locals>.<genexpr>��:�����_�_�PR�b��n�n�4�;�;�r�?�?�?�)�_�_�_�_�_�_ru�\right\}) �object�start� is_infinite�stop�step� is_positive�iter�next�is_emptyrur� is_iterablerS)r�rrr��printset�itr�s`` @rs� _print_RangezLatexPrinter._print_Rangecs������ <� <� <� <� <� <��x�x�� �7� � +�1�6�#5� +��v�!� 0���Q��4�/�����A�r�4�/��� �W� � +��Q�r�U�Q�V�^�Q�r�U�2�H�H� �V� � +��a���B��B�x�x��b���4�/�H�H� �Z� #���� �t�#�#� ��8�8����� /��!�W�W����8�8�T�"�X�X�t�Q�r�U�:���,�,�.�.�.�(�(�*�*� *��� � �_�_�_�_�_�V^�_�_�_�_�_�`��� ruc ��t|j��dkr�|�J|�d|�|jd���d|�d|�|jd���d�S|�d|�|jd���d|�|jd���d�S|�d|�|jd���d�}|�|�d |�d�}|S) Nr�rvrrwr7rprsror�r�)r�r�letterrIrs rs�__print_number_polynomialz&LatexPrinter.__print_number_polynomial�s��� �t�y�>�>�Q� � ���9?��� �K�K�� �!� �5�5�5�5�s�s�s� �K�K�� �!� �5�5�5�5�7�7�17���� � �D�I�a�L�1�1�1�1�4�;�;�t�y��|�3L�3L�3L�3L�N� N�#�F�F�D�K�K�� �!� �$=�$=�$=�$=�>�� �?� #���S�S�S�)�C�� ruc�0�|�|d|��S�Nr��&_LatexPrinter__print_number_polynomialrHs rs�_print_bernoullizLatexPrinter._print_bernoulli�����-�-�d�C��=�=�=ruc�0�|�|d|��S)N�Gr�rHs rs�_print_genocchizLatexPrinter._print_genocchi�r�ruc�r��t|j��dkr�d��|jd���d��|jd���d�}dd��fd�|jd D����z}|� |�d |�d|��}n||z}|S��|d |��S) Nr4zB_{rrOrprordc3�B�K�|]}��|��V��dSrrM)r/r�r�s �rsr1z+LatexPrinter._print_bell.<locals>.<genexpr>�sI�����3C�3C�/1�48�;�;�r�?�?�3C�3C�3C�3C�3C�3Crur�r�r)r�rBr rSr�)r�rrI�tex1�tex2rs` rs� _print_bellzLatexPrinter._print_bell�s���� �t�y�>�>�Q� � � �$(�K�K�� �!� �$=�$=�$=�$=� $� � �D�I�a�L� 9� 9� 9� 9�;�D�%�� � �3C�3C�3C�3C�59�Y�q�\�3C�3C�3C�)C�)C�C�D���&*�d�d�C�C�C���6����T�k���J��-�-�d�C��=�=�=ruc�0�|�|d|��S�N�Fr�rHs rs�_print_fibonaccizLatexPrinter._print_fibonacci�r�ruc�`�d|�|jd��z}|�|�d|�d�}|S)NzL_{%s}rr�ror r�s rs� _print_lucaszLatexPrinter._print_lucas��:���$�+�+�d�i��l�3�3�3�� �?� #���S�S�S�)�C�� ruc�0�|�|d|��S)N�Tr�rHs rs�_print_tribonaccizLatexPrinter._print_tribonacci�r�ruc��|�#d|�|jd��zSd|�d|�|jd���d�S)Nz\mu\left(%s\right)rz\mu^{r7rsr rHs rs� _print_mobiuszLatexPrinter._print_mobius�sP�� �;�(�4�;�;�t�y��|�+D�+D�D� D� �-0�S�S�$�+�+�d�i��l�2K�2K�2K�2K�L�Lruc �X���t���t|jj��dkst|jj��dkrud��|j���d��|jd���d��|j���d��|j���d� S|jtj urd|j}�|� |dz ��|� |dz ��|� |d z ��|� |��f}nM|jtj us |j d kr |dd �}|� ���nt|��}d d ���fd �|D����zdzS)Nrr�z \right\}_{rerwror4r�rprorrOc3�N�K�|]}|�ur��|��ndV�� dSr�rMr�s ��rsr1z1LatexPrinter._print_SeqFormula.<locals>.<genexpr>�r�rur)r�r�r�� free_symbolsr�r �formular�r r��coeffr�lengthr<rrS)r�rrr�r�r�s` @rs�_print_SeqFormulazLatexPrinter._print_SeqFormula�s������x�x�� �q�w�#� $� $�q� (� (�C���0C�,D�,D�q�,H�,H��� � �A�I�&�&�&�&�� � �A�K��N�+�+�+�+�� � �A�G�$�$�$�$�� � �A�F�#�#�#�#� � � �7�a�(� (� (��6�D��a�g�g�d�Q�h�/�/�������1B�1B�����q��)�)�1�7�7�4�=�=�:�H�H� �V�q�z� !� !�Q�X��\�\���!��u�H� �O�O�D� !� !� !� !��Q�x�x�H��� � �_�_�_�_�_�V^�_�_�_�_�_�`��� ruc��|j|jkrd|�|j��zS|jrd}nd}|jrd}nd}d|�|�|j���d|�|j���d|��S) Nr�r�r�r�r�r�rOr�)r��endr � left_open� right_open)r�r��left�rights rs�_print_IntervalzLatexPrinter._print_Interval�s��� �7�a�e� � �'�$�+�+�a�g�*>�*>�>� >��{� �������|� ��������D�$�+�+�a�g�.�.�.�.�� � �A�E�0B�0B�0B�0B�E�E�K� Kruc�t�d|�|j���d|�|j���d�S)Nz \left\langle rOz \right\rangle)r r�r��r�r�s rs�_print_AccumulationBoundsz&LatexPrinter._print_AccumulationBounds�s;������Q�U�#�#�#�#�T�[�[���%7�%7�%7�%7�9� 9ruc�v���t|�����fd�|jD��}d�|��S)Nc�<��g|]}��|�����Srp�r�r/r�r-r�s ��rsrNz-LatexPrinter._print_Union.<locals>.<listcomp>��)���?�?�?�1�D�%�%�a��.�.�?�?�?ruz \cup �rrBrS�r��u�args_strr-s` @rs� _print_UnionzLatexPrinter._print_Union��A����%�a�(�(��?�?�?�?�?���?�?�?���~�~�h�'�'�'ruc�v���t|�����fd�|jD��}d�|��S)Nc�<��g|]}��|�����Srprrs ��rsrNz2LatexPrinter._print_Complement.<locals>.<listcomp>�rruz \setminus rrs` @rs�_print_ComplementzLatexPrinter._print_Complement��C����%�a�(�(��?�?�?�?�?���?�?�?���"�"�8�,�,�,ruc�v���t|�����fd�|jD��}d�|��S)Nc�<��g|]}��|�����Srprrs ��rsrNz4LatexPrinter._print_Intersection.<locals>.<listcomp>�rruz \cap rrs` @rs�_print_Intersectionz LatexPrinter._print_Intersection�r ruc�v���t|�����fd�|jD��}d�|��S)Nc�<��g|]}��|�����Srprrs ��rsrNz;LatexPrinter._print_SymmetricDifference.<locals>.<listcomp> rruz \triangle rrs` @rs�_print_SymmetricDifferencez'LatexPrinter._print_SymmetricDifference�rruc�<���t|���t|j��dkrMt|j��s9��|jd���dt|j��zzSd���fd�|jD����S)Nrprz^{%d}r�c3�D�K�|]}��|���V��dSrr)r/r�r-r�s ��rsr1z1LatexPrinter._print_ProductSet.<locals>.<genexpr> sD����� <� <�-0�D� � �c�4� (� (� <� <� <� <� <� <ru)rr��setsr$rrS)r�r�r-s` @rs�_print_ProductSetzLatexPrinter._print_ProductSet s�����%�a�(�(�� �q�v�;�;�!� � �K���$7�$7� ��$�$�Q�V�A�Y��5�5��#�a�f�+�+�8M�M� M���� <� <� <� <� <�45�F� <� <� <�<�<� <ruc��dS)Nz \emptysetrpr\s rs�_print_EmptySetzLatexPrinter._print_EmptySet s���|ruc��dS)Nz \mathbb{N}rp�r�r0s rs�_print_NaturalszLatexPrinter._print_Naturals r{ruc��dS)Nz \mathbb{N}_0rprs rs�_print_Naturals0zLatexPrinter._print_Naturals0 s���ruc��dS�Nz \mathbb{Z}rprs rs�_print_IntegerszLatexPrinter._print_Integers r{ruc��dS�Nz \mathbb{Q}rprs rs�_print_RationalszLatexPrinter._print_Rationals r{ruc��dS�Nz \mathbb{R}rprs rs� _print_RealszLatexPrinter._print_Reals r{ruc��dS�Nz \mathbb{C}rprs rs�_print_ComplexeszLatexPrinter._print_Complexes r{ruc����|jj}|jj}�fd�t||j��D��}d�d�|D����}d��|���d|�d�S)Nc3�r�K�|]1\}}��|����|��fV��2dSrrM)r/r0rr�s �rsr1z/LatexPrinter._print_ImageSet.<locals>.<genexpr># s@�����R�R�D�A�q�� � �A���� � �A���/�R�R�R�R�R�RrurOc3� K�|] }d|zV�� dS)� %s \in %sNrp)r/�xys rsr1z/LatexPrinter._print_ImageSet.<locals>.<genexpr>$ s'����;�;��<�"�,�;�;�;�;�;�;rur��\; \middle|\; r�)rXr� signaturerf� base_setsrSr )r�rrr�sig�xys�xinyss` rs�_print_ImageSetzLatexPrinter._print_ImageSet s~����w�|���g���R�R�R�R�C��Q�[�<Q�<Q�R�R�R��� � �;�;�s�;�;�;�;�;���7;�{�{�4�7H�7H�7H�7H�%�%�%�P�Pruc �P��d��fd�t|j��D����}|jtjur!d|�d��|j���d�Sd|�d|�d��|j���d��|j���d� S)NrOc�:��g|]}��|����SrprM�r/r�r�s �rsrNz4LatexPrinter._print_ConditionSet.<locals>.<listcomp>( s%���I�I�I�S�� � �C� 0� 0�I�I�Irur�r3� \right\}r�r�)rSrr5�base_setr � UniversalSetr � condition�r�rr� vars_prints` rs�_print_ConditionSetz LatexPrinter._print_ConditionSet' s�����Y�Y�I�I�I�I�E�!�%�L�L�I�I�I�J�J� � �:��� '� '� '����T�[�[���5�5�5�5�7� 7� (� �J�J� �J�J� �K�K�� � #� #� #� #� �K�K�� � $� $� $� $� &� &ruc�l�|�|jd��}d�|��S)Nrz\mathcal{{P}}\left({}\right)�r rBr)r�r� arg_prints rs�_print_PowerSetzLatexPrinter._print_PowerSet3 s-���K�K�� �!� �-�-� �.�5�5�i�@�@�@ruc����d��fd�|jD����}d��|j���d|�d��|j���d�S)NrOc�:��g|]}��|����SrprMr<s �rsrNz5LatexPrinter._print_ComplexRegion.<locals>.<listcomp>8 s%���H�H�H�S�� � �C� 0� 0�H�H�Hrur�r3r�r=)rSr�r rrrAs` rs�_print_ComplexRegionz!LatexPrinter._print_ComplexRegion7 sl����Y�Y�H�H�H�H�A�K�H�H�H�I�I� � � �K�K��� � � � � �J�J� �K�K��� � � � �!� !ruc�J��dt�fd�|jD����zS)Nr1c3�B�K�|]}��|��V��dSrrMr�s �rsr1z/LatexPrinter._print_Contains.<locals>.<genexpr>? s-�����#C�#C�q�D�K�K��N�N�#C�#C�#C�#C�#C�#Cru)rrBr\s` rs�_print_ContainszLatexPrinter._print_Contains> s-����e�#C�#C�#C�#C�A�F�#C�#C�#C�C�C�C�Cruc���|jjtjur2|jjtjur|�|j��S|�|�����dzS)Nz + \ldots) rur�r rQ�bnr �a0rj�truncaters rs�_print_FourierSeriesz!LatexPrinter._print_FourierSeriesA sV�� �4�<�1�6� !� !�a�d�l�a�f�&<�&<��;�;�q�t�$�$� $����q�z�z�|�|�,�,�|�;�;ruc�6�|�|j��Sr)rj�infiniters rs�_print_FormalPowerSeriesz%LatexPrinter._print_FormalPowerSeriesF s�����q�z�*�*�*ruc��d|jzS)Nz\mathbb{F}_{%s})�modrs rs�_print_FiniteFieldzLatexPrinter._print_FiniteFieldI s��!�D�H�,�,ruc��dSr#rprs rs�_print_IntegerRingzLatexPrinter._print_IntegerRingL r{ruc��dSr&rprs rs�_print_RationalFieldz!LatexPrinter._print_RationalFieldO r{ruc��dSr)rprs rs�_print_RealFieldzLatexPrinter._print_RealFieldR r{ruc��dSr,rprs rs�_print_ComplexFieldz LatexPrinter._print_ComplexFieldU r{ruc��|�|j��}d�t|j|j����}|�d|�d�S)NrOrr�r �domainrSrHr|�r�rrcr|s rs�_print_PolynomialRingz"LatexPrinter._print_PolynomialRingX �G�����T�[�)�)���)�)�C�� �T�\�:�:�;�;��'-�v�v�w�w�w�7�7ruc��|�|j��}d�t|j|j����}|�d|�d�S)NrOrFrsrbrds rs�_print_FractionFieldz!LatexPrinter._print_FractionField] rfruc��|�|j��}d�t|j|j����}d}|jsd}|�|�d|�d�S)NrOr�zS_<^{-1}rr)r rcrSrHr|�is_Poly)r�rrcr|�invs rs�_print_PolynomialRingBasez&LatexPrinter._print_PolynomialRingBaseb s_�����T�[�)�)���)�)�C�� �T�\�:�:�;�;�����|� ��C�),��f�f�f�g�g�g�>�>ruc ���|jj}g}|���D�]t\}}d}t|��D]f\}}|dkr[|dkr$||�|j|��z }�5||�t |j||����z }�g|jr1|rd|�|��z} nz|�|��} nd|rM|tj ur|� d|g����|tj ur|� d|g����|�|��} |s| } n| dz|z} | � d��r!|� d| dd�g����]|� d| g����v|ddvr)|� d��} | dkrd|dz|d<d�|��} tt!|j|j����} d |�|�����z}d �| g| z|gz��}|t$vr d |�d |�d �}n d|�d|�d �}|S)Nr�rrprdr�r3r�)r3r�z domain=%srOr�� {\left(z \right)}r�z }{\left( )rQrRrgrfr �gens�powr$r r��extendrr�poprSr�rH� get_domainr�)r��polyr�rg�monomr��s_monomr�rI�s_coeff�s_term�modifierrrorcrBrs rs� _print_PolyzLatexPrinter._print_Polyj s����n�%���� �J�J�L�L�" ,�" ,�L�E�5��G�#�E�*�*� G� G���3���7�7��a�x�x��4�;�;�t�y��|�#<�#<�<����4�;�;�s�4�9�Q�<��/E�/E�#F�#F�F����|� -��1�0�4�;�;�u�3E�3E�E�G�G�"�k�k�%�0�0�G�G��!����~�~�� � �c�7�^�4�4�4� ��� �-�-�� � �c�7�^�4�4�4� ��+�+�e�,�,��� 1� ��� �3���0��� � ��%�%� ,�� � �c�6�!�"�"�:�.�/�/�/�/�� � �c�6�]�+�+�+�+� ��8�z� !� !��y�y��|�|�H��3�����q��>��a���x�x������C�� �T�Y�/�/�0�0���t�{�{�4�?�?�+<�+<�=�=�=���y�y�$��$��&��1�2�2�� �*� *� *� *�/2�s�s�D�D�D�9�C�C� +�>A�S�S�$�$�$�G�C�� ruc��|jj}|dkrd}|�|j��}|j}|t vrd|||fzSd|||fzS)N� ComplexRootOf�CRootOfz\%s {\left(%s, %d\right)}z'\operatorname{%s} {\left(%s, %d\right)})rQrRr rrar�)r�r;r�rras rs�_print_ComplexRootOfz!LatexPrinter._print_ComplexRootOf� sq���n�%�� �/� !� !��C��{�{�4�9�%�%��� �� �*� *� *�/�3��e�2D�D� D�=��d�AF�AH�H� Hruc�R�|jj}|�|j��g}|jt jur-|�|�|j����|tvrd|�dd� |���d�Sd|�dd� |���d�S)Nr�rnrOr.r�z } {\left() rQrRr r�funr �IdentityFunctionr<r�rS)r�rr�rBs rs�_print_RootSumzLatexPrinter._print_RootSum� s����n�%��� � �D�I�&�&�'�� �8�1�-� -� -� �K�K�� � �D�H�-�-� .� .� .� �*� *� *� *�/2�s�s�D�I�I�d�O�O�O�O�D� D� +�>A�S�S�=A�Y�Y�t�_�_�_�_�N� Nruc��dS)N�\omegarprs rs�_print_OrdinalOmegaz LatexPrinter._print_OrdinalOmega� s���yruc��|j\}}|dkr1|dkrd�||��Sd�|��S|dkrd�|��SdS)Nrpz{} \omega^{{{}}}z {} \omegaz \omega^{{{}}}r�)rBr)r�rrI�muls rs�_print_OmegaPowerzLatexPrinter._print_OmegaPower� sk���9���S� �!�8�8��a�x�x�*�1�1�#�s�;�;�;�#�*�*�3�/�/�/��a�x�x�'�.�.�s�3�3�3� �yruc�P��d��fd�|jD����S)Nrcc�:��g|]}��|����SrprMr�s �rsrNz/LatexPrinter._print_Ordinal.<locals>.<listcomp>� s%���A�A�A��4�;�;�s�+�+�A�A�Aru)rSrBrs` rs�_print_OrdinalzLatexPrinter._print_Ordinal� s,����z�z�A�A�A�A�t�y�A�A�A�B�B�Bruc�V�|jd}|�|td|��S)Nr�z {%s}^{%d})r�r�r!)r�rtr�s rs�_print_PolyElementzLatexPrinter._print_PolyElement� s'���^�$6�7� ��x�x��j�+�z�B�B�Bruc���|jdkr|�|j��S|�|j��}|�|j��}d|�d|�d�S)Nrpr�r�ro)r�r r�)r�r:r�r�s rs�_print_FracElementzLatexPrinter._print_FracElement� s\�� �:��?�?��;�;�t�z�*�*� *��K�K�� �+�+�E��K�K�� �+�+�E�E�',�u�u�e�e�e�4� 4ruc���t|j��dkr|jddfn|j\}}d|�|��z}|�|�d|�d�}|�|�d|�|���d�}|S)NrprzE_{%s}r�rorFrsr�)r�rrIr�r0rs rs� _print_eulerzLatexPrinter._print_euler� s���'*�4�9�~�~��':�':�� �!� �d�#�#�� ���1��$�+�+�a�.�.�(�� �?� #���S�S�S�)�C� �=�*-�#�#�t�{�{�1�~�~�~�~�>�C�� ruc�`�d|�|jd��z}|�|�d|�d�}|S)NzC_{%s}rr�ror r�s rs�_print_catalanzLatexPrinter._print_catalan� r�ruc ���d�||rdnd|�|jd��|�|jd��|�|jd����S)Nz5\mathcal{{{}}}{}_{{{}}}\left[{}\right]\left({}\right)z^{-1}r�rprr��rr rB)r�rrr�inverses rs�_print_UnifiedTransformz$LatexPrinter._print_UnifiedTransform� s���G�N�N�q�]d�Rl�RY�RY�jl�nr�ny�ny�z~�{D�EF�{G�oH�oH�JN�JU�JU�VZ�V_�`a�Vb�Jc�Jc�ei�ep�ep�qu�qz�{|�q}�e~�e~��� ruc�.�|�|d��S)N�M�r�rs rs�_print_MellinTransformz#LatexPrinter._print_MellinTransform� ����+�+�D�#�6�6�6ruc�0�|�|dd��S)Nr�Tr�rs rs�_print_InverseMellinTransformz*LatexPrinter._print_InverseMellinTransform� ����+�+�D�#�t�<�<�<ruc�.�|�|d��S)N�Lr�rs rs�_print_LaplaceTransformz$LatexPrinter._print_LaplaceTransform� r�ruc�0�|�|dd��S)Nr�Tr�rs rs�_print_InverseLaplaceTransformz+LatexPrinter._print_InverseLaplaceTransform� r�ruc�.�|�|d��Sr�r�rs rs�_print_FourierTransformz$LatexPrinter._print_FourierTransform� r�ruc�0�|�|dd��S)Nr�Tr�rs rs�_print_InverseFourierTransformz+LatexPrinter._print_InverseFourierTransform� r�ruc�.�|�|d��S)N�SINr�rs rs�_print_SineTransformz!LatexPrinter._print_SineTransform� ����+�+�D�%�8�8�8ruc�0�|�|dd��S)Nr�Tr�rs rs�_print_InverseSineTransformz(LatexPrinter._print_InverseSineTransform ����+�+�D�%��>�>�>ruc�.�|�|d��S)N�COSr�rs rs�_print_CosineTransformz#LatexPrinter._print_CosineTransform r�ruc�0�|�|dd��S)Nr�Tr�rs rs�_print_InverseCosineTransformz*LatexPrinter._print_InverseCosineTransform r�ruc��� |j�-|�|j�|����Sn#t$rYnwxYw|�t |����Sr)�ringr �to_sympyr�repr�r�r�s rs� _print_DMPzLatexPrinter._print_DMP sn�� ��v�!��{�{�1�6�?�?�1�#5�#5�6�6�6�"��� � � � �D� �����{�{�4��7�7�#�#�#s�37� A�Ac�,�|�|��Sr)r�r�s rs� _print_DMFzLatexPrinter._print_DMF s�����q�!�!�!ruc�P�|�t|j����Sr�r r rT)r�r�s rs� _print_ObjectzLatexPrinter._print_Object s���{�{�6�&�+�.�.�/�/�/ruc� �|�|jd��}|�d|�d�nd}t|j��dkr d|�d|�d�}n7|�|jd��}d �|||��}|S) Nrr�ror�rp�WrFrszW{0}_{{{1}}}\left({2}\right))r rBr�r)r�rrI�arg0�result�arg1s rs�_print_LambertWzLatexPrinter._print_LambertW s����{�{�4�9�Q�<�(�(��#&�?�?�#�#�#����� �t�y�>�>�Q� � � �.1�c�c�4�4�4�8�F�F��;�;�t�y��|�,�,�D�5�<�<�S�$��M�M�F�� ruc�h�d�|�|jd����S)Nz!\operatorname{{E}}\left[{}\right]rr�rs rs�_print_ExpectationzLatexPrinter._print_Expectation$ �)��3�:�:�4�;�;�t�y�QR�|�;T�;T�U�U�Uruc�h�d�|�|jd����S)Nz#\operatorname{{Var}}\left({}\right)rr�rs rs�_print_VariancezLatexPrinter._print_Variance' s)��5�<�<�T�[�[���ST��=V�=V�W�W�Wruc�v��d�d��fd�|jD������S)Nz#\operatorname{{Cov}}\left({}\right)rOc3�B�K�|]}��|��V��dSrrMr�s �rsr1z1LatexPrinter._print_Covariance.<locals>.<genexpr>+ s1�����Fm�Fm�\_�t�{�{�SV�GW�GW�Fm�Fm�Fm�Fm�Fm�Fmru)rrSrBrs` rs�_print_CovariancezLatexPrinter._print_Covariance* s<���5�<�<�T�Y�Y�Fm�Fm�Fm�Fm�cg�cl�Fm�Fm�Fm�=m�=m�n�n�nruc�h�d�|�|jd����S)Nz!\operatorname{{P}}\left({}\right)rr�rs rs�_print_ProbabilityzLatexPrinter._print_Probability- r�ruc�x�|�|j��}|�|j��}|�d|��S)Nr�)r rc�codomain)r��morphismrcr�s rs�_print_MorphismzLatexPrinter._print_Morphism0 s:�����X�_�-�-���;�;�x�0�1�1��&,�f�f�h�h�7�7ruc�|�|�|j��|�|j��}}d|�d|�d�S)Nr�r�ro)r r]�den)r�rr]r�s rs�_print_TransferFunctionz$LatexPrinter._print_TransferFunction5 s<���;�;�t�x�(�(�$�+�+�d�h�*?�*?�S���#&�3�3����,�,ruc����t�j��}��fd�}d�t||����S)Nc�L����|t���d��Sr )rr)r0rr�s ��rsrtz,LatexPrinter._print_Series.<locals>.<lambda>; s'���4�,�,�Q�0F�t�0L�0L�,1�3�3�rur�)r�rBrSrH)r�rrBr"s`` rs� _print_SerieszLatexPrinter._print_Series9 sH�����D�I����3�3�3�3�3���x�x��F�D�)�)�*�*�*ruc�����ddlm�t�j��ddd�}���fd�}d�t ||����S)Nr)� MIMOParallelroc���t|���r$��|t���d��n��|��Sr )r�rrr )r0r�rr�s ���rsrtz0LatexPrinter._print_MIMOSeries.<locals>.<lambda>B sT���7A�!�\�7R�7R�g�4�,�,�Q�0F�t�0L�0L�-2�4�4�4�X\�Xc�Xc�de�Xf�Xf�ruz\cdot)�sympy.physics.control.ltir�r�rBrSrH)r�rrBr"r�s`` @rs�_print_MIMOSerieszLatexPrinter._print_MIMOSeries? sq�����:�:�:�:�:�:��D�I���t�t��t�$��g�g�g�g�g�g���}�}�S���.�.�/�/�/ruc�\�d�t|j|j����S�Nrc�rSrHr rBrs rs�_print_ParallelzLatexPrinter._print_ParallelF �"���z�z�#�d�k�4�9�5�5�6�6�6ruc�\�d�t|j|j����Sr�r�rs rs�_print_MIMOParallelz LatexPrinter._print_MIMOParallelI r�ruc �p�ddlm}m}|j|dd|j��}}t ||��rt |j��n|g}t |j|��rt |jj��n|jg}|}t ||��r t |j|��r |g|�|�R�} n�t ||��r8t |j|��r#|j|kr||�} nt||g|�|j�R�f} nbt ||��r+t |j|��r||kr||�} n1||g|�R�} n'||kr||�} n|j|kr||�} n |g|�|�R�} |� |��} |� |��} |� | ��} |j dkrdnd} d| �d| �d | �d | �d � S) Nr)�TransferFunction�Seriesrpror�r3r�r�r�ro) �sympy.physics.controlr�r��sys1r�r�r�rB�sys2r r�)r�rr�r�r]�tf� num_arg_list� den_arg_list� den_term_1� den_term_2r��denom_1�denom_2�_signs rs�_print_FeedbackzLatexPrinter._print_FeedbackL s?��B�B�B�B�B�B�B�B��)�-�-�a��D�H�=�=�R��)3�C��)@�)@�K�t�C�H�~�~�~�s�e� � �t�y�&� )� )�;�t�D�I�N�+�+�+�04� �{� �� � �c�6� "� "� B�z�$�)�V�'D�'D� B���=��=� �=�=�=�J�J� ��V� $� $� B��D�I�?O�)P�)P� B��y�B���#�V�\�2� � ����!A��!A�t�y�!A�!A�!A�A� � � ��-� .� .� B�:�d�i��3P�3P� B��b�y�y�#�V�\�2� � �#�V�C�7�,�7�7�7� � ��b�y�y�#�V�\�2� � ���b���#�V�\�2� � �#�V�A�\�A�L�A�A�A� �� � �C� � ���+�+�j�)�)���+�+�j�)�)���y�B�����C���).������������H�Hruc���ddlm}|�||j|j����}|�|j��}|jdkrdnd}d|�d|�d|��S) Nr)� MIMOSeriesror�r3z\left(I_{\tau} r�z\right)^{-1} \cdot )r�r�r r�r�r�)r�rr��inv_matr�r�s rs�_print_MIMOFeedbackz LatexPrinter._print_MIMOFeedbackp st��4�4�4�4�4�4��+�+�j�j���D�I�>�>�?�?���{�{�4�9�%�%���y�B�����C���?D�u�u�g�g�g�t�t�T�Truc�@�|�|j��}d|zS)Nz%s_\tau)r � _expr_matrs rs�_print_TransferFunctionMatrixz*LatexPrinter._print_TransferFunctionMatrixw s ���k�k�$�.�)�)���C��ruc�L�d�|jj|j��S)Nz\text{{{}}}_{{{}}})rrQrRr0rs rs� _print_DFTzLatexPrinter._print_DFT{ s��$�+�+�D�N�,C�T�V�L�L�Lruc��|�t|j����}|�|��}|�d|��S)Nr)r r rTr�)r�r�� pretty_name�pretty_morphisms rs�_print_NamedMorphismz!LatexPrinter._print_NamedMorphism sA���k�k�&���"7�"7�8�8� ��.�.�x�8�8��%�+�+���7�7ruc�b�ddlm}|�||j|jd����S)Nr)� NamedMorphism�id)�sympy.categoriesrrrcr�)r�r�rs rs�_print_IdentityMorphismz$LatexPrinter._print_IdentityMorphism� sF��2�2�2�2�2�2��(�(��� �O�X�.��*6�*6�7�7� 7ruc����fd�|jD��}|���d�|��dz}��|��}||zS)Nc�^��g|])}��t|j������*Srpr�)r/� componentr�s �rsrNz9LatexPrinter._print_CompositeMorphism.<locals>.<listcomp>� sE��� B� B� B� )�!%� � �F�9�>�,B�,B� C� C� B� B� Bruz\circ r)r:�reverserSr�)r�r��component_names_list�component_namesrs` rs�_print_CompositeMorphismz%LatexPrinter._print_CompositeMorphism� s}��� B� B� B� B�-5�-@� B� B� B���$�$�&�&�&�#�.�.�)=�>�>��D���.�.�x�8�8����0�0ruc�v�d�|�t|j������S�Nr�)rr r rT)r�r�s rs�_print_CategoryzLatexPrinter._print_Category� s,���&�&�t�{�{�6�(�-�3H�3H�'I�'I�J�J�Jruc���|js|�tj��S|�|j��}|jr |d|�|j��zz }|S)Nz\Longrightarrow %s)�premisesr r �EmptySet� conclusions)r��diagram� latex_results rs�_print_DiagramzLatexPrinter._print_Diagram� sl���� +��;�;�q�z�*�*� *��{�{�7�#3�4�4� � � � =� �1� �K�K��(;�<�<�=� =�L��ruc�.�dd|jzz}t|j��D]m}t|j��D]>}|||fr|t|||f��z }|dz }||jdz kr|dz }�?||jdz kr|dz }|dz }�n|dz }|S) Nz\begin{array}{%s} r�r�rp�& r� z \end{array} )�widthr��height�latex)r��gridrr�r�s rs�_print_DiagramGridzLatexPrinter._print_DiagramGrid� s���-��t�z�1A�B� ��t�{�#�#� !� !�A��4�:�&�&� )� )����1��:�6� �E�$�q�!�t�*�$5�$5�5�L���#� ��� �Q��&�&� �D�(�L���D�K�!�O�#�#���&� � �D� �L�L��(�(� ��ruc��d�|�|j��|�|j����S)Nz {{{}}}^{{{}}})rr r�rP�r�r�s rs�_print_FreeModulezLatexPrinter._print_FreeModule� s4���%�%�d�k�k�!�&�&9�&9�4�;�;�q�v�;N�;N�O�O�Oruc�l��d�d��fd�|D������S)N�\left[ {} \right]rqc3�N�K�|]}d��|��zdzV�� dS�r�roNrM�r/r0r�s �rsr1z8LatexPrinter._print_FreeModuleElement.<locals>.<genexpr>� sH�����43�43�+,�C�$�+�+�a�.�.� �3� &�43�43�43�43�43�43ru)rrS)r�r�s` rs�_print_FreeModuleElementz%LatexPrinter._print_FreeModuleElement� sQ���#�*�*�3�8�8�43�43�43�43�01�43�43�43�,3�,3�4�4� 4ruc��������fd��jD��}d��d��d���fd�|D����}d�|��S)Nc�.��g|]}��fd�|D����S)c�j��g|]/}���j�|������0Srp)r r�r�)r/r0r�r�s ��rsrNz<LatexPrinter._print_SubModule.<locals>.<listcomp>.<listcomp>� s3���<�<�<�Q����Q�V�_�_�Q�/�/�0�0�<�<�<rurp)r/�gr�r�s ��rsrNz1LatexPrinter._print_SubModule.<locals>.<listcomp>� s1���M�M�M��<�<�<�<�<�!�<�<�<�M�M�Mruc��d|zdzS)Nr�rorp�rMs rsrtz/LatexPrinter._print_SubModule.<locals>.<lambda>� s��$��(�T�/�ruc��d|zdzS)Nz\left[ z \right]rpr.s rsrtz/LatexPrinter._print_SubModule.<locals>.<lambda>� s��:��>�K�7�rurqc 3�~�K�|]7}��d��fd�|D��������V��8dS)rqc3�.�K�|]}�|��V��dSrrp)r/r0�curlys �rsr1z:LatexPrinter._print_SubModule.<locals>.<genexpr>.<genexpr>� s+�����3H�3H��E�E�!�H�H�3H�3H�3H�3H�3H�3HruN)rS)r/r,r2�squares ��rsr1z0LatexPrinter._print_SubModule.<locals>.<genexpr>� sX�����Y�Y�q�e�e�F�F�3�8�8�3H�3H�3H�3H�a�3H�3H�3H�+H�+H�$I�$I�J�J�Y�Y�Y�Y�Y�Yru�\left\langle {} \right\rangle)rorSr)r�r�ro� gens_latexr2r3s`` @@rs�_print_SubModulezLatexPrinter._print_SubModule� sr������M�M�M�M�M�a�f�M�M�M��)�)��7�7���X�X�Y�Y�Y�Y�Y�TX�Y�Y�Y�Y�Y� �/�6�6�z�B�B�Bruc�z��d��fd�|jD����}d�|��S)Nrqc�F��g|]}d��|��zdz��S)r�rorM)r/r,r�s �rsrNz9LatexPrinter._print_SubQuotientModule.<locals>.<listcomp>� s-���J�J�J�a�s�T�[�[��^�^�3�c�9�J�J�Jrur4)rSror)r�r�r5s` rs�_print_SubQuotientModulez%LatexPrinter._print_SubQuotientModule� s?����X�X�J�J�J�J�1�6�J�J�J�K�K� �/�6�6�z�B�B�Bruc�����fd��jjD��}d��fd�|D����}d�|��S)Nc�H��g|]\}�j�|����Srp)r�r��r/r0r�s �rsrNz>LatexPrinter._print_ModuleImplementedIdeal.<locals>.<listcomp>� s)���=�=�=�s�������"�"�=�=�=rurqc3�N�K�|]}d��|��zdzV�� dSr&rMr's �rsr1z=LatexPrinter._print_ModuleImplementedIdeal.<locals>.<genexpr>� s7�����G�G�Q�c�D�K�K��N�N�2�S�8�G�G�G�G�G�Grur4)�_modulerorSr)r�r�ror5s`` rs�_print_ModuleImplementedIdealz*LatexPrinter._print_ModuleImplementedIdeal� s[����=�=�=�=�a�i�n�=�=�=���X�X�G�G�G�G�$�G�G�G�G�G� �/�6�6�z�B�B�Bruc����fd�|jD��}|dgd�t|dd�d��D��z}d�|��S)Nc�V��g|]%}��|tdd�����&S)r Tr�)rr!rs �rsrNz2LatexPrinter._print_Quaternion.<locals>.<listcomp>� sC��� !� !� !��� � �q�*�U�"3�D� � A� A� !� !� !rurc�$�g|] \}}|dz|z��S)r�rp)r/r�r�s rsrNz2LatexPrinter._print_Quaternion.<locals>.<listcomp>� s$��<�<�<�$�!�Q�a��e�A�g�<�<�<rurp�ijkrc)rBrfrS)r�rrrr�s` rs�_print_QuaternionzLatexPrinter._print_Quaternion� sn��� !� !� !� !��i� !� !� !�� �q�T�F�<�<�#�a����e�U�*;�*;�<�<�<� <���z�z�!�}�}�ruc��d�|�|j��|�|j����S�Nz\frac{{{}}}{{{}}})rr r�� base_ideal)r��Rs rs�_print_QuotientRingz LatexPrinter._print_QuotientRing� s;��#�*�*�4�;�;�q�v�+>�+>����Q�\�*�*�,�,� ,ruc���|�|j�|����}d�||�|jj����S)N�{{{}}} + {{{}}})r r�r�rrG)r�r0�x_latexs rs�_print_QuotientRingElementz'LatexPrinter._print_QuotientRingElement� sO���+�+�a�f�o�o�a�0�0�1�1��!�(�(�����Q�V�.�/�/�1�1� 1ruc������fd��jD��}d�d��fd�|D������}d�|���jj����S)Nc�N��g|]!}�jj�|����"Srp)�moduler�r�r<s �rsrNz=LatexPrinter._print_QuotientModuleElement.<locals>.<listcomp>� s+���:�:�:�a��� �&�&�q�)�)�:�:�:rur$rqc3�N�K�|]}d��|��zdzV�� dSr&rMr's �rsr1z<LatexPrinter._print_QuotientModuleElement.<locals>.<genexpr>� sH�����:6�:6�+,�C�$�+�+�a�.�.� �3� &�:6�:6�:6�:6�:6�:6rurK)�datarrSr rP� killed_module)r�r�rR� data_latexs`` rs�_print_QuotientModuleElementz)LatexPrinter._print_QuotientModuleElement� s�����:�:�:�:�1�6�:�:�:��)�0�0����:6�:6�:6�:6�04�:6�:6�:6�26�26�7�7� �!�(�(�����Q�X�3�4�4�6�6� 6ruc��d�|�|j��|�|j����SrF)rr rDrSr!s rs�_print_QuotientModulez"LatexPrinter._print_QuotientModule� s;��#�*�*�4�;�;�q�v�+>�+>����Q�_�-�-�/�/� /ruc���d�|�|�����|�|j��|�|j����S)Nz{{{}}} : {{{}}} \to {{{}}})rr � _sympy_matrixrcr�)r�r�s rs�_print_MatrixHomomorphismz&LatexPrinter._print_MatrixHomomorphism� sS��,�3�3�D�K�K����@Q�@Q�4R�4R� �K�K��� !� !�4�;�;�q�z�#:�#:�<�<� <ruc�&�|jj}d|vr|gg}}}n:t|��\}}}t|��}d�|D��}d�|D��}d|z}|r|dd�|��zz }|r|dd�|��zz }|S)Nr�c�,�g|]}t|����Srpr�r�s rsrNz0LatexPrinter._print_Manifold.<locals>.<listcomp>� r�ruc�,�g|]}t|����Srpr�r�s rsrNz0LatexPrinter._print_Manifold.<locals>.<listcomp>� r�rur[rxr�rG)rTrr�rS)r��manifoldr�rTr�rgs rs�_print_ManifoldzLatexPrinter._print_Manifold� s�����#�� �&�=�=�!'��R�$�&�D�D�!0��!8�!8� �D�&�$��T�?�?�D�7�7��7�7�7�F�3�3�d�3�3�3�D��d�"�� � /� �G�c�h�h�v�.�.�.� .�D� � -� �G�c�h�h�t�n�n�,� ,�D�� ruc�t�d|�|j���d|�|j���d�S)N�\text{r�ro)r rTr^)r��patchs rs� _print_PatchzLatexPrinter._print_Patch s7���$(�K�K�� �$;�$;�$;�$;�T�[�[���=X�=X�=X�=X�Y�Yruc��d|�|j���d|�|jj���d|�|j���d�S)Nraz }^{\text{z}}_{ro)r rTrbr^)r��coordsyss rs�_print_CoordSystemzLatexPrinter._print_CoordSystem sV��� �K�K�� � &� &� &� &�� � �H�N�4G�(H�(H�(H�(H�$�+�+�V^�Vg�Jh�Jh�Jh�Jh� � ruc�<�d|�|j��zS)Nz\mathbb{\nabla}_{%s})r �_wrt)r��cvds rs�_print_CovarDerivativeOpz%LatexPrinter._print_CovarDerivativeOp s��&����S�X�)>�)>�>�>ruc��|jj|jj}d�|�t |������Sr�� _coord_sysr|�_indexrTrr r �r��fieldr�s rs�_print_BaseScalarFieldz#LatexPrinter._print_BaseScalarField s=���!�)�%�,�7�<���&�&�t�{�{�6�&�>�>�'B�'B�C�C�Cruc��|jj|jj}d�|�t |������S)Nz\partial_{{{}}}rlros rs�_print_BaseVectorFieldz#LatexPrinter._print_BaseVectorField s=���!�)�%�,�7�<��!�(�(����V�F�^�^�)D�)D�E�E�Eruc�&�|j}t|d��rQ|jj|jj}d�|�t|������S|�|��}d�|��S)Nrmz\operatorname{{d}}{}z!\operatorname{{d}}\left({}\right)) � _form_fieldr�rmr|rnrTrr r )r��diffrpr�s rs�_print_Differentialz LatexPrinter._print_Differential s}��� �� �5�,� '� '� G��%�-�e�l�;�@�F�*�1�1�$�+�+�f�V�n�n�2M�2M�N�N� N��[�[��'�'�F�7�>�>�v�F�F� Fruc�l�|�|jd��}d�|��S)Nrz"\operatorname{{tr}}\left({}\right)rE)r�r��contentss rs� _print_TrzLatexPrinter._print_Tr s-���;�;�q�v�a�y�)�)��4�;�;�H�E�E�Eruc��|�'d|�|jd���d|�d�Sd|�|jd��zS)Nz\left(\phi\left(r�\right)\right)^{roz\phi\left(%s\right)r rHs rs�_print_totientzLatexPrinter._print_totient# sQ�� �?�?����T�Y�q�\�*�*�*�*�C�C�C�1� 1�%�� � �D�I�a�L�(A�(A�A�Aruc��|�'d|�|jd���d|�d�Sd|�|jd��zS)Nz\left(\lambda\left(rr|roz\lambda\left(%s\right)r rHs rs�_print_reduced_totientz#LatexPrinter._print_reduced_totient) sQ�� �?�?����T�Y�q�\�*�*�*�*�C�C�C�1� 1�(�4�;�;�t�y��|�+D�+D�D�Druc ��t|j��dkr>dtt|j|jd|jdf����z}n#d|�|jd��z}|�d|�d|��Sd|zS) Nr��_%s\left(%s\right)rprrdz\sigma^{roz\sigma%sr|r�s rs�_print_divisor_sigmaz!LatexPrinter._print_divisor_sigma/ s��� �t�y�>�>�Q� � �'�%��D�K�15��1��t�y��|�0L�1N�1N�+O�+O�O�C�C�%�t�{�{�4�9�Q�<�'@�'@�@�C� �?�?�'*�s�s�C�C�0� 0��S� � ruc ��t|j��dkr>dtt|j|jd|jdf����z}n#d|�|jd��z}|�d|�d|��Sd|zS) Nr�r�rprrdz \sigma^*^{roz \sigma^*%sr|r�s rs�_print_udivisor_sigmaz"LatexPrinter._print_udivisor_sigma9 s��� �t�y�>�>�Q� � �'�%��D�K�15��1��t�y��|�0L�1N�1N�+O�+O�O�C�C�%�t�{�{�4�9�Q�<�'@�'@�@�C� �?�?�),���c�c�2� 2��s�"�"ruc��|�'d|�|jd���d|�d�Sd|�|jd��zS)Nz\left(\nu\left(rr|roz\nu\left(%s\right)r rHs rs�_print_primenuzLatexPrinter._print_primenuC sQ�� �?�?����T�Y�q�\�*�*�*�*�C�C�C�1� 1�$�t�{�{�4�9�Q�<�'@�'@�@�@ruc��|�'d|�|jd���d|�d�Sd|�|jd��zS)Nz\left(\Omega\left(rr|roz\Omega\left(%s\right)r rHs rs�_print_primeomegazLatexPrinter._print_primeomegaI sQ�� �?�?����T�Y�q�\�*�*�*�*�C�C�C�1� 1�'�$�+�+�d�i��l�*C�*C�C�Cruc�*�t|j��Sr)r�rTrs rs� _print_StrzLatexPrinter._print_StrO s���1�6�{�{�ruc�F�|�t|����Sr)r rrs rs� _print_floatzLatexPrinter._print_floatR s���{�{�5��;�;�'�'�'ruc� �t|��Sr�r�rs rs� _print_intzLatexPrinter._print_intU ����4�y�y�ruc� �t|��Srr�rs rs� _print_mpzzLatexPrinter._print_mpzX r�ruc� �t|��Srr�rs rs� _print_mpqzLatexPrinter._print_mpq[ r�ruc� �t|��Srr�rs rs� _print_fmpzzLatexPrinter._print_fmpz^ r�ruc� �t|��Srr�rs rs� _print_fmpqzLatexPrinter._print_fmpqa r�ruc�j�d�tt|j������S)Nz"\operatorname{{Q}}_{{\text{{{}}}}})rr�r�rTrs rs�_print_PredicatezLatexPrinter._print_Predicated s&��4�;�;�L��T�Y���<X�<X�Y�Y�Yruc���|j}|j}��|��}d��fd�|D����}|�d|�d�S)NrOc�:��g|]}��|����SrprMr�s �rsrNz8LatexPrinter._print_AppliedPredicate.<locals>.<listcomp>k s#���=�=�=�1�� � �A���=�=�=rur�r�)r#� argumentsr rS)r�r�predrB� pred_latex� args_latexs` rs�_print_AppliedPredicatez$LatexPrinter._print_AppliedPredicateg s[����}���~���[�[��&�&� ��Y�Y�=�=�=�=��=�=�=�>�>� �%�:�:�z�z�z�2�2ruc�j��t���|��}dt|��zS)Nz\mathtt{\text{%s}})�super� emptyPrinterr�)r�rrrrQs �rsr�zLatexPrinter.emptyPrintern s+��� �G�G� � �� &� &��$�|�A���6�6rurr�)FF)r�r)rr�)rWrX)rr)rr)rr�r�r�)rr,)r�r�r�r�)rrr�r�r�)r5r�r�r�r)FN)r�)rr )r�r�r�r�)rr&)r[r\)F(ArR� __module__� __qualname__� printmethodr��__annotations__r�rrrr�rrr&r=r@r!r#rJrVr]�_print_BooleanTrue�_print_BooleanFalser`rjrzr�r�r�r�r�r�r�r�r�r�r�r�rrr r%r+rErKrNrRr^rmr}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�r�r�r�r�r�r�rrr rrrr� _print_gammarrrr!r%r'r)r+r1r4r:r<r@rCrFrIrKrMrOrRrTrVrZr\rarfrirlrrrxrzr}rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��_print_RandomSymbolrPr�r�r�r�r�r r rrrr#r&r(r1r3r7r:r<rArFrHrLrZrcrfrhrlrnrprsrurxrzr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r��_print_frozensetr�r�r�r�r�r�r�r�r�r�� _print_SeqPer� _print_SeqAdd� _print_SeqMulr�rr rrrrrrr!r$r'r*r-r9rCrGrJrMrRrUrXrZr\r^r`rerhrlrzr~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�� _print_IDFTrrr rrrr"r(r6r9r?rDrIrMrUrWrZr_rcrfrjrqrsrwrzr}rr�r�r�r�r�r�r�r�r�r�r�r�r�r�� __classcell__)rQs@rsr�r��s����������K�)��U�)��E�)� �e�)� �4� )� �-� )� �� )� �u�)� �4�)� �S�)� �4�)� ��)� �d�)� ��)� ��)� ��)� �G�!)�" �#�#)�$�%��"����!�3)�)�)������8;f�;f�;f�;f�z,�,�,�,�-�-�-�-�%�%�%�%�%� � � � E� E� E� E�K�K�K�K�����.�����> � � � ����� 3�3�3�3����� /�/�/� � � � �%��%�� � � �����&��� 9�9�9�BJ�J�J����<N�N�N� N�N�N�M�M�M�M�M�M� I�I�I�I�I�I�q�q�q�q�f/�/�/� -�-�-�+<�+<�+<�+<�Z&�&�&�&�")�)�)����&���&����<��� '�'�'� � � �@�@�@�BE�E�E�"/�"/�"/�H 4� 4� 4�����@J)�J)�J)�J)�J)�X0�0�0� � � � � ,� ,��X� ,�0�0�0� � � �-�-�-������8�7�J���������� � � � �����+�+�+�+�+�+�+�+� 7� 7� 7� � � �2�2�2�0�0�0�3�3�3�D�D�D�D�F�F�F�F�����)�)�)�)�+�+�+�+� ���� � � � � � � � �  �  �  �  � "� "� "� "� /� /� /� /�[�[�[�[�<�<�<�<�%�%�%�%�%�%�%�%�;�;�;�;�;�(�L�1�1�1�1�:�:�:�:� � � � � � � � �����������������+�+�+�+�+�+�+�+�����"����7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�-�-�-�-�-�4�4�4�4�4�2�2�2�2�2�2�2�2�8�8�8�8�8�8�8�8� � � � � � � � �����  � � � �!�!�!�!�+�+�+�+� @�@�@�@���������������������������������������������Q�Q�Q�Q� G�G�G�G�G�G�G�G�S�S�S�S�S�S�S�S� '� '� '�'�'�'� A�A�A�A�A�(�������,J�J�J�( *� *� *�+�+�+�,���5�5�5� J� J� J�(�(�(� $� $� $�G�G�G�7�7�7�&/�/�/�"G�G�G� A� A� A� A�>�>�>�A�A�A�>�>�>� @� @� @�!�!�!�>�>�>�>�>�>�>�>�>�#�#�#�5�5�5�5�n����8?�?�?� F�F�F�  � � ���� � � � � � �&�&�&�D�D�D� ���4�4�4�4� F� F� F�+�+�+�*�*�*�'�'�'�:�:�:�<�<�<�&�&�&������������� � � � ����� %� %� %�&�&�&�,�,�,�"��(�(�(�T � � � �>�>�>�>�>�>�>�>� >� >� >� >�>�>�>�>����� >�>�>�>�M�M�M�M� ���.&�M�%�M�%�M�K�K�K�$9�9�9�(�(�(� -�-�-� (�(�(� -�-�-� <�<�<����������������������Q�Q�Q� &� &� &�A�A�A�!�!�!�D�D�D�<�<�<� +�+�+�-�-�-�������������8�8�8� 8�8�8� ?�?�?�7�7�7�r H� H� H� N� N� N���� !� !� !�C�C�C�C�C�C�5�5�5��������� ����7�7�7�=�=�=�7�7�7�=�=�=�7�7�7�=�=�=�9�9�9�?�?�?�9�9�9�?�?�?�$�$�$�"�"�"�0�0�0�����V�V�V�X�X�X�o�o�o�V�V�V�8�8�8� -�-�-�+�+�+� 0�0�0�7�7�7�7�7�7�"I�"I�"I�HU�U�U� � � �M�M�M��K�8�8�8� 7�7�7� 1� 1� 1�K�K�K� � � ����$P�P�P�4�4�4� C�C�C�C�C�C�C�C�C� ���,�,�,� 1�1�1� 6�6�6�/�/�/� <�<�<����&Z�Z�Z� � � � ?�?�?�D�D�D�F�F�F�G�G�G�F�F�F� B�B�B�B� E�E�E�E� !�!�!�!�#�#�#�#�A�A�A�A� D�D�D�D� ���(�(�(����������������Z�Z�Z�3�3�3�7�7�7�7�7�7�7�7�7rur�c �&�t�|��}|r|S|���tvrd|���zS|tvrd|zSt t ���td���D]�}|���� |��rZt|��t|��kr:t |t|dt|�� �����cS��|S)a� Check for a modifier ending the string. If present, convert the modifier to latex and translate the rest recursively. Given a description of a Greek letter or other special character, return the appropriate latex. Let everything else pass as given. >>> from sympy.printing.latex import translate >>> translate('alphahatdotprime') "{\\dot{\\hat{\\alpha}}}'" r�T)r2r N) �tex_greek_dictionaryr�r��greek_letters_set� other_symbolsr�r�r�r�r r�)rrrr2s rsr�r�u s��� � "� "�1� %� %�C� � �� � �����'� '� '��a�g�g�i�i��� �m� � ��a�x���-�,�,�.�.�C��F�F�F� D� D�C��w�w�y�y�!�!�#�&�&� D�3�q�6�6�C��H�H�+<�+<�$�S�)�)�A�j��C���y�j�M�*B�*B�C�C�C�C�C���ruc �F�t|���|��S)a�%Convert the given expression to LaTeX string representation. Parameters ========== full_prec: boolean, optional If set to True, a floating point number is printed with full precision. fold_frac_powers : boolean, optional Emit ``^{p/q}`` instead of ``^{\frac{p}{q}}`` for fractional powers. fold_func_brackets : boolean, optional Fold function brackets where applicable. fold_short_frac : boolean, optional Emit ``p / q`` instead of ``\frac{p}{q}`` when the denominator is simple enough (at most two terms and no powers). The default value is ``True`` for inline mode, ``False`` otherwise. inv_trig_style : string, optional How inverse trig functions should be displayed. Can be one of ``'abbreviated'``, ``'full'``, or ``'power'``. Defaults to ``'abbreviated'``. itex : boolean, optional Specifies if itex-specific syntax is used, including emitting ``$$...$$``. ln_notation : boolean, optional If set to ``True``, ``\ln`` is used instead of default ``\log``. long_frac_ratio : float or None, optional The allowed ratio of the width of the numerator to the width of the denominator before the printer breaks off long fractions. If ``None`` (the default value), long fractions are not broken up. mat_delim : string, optional The delimiter to wrap around matrices. Can be one of ``'['``, ``'('``, or the empty string ``''``. Defaults to ``'['``. mat_str : string, optional Which matrix environment string to emit. ``'smallmatrix'``, ``'matrix'``, ``'array'``, etc. Defaults to ``'smallmatrix'`` for inline mode, ``'matrix'`` for matrices of no more than 10 columns, and ``'array'`` otherwise. mode: string, optional Specifies how the generated code will be delimited. ``mode`` can be one of ``'plain'``, ``'inline'``, ``'equation'`` or ``'equation*'``. If ``mode`` is set to ``'plain'``, then the resulting code will not be delimited at all (this is the default). If ``mode`` is set to ``'inline'`` then inline LaTeX ``$...$`` will be used. If ``mode`` is set to ``'equation'`` or ``'equation*'``, the resulting code will be enclosed in the ``equation`` or ``equation*`` environment (remember to import ``amsmath`` for ``equation*``), unless the ``itex`` option is set. In the latter case, the ``$$...$$`` syntax is used. mul_symbol : string or None, optional The symbol to use for multiplication. Can be one of ``None``, ``'ldot'``, ``'dot'``, or ``'times'``. order: string, optional Any of the supported monomial orderings (currently ``'lex'``, ``'grlex'``, or ``'grevlex'``), ``'old'``, and ``'none'``. This parameter does nothing for `~.Mul` objects. Setting order to ``'old'`` uses the compatibility ordering for ``~.Add`` defined in Printer. For very large expressions, set the ``order`` keyword to ``'none'`` if speed is a concern. symbol_names : dictionary of strings mapped to symbols, optional Dictionary of symbols and the custom strings they should be emitted as. root_notation : boolean, optional If set to ``False``, exponents of the form 1/n are printed in fractonal form. Default is ``True``, to print exponent in root form. mat_symbol_style : string, optional Can be either ``'plain'`` (default) or ``'bold'``. If set to ``'bold'``, a `~.MatrixSymbol` A will be printed as ``\mathbf{A}``, otherwise as ``A``. imaginary_unit : string, optional String to use for the imaginary unit. Defined options are ``'i'`` (default) and ``'j'``. Adding ``r`` or ``t`` in front gives ``\mathrm`` or ``\text``, so ``'ri'`` leads to ``\mathrm{i}`` which gives `\mathrm{i}`. gothic_re_im : boolean, optional If set to ``True``, `\Re` and `\Im` is used for ``re`` and ``im``, respectively. The default is ``False`` leading to `\operatorname{re}` and `\operatorname{im}`. decimal_separator : string, optional Specifies what separator to use to separate the whole and fractional parts of a floating point number as in `2.5` for the default, ``period`` or `2{,}5` when ``comma`` is specified. Lists, sets, and tuple are printed with semicolon separating the elements when ``comma`` is chosen. For example, [1; 2; 3] when ``comma`` is chosen and [1,2,3] for when ``period`` is chosen. parenthesize_super : boolean, optional If set to ``False``, superscripted expressions will not be parenthesized when powered. Default is ``True``, which parenthesizes the expression when powered. min: Integer or None, optional Sets the lower bound for the exponent to print floating point numbers in fixed-point format. max: Integer or None, optional Sets the upper bound for the exponent to print floating point numbers in fixed-point format. diff_operator: string, optional String to use for differential operator. Default is ``'d'``, to print in italic form. ``'rd'``, ``'td'`` are shortcuts for ``\mathrm{d}`` and ``\text{d}``. adjoint_style: string, optional String to use for the adjoint symbol. Defined options are ``'dagger'`` (default),``'star'``, and ``'hermitian'``. Notes ===== Not using a print statement for printing, results in double backslashes for latex commands since that's the way Python escapes backslashes in strings. >>> from sympy import latex, Rational >>> from sympy.abc import tau >>> latex((2*tau)**Rational(7,2)) '8 \\sqrt{2} \\tau^{\\frac{7}{2}}' >>> print(latex((2*tau)**Rational(7,2))) 8 \sqrt{2} \tau^{\frac{7}{2}} Examples ======== >>> from sympy import latex, pi, sin, asin, Integral, Matrix, Rational, log >>> from sympy.abc import x, y, mu, r, tau Basic usage: >>> print(latex((2*tau)**Rational(7,2))) 8 \sqrt{2} \tau^{\frac{7}{2}} ``mode`` and ``itex`` options: >>> print(latex((2*mu)**Rational(7,2), mode='plain')) 8 \sqrt{2} \mu^{\frac{7}{2}} >>> print(latex((2*tau)**Rational(7,2), mode='inline')) $8 \sqrt{2} \tau^{7 / 2}$ >>> print(latex((2*mu)**Rational(7,2), mode='equation*')) \begin{equation*}8 \sqrt{2} \mu^{\frac{7}{2}}\end{equation*} >>> print(latex((2*mu)**Rational(7,2), mode='equation')) \begin{equation}8 \sqrt{2} \mu^{\frac{7}{2}}\end{equation} >>> print(latex((2*mu)**Rational(7,2), mode='equation', itex=True)) $$8 \sqrt{2} \mu^{\frac{7}{2}}$$ >>> print(latex((2*mu)**Rational(7,2), mode='plain')) 8 \sqrt{2} \mu^{\frac{7}{2}} >>> print(latex((2*tau)**Rational(7,2), mode='inline')) $8 \sqrt{2} \tau^{7 / 2}$ >>> print(latex((2*mu)**Rational(7,2), mode='equation*')) \begin{equation*}8 \sqrt{2} \mu^{\frac{7}{2}}\end{equation*} >>> print(latex((2*mu)**Rational(7,2), mode='equation')) \begin{equation}8 \sqrt{2} \mu^{\frac{7}{2}}\end{equation} >>> print(latex((2*mu)**Rational(7,2), mode='equation', itex=True)) $$8 \sqrt{2} \mu^{\frac{7}{2}}$$ Fraction options: >>> print(latex((2*tau)**Rational(7,2), fold_frac_powers=True)) 8 \sqrt{2} \tau^{7/2} >>> print(latex((2*tau)**sin(Rational(7,2)))) \left(2 \tau\right)^{\sin{\left(\frac{7}{2} \right)}} >>> print(latex((2*tau)**sin(Rational(7,2)), fold_func_brackets=True)) \left(2 \tau\right)^{\sin {\frac{7}{2}}} >>> print(latex(3*x**2/y)) \frac{3 x^{2}}{y} >>> print(latex(3*x**2/y, fold_short_frac=True)) 3 x^{2} / y >>> print(latex(Integral(r, r)/2/pi, long_frac_ratio=2)) \frac{\int r\, dr}{2 \pi} >>> print(latex(Integral(r, r)/2/pi, long_frac_ratio=0)) \frac{1}{2 \pi} \int r\, dr Multiplication options: >>> print(latex((2*tau)**sin(Rational(7,2)), mul_symbol="times")) \left(2 \times \tau\right)^{\sin{\left(\frac{7}{2} \right)}} Trig options: >>> print(latex(asin(Rational(7,2)))) \operatorname{asin}{\left(\frac{7}{2} \right)} >>> print(latex(asin(Rational(7,2)), inv_trig_style="full")) \arcsin{\left(\frac{7}{2} \right)} >>> print(latex(asin(Rational(7,2)), inv_trig_style="power")) \sin^{-1}{\left(\frac{7}{2} \right)} Matrix options: >>> print(latex(Matrix(2, 1, [x, y]))) \left[\begin{matrix}x\\y\end{matrix}\right] >>> print(latex(Matrix(2, 1, [x, y]), mat_str = "array")) \left[\begin{array}{c}x\\y\end{array}\right] >>> print(latex(Matrix(2, 1, [x, y]), mat_delim="(")) \left(\begin{matrix}x\\y\end{matrix}\right) Custom printing of symbols: >>> print(latex(x**2, symbol_names={x: 'x_i'})) x_i^{2} Logarithms: >>> print(latex(log(10))) \log{\left(10 \right)} >>> print(latex(log(10), ln_notation=True)) \ln{\left(10 \right)} ``latex()`` also supports the builtin container types :class:`list`, :class:`tuple`, and :class:`dict`: >>> print(latex([2/x, y], mode='inline')) $\left[ 2 / x, \ y\right]$ Unsupported types are rendered as monospaced plaintext: >>> print(latex(int)) \mathtt{\text{<class 'int'>}} >>> print(latex("plain % text")) \mathtt{\text{plain \% text}} See :ref:`printer_method_example` for an example of how to override this behavior for your own types by implementing ``_latex``. .. versionchanged:: 1.7.0 Unsupported types no longer have their ``str`` representation treated as valid latex. )r�r�rr�s rsrr� s!��n �� !� !� )� )�$� /� /�/ruc �:�tt|fi|����dS)z`Prints LaTeX representation of the given expression. Takes the same settings as ``latex()``.N)�printrr�s rs� print_latexr�n s(�� �%�� !� !�� !� !�"�"�"�"�"rurp�align*Fc ��tdi|��}|dkr d}d}d} d} d} nD|dkr d}d}d} d } d} n3|d kr d }d }d } d} d} n"td�|�����d } |rd} |���} t | ��}d}t |��D]�}| |}d }d }d}||kr | rd}nd}d}||kr||dz kr | | zdzdz}nd }|���ddkrd|z}d}|dkrK|dkrd }|d�|�|��|||�|��|��z }n.|d�|||�|��|��z }|dz }��|| z }|S)a� This function generates a LaTeX equation with a multiline right-hand side in an ``align*``, ``eqnarray`` or ``IEEEeqnarray`` environment. Parameters ========== lhs : Expr Left-hand side of equation rhs : Expr Right-hand side of equation terms_per_line : integer, optional Number of terms per line to print. Default is 1. environment : "string", optional Which LaTeX wnvironment to use for the output. Options are "align*" (default), "eqnarray", and "IEEEeqnarray". use_dots : boolean, optional If ``True``, ``\\dots`` is added to the end of each line. Default is ``False``. Examples ======== >>> from sympy import multiline_latex, symbols, sin, cos, exp, log, I >>> x, y, alpha = symbols('x y alpha') >>> expr = sin(alpha*y) + exp(I*alpha) - cos(log(y)) >>> print(multiline_latex(x, expr)) \begin{align*} x = & e^{i \alpha} \\ & + \sin{\left(\alpha y \right)} \\ & - \cos{\left(\log{\left(y \right)} \right)} \end{align*} Using at most two terms per line: >>> print(multiline_latex(x, expr, 2)) \begin{align*} x = & e^{i \alpha} + \sin{\left(\alpha y \right)} \\ & - \cos{\left(\log{\left(y \right)} \right)} \end{align*} Using ``eqnarray`` and dots: >>> print(multiline_latex(x, expr, terms_per_line=2, environment="eqnarray", use_dots=True)) \begin{eqnarray} x & = & e^{i \alpha} + \sin{\left(\alpha y \right)} \dots\nonumber\\ & & - \cos{\left(\log{\left(y \right)} \right)} \end{eqnarray} Using ``IEEEeqnarray``: >>> print(multiline_latex(x, expr, environment="IEEEeqnarray")) \begin{IEEEeqnarray}{rCl} x & = & e^{i \alpha} \nonumber\\ & & + \sin{\left(\alpha y \right)} \nonumber\\ & & - \cos{\left(\log{\left(y \right)} \right)} \end{IEEEeqnarray} Notes ===== All optional parameters from ``latex`` can also be used. �eqnarrayz\begin{eqnarray} z& = &z \nonumberz \end{eqnarray}T� IEEEeqnarrayz\begin{IEEEeqnarray}{rCl} z \end{IEEEeqnarray}r�z\begin{align*} z= &r�z \end{align*}FzUnknown environment: {}z\dotsrpr�z& & rrrrror3z{:s} {:s}{:s} {:s} {:s}z{:s}{:s} {:s} {:s}rp)r�r�r�as_ordered_termsr�r�r�r)r�r��terms_per_line� environment�use_dotsr�rr�� first_term�nonumber�end_term�doubleetr�rg�n_terms� term_countr�rh� term_start�term_endr�s rs�multiline_latexr�u s+��F � � �x� � �A��j� � �+��� ���&����� �� &� &�4��� ���*����� �� � �)��� ���%������2�9�9�+�F�F�G�G�G� �D��� �� � � � "� "�E��%�j�j�G��J� �7�^�^�����Q�x��� ����� �� &� &�� "�#� � �!� ��J� �� '� '��7�1�9�}�}��(�?�U�2�T�9����� � "� "� $� $�Q� '�2� -� -��d�7�D��D� ��6�6��s�{�{��� �0�7�7�� � �#���"�D�!�)�)�D�/�/�8�E�E� E�F�F� �+�2�2�:�t�� � �$����3�3� 3�F��a�� � � �h��F� �Mru)rrr�r�r�)rpr�F)J�__doc__� __future__r�typingrrrrR� sympy.corerrr r r r r r�sympy.core.alphabetsr�sympy.core.containersr�sympy.core.functionrrr�sympy.core.operationsr�sympy.core.powerr�sympy.core.sortingr�sympy.core.sympifyrr�rrr�sympy.printing.precedencer�sympy.printing.printerrr�sympy.printing.conventionsrrr 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�r�rr�r�rprurs�<module>r�s8�����#�"�"�"�"�"�/�/�/�/�/�/�/�/�/�/�����D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�D�'�'�'�'�'�'�'�'�'�'�'�'�B�B�B�B�B�B�B�B�B�B�)�)�)�)�)�)� � � � � � �/�/�/�/�/�/�+�+�+�+�+�+�?�?�?�?�?�?�?�?�?�?�=�<�<�<�<�<�:�:�:�:�:�:�:�:�H�H�H�H�H�H�H�H�<�<�<�<�<�<�<�<�B�B�B�B�B�B�B�B�7�7�7�7�7�7�7�7� � � � ��;�,�,�,�,�,�,�:�:�:�:�:�:� ���� %� �]�%� �M�%� �Y�%� �Y� %� �}� %�  �M� %� �=�%� �Y�%� �M�%� �]�%� �j�%� �-�%� �-�%� �&�%��s�%� �}�!%�" �&�#%�%�$ �=�%%�& �Y�'%�( �=�)%�*�{�+%�, �7�-%�. �=�/%�0 �7�1%�2 �Y�3%�4 �Z�5%�6 �Z�7%�8 �7�9%�: �=�;%�<�.�=%�>� �?%�@ �j�A%�B �Y�C%�D �j�E%�%�F��I%�%�%��N,�,�,� �2��.�.�2� �*�*�2� � (� (� 2�  � &� &� 2�  � $� $� 2� � (� (�2� � (� (�2� � (� (�2� � (� (�2� � (� (�2� � $� $�2� � $� $�2� � $� $�2� � !� !�2�  � � �!2�$ � ,� ,�%2�& � *� *�'2�( )� (� (� (� *� *� 0� 0� 9� 9� -� -� -� -�72�2�2� �����<�I�f�%�%���B�J�~����B�J�'�(�(���  �  �  �  �d+7�d+7�d+7�d+7�d+7�7�d+7�d+7�d+7�NW����>�� ���V0�V0���V0�r#�#�#�~�~�~�~�~�~ru
Memory