Essential Functions (Docstrings)

dynamicsymbols

sympy.physics.vector.dynamicsymbols(names, level=0)[source]

Uses symbols and Function for functions of time.

Creates a SymPy UndefinedFunction, which is then initialized as a function of a variable, the default being Symbol(‘t’).

Parameters

names : str

Names of the dynamic symbols you want to create; works the same way as inputs to symbols

level : int

Level of differentiation of the returned function; d/dt once of t, twice of t, etc.

Examples

>>> from sympy.physics.vector import dynamicsymbols
>>> from sympy import diff, Symbol
>>> q1 = dynamicsymbols('q1')
>>> q1
q1(t)
>>> diff(q1, Symbol('t'))
Derivative(q1(t), t)

dot

sympy.physics.vector.functions.dot(vec1, vec2)[source]

Dot product convenience wrapper for Vector.dot(): Dot product of two vectors.

Returns a scalar, the dot product of the two Vectors

Parameters

other : Vector

The Vector which we are dotting with

Examples

>>> from sympy.physics.vector import ReferenceFrame, dot
>>> from sympy import symbols
>>> q1 = symbols('q1')
>>> N = ReferenceFrame('N')
>>> dot(N.x, N.x)
1
>>> dot(N.x, N.y)
0
>>> A = N.orientnew('A', 'Axis', [q1, N.x])
>>> dot(N.y, A.y)
cos(q1)

cross

sympy.physics.vector.functions.cross(vec1, vec2)[source]

Cross product convenience wrapper for Vector.cross(): The cross product operator for two Vectors.

Returns a Vector, expressed in the same ReferenceFrames as self.

Parameters

other : Vector

The Vector which we are crossing with

Examples

>>> from sympy.physics.vector import ReferenceFrame, Vector
>>> from sympy import symbols
>>> q1 = symbols('q1')
>>> N = ReferenceFrame('N')
>>> N.x ^ N.y
N.z
>>> A = N.orientnew('A', 'Axis', [q1, N.x])
>>> A.x ^ N.y
N.z
>>> N.y ^ A.x
- sin(q1)*A.y - cos(q1)*A.z

outer

sympy.physics.vector.functions.outer(vec1, vec2)[source]

Outer product convenience wrapper for Vector.outer(): Outer product between two Vectors.

A rank increasing operation, which returns a Dyadic from two Vectors

Parameters

other : Vector

The Vector to take the outer product with

Examples

>>> from sympy.physics.vector import ReferenceFrame, outer
>>> N = ReferenceFrame('N')
>>> outer(N.x, N.x)
(N.x|N.x)

express

sympy.physics.vector.functions.express(expr, frame, frame2=None, variables=False)[source]

Global function for ‘express’ functionality.

Re-expresses a Vector, scalar(sympyfiable) or Dyadic in given frame.

Refer to the local methods of Vector and Dyadic for details. If ‘variables’ is True, then the coordinate variables (CoordinateSym instances) of other frames present in the vector/scalar field or dyadic expression are also substituted in terms of the base scalars of this frame.

Parameters

expr : Vector/Dyadic/scalar(sympyfiable)

The expression to re-express in ReferenceFrame ‘frame’

frame: ReferenceFrame

The reference frame to express expr in

frame2 : ReferenceFrame

The other frame required for re-expression(only for Dyadic expr)

variables : boolean

Specifies whether to substitute the coordinate variables present in expr, in terms of those of frame

Examples

>>> from sympy.physics.vector import ReferenceFrame, outer, dynamicsymbols
>>> N = ReferenceFrame('N')
>>> q = dynamicsymbols('q')
>>> B = N.orientnew('B', 'Axis', [q, N.z])
>>> d = outer(N.x, N.x)
>>> from sympy.physics.vector import express
>>> express(d, B, N)
cos(q)*(B.x|N.x) - sin(q)*(B.y|N.x)
>>> express(B.x, N)
cos(q)*N.x + sin(q)*N.y
>>> express(N[0], B, variables=True)
B_x*cos(q(t)) - B_y*sin(q(t))

time_derivative

sympy.physics.vector.functions.time_derivative(expr, frame, order=1)[source]

Calculate the time derivative of a vector/scalar field function or dyadic expression in given frame.

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

References

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

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)