On this page

simplify_metrics

symbolica.community.idenso Function

simplify_metrics(self_: Expression) -> Expression

Simplifies contractions involving metric tensors and identity tensors.

Applies fundamental tensor algebra rules for metric and identity tensors:

Metric tensor rules:

  • gᵘᵛ pᵥ → pᵘ (index raising/lowering)
  • gᵘᵛ gᵥρ → gᵘρ or δᵘρ (metric composition)
  • gᵘᵤ → D (dimension of spacetime)
  • ηᵘᵛ pᵥ → pᵘ (flat metric contractions)

Identity tensor rules:

  • δᵘᵛ pᵥ → pᵘ (Kronecker delta contraction)
  • δᵘᵤ → D (trace of identity)

The function recognizes metrics as spenso::g(...)

Arguments

  • self_: expression containing metric/identity tensor contractions

Returns

The simplified expression with metric rules applied.

Examples

from symbolica.community.idenso import simplify_metrics, to_dots
from symbolica.community.spenso import Representation, TensorName
q = TensorName("q")
g = TensorName.g()
rep = Representation.euc(3)
# With slots (creates TensorIndices)
mu = rep("mu")
nu = rep("nu")
print(simplify_metrics(g(mu, nu) * q(mu)))