Algebraic operations¶
This page covers the pointwise algebra: sums and coefficients, wedge and tensor products, pairings and evaluations, musical isomorphisms, symmetrization and the Hodge star, frame indices, bundle endomorphisms, operator algebra, degree queries and simplification.
Every expression on this page is inert: writing it builds a node and nothing is expanded.
Expansion is done by an engine (see Running proofs); the one exception
is simplify, which can be called directly. The “LaTeX” column shows the output of
jacopy.to_latex() for the expression in the “In code” column.
Setup¶
The objects are those of Defining objects; the second group of imports is specific to this page.
import jacopy
from jacopy.core import Degree, Scalar
from jacopy.central.objects.frame import FrameIndex
reg = jacopy.PropertyRegistry()
f, h = jacopy.functions("f h", registry=reg)
lam = jacopy.Symbol("lambda"); reg.declare(lam, Scalar())
two, half = jacopy.Integer(2), jacopy.Rational(1, 2)
M3 = jacopy.tangent_bundle(dim=3)
X, Y, Z = jacopy.vector_fields("X Y Z")
alpha, beta = jacopy.forms("alpha beta", degree=1)
(omega,) = jacopy.forms("omega", degree=2)
p = Degree.var("p"); (eta,) = jacopy.forms("eta", degree=p)
P, Q = jacopy.p_vectors("P Q", degree=2)
pi = jacopy.bivector("pi")
(T,) = jacopy.tensors("T", upper=1, lower=2)
g = jacopy.metric("g"); ginv = g.inverse()
g3 = jacopy.metric("g", bundle=M3)
nabla = jacopy.connection()
e = jacopy.frame("e"); ce = jacopy.coframe("e")
ea, eb = e.fields("a b")
s = FrameIndex("s")
D = jacopy.Derivation("D", degree=1)
from jacopy.central.objects import (tensor_product, symmetrize, antisymmetrize, hodge_star,
partial_eval, musical_view, flat, sharp, scale, contract_all, form_on_vector,
vector_on_form, apply_to_function, kronecker_delta, kind_of, signature_of)
from jacopy.core.indexed_sum import indexed_sum
from jacopy.central.objects.endomorphism import EndoVF, EndoForm
from jacopy.algebra.commutator import commutator, expand_commutator
from jacopy.algebra.derivation import compose, degree_of
from jacopy.algebra.grading import exterior_degree, exterior_parity
from jacopy.algorithms.simplify import simplify
from jacopy.central.tangent import d
Sum, difference, coefficient¶
Mathematics |
In code |
Arguments |
Result |
LaTeX |
Note |
|---|---|---|---|---|---|
\(X+Y\) |
|
X, Y: vector fields |
vector field |
|
The same for every type: forms, functions, … |
\(X-Y\) |
|
X, Y: vector fields |
vector field |
|
Stored internally as \(X+(-Y)\) |
\(-\omega\) |
|
omega: 2-form |
2-form |
|
|
\(fX\) |
|
f: function; X: vector field |
vector field |
|
\(C^\infty(M)\)-module multiplication; the left factor stays on the left |
\(\lambda X\) |
|
lam: constant; X: vector field |
vector field |
|
|
\(2X+\tfrac12X\) |
|
numbers; X |
vector field |
|
A Python number also works |
\(f\omega\) |
|
f: function; omega: \(p\)-form |
\(p\)-form |
|
|
\(fh\) |
|
f, h: functions |
function |
|
|
\(f^2\) |
|
f: function; integer exponent |
function |
|
Same as |
\(fT\) |
|
f: function; T: tensor |
tensor of the same type |
|
Same as |
Products¶
Mathematics |
In code |
Arguments |
Result |
LaTeX |
Note |
|---|---|---|---|---|---|
\(\alpha\wedge\beta\) |
|
forms of any degree |
\((p+q)\)-form |
|
Several arguments are allowed: |
\(\alpha\wedge\eta\) |
|
alpha: 1-form; eta: form of symbolic degree \(p\) |
\((1+p)\)-form |
|
|
\(X\wedge Y\) |
|
X, Y: vector fields |
2-vector |
|
Produces a multivector |
\(\alpha\wedge 0\) |
|
0 |
|
0 absorbs and 1 is the unit |
|
\(T\otimes\alpha\) |
|
tensors, forms or vectors (any number) |
tensor |
|
Non-commutative; the types add up |
See jacopy.wedge().
Pairing and evaluation¶
Mathematics |
In code |
Arguments |
Result |
LaTeX |
Note |
|---|---|---|---|---|---|
\(\langle\alpha,X\rangle=\alpha(X)\) |
|
alpha: 1-form; X: vector field |
function |
|
Form first, then vector |
\(\alpha(X)\) |
|
alpha: 1-form; X: vector field |
function |
|
The same node as |
\(\alpha(X)\) (named form) |
|
1-form; vector field |
function |
|
|
\(X(\alpha)=\langle\alpha,X\rangle\) |
|
vector field; 1-form |
function |
|
Reversed argument order |
\(\omega(X,Y)\) |
|
omega: 2-form; X, Y: vector fields |
function |
|
Requires exactly \(p\) arguments; for partial evaluation use \(\iota_X\) |
\(\omega(X,Y)\) (general form) |
|
head: form, tensor, …; slot values |
function |
|
The only way to evaluate heads that are not callable, such as \(d\alpha\) or \(\alpha\wedge\beta\) |
\((\alpha\wedge\beta)(X,Y)\) |
|
wedge; vectors |
function |
|
Its expansion needs an optional engine rule (see Running proofs) |
\((d\alpha)(X,Y)\) |
|
\(d\alpha\): 2-form; X, Y |
function |
|
|
\(\omega(X,X)=0\) |
|
the same argument twice |
function (\(=0\)) |
|
A repeated argument gives zero after simplification |
\(P(\alpha,\beta)\) |
|
P: 2-vector; alpha, beta: 1-forms |
function |
|
Alternating |
\(\pi(\alpha,\beta)\) |
|
pi: bivector; 1-forms |
function |
|
|
\(T(\alpha,X,Y)\) |
|
T: \((1,2)\)-tensor; one covector, then two vectors |
function |
|
Not alternating |
\(g(X,Y)\) |
|
g: metric; X, Y: vector fields |
function |
|
Symmetric |
\(g^{-1}(\alpha,\beta)\) |
|
ginv: inverse metric; 1-forms |
function |
|
|
\(X(f)\) |
|
X: vector field; f: function |
function |
|
Directional derivative |
\(X(f)\) (named form) |
|
vector field; function |
function |
|
See jacopy.pairing() and jacopy.multi_eval().
Partial evaluation and musical isomorphisms¶
Mathematics |
In code |
Arguments |
Result |
LaTeX |
Note |
|---|---|---|---|---|---|
\(g(X,\cdot)\) |
|
head; a value or |
partial map |
|
|
\(g(X,\cdot)(Y)=g(X,Y)\) |
|
partial map; values of the open slots |
function |
|
Open slots are filled in order |
\(T(\alpha,\cdot,Y)\) |
|
tensor; one entry per slot |
partial map |
|
|
\(T(\alpha,\cdot,\cdot)\) |
|
head; values of the leading slots |
partial map |
|
Leading slots fixed, the rest open |
degree of \(\omega(X,\cdot)\) |
|
partial map |
degree |
|
|
\(g^\flat(X)\) |
|
g: metric; X: vector field |
1-form |
|
|
\(\pi^\sharp(\alpha)\) |
|
pi: bivector or inverse metric; alpha: 1-form |
vector field |
|
|
\(g^\sharp(\alpha)\) |
|
inverse metric; 1-form |
vector field |
|
Known display limitation: the LaTeX contains a double superscript |
Symmetrization and the Hodge star¶
Mathematics |
In code |
Arguments |
Result |
LaTeX |
Note |
|---|---|---|---|---|---|
\(\mathrm{Sym}(T)\) |
|
tensor or evaluation |
same type |
|
Expands under evaluation: \(T_{(ab)}=\tfrac12(T_{ab}+T_{ba})\) |
\(\mathrm{Alt}(T(\alpha,X,Y))\) |
|
evaluated tensor |
function |
|
|
\(\star_g\omega\) |
|
omega: \(p\)-form; g: metric |
\((n-p)\)-form |
|
Structural only: no rules such as \(\star\star=\pm1\); \(n\) is symbolic |
\(\star_g\omega\), \(n=3\) |
|
omega; metric in dimension 3 |
1-form |
|
For concrete \(p,n\), \(0\le p\le n\) is checked |
\(\star\omega\) (no metric) |
|
omega; dimension (int or degree) |
\((4-p)\)-form |
|
Bare structural star |
See jacopy.hodge().
Frames, indices, Kronecker delta¶
Mathematics |
In code |
Arguments |
Result |
LaTeX |
Note |
|---|---|---|---|---|---|
\(e_a\) |
|
index name (str or int) |
vector field |
|
|
\(e^a\) |
|
index name |
1-form |
|
|
\(\langle e^a,e_b\rangle\) |
|
upper index, lower index |
function |
|
The engine reduces it to \(\delta^a_b\) |
\(\delta^a_b\) |
|
upper, lower index |
constant |
|
1 for equal indices |
\(\sum_s\langle e^s,X\rangle e_s\) |
|
dummy index; range (a frame); body |
type of the body |
|
Equality is up to renaming of the dummy index |
Bundle endomorphisms¶
Mathematics |
In code |
Arguments |
Result |
LaTeX |
Note |
|---|---|---|---|---|---|
\(m(X)\) |
|
name; vector field |
vector field |
|
|
\(m^{-1}(X)\) |
|
name; vector field; |
vector field |
|
The rule \(m^{-1}(m(x))=x\) is optional (see Automatic rules) |
\(\tilde m(\alpha)\) |
|
name; form |
form of the same degree |
|
Operator algebra¶
Mathematics |
In code |
Arguments |
Result |
LaTeX |
Note |
|---|---|---|---|---|---|
\(D(f)\) |
|
D: derivation; f |
expression |
|
Same as |
\(D(fh)=D(f)h+fD(h)\) |
|
D: derivation of degree 1 |
expression |
|
The graded Leibniz rule is applied by the engine |
\(A\circ B\) |
|
operators |
operator |
|
The composition is a product node |
\([A,B]\) (graded commutator) |
|
operators |
operator |
|
Inert node |
\([A,B]=AB-(-1)^{\lvert A\rvert\lvert B\rvert}BA\) |
|
commutator; registry |
operator |
|
The sign is computed from the degrees |
Degree and type queries¶
Mathematics |
In code |
Arguments |
Result |
Note |
|---|---|---|---|---|
\(\lvert d\rvert=1\) |
|
expression or operator; registry |
degree |
|
\(\lvert\iota_X\rvert=-1\) |
|
degree |
|
|
\(\lvert\eta\rvert=p\) |
|
degree |
|
|
\(p+1\) |
|
degree plus an integer |
degree |
|
\(2p \bmod 2\) |
|
degree |
|
|
\(\lvert\alpha\wedge\omega\rvert\) |
|
expression; registry |
degree or unknown |
|
\(\lvert\alpha\wedge\omega\rvert\bmod 2\) |
|
expression; registry |
|
|
type judgment |
|
expression; registry |
|
|
\((q,r)\) signature |
|
tensor expression |
|
|
Simplification¶
simplify collects terms, reorders the arguments of alternating maps and applies Koszul
signs. It can be called on any expression:
print(simplify(omega(Y, X) + omega(X, Y) + 2*X(f) - X(f) - X(f), reg))
print(degree_of(jacopy.interior(X), reg), (2*p).parity(), signature_of(scale(f, T)))
0
-1 0 (1, 2)