(field, frame)
return temp_function
Returns the scalar potential function of a field in a given frame
    (without the added integration constant).

    Parameters
    ==========

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

    frame : ReferenceFrame
        The frame to do the calculation in

    Examples
    ========

    >>> from sympy.physics.vector import ReferenceFrame
    >>> from sympy.physics.vector import scalar_potential, gradient
    >>> R = ReferenceFrame('R')
    >>> scalar_potential(R.z, R) == R[2]
    True
    >>> scalar_field = 2*R[0]**2*R[1]*R[2]
    >>> grad_field = gradient(scalar_field, R)
    >>> scalar_potential(grad_field, R)
    2*R_x**2*R_y*R_z
Returns the scalar potential function of a field in a given frame
    (without the added integration constant).
Returns the scalar potential function of a field in a given frame ( without the added integration constant ) .
def scalar_potential(field, frame):
    """
    Returns the scalar potential function of a field in a given frame
    (without the added integration constant).

    Parameters
    ==========

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

    frame : ReferenceFrame
        The frame to do the calculation in

    Examples
    ========

    >>> from sympy.physics.vector import ReferenceFrame
    >>> from sympy.physics.vector import scalar_potential, gradient
    >>> R = ReferenceFrame('R')
    >>> scalar_potential(R.z, R) == R[2]
    True
    >>> scalar_field = 2*R[0]**2*R[1]*R[2]
    >>> grad_field = gradient(scalar_field, R)
    >>> scalar_potential(grad_field, R)
    2*R_x**2*R_y*R_z

    """

    #Check whether field is conservative
    if not is_conservative(field):
        raise ValueError("Field is not conservative")
    if field == Vector(0):
        return S(0)
    #Express the field exntirely in frame
    #Subsitute coordinate variables also
    _check_frame(frame)
    field = express(field, frame, variables=True)
    #Make a list of dimensions of the frame
    dimensions = [x for x in frame]
    #Calculate scalar potential function
    temp_function = integrate(field.dot(dimensions[0]), frame[0])
    for i, dim in enumerate(dimensions[1:]):
        partial_diff = diff(temp_function, frame[i + 1])
        partial_diff = field.dot(dim) - partial_diff
        temp_function += integrate(partial_diff, frame[i + 1])
    return temp_function
def scalar_potential ( field , frame ) : #Check whether field is conservative if not is_conservative ( field ) : raise ValueError ( "Field is not conservative" ) if field == Vector ( 0 ) : return S ( 0 ) #Express the field exntirely in frame #Subsitute coordinate variables also _check_frame ( frame ) field = express ( field , frame , variables = True ) #Make a list of dimensions of the frame dimensions = [ x for x in frame ] #Calculate scalar potential function temp_function = integrate ( field . dot ( dimensions [ 0 ] ) , frame [ 0 ] ) for i , dim in enumerate ( dimensions [ 1 : ] ) : partial_diff = diff ( temp_function , frame [ i + 1 ] ) partial_diff = field . dot ( dim ) - partial_diff temp_function += integrate ( partial_diff , frame [ i + 1 ] ) return temp_function