Metric Tensor and Derivatives of Basis Vectors.
linear_expand takes an expression that is the sum of a scalar expression and a linear combination of noncommutative terms with scalar coefficients and generates lists of coefficients and noncommutative symbols the coefficients multiply. The list of noncommutatives symbols contains the scalar 1 if there is a scalar term in the sum and also does not contain any repeated noncommutative symbols.
A – a linear combination of noncommutative symbols with scalar expressions as coefficients
nc_list – noncommutative symbols in A to combine
A sum of the terms containing the noncommutative symbols in nc_list such that no elements of nc_list appear more than once in the sum. All coefficients of a given element of nc_list are combined into a single coefficient.
- Return type
If expression is product of even powers then every power is divided by two and the product is returned. If some terms in product are not even powers the sqrt of the absolute value of the expression is returned. If the expression is a number the sqrt of the absolute value of the number is returned.
symbols_list(s, indices=None, sub=True, commutative=False)¶
Convert a string to a list of symbols.
galgebra.printer.Eprintis enabled, the symbol names will contain ANSI escape sequences.
s (str) –
Specification. If indices is specified, then this is just a prefix. If indices is not specified then this is a string of one of the forms:
prefix + "*" + index_1 + "|" + index_2 + "|" + ... + index_n
prefix + "*" + n_indices
name_1 + "," + name_2 + "," + ... + name_n
name_1 + " " + name_2 + " " + ... + name_n
indices (list, optional) – List of indices to append to the prefix.
sub (bool) – If true, mark as subscript separating prefix and suffix with
_, else mark as superscript using
commutative (bool) – Passed on to
- Return type
Names can be comma or space separated:
>>> symbols_list('a,b,c') [a, b, c] >>> symbols_list('a b c') [a, b, c]
Mixing commas and spaces gives surprising results:
>>> symbols_list('a b,c') [a b, c]
A trailing comma is allowed, and required to generate lists of one element:
>>> symbols_list('a,') [a] >>> symbols_list('') 
Subscripts will be converted to superscripts if requested:
>>> symbols_list('a_1 a_2', sub=False) [a__1, a__2] >>> symbols_list('a__1 a__2', sub=False) [a___1, a___2]
But not vice versa:
>>> symbols_list('a__1 a__2', sub=True) [a__1, a__2]
Asterisk can be used for repetition:
>>> symbols_list('a*b|c|d') [a_b, a_c, a_d] >>> symbols_list('a*3') [a_0, a_1, a_2] >>> symbols_list('a*3') [a_0, a_1, a_2]
Or the indices argument:
>>> symbols_list('a', [2, 4, 6]) [a_2, a_4, a_6] >>> symbols_list('a', [2, 4, 6], sub=False) [a__2, a__4, a__6]
a similar function builtin to sympy
Metric(basis, *, g=None, coords=None, X=None, norm=False, debug=False, gsym=None, sig='e', Isq='-')¶
normalized diagonal metric tensor
list of sympy numbers
dimension of vector space/manifold
list of basis indices
derivatives of basis functions. Two dimensional list. First entry is differentiating coordiate. Second entry is basis vector. Quantities are linear combinations of basis vector symbols.
Signature of metric
n = p+q. If metric tensor is numerical and orthogonal it is calculated. Otherwise the following inputs are used:
Minkowski (One negative square)
Minkowski (One positive square)
General (integer not string input)
String for symbolic metric determinant. If self.gsym = ‘g’ then det(g) is sympy scalar function of coordinates with name ‘det(g)’. Useful for complex non-orthogonal coordinate systems or for calculations with general metric.
basis – string specification
g – metric tensor
coords – manifold/vector space coordinate list/tuple (sympy symbols)
X – vector manifold function
norm – True to normalize basis vectors
debug – True to print out debugging information
gsym – String s to use
"det("+s+")"function in reciprocal basis
sig – Signature of metric, default is (n,0) a Euclidean metric
Isq – Sign of square of pseudo-scalar, default is ‘-‘
dot_orthogonal(V1, V2, g=None)¶
Returns the dot product of two vectors in an orthogonal coordinate system. V1 and V2 are lists of sympy expressions. g is a list of constants that gives the signature of the vector space to allow for non-euclidian vector spaces.
This function is only used to form the dot product of vectors in the embedding space of a vector manifold or in the case where the basis vectors are explicitly defined by vector fields in the embedding space.
A g of None is for a Euclidian embedding space.
rows of metric tensor are separated by “,” and elements of each row separated by ” “. If the input is a single row it is assummed that the metric tensor is diagonal.
Output is a square matrix.
True if connection is non-zero
Adjugate of g
mode = 1 Christoffel symbols of the first kind mode = 2 Christoffel symbols of the second kind
Determinant of \(g\), \(\det g\)
Sign of I**2, only needed if I**2 not a number