Elements of the algebra of differential forms¶
AUTHORS:
- Joris Vankerschaver (2010-07-25)
-
class
sage.tensor.differential_form_element.DifferentialForm(parent, degree, fun=None)¶ Bases:
sage.structure.element.AlgebraElementDifferential form class.
EXAMPLES:
In order to instantiate differential forms of various degree, we begin by specifying the CoordinatePatch on which they live, as well as their parent DifferentialForms algebra.
sage: x, y, z = var('x, y, z') sage: U = CoordinatePatch((x, y, z)) sage: F = DifferentialForms(U) sage: form1 = DifferentialForm(F, 0, sin(x*y)); form1 sin(x*y)
In the previous example, we created a zero-form from a given function. To create forms of higher degree, we can use the subscript operator access the various components:
sage: form2 = DifferentialForm(F, 1); form2 0 sage: form2[0] = 1 sage: form2[1] = exp(cos(x)) sage: form2[2] = 1/ln(y) sage: form2 1/log(y)*dz + dx + e^cos(x)*dy
We may calculate the exterior derivative of a form, and observe that applying the exterior derivative twice always yields zero:
sage: dform = form1.diff(); dform y*cos(x*y)*dx + x*cos(x*y)*dy sage: dform.diff() 0
As can be seen from the previous example, the exterior derivative increases the degree of a form by one:
sage: form2.degree() 1 sage: form2.diff().degree() 2
The
dfunction provides a convenient shorthand for applying the diff member function. Since d appears in other areas of mathematics as well, this function is not imported in the global namespace automatically:sage: from sage.tensor.differential_form_element import d sage: form2 1/log(y)*dz + dx + e^cos(x)*dy sage: d(form2) -1/(y*log(y)^2)*dy/\dz + -e^cos(x)*sin(x)*dx/\dy sage: form2.diff() -1/(y*log(y)^2)*dy/\dz + -e^cos(x)*sin(x)*dx/\dy sage: d(form1) == form1.diff() True
The wedge product of two forms can be computed by means of the wedge member function:
sage: form1 = DifferentialForm(F, 2) sage: form1[0, 1] = exp(z); form1 e^z*dx/\dy sage: form2 = DifferentialForm(F, 1) sage: form2[2] = exp(-z) sage: form1.wedge(form2) dx/\dy/\dz
For this member function, there exists again a procedural function which is completely equivalent:
sage: from sage.tensor.differential_form_element import wedge sage: form1.wedge(form2) dx/\dy/\dz sage: wedge(form1, form2) dx/\dy/\dz sage: form1.wedge(form2) == wedge(form1, form2) True
NOTES:
Differential forms are stored behind the screens as dictionaries, where the keys are the subscripts of the non-zero components, and the values are those components.
For example, on a space with coordinates x, y, z, the form
f = sin(x*y) dx /\ dy + exp(z) dy /\ dzwould be represented as the dictionary
{(0, 1): sin(x*y), (1, 2): exp(z)}.Most differential forms are ‘’sparse’’ in the sense that most of their components are zero, so that this representation is more efficient than storing all of the components in a vector.
-
abs()¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.abs() Traceback (most recent call last): ... NotImplementedError: Absolute value not defined for differential forms.
-
degree()¶ Return the degree of self.
EXAMPLES:
sage: F = DifferentialForms(); F Algebra of differential forms in the variables x, y, z sage: f = DifferentialForm(F, 2) sage: f[1, 2] = x; f x*dy/\dz sage: f.degree() 2
The exterior differential increases the degree of forms by one:
sage: g = f.diff(); g dx/\dy/\dz sage: g.degree() 3
-
derivative(*args, **kwargs)¶ Compute the exterior derivative of
self. This is the same as calling thediffmember function.EXAMPLES:
sage: x, y = var('x, y') sage: U = CoordinatePatch((x, y)) sage: F = DifferentialForms(U) sage: q = DifferentialForm(F, 1) sage: q[0] = -y/2 sage: q[1] = x/2 sage: q.diff() dx/\dy sage: q.derivative() dx/\dy
Invoking
diffon a differential form has the same effect as calling this member function:sage: diff(q) dx/\dy sage: diff(q) == q.derivative() True
When additional arguments are supplied to
diff, an error is raised, since only the exterior derivative has intrinsic meaning while derivatives with respect to the coordinate variables (in whichever way) are coordinate dependent, and hence not intrinsic.sage: diff(q, x) Traceback (most recent call last): ... ValueError: Differentiation of a form does not take any arguments.
-
diff()¶ Compute the exterior differential of
self.EXAMPLES:
sage: x, y, z = var('x, y, z') sage: F = DifferentialForms() sage: f = DifferentialForm(F, 0, sin(x*y)); f sin(x*y) sage: f.diff() y*cos(x*y)*dx + x*cos(x*y)*dy sage: g = DifferentialForm(F, 1) sage: g[0] = y/2 sage: g[1] = -x/2 sage: g 1/2*y*dx + -1/2*x*dy sage: g.diff() -1*dx/\dy sage: h = DifferentialForm(F, 2) sage: h[0, 1] = exp(z) sage: h.diff() e^z*dx/\dy/\dz
The square of the exterior differential operator is identically zero:
sage: f sin(x*y) sage: f.diff() y*cos(x*y)*dx + x*cos(x*y)*dy sage: f.diff().diff() 0 sage: g.diff().diff() 0
The exterior differential operator is a derivation of degree one on the space of differential forms. In this example we import the operator d() as a short-hand for having to call the diff() member function.
sage: from sage.tensor.differential_form_element import d sage: d(f) y*cos(x*y)*dx + x*cos(x*y)*dy sage: d(f).wedge(g) + f.wedge(d(g)) (-x*y*cos(x*y) - sin(x*y))*dx/\dy sage: d(f.wedge(g)) (-x*y*cos(x*y) - sin(x*y))*dx/\dy sage: d(f.wedge(g)) == d(f).wedge(g) + f.wedge(d(g)) True
-
is_zero()¶ Return True if
selfis the zero form.EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1); f 0 sage: f.is_zero() True sage: f[1] = 1 sage: f.is_zero() False sage: f.diff() 0 sage: f.diff().is_zero() True
-
leading_coefficient(key=None)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.leading_coefficient() Traceback (most recent call last): ... NotImplementedError: leading_coefficient not defined for differential forms.
-
leading_item(key=None)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.leading_item() Traceback (most recent call last): ... NotImplementedError: leading_item not defined for differential forms.
-
leading_monomial(key=None)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.leading_monomial() Traceback (most recent call last): ... NotImplementedError: leading_monomial not defined for differential forms.
-
leading_support(key=None)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.leading_support() Traceback (most recent call last): ... NotImplementedError: leading_support not defined for differential forms.
-
leading_term(key=None)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.leading_term() Traceback (most recent call last): ... NotImplementedError: leading_term not defined for differential forms.
-
map_coefficients(f)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.map_coefficients(lambda x: x) Traceback (most recent call last): ... NotImplementedError: map_coefficients not defined for differential forms.
-
map_item(f)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.map_item(lambda x: x) Traceback (most recent call last): ... NotImplementedError: map_item not defined for differential forms.
-
map_support(f)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.map_support(lambda x: x) Traceback (most recent call last): ... NotImplementedError: map_support not defined for differential forms.
-
trailing_coefficient(key=None)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.trailing_coefficient() Traceback (most recent call last): ... NotImplementedError: trailing_coefficient not defined for differential forms.
-
trailing_item(key=None)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.trailing_item() Traceback (most recent call last): ... NotImplementedError: leading_coefficient not defined for differential forms.
-
trailing_monomial(key=None)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.trailing_monomial() Traceback (most recent call last): ... NotImplementedError: trailing_monomial not defined for differential forms.
-
trailing_support(key=None)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.trailing_support() Traceback (most recent call last): ... NotImplementedError: trailing_support not defined for differential forms.
-
trailing_term(key=None)¶ Method not defined for differential forms.
EXAMPLES:
sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f.trailing_term() Traceback (most recent call last): ... NotImplementedError: trailing_term not defined for differential forms.
-
wedge(other)¶ Returns the wedge product of
selfand other.EXAMPLES:
sage: x, y, z = var('x, y, z') sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f[0] = x^2 sage: f[1] = y sage: f x^2*dx + y*dy sage: g = DifferentialForm(F, 1) sage: g[2] = z^3 sage: g z^3*dz sage: f.wedge(g) y*z^3*dy/\dz + x^2*z^3*dx/\dz
The wedge product is graded commutative:
sage: f.wedge(g) y*z^3*dy/\dz + x^2*z^3*dx/\dz sage: g.wedge(f) -y*z^3*dy/\dz + -x^2*z^3*dx/\dz sage: f.wedge(f) 0
When the wedge product of forms belonging to different algebras is computed, an error is raised:
sage: x, y, p, q = var('x, y, p, q') sage: F = DifferentialForms(CoordinatePatch((x, y))) sage: G = DifferentialForms(CoordinatePatch((p, q))) sage: f = DifferentialForm(F, 0, 1); f 1 sage: g = DifferentialForm(G, 0, x); g x sage: f.parent() Algebra of differential forms in the variables x, y sage: g.parent() Algebra of differential forms in the variables p, q sage: f.wedge(g) Traceback (most recent call last): ... TypeError: unsupported operand parents for wedge: 'Algebra of differential forms in the variables x, y' and 'Algebra of differential forms in the variables p, q'
-
-
class
sage.tensor.differential_form_element.DifferentialFormFormatter(space)¶ This class contains all the functionality to print a differential form in a graphically pleasing way. This class is called by the
_latex_and_repr_methods of the DifferentialForm class.In a nutshell (see the documentation of
DifferentialFormfor more details), differential forms are represented internally as a dictionary, where the keys are tuples representing the non-zero components of the form and the values are the component functions. The methods of this class create string and latex representations out of the specification of a subscript and a component function.EXAMPLES:
sage: from sage.tensor.differential_form_element import DifferentialFormFormatter sage: x, y, z = var('x, y, z') sage: U = CoordinatePatch((x, y, z)) sage: D = DifferentialFormFormatter(U) sage: D.repr((0, 2), sin(x*y)) 'sin(x*y)*dx/\\dz' sage: D.latex((0, 2), sin(x*y)) '\\sin\\left(x y\\right) d x \\wedge d z' sage: D.latex((1, 2), exp(z)) 'e^{z} d y \\wedge d z'
-
latex(comp, fun)¶ Latex representation of a primitive differential form, i.e. a function times a wedge product of d’s of the coordinate functions.
INPUT:
comp– a subscript of a differential form.fun– the component function of this form.
EXAMPLES:
sage: from sage.tensor.differential_form_element import DifferentialFormFormatter sage: x, y, z = var('x, y, z') sage: U = CoordinatePatch((x, y, z)) sage: D = DifferentialFormFormatter(U) sage: D.latex((0, 1), z^3) 'z^{3} d x \\wedge d y' sage: D.latex((), 1) '1' sage: D.latex((), z^3) 'z^{3}' sage: D.latex((0,), 1) 'd x'
-
repr(comp, fun)¶ String representation of a primitive differential form, i.e. a function times a wedge product of d’s of the coordinate functions.
INPUT:
comp– a subscript of a differential form.fun– the component function of this form.
EXAMPLES:
sage: from sage.tensor.differential_form_element import DifferentialFormFormatter sage: x, y, z = var('x, y, z') sage: U = CoordinatePatch((x, y, z)) sage: D = DifferentialFormFormatter(U) sage: D.repr((0, 1), z^3) 'z^3*dx/\\dy'
-
-
sage.tensor.differential_form_element.d(form)¶ Returns the exterior derivative of a given form, i.e. calls the diff() member function.
EXAMPLES:
sage: from sage.tensor.differential_form_element import d sage: x, y, z = var('x, y, z') sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f[2] = cos(x); f cos(x)*dz sage: d(f) -sin(x)*dx/\dz sage: f.diff() -sin(x)*dx/\dz sage: d(f) == f.diff() True
-
sage.tensor.differential_form_element.sort_subscript(subscript)¶ A subscript is a range of integers. This function sorts a subscript in the sense of arranging it in ascending order. The return values are the sign of the subscript and the sorted subscript, where the sign is defined as follows:
- sign == 0 if two or more entries in the subscript were equal.
- sign == +1, -1 if a positive (resp. negative) permutation was used to sort the subscript.
INPUT:
subscript– a subscript, i.e. a range of not necessarily distinct integers
OUTPUT:
- Sign of the permutation used to arrange the subscript, where 0
- means that the original subscript had two or more entries that were the same
- Sorted subscript.
EXAMPLES:
sage: from sage.tensor.differential_form_element import sort_subscript sage: sort_subscript((1, 3, 2)) (-1, (1, 2, 3)) sage: sort_subscript((1, 3)) (1, (1, 3)) sage: sort_subscript((4, 2, 7, 9, 8)) (1, (2, 4, 7, 8, 9))
-
sage.tensor.differential_form_element.wedge(left, right)¶ Computes the wedge product of two forms, i.e. calls the wedge() member function.
EXAMPLES:
sage: from sage.tensor.differential_form_element import wedge sage: x, y, z = var('x, y, z') sage: F = DifferentialForms() sage: f = DifferentialForm(F, 1) sage: f[2] = cos(x); f cos(x)*dz sage: g = DifferentialForm(F, 1) sage: g[1] = sin(y); g sin(y)*dy sage: wedge(f, g) -cos(x)*sin(y)*dy/\dz sage: f.wedge(g) -cos(x)*sin(y)*dy/\dz sage: wedge(f, g) == f.wedge(g) True