Ë
    7^(h^<  ã                   óÌ   — d dl mZ d dlmZ d dlmZ d dlmZ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„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zddœd„Z y)é    )Ú
CoordSys3D)ÚDel)Ú
BaseScalar)ÚVectorÚ
BaseVector)ÚgradientÚcurlÚ
divergence)Údiff)ÚS)Ú	integrate)Úsympify)ÚDyadicNFc           	      ó
  — | dt         j                  fv r| S t        |t        «      st	        d«      ‚t        | t         «      rë|�t        d«      ‚|rp| j                  t        t        «      D �ch c]  }|j                  ’Œ c}|hz
  }i }|D ]"  }|j                  |j                  |«      «       Œ$ | j                  |«      } t         j                  }| j                  «       }	|	D ]E  }||k7  r6|j                  |«      |	|   j                  |«      z  }
|t!        |
|«      z  }Œ>||	|   z  }ŒG |S t        | t"        «      rž|€|}t        |t        «      st	        d«      ‚t"        j                  }|}| j$                  j'                  «       D ]N  \  }}|t)        |||¬«      t)        |j*                  d   ||¬«      t)        |j*                  d   ||¬«      z  z  z  }ŒP |S |�t        d«      ‚|r”t-        «       }t/        | «      } | j                  t        «      D ]-  }|j                  |k7  sŒ|j1                  |j                  «       Œ/ i }|D ]"  }|j                  |j                  |«      «       Œ$ | j                  |«      S | S c c}w )aK  
    Global function for 'express' functionality.

    Re-expresses a Vector, Dyadic or scalar(sympyfiable) in the given
    coordinate system.

    If 'variables' is True, then the coordinate variables (base scalars)
    of other coordinate systems present in the vector/scalar field or
    dyadic are also substituted in terms of the base scalars of the
    given system.

    Parameters
    ==========

    expr : Vector/Dyadic/scalar(sympyfiable)
        The expression to re-express in CoordSys3D 'system'

    system: CoordSys3D
        The coordinate system the expr is to be expressed in

    system2: CoordSys3D
        The other coordinate system required for re-expression
        (only for a Dyadic Expr)

    variables : boolean
        Specifies whether to substitute the coordinate variables present
        in expr, in terms of those of parameter system

    Examples
    ========

    >>> from sympy.vector import CoordSys3D
    >>> from sympy import Symbol, cos, sin
    >>> N = CoordSys3D('N')
    >>> q = Symbol('q')
    >>> B = N.orient_new_axis('B', q, N.k)
    >>> from sympy.vector import express
    >>> express(B.i, N)
    (cos(q))*N.i + (sin(q))*N.j
    >>> express(N.x, B, variables=True)
    B.x*cos(q) - B.y*sin(q)
    >>> d = N.i.outer(N.i)
    >>> express(d, B, N) == (cos(q))*(B.i|N.i) + (-sin(q))*(B.j|N.i)
    True

    r   z>system should be a CoordSys3D                         instancezJsystem2 should not be provided for                                 VectorszCsystem2 should be a CoordSys3D                             instance©Ú	variablesé   )r   ÚzeroÚ
isinstancer   Ú	TypeErrorÚ
ValueErrorÚatomsr   r   ÚsystemÚupdateÚ
scalar_mapÚsubsÚseparateÚrotation_matrixÚ	to_matrixÚmatrix_to_vectorr   Ú
componentsÚitemsÚexpressÚargsÚsetr   Úadd)Úexprr   Úsystem2r   ÚxÚsystem_listÚ	subs_dictÚfÚoutvecÚpartsÚtempÚoutdyadÚvarÚkÚvÚ
system_sets                   úT/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/vector/functions.pyr#   r#      s’  € ð` �”6—;‘;ÐÑØˆä�fœjÔ)Üð "ó #ð 	#ô �$œÔØÐÜð )ó *ð *ñ ð .2¯Z©Z¼
ÄJÓ-OÖP¨˜1Ÿ8›8ÒPÐTZÐS[Ñ[ˆKØˆIØ ò 7�Ø× Ñ  §¡¨fÓ!5Õ6ð7à—9‘9˜YÓ'ˆDä—‘ˆØ—‘“ˆØò 	#ˆAØ�FŠ{Ø×-Ñ-¨aÓ0°5¸±8×3EÑ3EÀaÓ3HÑH�ØÔ*¨4°Ó8Ñ8‘à˜% ™(Ñ"‘ð	#ð ˆä	�Dœ&Ô	!Øˆ?ØˆGÜ˜'¤:Ô.Üð &ó 'ð 'ä—+‘+ˆØˆØ—O‘O×)Ñ)Ó+ò 	F‰DˆAˆqØœ  6°SÔ9Ü  §¡¨¡¨F¸cÔBÜ  §¡¨¡¨G¸sÔCñDñEñ F‰Gð	Fð
 ˆð ÐÜð )ó *ð *áä›ˆJÜ˜4“=ˆDà—Z‘Z¤
