differential_geometry.symbolic.lower_index#
- differential_geometry.symbolic.lower_index(tensor: MutableDenseNDimArray | ImmutableDenseNDimArray | ImmutableDenseMatrix | MutableDenseMatrix, metric: ImmutableDenseMatrix | MutableDenseMatrix | ImmutableDenseNDimArray | MutableDenseNDimArray, axis: int) MutableDenseNDimArray | ImmutableDenseNDimArray | ImmutableDenseMatrix | MutableDenseMatrix [source]#
Lower a single index of a tensor using the provided metric.
This function supports:
A full metric \(g_{\mu\nu}\) (shape
(n,n)
).A diagonal metric (1D array of length
n
) for orthogonal coordinates.
General Formula (when metric is a full matrix):
\[T_{\ldots\nu\ldots} \;=\; T^{\ldots\mu\ldots}\; g_{\mu\nu},\]Orthogonal Diagonal Case (1D array):
\[T_{\ldots\mu\ldots} \;=\; T^{\ldots\mu\ldots} \;\times\; g_{\mu\mu}.\]- Parameters:
tensor (
MutableDenseNDimArray
) – A symbolic tensor of arbitrary rank.metric (
MutableDenseNDimArray
) – The metric used to lower the index. Either a full(n x n)
matrix or a 1D array of lengthn
.axis (
int
) – The index position to lower.
- Returns:
A new tensor with the specified index lowered.
- Return type:
See also
Examples
Full matrix usage:
>>> import sympy as sp >>> from pymetric.differential_geometry.symbolic import lower_index >>> >>> r, theta = sp.symbols('r theta', positive=True) >>> # Metric for polar coords >>> g = sp.Matrix([[1, 0], [0, r**2]]) >>> # Rank-2 tensor >>> T = sp.Array([ ... [sp.Function("T0")(r, theta), sp.Function("T1")(r, theta)], ... [sp.Function("T2")(r, theta), sp.Function("T3")(r, theta)] ... ]) >>> >>> lower_index(T, g, axis=1) [[T0(r, theta), r**2*T1(r, theta)], [T2(r, theta), r**2*T3(r, theta)]]
Orthogonal diagonal usage (just multiply each slice):
>>> g_diag = sp.Array([1, r**2]) >>> lower_index(T, g_diag, axis=1) [[T0(r, theta), r**2*T1(r, theta)], [T2(r, theta), r**2*T3(r, theta)]]