(expr, frame, order=1)
Calculate the time derivative of a vector/scalar field function
    or dyadic expression in given frame.

    References
    ==========

    http://en.wikipedia.org/wiki/Rotating_reference_frame#Time_derivatives_in_the_two_frames

    Parameters
    ==========

    expr : Vector/Dyadic/sympifyable
        The expression whose time derivative is to be calculated

    frame : ReferenceFrame
        The reference frame to calculate the time derivative in

    order : integer
        The order of the derivative to be calculated

    Examples
    ========

    >>> from sympy.physics.vector import ReferenceFrame, dynamicsymbols
    >>> from sympy import Symbol
    >>> q1 = Symbol('q1')
    >>> u1 = dynamicsymbols('u1')
    >>> N = ReferenceFrame('N')
    >>> A = N.orientnew('A', 'Axis', [q1, N.x])
    >>> v = u1 * N.x
    >>> A.set_ang_vel(N, 10*A.x)
    >>> from sympy.physics.vector import time_derivative
    >>> time_derivative(v, N)
    u1'*N.x
    >>> time_derivative(u1*A[0], N)
    N_x*Derivative(u1(t), t)
    >>> B = N.orientnew('B', 'Axis', [u1, N.z])
    >>> from sympy.physics.vector import outer
    >>> d = outer(N.x, N.x)
    >>> time_derivative(d, B)
    - u1'*(N.y|N.x) - u1'*(N.x|N.y)
Calculate the time derivative of a vector/scalar field function
    or dyadic expression in given frame.
Calculate the time derivative of a vector / scalar field function or dyadic expression in given frame .
def time_derivative(expr, frame, order=1):
    """
    Calculate the time derivative of a vector/scalar field function
    or dyadic expression in given frame.

    References
    ==========

    http://en.wikipedia.org/wiki/Rotating_reference_frame#Time_derivatives_in_the_two_frames

    Parameters
    ==========

    expr : Vector/Dyadic/sympifyable
        The expression whose time derivative is to be calculated

    frame : ReferenceFrame
        The reference frame to calculate the time derivative in

    order : integer
        The order of the derivative to be calculated

    Examples
    ========

    >>> from sympy.physics.vector import ReferenceFrame, dynamicsymbols
    >>> from sympy import Symbol
    >>> q1 = Symbol('q1')
    >>> u1 = dynamicsymbols('u1')
    >>> N = ReferenceFrame('N')
    >>> A = N.orientnew('A', 'Axis', [q1, N.x])
    >>> v = u1 * N.x
    >>> A.set_ang_vel(N, 10*A.x)
    >>> from sympy.physics.vector import time_derivative
    >>> time_derivative(v, N)
    u1'*N.x
    >>> time_derivative(u1*A[0], N)
    N_x*Derivative(u1(t), t)
    >>> B = N.orientnew('B', 'Axis', [u1, N.z])
    >>> from sympy.physics.vector import outer
    >>> d = outer(N.x, N.x)
    >>> time_derivative(d, B)
    - u1'*(N.y|N.x) - u1'*(N.x|N.y)

    """

    t = dynamicsymbols._t
    _check_frame(frame)

    if order == 0:
        return expr
    if order % 1 != 0 or order < 0:
        raise ValueError("Unsupported value of order entered")

    if isinstance(expr, Vector):
        outvec = Vector(0)
        for i, v in enumerate(expr.args):
            if v[1] == frame:
                outvec += Vector([(express(v[0], frame,
                                           variables=True).diff(t), frame)])
            else:
                outvec += time_derivative(Vector([v]), v[1]) + \
                    (v[1].ang_vel_in(frame) ^ Vector([v]))
        return time_derivative(outvec, frame, order - 1)

    if isinstance(expr, Dyadic):
        ol = Dyadic(0)
        for i, v in enumerate(expr.args):
            ol += (v[0].diff(t) * (v[1] | v[2]))
            ol += (v[0] * (time_derivative(v[1], frame) | v[2]))
            ol += (v[0] * (v[1] | time_derivative(v[2], frame)))
        return time_derivative(ol, frame, order - 1)

    else:
        return diff(express(expr, frame, variables=True), t, order)
def time_derivative ( expr , frame , order = 1 ) : t = dynamicsymbols . _t _check_frame ( frame ) if order == 0 : return expr if order % 1 != 0 or order < 0 : raise ValueError ( "Unsupported value of order entered" ) if isinstance ( expr , Vector ) : outvec = Vector ( 0 ) for i , v in enumerate ( expr . args ) : if v [ 1 ] == frame : outvec += Vector ( [ ( express ( v [ 0 ] , frame , variables = True ) . diff ( t ) , frame ) ] ) else : outvec += time_derivative ( Vector ( [ v ] ) , v [ 1 ] ) + ( v [ 1 ] . ang_vel_in ( frame ) ^ Vector ( [ v ] ) ) return time_derivative ( outvec , frame , order - 1 ) if isinstance ( expr , Dyadic ) : ol = Dyadic ( 0 ) for i , v in enumerate ( expr . args ) : ol += ( v [ 0 ] . diff ( t ) * ( v [ 1 ] | v [ 2 ] ) ) ol += ( v [ 0 ] * ( time_derivative ( v [ 1 ] , frame ) | v [ 2 ] ) ) ol += ( v [ 0 ] * ( v [ 1 ] | time_derivative ( v [ 2 ] , frame ) ) ) return time_derivative ( ol , frame , order - 1 ) else : return diff ( express ( expr , frame , variables = True ) , t , order )