Ó+ò -�Ø—8‘8˜vÓ%Ø—N‘N 1§8¡8Õ,ð-ð ˆIØò 7�Ø× Ñ  §¡¨fÓ!5Õ6ð7à—9‘9˜YÓ'Ð'Øˆùò_ Qs   Á-J c                 óZ  — ddl m}  || «      }t        |«      dkD  ràt        t	        |«      «      }t        | |d¬«      } |j                  «       \  }}}|j                  «       \  }}}	t        j                  ||«      t        | |«      z  }
|
t        j                  ||«      t        | |«      z  z  }
|
t        j                  ||«      t        | |	«      z  z  }
|
dk(  r t        | t        «      rt        j                  }
|
S t        | t        «      rt        j                  S t        j                  S )aé  
    Returns the directional derivative of a scalar or vector field computed
    along a given vector in coordinate system which parameters are expressed.

    Parameters
    ==========

    field : Vector or Scalar
        The scalar or vector field to compute the directional derivative of

    direction_vector : Vector
        The vector to calculated directional derivative along them.


    Examples
    ========

    >>> from sympy.vector import CoordSys3D, directional_derivative
    >>> R = CoordSys3D('R')
    >>> f1 = R.x*R.y*R.z
    >>> v1 = 3*R.i + 4*R.j + R.k
    >>> directional_derivative(f1, v1)
    R.x*R.y + 4*R.x*R.z + 3*R.y*R.z
    >>> f2 = 5*R.x**2*R.z
    >>> directional_derivative(f2, v1)
    5*R.x**2 + 30*R.x*R.z

    r   )Ú_get_coord_systemsTr   )Úsympy.vector.operatorsr7   ÚlenÚnextÚiterr#   Úbase_vectorsÚbase_scalarsr   Údotr   r   r   r   ÚZero)ÚfieldÚdirection_vectorr7   Ú	coord_sysÚiÚjr2   r)   ÚyÚzÚouts              r5   Údirectional_derivativerH   ~   sú   € õ: :Ù" 5Ó)€IÜ
