Essential Classes in sympy.vector (docstrings)¶
- class sympy.vector.coordsysrect.CoordSys3D(
- name,
- transformation=None,
- parent=None,
- location=None,
- rotation_matrix=None,
- vector_names=None,
- variable_names=None,
Represents a coordinate system in 3-D space.
- __init__(
- name,
- location=None,
- rotation_matrix=None,
- parent=None,
- vector_names=None,
- variable_names=None,
- latex_vects=None,
- pretty_vects=None,
- latex_scalars=None,
- pretty_scalars=None,
- transformation=None,
The orientation/location parameters are necessary if this system is being defined at a certain orientation or location wrt another.
- Parameters:
name : str
The name of the new CoordSys3D instance.
transformation : Lambda, Tuple, str
Transformation defined by transformation equations or chosen from predefined ones.
location : Vector
The position vector of the new system’s origin wrt the parent instance.
rotation_matrix : SymPy ImmutableMatrix
The rotation matrix of the new coordinate system with respect to the parent. In other words, the output of new_system.rotation_matrix(parent).
parent : CoordSys3D
The coordinate system wrt which the orientation/location (or both) is being defined.
vector_names, variable_names : iterable(optional)
Iterables of 3 strings each, with custom names for base vectors and base scalars of the new system respectively. Used for simple str printing.
- create_new(
- name,
- transformation,
- variable_names=None,
- vector_names=None,
Returns a CoordSys3D which is connected to self by transformation.
- Parameters:
name : str
The name of the new CoordSys3D instance.
transformation : Lambda, Tuple, str
Transformation defined by transformation equations or chosen from predefined ones.
vector_names, variable_names : iterable(optional)
Iterables of 3 strings each, with custom names for base vectors and base scalars of the new system respectively. Used for simple str printing.
Examples
>>> from sympy.vector import CoordSys3D >>> a = CoordSys3D('a') >>> b = a.create_new('b', transformation='spherical') >>> b.transformation_to_parent() (b.r*sin(b.theta)*cos(b.phi), b.r*sin(b.phi)*sin(b.theta), b.r*cos(b.theta)) >>> b.transformation_from_parent() (sqrt(a.x**2 + a.y**2 + a.z**2), acos(a.z/sqrt(a.x**2 + a.y**2 + a.z**2)), atan2(a.y, a.x))
- locate_new(
- name,
- position,
- vector_names=None,
- variable_names=None,
Returns a CoordSys3D with its origin located at the given position wrt this coordinate system’s origin.
- Parameters:
name : str
The name of the new CoordSys3D instance.
position : Vector
The position vector of the new system’s origin wrt this one.
vector_names, variable_names : iterable(optional)
Iterables of 3 strings each, with custom names for base vectors and base scalars of the new system respectively. Used for simple str printing.
Examples
>>> from sympy.vector import CoordSys3D >>> A = CoordSys3D('A') >>> B = A.locate_new('B', 10 * A.i) >>> B.origin.position_wrt(A.origin) 10*A.i
- orient_new(
- name,
- orienters,
- location=None,
- vector_names=None,
- variable_names=None,
Creates a new CoordSys3D oriented in the user-specified way with respect to this system.
Please refer to the documentation of the orienter classes for more information about the orientation procedure.
- Parameters:
name : str
The name of the new CoordSys3D instance.
orienters : iterable/Orienter
An Orienter or an iterable of Orienters for orienting the new coordinate system. If an Orienter is provided, it is applied to get the new system. If an iterable is provided, the orienters will be applied in the order in which they appear in the iterable.
location : Vector(optional)
The location of the new coordinate system’s origin wrt this system’s origin. If not specified, the origins are taken to be coincident.
vector_names, variable_names : iterable(optional)
Iterables of 3 strings each, with custom names for base vectors and base scalars of the new system respectively. Used for simple str printing.
Examples
>>> from sympy.vector import CoordSys3D >>> from sympy import symbols >>> q0, q1, q2, q3 = symbols('q0 q1 q2 q3') >>> N = CoordSys3D('N')
Using an AxisOrienter
>>> from sympy.vector import AxisOrienter >>> axis_orienter = AxisOrienter(q1, N.i + 2 * N.j) >>> A = N.orient_new('A', (axis_orienter, ))
Using a BodyOrienter
>>> from sympy.vector import BodyOrienter >>> body_orienter = BodyOrienter(q1, q2, q3, '123') >>> B = N.orient_new('B', (body_orienter, ))
Using a SpaceOrienter
>>> from sympy.vector import SpaceOrienter >>> space_orienter = SpaceOrienter(q1, q2, q3, '312') >>> C = N.orient_new('C', (space_orienter, ))
Using a QuaternionOrienter
>>> from sympy.vector import QuaternionOrienter >>> q_orienter = QuaternionOrienter(q0, q1, q2, q3) >>> D = N.orient_new('D', (q_orienter, ))
- orient_new_axis(
- name,
- angle,
- axis,
- location=None,
- vector_names=None,
- variable_names=None,
Axis rotation is a rotation about an arbitrary axis by some angle. The angle is supplied as a SymPy expr scalar, and the axis is supplied as a Vector.
- Parameters:
name : string
The name of the new coordinate system
angle : Expr
The angle by which the new system is to be rotated
axis : Vector
The axis around which the rotation has to be performed
location : Vector(optional)
The location of the new coordinate system’s origin wrt this system’s origin. If not specified, the origins are taken to be coincident.
vector_names, variable_names : iterable(optional)
Iterables of 3 strings each, with custom names for base vectors and base scalars of the new system respectively. Used for simple str printing.
Examples
>>> from sympy.vector import CoordSys3D >>> from sympy import symbols >>> q1 = symbols('q1') >>> N = CoordSys3D('N') >>> B = N.orient_new_axis('B', q1, N.i + 2 * N.j)
- orient_new_body(
- name,
- angle1,
- angle2,
- angle3,
- rotation_order,
- location=None,
- vector_names=None,
- variable_names=None,
Body orientation takes this coordinate system through three successive simple rotations.
Body fixed rotations include both Euler Angles and Tait-Bryan Angles, see https://en.wikipedia.org/wiki/Euler_angles.
- Parameters:
name : string
The name of the new coordinate system
angle1, angle2, angle3 : Expr
Three successive angles to rotate the coordinate system by
rotation_order : string
String defining the order of axes for rotation
location : Vector(optional)
The location of the new coordinate system’s origin wrt this system’s origin. If not specified, the origins are taken to be coincident.
vector_names, variable_names : iterable(optional)
Iterables of 3 strings each, with custom names for base vectors and base scalars of the new system respectively. Used for simple str printing.
Examples
>>> from sympy.vector import CoordSys3D >>> from sympy import symbols >>> q1, q2, q3 = symbols('q1 q2 q3') >>> N = CoordSys3D('N')
A ‘Body’ fixed rotation is described by three angles and three body-fixed rotation axes. To orient a coordinate system D with respect to N, each sequential rotation is always about the orthogonal unit vectors fixed to D. For example, a ‘123’ rotation will specify rotations about N.i, then D.j, then D.k. (Initially, D.i is same as N.i) Therefore,
>>> D = N.orient_new_body('D', q1, q2, q3, '123')
is same as
>>> D = N.orient_new_axis('D', q1, N.i) >>> D = D.orient_new_axis('D', q2, D.j) >>> D = D.orient_new_axis('D', q3, D.k)
Acceptable rotation orders are of length 3, expressed in XYZ or 123, and cannot have a rotation about about an axis twice in a row.
>>> B = N.orient_new_body('B', q1, q2, q3, '123') >>> B = N.orient_new_body('B', q1, q2, 0, 'ZXZ') >>> B = N.orient_new_body('B', 0, 0, 0, 'XYX')
- orient_new_quaternion(
- name,
- q0,
- q1,
- q2,
- q3,
- location=None,
- vector_names=None,
- variable_names=None,
Quaternion orientation orients the new CoordSys3D with Quaternions, defined as a finite rotation about lambda, a unit vector, by some amount theta.
This orientation is described by four parameters:
q0 = cos(theta/2)
q1 = lambda_x sin(theta/2)
q2 = lambda_y sin(theta/2)
q3 = lambda_z sin(theta/2)
Quaternion does not take in a rotation order.
- Parameters:
name : string
The name of the new coordinate system
q0, q1, q2, q3 : Expr
The quaternions to rotate the coordinate system by
location : Vector(optional)
The location of the new coordinate system’s origin wrt this system’s origin. If not specified, the origins are taken to be coincident.
vector_names, variable_names : iterable(optional)
Iterables of 3 strings each, with custom names for base vectors and base scalars of the new system respectively. Used for simple str printing.
Examples
>>> from sympy.vector import CoordSys3D >>> from sympy import symbols >>> q0, q1, q2, q3 = symbols('q0 q1 q2 q3') >>> N = CoordSys3D('N') >>> B = N.orient_new_quaternion('B', q0, q1, q2, q3)
- orient_new_space(
- name,
- angle1,
- angle2,
- angle3,
- rotation_order,
- location=None,
- vector_names=None,
- variable_names=None,
Space rotation is similar to Body rotation, but the rotations are applied in the opposite order.
- Parameters:
name : string
The name of the new coordinate system
angle1, angle2, angle3 : Expr
Three successive angles to rotate the coordinate system by
rotation_order : string
String defining the order of axes for rotation
location : Vector(optional)
The location of the new coordinate system’s origin wrt this system’s origin. If not specified, the origins are taken to be coincident.
vector_names, variable_names : iterable(optional)
Iterables of 3 strings each, with custom names for base vectors and base scalars of the new system respectively. Used for simple str printing.
Examples
>>> from sympy.vector import CoordSys3D >>> from sympy import symbols >>> q1, q2, q3 = symbols('q1 q2 q3') >>> N = CoordSys3D('N')
To orient a coordinate system D with respect to N, each sequential rotation is always about N’s orthogonal unit vectors. For example, a ‘123’ rotation will specify rotations about N.i, then N.j, then N.k. Therefore,
>>> D = N.orient_new_space('D', q1, q2, q3, '312')
is same as
>>> B = N.orient_new_axis('B', q1, N.i) >>> C = B.orient_new_axis('C', q2, N.j) >>> D = C.orient_new_axis('D', q3, N.k)
See also
CoordSys3D.orient_new_body
method to orient via Euler angles
- position_wrt(other)[source]¶
Returns the position vector of the origin of this coordinate system with respect to another Point/CoordSys3D.
- Parameters:
other : Point/CoordSys3D
If other is a Point, the position of this system’s origin wrt it is returned. If its an instance of CoordSyRect, the position wrt its origin is returned.
Examples
>>> from sympy.vector import CoordSys3D >>> N = CoordSys3D('N') >>> N1 = N.locate_new('N1', 10 * N.i) >>> N.position_wrt(N1) (-10)*N.i
- rotation_matrix(other)[source]¶
Returns the direction cosine matrix(DCM), also known as the ‘rotation matrix’ of this coordinate system with respect to another system.
If v_a is a vector defined in system ‘A’ (in matrix format) and v_b is the same vector defined in system ‘B’, then v_a = A.rotation_matrix(B) * v_b.
A SymPy Matrix is returned.
- Parameters:
other : CoordSys3D
The system which the DCM is generated to.
Examples
>>> from sympy.vector import CoordSys3D >>> from sympy import symbols >>> q1 = symbols('q1') >>> N = CoordSys3D('N') >>> A = N.orient_new_axis('A', q1, N.i) >>> N.rotation_matrix(A) Matrix([ [1, 0, 0], [0, cos(q1), -sin(q1)], [0, sin(q1), cos(q1)]])
- scalar_map(other)[source]¶
Returns a dictionary which expresses the coordinate variables (base scalars) of this frame in terms of the variables of otherframe.
- Parameters:
otherframe : CoordSys3D
The other system to map the variables to.
Examples
>>> from sympy.vector import CoordSys3D >>> from sympy import Symbol >>> A = CoordSys3D('A') >>> q = Symbol('q') >>> B = A.orient_new_axis('B', q, A.k) >>> A.scalar_map(B) {A.x: B.x*cos(q) - B.y*sin(q), A.y: B.x*sin(q) + B.y*cos(q), A.z: B.z}
- class sympy.vector.vector.Vector(*args)[source]¶
Super class for all Vector classes. Ideally, neither this class nor any of its subclasses should be instantiated by the user.
- property components¶
Returns the components of this vector in the form of a Python dictionary mapping BaseVector instances to the corresponding measure numbers.
Examples
>>> from sympy.vector import CoordSys3D >>> C = CoordSys3D('C') >>> v = 3*C.i + 4*C.j + 5*C.k >>> v.components {C.i: 3, C.j: 4, C.k: 5}
- cross(other)[source]¶
Returns the cross product of this Vector with another Vector or Dyadic instance. The cross product is a Vector, if ‘other’ is a Vector. If ‘other’ is a Dyadic, this returns a Dyadic instance.
- Parameters:
other: Vector/Dyadic
The Vector or Dyadic we are crossing with.
Examples
>>> from sympy.vector import CoordSys3D >>> C = CoordSys3D('C') >>> C.i.cross(C.j) C.k >>> C.i ^ C.i 0 >>> v = 3*C.i + 4*C.j + 5*C.k >>> v ^ C.i 5*C.j + (-4)*C.k >>> d = C.i.outer(C.i) >>> C.j.cross(d) (-1)*(C.k|C.i)
- dot(other)[source]¶
Returns the dot product of this Vector, either with another Vector, or a Dyadic, or a Del operator. If ‘other’ is a Vector, returns the dot product scalar (SymPy expression). If ‘other’ is a Dyadic, the dot product is returned as a Vector. If ‘other’ is an instance of Del, returns the directional derivative operator as a Python function. If this function is applied to a scalar expression, it returns the directional derivative of the scalar field wrt this Vector.
- Parameters:
other: Vector/Dyadic/Del
The Vector or Dyadic we are dotting with, or a Del operator .
Examples
>>> from sympy.vector import CoordSys3D, Del >>> C = CoordSys3D('C') >>> delop = Del() >>> C.i.dot(C.j) 0 >>> C.i & C.i 1 >>> v = 3*C.i + 4*C.j + 5*C.k >>> v.dot(C.k) 5 >>> (C.i & delop)(C.x*C.y*C.z) C.y*C.z >>> d = C.i.outer(C.i) >>> C.i.dot(d) C.i
- equals(other)[source]¶
Check if
self
andother
are identically equal vectors.- Parameters:
other: Vector
The other vector expression to compare with.
- Returns:
True
,False
orNone
. A return value ofTrue
indicatesthat the two vectors are identically equal. A return value of
False
indictes that they are not. In some cases it is not possible to
determine if the two vectors are identically equal and
None
isreturned.
Explanation
Checks if two vector expressions are equal for all possible values of the symbols present in the expressions.
Examples
>>> from sympy.vector import CoordSys3D >>> from sympy.abc import x, y >>> from sympy import pi >>> C = CoordSys3D('C')
Compare vectors that are equal or not:
>>> C.i.equals(C.j) False >>> C.i.equals(C.i) True
These two vectors are equal if \(x = y\) but are not identically equal as expressions since for some values of \(x\) and \(y\) they are unequal:
>>> v1 = x*C.i + C.j >>> v2 = y*C.i + C.j >>> v1.equals(v1) True >>> v1.equals(v2) False
Vectors from different coordinate systems can be compared:
>>> D = C.orient_new_axis('D', pi/2, C.i) >>> D.j.equals(C.j) False >>> D.j.equals(C.k) True
See also
- outer(other)[source]¶
Returns the outer product of this vector with another, in the form of a Dyadic instance.
- Parameters:
other : Vector
The Vector with respect to which the outer product is to be computed.
Examples
>>> from sympy.vector import CoordSys3D >>> N = CoordSys3D('N') >>> N.i.outer(N.j) (N.i|N.j)
- projection(other, scalar=False)[source]¶
Returns the vector or scalar projection of the ‘other’ on ‘self’.
Examples
>>> from sympy.vector.coordsysrect import CoordSys3D >>> C = CoordSys3D('C') >>> i, j, k = C.base_vectors() >>> v1 = i + j + k >>> v2 = 3*i + 4*j >>> v1.projection(v2) 7/3*C.i + 7/3*C.j + 7/3*C.k >>> v1.projection(v2, scalar=True) 7/3
- separate()[source]¶
The constituents of this vector in different coordinate systems, as per its definition.
Returns a dict mapping each CoordSys3D to the corresponding constituent Vector.
Examples
>>> from sympy.vector import CoordSys3D >>> R1 = CoordSys3D('R1') >>> R2 = CoordSys3D('R2') >>> v = R1.i + R2.i >>> v.separate() == {R1: R1.i, R2: R2.i} True
- to_matrix(system)[source]¶
Returns the matrix form of this vector with respect to the specified coordinate system.
- Parameters:
system : CoordSys3D
The system wrt which the matrix form is to be computed
Examples
>>> from sympy.vector import CoordSys3D >>> C = CoordSys3D('C') >>> from sympy.abc import a, b, c >>> v = a*C.i + b*C.j + c*C.k >>> v.to_matrix(C) Matrix([ [a], [b], [c]])
- class sympy.vector.dyadic.Dyadic(*args)[source]¶
Super class for all Dyadic-classes.
References
[R1083]Kane, T., Levinson, D. Dynamics Theory and Applications. 1985 McGraw-Hill
- property components¶
Returns the components of this dyadic in the form of a Python dictionary mapping BaseDyadic instances to the corresponding measure numbers.
- cross(other)[source]¶
Returns the cross product between this Dyadic, and a Vector, as a Vector instance.
- Parameters:
other : Vector
The Vector that we are crossing this Dyadic with
Examples
>>> from sympy.vector import CoordSys3D >>> N = CoordSys3D('N') >>> d = N.i.outer(N.i) >>> d.cross(N.j) (N.i|N.k)
- dot(other)[source]¶
Returns the dot product(also called inner product) of this Dyadic, with another Dyadic or Vector. If ‘other’ is a Dyadic, this returns a Dyadic. Else, it returns a Vector (unless an error is encountered).
- Parameters:
other : Dyadic/Vector
The other Dyadic or Vector to take the inner product with
Examples
>>> from sympy.vector import CoordSys3D >>> N = CoordSys3D('N') >>> D1 = N.i.outer(N.j) >>> D2 = N.j.outer(N.j) >>> D1.dot(D2) (N.i|N.j) >>> D1.dot(N.j) N.i
- to_matrix(system, second_system=None)[source]¶
Returns the matrix form of the dyadic with respect to one or two coordinate systems.
- Parameters:
system : CoordSys3D
The coordinate system that the rows and columns of the matrix correspond to. If a second system is provided, this only corresponds to the rows of the matrix.
second_system : CoordSys3D, optional, default=None
The coordinate system that the columns of the matrix correspond to.
Examples
>>> from sympy.vector import CoordSys3D >>> N = CoordSys3D('N') >>> v = N.i + 2*N.j >>> d = v.outer(N.i) >>> d.to_matrix(N) Matrix([ [1, 0, 0], [2, 0, 0], [0, 0, 0]]) >>> from sympy import Symbol >>> q = Symbol('q') >>> P = N.orient_new_axis('P', q, N.k) >>> d.to_matrix(N, P) Matrix([ [ cos(q), -sin(q), 0], [2*cos(q), -2*sin(q), 0], [ 0, 0, 0]])
- class sympy.vector.deloperator.Del[source]¶
Represents the vector differential operator, usually represented in mathematical expressions as the ‘nabla’ symbol.
- cross(vect, doit=False)[source]¶
Represents the cross product between this operator and a given vector - equal to the curl of the vector field.
- Parameters:
vect : Vector
The vector whose curl is to be calculated.
doit : bool
If True, the result is returned after calling .doit() on each component. Else, the returned expression contains Derivative instances
Examples
>>> from sympy.vector import CoordSys3D, Del >>> C = CoordSys3D('C') >>> delop = Del() >>> v = C.x*C.y*C.z * (C.i + C.j + C.k) >>> delop.cross(v, doit = True) (-C.x*C.y + C.x*C.z)*C.i + (C.x*C.y - C.y*C.z)*C.j + (-C.x*C.z + C.y*C.z)*C.k >>> (delop ^ C.i).doit() 0
- dot(vect, doit=False)[source]¶
Represents the dot product between this operator and a given vector - equal to the divergence of the vector field.
- Parameters:
vect : Vector
The vector whose divergence is to be calculated.
doit : bool
If True, the result is returned after calling .doit() on each component. Else, the returned expression contains Derivative instances
Examples
>>> from sympy.vector import CoordSys3D, Del >>> delop = Del() >>> C = CoordSys3D('C') >>> delop.dot(C.x*C.i) Derivative(C.x, C.x) >>> v = C.x*C.y*C.z * (C.i + C.j + C.k) >>> (delop & v).doit() C.x*C.y + C.x*C.z + C.y*C.z
- gradient(scalar_field, doit=False)[source]¶
Returns the gradient of the given scalar field, as a Vector instance.
- Parameters:
scalar_field : SymPy expression
The scalar field to calculate the gradient of.
doit : bool
If True, the result is returned after calling .doit() on each component. Else, the returned expression contains Derivative instances
Examples
>>> from sympy.vector import CoordSys3D, Del >>> C = CoordSys3D('C') >>> delop = Del() >>> delop.gradient(9) 0 >>> delop(C.x*C.y*C.z).doit() C.y*C.z*C.i + C.x*C.z*C.j + C.x*C.y*C.k
- class sympy.vector.parametricregion.ParametricRegion(definition, *bounds)[source]¶
Represents a parametric region in space.
- Parameters:
definition : tuple to define base scalars in terms of parameters.
bounds : Parameter or a tuple of length 3 to define parameter and corresponding lower and upper bound.
Examples
>>> from sympy import cos, sin, pi >>> from sympy.abc import r, theta, t, a, b, x, y >>> from sympy.vector import ParametricRegion
>>> ParametricRegion((t, t**2), (t, -1, 2)) ParametricRegion((t, t**2), (t, -1, 2)) >>> ParametricRegion((x, y), (x, 3, 4), (y, 5, 6)) ParametricRegion((x, y), (x, 3, 4), (y, 5, 6)) >>> ParametricRegion((r*cos(theta), r*sin(theta)), (r, -2, 2), (theta, 0, pi)) ParametricRegion((r*cos(theta), r*sin(theta)), (r, -2, 2), (theta, 0, pi)) >>> ParametricRegion((a*cos(t), b*sin(t)), t) ParametricRegion((a*cos(t), b*sin(t)), t)
>>> circle = ParametricRegion((r*cos(theta), r*sin(theta)), r, (theta, 0, pi)) >>> circle.parameters (r, theta) >>> circle.definition (r*cos(theta), r*sin(theta)) >>> circle.limits {theta: (0, pi)}
Dimension of a parametric region determines whether a region is a curve, surface or volume region. It does not represent its dimensions in space.
>>> circle.dimensions 1
- class sympy.vector.implicitregion.ImplicitRegion(variables, equation)[source]¶
Represents an implicit region in space.
- Parameters:
variables : tuple to map variables in implicit equation to base scalars.
equation : An expression or Eq denoting the implicit equation of the region.
Examples
>>> from sympy import Eq >>> from sympy.abc import x, y, z, t >>> from sympy.vector import ImplicitRegion
>>> ImplicitRegion((x, y), x**2 + y**2 - 4) ImplicitRegion((x, y), x**2 + y**2 - 4) >>> ImplicitRegion((x, y), Eq(y*x, 1)) ImplicitRegion((x, y), x*y - 1)
>>> parabola = ImplicitRegion((x, y), y**2 - 4*x) >>> parabola.degree 2 >>> parabola.equation -4*x + y**2 >>> parabola.rational_parametrization(t) (4/t**2, 4/t)
>>> r = ImplicitRegion((x, y, z), Eq(z, x**2 + y**2)) >>> r.variables (x, y, z) >>> r.singular_points() EmptySet >>> r.regular_point() (-10, -10, 200)
- multiplicity(point)[source]¶
Returns the multiplicity of a singular point on the region.
A singular point (x,y) of region is said to be of multiplicity m if all the partial derivatives off to order m - 1 vanish there.
Examples
>>> from sympy.abc import x, y, z >>> from sympy.vector import ImplicitRegion >>> I = ImplicitRegion((x, y, z), x**2 + y**3 - z**4) >>> I.singular_points() {(0, 0, 0)} >>> I.multiplicity((0, 0, 0)) 2
- rational_parametrization(
- parameters=('t', 's'),
- reg_point=None,
Returns the rational parametrization of implicit region.
Examples
>>> from sympy import Eq >>> from sympy.abc import x, y, z, s, t >>> from sympy.vector import ImplicitRegion
>>> parabola = ImplicitRegion((x, y), y**2 - 4*x) >>> parabola.rational_parametrization() (4/t**2, 4/t)
>>> circle = ImplicitRegion((x, y), Eq(x**2 + y**2, 4)) >>> circle.rational_parametrization() (4*t/(t**2 + 1), 4*t**2/(t**2 + 1) - 2)
>>> I = ImplicitRegion((x, y), x**3 + x**2 - y**2) >>> I.rational_parametrization() (t**2 - 1, t*(t**2 - 1))
>>> cubic_curve = ImplicitRegion((x, y), x**3 + x**2 - y**2) >>> cubic_curve.rational_parametrization(parameters=(t)) (t**2 - 1, t*(t**2 - 1))
>>> sphere = ImplicitRegion((x, y, z), x**2 + y**2 + z**2 - 4) >>> sphere.rational_parametrization(parameters=(t, s)) (-2 + 4/(s**2 + t**2 + 1), 4*s/(s**2 + t**2 + 1), 4*t/(s**2 + t**2 + 1))
For some conics, regular_points() is unable to find a point on curve. To calulcate the parametric representation in such cases, user need to determine a point on the region and pass it using reg_point.
>>> c = ImplicitRegion((x, y), (x - 1/2)**2 + (y)**2 - (1/4)**2) >>> c.rational_parametrization(reg_point=(3/4, 0)) (0.75 - 0.5/(t**2 + 1), -0.5*t/(t**2 + 1))
References
Christoph M. Hoffmann, “Conversion Methods between Parametric and Implicit Curves and Surfaces”, Purdue e-Pubs, 1990. Available: https://docs.lib.purdue.edu/cgi/viewcontent.cgi?article=1827&context=cstech
- regular_point()[source]¶
Returns a point on the implicit region.
Examples
>>> from sympy.abc import x, y, z >>> from sympy.vector import ImplicitRegion >>> circle = ImplicitRegion((x, y), (x + 2)**2 + (y - 3)**2 - 16) >>> circle.regular_point() (-2, -1) >>> parabola = ImplicitRegion((x, y), x**2 - 4*y) >>> parabola.regular_point() (0, 0) >>> r = ImplicitRegion((x, y, z), (x + y + z)**4) >>> r.regular_point() (-10, -10, 20)
References
Erik Hillgarter, “Rational Points on Conics”, Diploma Thesis, RISC-Linz, J. Kepler Universitat Linz, 1996. Available: https://www3.risc.jku.at/publications/download/risc_1355/Rational%20Points%20on%20Conics.pdf
- singular_points()[source]¶
Returns a set of singular points of the region.
The singular points are those points on the region where all partial derivatives vanish.
Examples
>>> from sympy.abc import x, y >>> from sympy.vector import ImplicitRegion >>> I = ImplicitRegion((x, y), (y-1)**2 -x**3 + 2*x**2 -x) >>> I.singular_points() {(1, 1)}
- class sympy.vector.integrals.ParametricIntegral(field, parametricregion)[source]¶
Represents integral of a scalar or vector field over a Parametric Region
Examples
>>> from sympy import cos, sin, pi >>> from sympy.vector import CoordSys3D, ParametricRegion, ParametricIntegral >>> from sympy.abc import r, t, theta, phi
>>> C = CoordSys3D('C') >>> curve = ParametricRegion((3*t - 2, t + 1), (t, 1, 2)) >>> ParametricIntegral(C.x, curve) 5*sqrt(10)/2 >>> length = ParametricIntegral(1, curve) >>> length sqrt(10) >>> semisphere = ParametricRegion((2*sin(phi)*cos(theta), 2*sin(phi)*sin(theta), 2*cos(phi)), (theta, 0, 2*pi), (phi, 0, pi/2)) >>> ParametricIntegral(C.z, semisphere) 8*pi
>>> ParametricIntegral(C.j + C.k, ParametricRegion((r*cos(theta), r*sin(theta)), r, theta)) 0