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
Basic Tensor Computation
Plus
Tensor Addition
Times
Scalar Multiplication, Tensor Product and Contract
Wedge
Tensor wedge (for {0,n} tensor/differential form)
Grad
Derivative Operator
D
Ordinary Derivative Operator

Plus

Plus two tensors together:
In[10]:=
T=
CreateTensor
["T",{0,2},{x,y},Array["T",{2,2}]];​​S=
CreateTensor
["S",{0,2},{x,y},Array["S",{2,2}]];​​sum=S["ab"]+T["ab"]
Out[12]=
STensor
Symbol: T+S
Rank: {0,2}
[,ab]
In[13]:=
sum["Components"]//MatrixForm
Out[13]//MatrixForm=
S[1,1]+T[1,1]
S[1,2]+T[1,2]
S[2,1]+T[2,1]
S[2,2]+T[2,2]
Two tensor with different rank or coordinate system can not be added together. The result will be unevaluated.
In[14]:=
T=
CreateTensor
["T",{0,2},{x,y},Array["T",{2,2}]];​​S=
CreateTensor
["S",{1,1},{x,y},Array["S",{2,2}]];​​P=
CreateTensor
["P",{0,2},{r,θ},Array["S",{2,2}]];
In[18]:=
{T+S,T+P}
Out[18]=
STensor
Symbol: S
Rank: {1,1}
+STensor
Symbol: T
Rank: {0,2}
,STensor
Symbol: P
Rank: {0,2}
+STensor
Symbol: T
Rank: {0,2}


Times

Scalar multiplication can be done directly as any other expressions:
In[23]:=
T=
CreateTensor
["T",{0,2},{x,y},Array["T",{2,2}]];​​kT
Out[24]=
STensor
Symbol: (k) T
Rank: {0,2}
Symmetry: {}
Coordinate System: {x,y}
Components: {{kT[1,1],kT[1,2]},{kT[2,1],kT[2,2]}}

Tensor product can be done with indices:
In[5]:=
T=
CreateTensor
["T",{0,2},{x,y},Array["T",{2,2}]];​​S=
CreateTensor
["S",{1,1},{x,y},Array["S",{2,2}]];
In[7]:=
T["ab"]S["c","d"]
Out[7]=
STensor
Symbol: T S
Rank: {1,3}
[c,abd]
Tensor contract can be done when there are common indices both in sup and sub:
In[8]:=
{T["ab"]S["a","c"],S["a","a"]}
Out[8]=
STensor
Symbol: T S
Rank: {0,2}
[,bc],S[1,1]+S[2,2]
When calculating product of two tensors with different coordinate system, a warning will be given:
In[9]:=
T=
CreateTensor
["T",{0,2},{x,y},Array["T",{2,2}]];​​S=
CreateTensor
["S",{1,1},{r,θ},Array["S",{2,2}]];
In[12]:=
T["ab"]S["c","d"]
Out[12]=
STensor
Symbol: T S
Rank: {1,3}
[c,abd]

Wedge

Compute wedge product of two differential forms:
In[13]:=
T=
CreateTensor
"T",{0,2},{x,y,z},​​
Symmetrize
[Array["T",{3,3}],Antisymmetric[All]]​​;​​S=
CreateTensor
"T",{0,2},{x,y,z},​​
Symmetrize
[Array["T",{3,3}],Antisymmetric[All]]​​;​​T["ab"]⋀S["cd"]
Out[15]=
STensor
Symbol: T⋀T
Rank: {0,4}
[abcd]
The tensors involved will be antisymmetrized automatically:
In[16]:=
T=
CreateTensor
["T",{0,2},{x,y,z},Array["T",{3,3}]];​​S=
CreateTensor
["T",{0,2},{x,y,z},Array[
"s"
##
&,{3,3}]];​​T["ab"]⋀S["cd"]
Out[18]=
STensor
Symbol: T⋀T
Rank: {0,4}
[abcd]

Grad

Derivative Operator will hold the same if the metric is not set:
In[19]:=
T=
CreateTensor
["T",{0,2},{r,θ,ϕ},Array["T",{3,3}]];​​Grad[T["ab"],"c"]
Out[20]=
It will operate on tensors when the metric is given:
In[21]:=
g=
CreateTensor
"g",{r,θ,ϕ},DiagonalMatrix[{1,r^2,r^2Sin[θ]^2}],
IsMetric
True;​​T=
CreateTensor
["T",{0,2},{r,θ,ϕ},Array["T"[r],{3,3}],g];​​dT=Grad[T["ab"],"c"]
Out[23]=
STensor
Symbol: ∇(T)
Rank: {0,3}
[,abc]

D

Similar to Grad, D represents the ordinary derivative operator replying on coordinate system:
In[24]:=
g=
CreateTensor
"g",{r,θ,ϕ},DiagonalMatrix[{1,r^2,r^2Sin[θ]^2}],
IsMetric
True;​​T=
CreateTensor
["T",{0,2},{r,θ,ϕ},Array["T"[r],{3,3}],g];​​DT=D[T["ab"],"c"]
Out[26]=
STensor
Symbol: ∂(T)
Rank: {0,3}
[,abc]
Check all non-zero components
In[27]:=
DT["Non-zero Components"]//TableForm
Out[27]//TableForm=
∂(T)
1,1,1

′
T
[r][1,1]
∂(T)
1,2,1

′
T
[r][1,2]
∂(T)
1,3,1

′
T
[r][1,3]
∂(T)
2,1,1

′
T
[r][2,1]
∂(T)
2,2,1

′
T
[r][2,2]
∂(T)
2,3,1

′
T
[r][2,3]
∂(T)
3,1,1

′
T
[r][3,1]
∂(T)
3,2,1

′
T
[r][3,2]
∂(T)
3,3,1

′
T
[r][3,3]
RelatedGuides
▪
Get Started
RelatedTechNotes
▪
Computation With Metric

© 2025 Wolfram. All rights reserved.

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