ˆ9ƒ~˜Òäœ˜i›Ó)ˆ	Ü˜˜y°DÔ9ˆØ×(Ñ(Ó*‰ˆˆ1ˆaØ×(Ñ(Ó*‰ˆˆ1ˆaÜ�j‰jÐ)¨1Ó-´°U¸A³Ñ>ˆØŒv�z‰zÐ*¨AÓ.´°e¸Q³Ñ?Ñ?ˆØŒv�z‰zÐ*¨AÓ.´°e¸Q³Ñ?Ñ?ˆØ�!Š8œ
 5¬&Ô1Ü—+‘+ˆCØˆ
Ü	�Eœ6Ô	"Ü�{‰{Ðä�v‰vˆó    c                 óæ   — t        «       }| j                  r7t        t        | «      «      t	        t	        | «      «      z
  j                  «       S |j                   || «      «      j                  «       S )a!  
    Return the laplacian of the given field computed in terms of
    the base scalars of the given coordinate system.

    Parameters
    ==========

    expr : SymPy Expr or Vector
        expr denotes a scalar or vector field.

    Examples
    ========

    >>> from sympy.vector import CoordSys3D, laplacian
    >>> R = CoordSys3D('R')
    >>> f = R.x**2*R.y**5*R.z
    >>> laplacian(f)
    20*R.x**2*R.y**3*R.z + 2*R.y**5*R.z
    >>> f = R.x**2*R.i + R.y**3*R.j + R.z**4*R.k
    >>> laplacian(f)
    2*R.i + 6*R.y*R.j + 12*R.z**2*R.k

    )r   Ú	is_Vectorr   r
   r	   Údoitr>   )r'   Údelops     r5   Ú	laplacianrN   ¯   sU   € ô2 ‹E€EØ‡~‚~Üœ DÓ)Ó*¬T´$°t³*Ó-=Ñ=×CÑCÓEÐEØ�9‰9‘U˜4“[Ó!×&Ñ&Ó(Ð(rI   c                 ó´   — t        | t        «      st        d«      ‚| t        j                  k(  ryt	        | «      j                  «       t        j                  k(  S )aŸ  
    Checks if a field is conservative.

    Parameters
    ==========

    field : Vector
        The field to check for conservative property

    Examples
    ========

    >>> from sympy.vector import CoordSys3D
    >>> from sympy.vector import is_conservative
    >>> R = CoordSys3D('R')
    >>> is_conservative(R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k)
    True
    >>> is_conservative(R.z*R.j)
    False

    úfield should be a VectorT)r   r   r   r   r	   Úsimplify©r@   s    r5   Úis_conservativerS   Î   sE   € ô4 �eœVÔ$ÜÐ2Ó3Ð3Ø”—‘ÒØÜ�‹;×ÑÓ!¤V§[¡[Ñ0Ð0rI   c                 ó²   — t        | t        «      st        d«      ‚| t        j                  k(  ryt	        | «      j                  «       t        j                  u S )a—  
    Checks if a field is solenoidal.

    Parameters
    ==========

    field : Vector
        The field to check for solenoidal property

    Examples
    ========

    >>> from sympy.vector import CoordSys3D
    >>> from sympy.vector import is_solenoidal
    >>> R = CoordSys3D('R')
    >>> is_solenoidal(R.y*R.z*R.i + R.x*R.z*R.j + R.x*R.y*R.k)
    True
    >>> is_solenoidal(R.y * R.j)
    False

    rP   T)r   r   r   r   r
   rQ   r   r?   rR   s    r5   Úis_solenoidalrU   ï   sF   € ô4 �eœVÔ$ÜÐ2Ó3Ð3Ø”—‘ÒØÜ�eÓ×%Ñ%Ó'¬1¯6©6Ð1Ð1rI   c                 óî  — t        | «      st        d«      ‚| t        j                  k(  rt        j
                  S t        |t        «      st        d«      ‚t        | |d¬«      } |j                  «       }|j                  «       }t        | j                  |d   «      |d   «      }t        |dd «      D ]@  \  }}t        |||dz      «      }| j                  |«      |z
  }|t        |||dz      «      z  }ŒB |S )aÃ  
    Returns the scalar potential function of a field in a given
    coordinate system (without the added integration constant).

    Parameters
    ==========

    field : Vector
        The vector field whose scalar potential function is to be
        calculated

    coord_sys : CoordSys3D
        The coordinate system to do the calculation in

    Examples
    ========

    >>> from sympy.vector import CoordSys3D
    >>> from sympy.vector import scalar_potential, gradient
    >>> R = CoordSys3D('R')
    >>> scalar_potential(R.k, R) == R.z
    True
    >>> scalar_field = 2*R.x**2*R.y*R.z
    >>> grad_field = gradient(scalar_field)
    >>> scalar_potential(grad_field, R)
    2*R.x**2*R.y*R.z

    zField is not conservativeúcoord_sys must be a CoordSys3DTr   r   r   N)rS   r   r   r   r   r?   r   r   r   r#   r<   r=   r   r>   Ú	enumerater   )r@   rB   Ú
dimensionsÚscalarsÚtemp_functionrC   ÚdimÚpartial_diffs           r5   Úscalar_potentialr^     só   € ô> ˜5Ô!ÜÐ4Ó5Ð5Ø”—‘ÒÜ�v‰vˆô �i¤Ô,ÜÐ8Ó9Ð9Ü�E˜9°Ô5€EØ×'Ñ'Ó)€JØ×$Ñ$Ó&€Gä˜eŸi™i¨
°1©Ó6¸À¹
ÓC€MÜ˜J q r˜NÓ+ò A‰ˆˆ3Ü˜M¨7°1°q±5©>Ó:ˆØ—y‘y “~¨Ñ4ˆØœ <°¸¸Q¹±Ó@Ñ@‰ðAð ÐrI   c                 ó  — t        |t        «      st        d«      ‚t        | t        «      rt	        | |«      }n| }|j
                  }t        |j                  |«      |d¬«      }t        |j                  |«      |d¬«      }i }i }	|j                  «       }
