Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

STensor

Guides

  • Get Started

Tech Notes

  • Basic Tensor Computation
  • ComputationWithMetric

Symbols

  • ChristoffelSymbol
  • CreateTensor
  • EinsteinTensor
  • Inverse
  • IsMetric
  • LineElement
  • RicciScalar
  • RicciTensor
  • RiemannTensor
  • SCoordinateTransform
  • STensor
  • STensorQ
  • Symmetrize
  • TensorRank
  • TensorSymmetry
  • Tr
  • VolumeElement
  • WeylTensor
BowenPing`STensor`
Tr
​
Tr[tensor]
calculate the trace of given {1, 1} tensor, or {0, 2}, {2, 0} tensor with metric known
​
Details and Options

Examples  
(1)
Basic Examples  
(1)
Calculate the trace of a {1,1} tensor:
In[1]:=
T=
CreateTensor
["T",{1,1},{x,y},Array[
"t"
##
&,{2,2}]];​​
Tr
[T]
Out[1]=
t
1,1
+
t
2,2
Calculate the trace of a {2, 0} tensor, with metric known:
In[2]:=
g=
CreateTensor
"g",{r,θ},DiagonalMatrix[{1,r^2}],
IsMetric
True;​​T=
CreateTensor
["T",{2,0},{r,θ},Array[
"t"
##
&,{2,2}],g];​​
Tr
[T],g["ab"]T["ab"]
Out[2]=

t
1,1
+
2
r
t
2,2
,
t
1,1
+
2
r
t
2,2

Calculate the trace of a {0, 2} tensor, with metric known:
In[3]:=
g=
CreateTensor
"g",{r,θ},DiagonalMatrix[{1,r^2}],
IsMetric
True;​​T=
CreateTensor
["T",{0,2},{r,θ},Array[
"t"
##
&,{2,2}],g];​​
Tr
[T],
Inverse
[g]["ab"]T["ab"]
Out[3]=

t
1,1
+
t
2,2
2
r
,
t
1,1
+
t
2,2
2
r

SeeAlso
CreateTensor
 
▪
IsMetric
RelatedGuides
▪
Get Started
""

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com