Ë
    7^(hl  ã                   ól   — 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y
)zX
This module implements a method to find
Euler-Lagrange Equations for given Lagrangian.
é    )Úcombinations_with_replacement)Ú
DerivativeÚFunctionÚdiff)ÚEq)ÚS)ÚSymbol©Úsympify)Úiterablec                 ó¤  — t        |«      rt        |«      n|f}|st        | j                  t        «      «      }n%|D ]   }t	        |t        «      rŒ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(  rŒt        d|›d|›�«      ‚ t        | j                  t        «      D �cg c]%  }|j                  |v rt        |j                  «      ‘Œ' c}dgz   «      }g }|D ]�  }t        | |«      }t        d|dz   «      D ]A  }t!        ||«      D ]0  }	|t"        j$                  |z  t        | t        |g|	¢­Ž g|	¢­Ž z  z   }Œ2 ŒC t'        |d«      }
t	        |
t&        «      sŒ|j)                  |
«       Œ‘ |S c c}w )	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   ó2   K  — | ]  }t        |«      –— Œ y ­w©Nr
   )Ú.0Úvars     úR/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/calculus/euler.pyú	<genexpr>z"euler_equations.<locals>.<genexpr>V   s   è ø€ Ò2 c”W˜S—\Ñ2ùs   ‚c              3   ó<   K  — | ]  }t        |t        «      –— Œ y ­wr   )Ú
isinstancer	   )r   Úvs     r   r   z"euler_equations.<locals>.<genexpr>X   s   è ø€ Ò3¨Œz˜!œV×$Ñ3ùs   ‚z!Variables are not symbols, got %sz
Variables z do not match args: é   )r   ÚtupleÚatomsr   r   Ú	TypeErrorÚargsÚallÚ
ValueErrorÚmaxr   ÚexprÚlenÚ	variablesr   Úranger   r   ÚNegativeOner   Úappend)ÚLÚfuncsÚvarsÚfÚdÚorderÚeqnsÚeqÚiÚpÚnew_eqs              r   Úeuler_equationsr0      sÑ  € ôt % UœOŒE�%ŒL°%°€EáÜ�a—g‘gœhÓ'Ó(‰àò 	BˆAÜ˜a¤Õ*ÜÐ <¸qÑ @ÓAÐAð	Bô # 4œ.Œ5�Œ;¨t¨g€DáØ�Q‰x�}‰}‰äÑ2¨TÔ2Ó2ˆäÑ3¨dÔ3Ô3ÜÐ;¸dÑBÓCÐCàò OˆØ�q—v‘v‹~ÝÂTÉ1ÐMÓNÐNðOô ¨1¯7©7´:Ó+>ö , aØŸ6™6 U™?ô �Q—[‘[Õ!ò ,Ø/0¨cñ2ó 3€Eð €DØò  ˆÜ�!�Q‹ZˆÜ�q˜% !™)Ó$ò 	DˆAÜ2°4¸Ó;ò D�Øœ!Ÿ-™-¨Ñ*¬4°´4¸°;¸A²;Ð+CÀÒ+CÑCÑC‘ñDð	Dô �B˜“ˆÜ�fœbÕ!Ø�K‰K˜Õð ð €Kùò,s   Ä *GN)© r1   )Ú__doc__Ú	itertoolsr   Úsympy.core.functionr   r   r   Úsympy.core.relationalr   Úsympy.core.singletonr   Úsympy.core.symbolr	   Úsympy.core.sympifyr   Úsympy.utilities.iterablesr   r0   r1   ó    r   ú<module>r;      s*   ðñõ 4ß <Ñ <Ý $Ý "Ý $Ý &Ý .ô^r:   