t        |j                  «       «      D ]3  \  }}|j                  |«      ||
|   <   |j                  |«      |	|
|   <   Œ5 |j                  |	«      |j                  |«      z
  S )a)  
    Returns the scalar potential difference between two points in a
    certain coordinate system, wrt a given field.

    If a scalar field is provided, its values at the two points are
    considered. If a conservative vector field is provided, the values
    of its scalar potential function at the two points are used.

    Returns (potential at point2) - (potential at point1)

    The position vectors of the two Points are calculated wrt the
    origin of the coordinate system provided.

    Parameters
    ==========

    field : Vector/Expr
        The field to calculate wrt

    coord_sys : CoordSys3D
        The coordinate system to do the calculations in

    point1 : Point
        The initial Point in given coordinate system

    position2 : Point
        The second Point in the given coordinate system

    Examples
    ========

    >>> from sympy.vector import CoordSys3D
    >>> from sympy.vector import scalar_potential_difference
    >>> R = CoordSys3D('R')
    >>> P = R.origin.locate_new('P', R.x*R.i + R.y*R.j + R.z*R.k)
    >>> vectfield = 4*R.x*R.y*R.i + 2*R.x**2*R.j
    >>> scalar_potential_difference(vectfield, R, R.origin, P)
    2*R.x**2*R.y
    >>> Q = R.origin.locate_new('O', 3*R.i + R.j + 2*R.k)
    >>> scalar_potential_difference(vectfield, R, P, Q)
    -2*R.x**2*R.y + 18

    rW   Tr   )r   r   r   r   r^   Úoriginr#   Úposition_wrtr=   rX   r<   r>   r   )r@   rB   Úpoint1Úpoint2Ú	scalar_fnr`   Ú	position1Ú	position2Ú
subs_dict1Ú
subs_dict2rZ   rC   r)   s                r5   Úscalar_potential_differenceri   C  s  € ôZ �i¤Ô,ÜÐ8Ó9Ð9Ü�%œÔ ä$ U¨IÓ6‰	ð ˆ	à×Ñ€FÜ˜×+Ñ+¨FÓ3°YØ"&ô(€Iä˜×+Ñ+¨FÓ3°YØ"&ô(€Ið €JØ€JØ×$Ñ$Ó&€GÜ˜)×0Ñ0Ó2Ó3ò 2‰ˆˆ1Ø!"§¡ yÓ!1ˆ
�7˜1‘:ÑØ!"§¡ yÓ!1ˆ
�7˜1‘:Òð2ð �>‰>˜*Ó%¨	¯©°zÓ(BÑBÐBrI   c                 ó‚   — t         j                  }|j                  «       }t        | «      D ]  \  }}||||   z  z  }Œ |S )aà  
    Converts a vector in matrix form to a Vector instance.

    It is assumed that the elements of the Matrix represent the
    measure numbers of the components of the vector along basis
    vectors of 'system'.

    Parameters
    ==========

    matrix : SymPy Matrix, Dimensions: (3, 1)
        The matrix to be converted to a vector

    system : CoordSys3D
        The coordinate system the vector is to be defined in

    Examples
    ========

    >>> from sympy import ImmutableMatrix as Matrix
    >>> m = Matrix([1, 2, 3])
    >>> from sympy.vector import CoordSys3D, matrix_to_vector
    >>> C = CoordSys3D('C')
    >>> v = matrix_to_vector(m, C)
    >>> v
    C.i + 2*C.j + 3*C.k
    >>> v.to_matrix(C) == m
    True

    )r   r   r<   rX   )Úmatrixr   r-   ÚvectsrC   r)   s         r5   r    r    ˆ  sK   € ô@ �[‰[€FØ×ÑÓ!€EÜ˜&Ó!ò ‰ˆˆ1Ø�!�e˜A‘h‘,Ñ‰ðà€MrI   c                 óê  — | j                   |j                   k7  r&t        dt        | «      z   dz   t        |«      z   «      ‚g }|}|j                  �*|j	                  |«       |j                  }|j                  �Œ*|j	                  |«       t        |«      }g }| }||vr"|j	                  |«       |j                  }||vrŒ"t        |«      }|j                  ||j                  |«      dd…   «       ||fS )z¿
    Calculates the 'path' of objects starting from 'from_object'
    to 'to_object', along with the index of the first common
    ancestor in the tree.

    Returns (index, list) tuple.
    z!No connecting path found between z and Néÿÿÿÿ)	Ú_rootr   ÚstrÚ_parentÚappendr%   r9   ÚextendÚindex)Úfrom_objectÚ	to_objectÚ
