§
    OŠtjl  ã                   ón   — d Z ddlmZ ddlmZmZmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd
„ZdS )zX
This module implements a method to find
Euler-Lagrange Equations for given Lagrangian.
é    )Úcombinations_with_replacement)Ú
DerivativeÚFunctionÚdiff)ÚEq)ÚS)ÚSymbol©Úsympify)Úiterable© c                 óä  ‡— t          ‰¦  «        rt          ‰¦  «        n‰fŠ‰s(t          |                      t          ¦  «        ¦  «        Šn,‰D ])}t	          |t          ¦  «        st          d|z  ¦  «        ‚Œ*t          |¦  «        rt          |¦  «        n|f}|s‰d         j        }nt          d„ |D ¦   «         ¦  «        }t          d„ |D ¦   «         ¦  «        st          d|z  ¦  «        ‚‰D ]"}||j        k    st          d|›d|›�¦  «        ‚Œ#t          ˆfd„|                      t          ¦  «        D ¦   «         dgz   ¦  «        }g }‰D ]¡}t          | |¦  «        }t          d	|d	z   ¦  «        D ]A}t          ||¦  «        D ].}|t          j        |z  t          | t          |g|¢R Ž g|¢R Ž z  z   }Œ/ŒBt!          |d¦  «        }	t	          |	t           ¦  «        r|                     |	¦  «         Œ¢|S )
a5  
    Find the Euler-Lagrange equations [1]_ for a given Lagrangian.

    Parameters
    ==========

    L : Expr
        The Lagrangian that should be a function of the functions listed
        in the second argument and their derivatives.

        For example, in the case of two functions $f(x,y)$, $g(x,y)$ and
        two independent variables $x$, $y$ the Lagrangian has the form:

            .. math:: L\left(f(x,y),g(x,y),\frac{\partial f(x,y)}{\partial x},
                      \frac{\partial f(x,y)}{\partial y},
                      \frac{\partial g(x,y)}{\partial x},
                      \frac{\partial g(x,y)}{\partial y},x,y\right)

        In many cases it is not necessary to provide anything, except the
        Lagrangian, it will be auto-detected (and an error raised if this
        cannot be done).

    funcs : Function or an iterable of Functions
        The functions that the Lagrangian depends on. The Euler equations
        are differential equations for each of these functions.

    vars : Symbol or an iterable of Symbols
        The Symbols that are the independent variables of the functions.

    Returns
    =======

    eqns : list of Eq
        The list of differential equations, one for each function.

    Examples
    ========

    >>> from sympy import euler_equations, Symbol, Function
    >>> x = Function('x')
    >>> t = Symbol('t')
    >>> L = (x(t).diff(t))**2/2 - x(t)**2/2
    >>> euler_equations(L, x(t), t)
    [Eq(-x(t) - Derivative(x(t), (t, 2)), 0)]
    >>> u = Function('u')
    >>> x = Symbol('x')
    >>> L = (u(t, x).diff(t))**2/2 - (u(t, x).diff(x))**2/2
    >>> euler_equations(L, u(t, x), [t, x])
    [Eq(-Derivative(u(t, x), (t, 2)) + Derivative(u(t, x), (x, 2)), 0)]

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Euler%E2%80%93Lagrange_equation

    zFunction expected, got: %sr   c              3   ó4   K  — | ]}t          |¦  «        V — Œd S ©Nr
   )Ú.0Úvars     úR/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/calculus/euler.pyú	<genexpr>z"euler_equations.<locals>.<genexpr>V   s(   è è € Ð2Ð2 c•W˜S‘\”\Ð2Ð2Ð2Ð2Ð2Ð2ó    c              3   ó@   K  — | ]}t          |t          ¦  «        V — Œd S r   )Ú
isinstancer	   )r   Úvs     r   r   z"euler_equations.<locals>.<genexpr>X   s,   è è € Ð3Ð3¨�z˜!�VÑ$Ô$Ð3Ð3Ð3Ð3Ð3Ð3r   z!Variables are not symbols, got %sz
Variables z do not match args: c                 óJ   •— g | ]}|j         ‰v ¯t          |j        ¦  «        ‘Œ S r   )ÚexprÚlenÚ	variables)r   ÚdÚfuncss     €r   ú
<listcomp>z#euler_equations.<locals>.<listcomp>_   s5   ø€ ð ,ð ,ð , aØœ6 U˜?˜?õ �Q”[Ñ!Ô!Ø*˜?˜?r   é   )r   ÚtupleÚatomsr   r   Ú	TypeErrorÚargsÚallÚ
ValueErrorÚmaxr   r   Úranger   r   ÚNegativeOner   Úappend)
ÚLr   ÚvarsÚfÚorderÚeqnsÚeqÚiÚpÚnew_eqs
    `        r   Úeuler_equationsr4      s_  ø€ õt % U™OœOÐ9�E�%‰LŒLˆL°%°€Eàð BÝ�a—g’g�hÑ'Ô'Ñ(Ô(ˆˆàð 	Bð 	BˆAÝ˜a¥Ñ*Ô*ð BÝÐ <¸qÑ @ÑAÔAÐAðBõ # 4™.œ.Ð5�5�‰;Œ;ˆ;¨t¨g€Dàð 3Ø�QŒxŒ}ˆˆåÐ2Ð2¨TÐ2Ñ2Ô2Ñ2Ô2ˆåÐ3Ð3¨dÐ3Ñ3Ô3Ñ3Ô3ð DÝÐ;¸dÑBÑCÔCÐCàð Oð OˆØ�q”vŠ~ˆ~Ý�*ÀTÀTÀTÈ1È1ÐMÑNÔNÐNð õ ð ,ð ,ð ,ð ,¨1¯7ª7µ:Ñ+>Ô+>ð ,ñ ,ô ,Ø/0¨cñ2ñ 3ô 3€Eð €DØð  ð  ˆÝ�!�Q‰ZŒZˆÝ�q˜% !™)Ñ$Ô$ð 	Dð 	DˆAÝ2°4¸Ñ;Ô;ð Dð D�Ø�!œ-¨Ñ*­4°µ4¸°;¸A°;°;°;Ð+CÀÐ+CÐ+CÐ+CÑCÑC��ðDå�B˜‘”ˆÝ�f�bÑ!Ô!ð 	 Ø�KŠK˜ÑÔÐøà€Kr   N)r   r   )Ú__doc__Ú	itertoolsr   Úsympy.core.functionr   r   r   Úsympy.core.relationalr   Úsympy.core.singletonr   Úsympy.core.symbolr	   Úsympy.core.sympifyr   Úsympy.utilities.iterablesr   r4   r   r   r   ú<module>r=      s¿   ððð ð 4Ð 3Ð 3Ð 3Ð 3Ð 3Ø <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ð <Ø $Ð $Ð $Ð $Ð $Ð $Ø "Ð "Ð "Ð "Ð "Ð "Ø $Ð $Ð $Ð $Ð $Ð $Ø &Ð &Ð &Ð &Ð &Ð &Ø .Ð .Ð .Ð .Ð .Ð .ð^ð ^ð ^ð ^ð ^ð ^r   