def scalar_potential(field, frame):
 if (not is_conservative(field)):
  raise ValueError('Field is not conservative')
 if (field == Vector(0)):
  return S(0)
 _check_frame(frame)
 field = express(field, frame, variables=True)
 dimensions = [x for x in frame]
 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 ) : if ( not is_conservative ( field ) ) : raise ValueError ( 'Field is not conservative' ) if ( field == Vector ( 0 ) ) : return S ( 0 ) _check_frame ( frame ) field = express ( field , frame , variables = True ) dimensions = [ x for x in frame ] 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
returns the scalar potential function of a field in a given coordinate system .