other_pathÚobjÚ
object_setÚ	from_pathrt   s          r5   Ú_pathr{   ¯  s  € ð ×Ñ˜IŸO™OÒ+ÜÐ<Ü˜[Ó)ñ*Ø,3ñ4Ü69¸)³nñEó Fð 	Fð €JØ
€CØ
�+‰+Ð
!Ø×Ñ˜#ÔØ�k‰kˆð �+‰+Ñ
!ð ×Ñ�cÔÜ�Z“€JØ€IØ
€CØ
�ZÑ
Ø×Ñ˜ÔØ�k‰kˆð �ZÒ
ô �	‹N€EØ×Ñ�Z 
× 0Ñ 0°Ó 5Ð 9°rÐ 9Ñ:Ô;Ø�)ÐÐrI   )Úorthonormalc                 ó|  — t        d„ |D «       «      st        d«      ‚g }t        |«      D ]j  \  }}t        |«      D ]  }|||   j	                  ||   «      z  }Œ |j                  t        j                  «      rt        d«      ‚|j                  |«       Œl | r|D �cg c]  }|j                  «       ‘Œ }}|S c c}w )aO  
    Takes a sequence of independent vectors and orthogonalizes them
    using the Gram - Schmidt process. Returns a list of
    orthogonal or orthonormal vectors.

    Parameters
    ==========

    vlist : sequence of independent vectors to be made orthogonal.

    orthonormal : Optional parameter
                  Set to True if the vectors returned should be
                  orthonormal.
                  Default: False

    Examples
    ========

    >>> from sympy.vector.coordsysrect import CoordSys3D
    >>> from sympy.vector.functions import orthogonalize
    >>> C = CoordSys3D('C')
    >>> i, j, k = C.base_vectors()
    >>> v1 = i + 2*j
    >>> v2 = 2*i + 3*j
    >>> orthogonalize(v1, v2)
    [C.i + 2*C.j, 2/5*C.i + (-1/5)*C.j]

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Gram-Schmidt_process

    c              3   ó<   K  — | ]  }t        |t        «      –— Œ y ­w)N)r   r   )Ú.0Úvecs     r5   ú	<genexpr>z orthogonalize.<locals>.<genexpr>ð  s   è ø€ Ò8¨3Œz˜#œv×&Ñ8ùs   ‚z#Each element must be of Type Vectorz#Vector set not linearly independent)Úallr   rX   ÚrangeÚ
projectionÚequalsr   r   r   rr   Ú	normalize)r|   ÚvlistÚortho_vlistrC   ÚtermrD   r€   s          r5   ÚorthogonalizerŠ   Í  sÁ   € ôF Ñ8°%Ô8Ô8ÜÐ=Ó>Ð>à€KÜ˜UÓ#ò !‰ˆˆ4Ü�q“ò 	8ˆAØ�K ‘N×-Ñ-¨e°A©hÓ7Ñ7‰Dð	8ð
 �;‰;”v—{‘{Ô#ÜÐBÓCÐCØ×Ñ˜4Õ ð!ñ Ø2=Ö>¨3�s—}‘}•Ð>ˆÐ>àÐùò ?s   ÂB9)NF)!Úsympy.vector.coordsysrectr   Úsympy.vector.deloperatorr   Úsympy.vector.scalarr   Úsympy.vector.vectorr   r   r8   r   r	   r
   Úsympy.core.functionr   Úsympy.core.singletonr   Úsympy.integrals.integralsr   Ú
sympy.corer   Úsympy.vector.dyadicr   r#   rH   rN   rS   rU   r^   ri   r    r{   rŠ   © rI   r5   ú<module>r•      sg   ðÝ 0Ý (Ý *ß 2ß =Ñ =Ý $Ý "Ý /Ý Ý &ónòb.òb)ò>1òB2òB0òfBCòJ$òNð< ',õ 4rI   