Questions tagged [tensors]

Use this tag for questions that involve tensors. Tensors are fundamental tools for linear computations, generalizing vectors and matrices to higher ranks. Mathematica 9 introduces powerful methods to algebraically manipulate tensors with any rank and symmetry.

Filter by
Sorted by
Tagged with
3
votes
1answer
83 views

'gradient' function in MMA

How to calculate Numerical gradient of 2D arrays using the "gradient function" ("Matlab-like")? "[___] = gradient(F,hx,hy,...,hN) specifies N spacing parameters for the ...
7
votes
1answer
182 views

What is the best source to learn how to use tensor operations (exterior algebra) in Mathematica?

I'm specifically interested in the TensorProduct,TensorWedge, HodgeDual and certain build in functions to do tensor arithmetic like TensorReduce, TensorExpand. I would like to do exterior algebra ...
0
votes
0answers
17 views

Wrong contraction in Feyncalc when restrictions are imposed over the metric

I have the following tensor which I will manipulate in Feyncalc ...
1
vote
1answer
96 views

How to write this tensor?

How can I write this tensor in Mathematica? $$\mathcal{P}_{ijkl}(N) = \Big( \delta_{ik} - N_iN_k \Big) \Big( \delta_{jl} - N_jN_l \Big) - \dfrac{1}{2} \Big( \delta_{ij} - N_iN_j \Big)\Big( \delta_{kl} ...
2
votes
1answer
147 views

Create a matrix without definition of dimensions

is it possible to define a matrix without giving its dimensions in Mathematica, e.g. First line: mattest[[1,2]] = 1; Second line: ...
0
votes
0answers
54 views

The VEST Package

Is any one here familiar with the VEST package [github link] by Squire et al. [arXiv article describing the package] ? Can you please tell me if there is an online forum for the users of this package ...
1
vote
1answer
122 views

how to define unit vectors in mathematica

I'm struggling a little bit trying to understand how to address this problem, I would like to do this in mathematica: is just that I don't know how to do the dot product between $\mathbf{J}$ and $\...
1
vote
1answer
48 views

Differential not returning the answer

I have the following set of rules for differentiation. ...
4
votes
1answer
74 views

Simplifying the Summation

I have to sum: $$\frac{1}{2} x_{i,k} x_{j,\nu } g_{i,j,k,\mu }+\frac{1}{2} x_{i,k} x_{j,\mu } g_{i,j,k,\nu }+x_{i,l} x_{j,\nu } g_{i,j,l,\mu }+x_{i,\mu } x_{k,l} g_{i,k,l,\nu }$$ g and x are real ...
2
votes
1answer
119 views

Operator products summing

Is there a way to perform the below summation in Mathematica? $$\frac{\left(\hat{X}_{ij}+\mathbb i\delta_{ij}\right)}{\mathbb{i}}\frac{\left(\hat{X}_{kl}+\mathbb i\delta_{kl}\right)}{\mathbb{i}}$$ I ...
3
votes
2answers
134 views

Tensor multiplication

I have eight Tensors to multiply as follows, $$P=\sum_{all indices}M_{ijkl}M_{mjkl}M_{inkl}M_{mnkl}X_{kl}Y_{kl}X_{kl}Y_{kl}$$ Each M Matrix is say $2^7\times2^7 \times2^7 \times 2^7$ size. Is there ...
2
votes
1answer
64 views

Splitting product of $\gamma$-matrices into symmetric and anti-symmetric part

The $\gamma$-matrices satisfy the relation $$\gamma^\mu \gamma^\nu +\gamma^\nu\gamma^\mu=2\eta^{\mu\nu}\mathrm{id},$$ where $\eta$ is the Minkowski metric. Consider now the following process $$\begin{...
0
votes
1answer
31 views

Simplifying cross product expressions II

This is related to Simplifying cross product expressions Consider the following: ...
0
votes
0answers
22 views

How to define an index list of local variables for arbitrarily long

Suppose initially I have a list that looks like list1 = {A, B, C} where the elements A, B, C are all matrices. I want to substitute all the three elements by list1 ...
2
votes
1answer
42 views

Neglecting higher order derivatives terms in xAct

For some gravity theory coupled to a scalar field $\phi$, I obtain, in xAct, the equations of motion $$\mathcal{E}_{ab}=R_{ab} (\nabla_{c}\phi \nabla^{c}\phi) + 2 R \nabla_{a}\phi\nabla_{b}\phi + 6 \...
2
votes
0answers
73 views

The Weyl Scalar: does anyone here knows a code to calculate it?

From pure differential geometry we have an important tensor called Weyl Tensor. Its components are given by: $$C_{ijkl} = R_{ijkl} - \frac{2}{n-2}(g_{ik}R_{jl} + g_{jl}R_{ik} - g_{il}R_{jk} - g_{jk}...
6
votes
3answers
131 views

Contraction of three tensors with the same index

I have a 3-dimensional tensor $T_{ijk}$. I need to calculate a tensor $$M_{ijnmpq}=\sum_k T_{ijk}T_{nkm}T_{kpq}$$ Is there a way to do such contractions in Mathematica, avoiding loops? Or maybe there ...
4
votes
1answer
79 views

Differentiation by indexed variable in equation of Christoffel Symbols

I am very new to Mathematica, and am trying to use it to compute Christoffel symbols for a certain manifold. All this requires is taking some indexed sums of derivatives, but it builds up on several ...
0
votes
0answers
91 views

Where I can find RGTC package? (2021 version)

I am not being able to find the RGTC package for Mac. I followed the instructions of this Mathematica Stack Exchange answer, however, the documentation notebook says "Not Found".
2
votes
0answers
61 views

How can I simplify a symbolic tensor expression?

My question is about simplifying tensor expressions. If I have $(a+b)\otimes (c+d)$ The function TensorExpand gives $a\otimes c + a\otimes d + b\otimes c + b\otimes ...
4
votes
1answer
121 views

How to generate isotropic tensors?

Consider a real tensor $\bf{T}$ upon $\mathop\otimes\limits_{n}(\mathbb{R}^3)$, with a definite order $n$, it could be isotropic, i.e., be invariant under the action of all elements in $SO(3)$(not $O(...
0
votes
0answers
44 views

How do I interpret this table of Christoffel symbols?

So I found a code that allows me to compute the covariant derivative of some vector, here it is: ...
3
votes
1answer
82 views

Covariant derivative of a vector

I have a code that gives me the Christoffel symbols of a metric. How do I take the covariant derivative of a vector? It does not necessarily have to build upon my code, but this is what I have used so ...
3
votes
2answers
252 views

Generate symmetric random tensor

I would like to generate a table $T$ of random values of rank $p$ such that my table is fully symmetric: If I swap any indices I get the same value. For example when $p=3$ I would like $T_{ijk}$ to be ...
8
votes
3answers
394 views

Equivalent of numpy's newaxis

Numpy has a newaxis object that allows you to insert a new dimension of length 1 into an array. So after ...
0
votes
0answers
48 views

Converting Tensor product to Matrix

I have a basic question regarding matrices and tensor product forms. Given $N > 0$, I am interested in the tensor product series $\sum_{i}^{N} X_i$, where $X_i$ is the Pauli $X$ spin operator at ...
3
votes
1answer
102 views

Generate C code from symbolic computation in Mathematica

I am doing some tensor multiplication operations and would like to have Mathematica generate C code so that I can use it later. I want to supply two 2nd order tensors(A and B) and get the entries of a ...
3
votes
1answer
96 views

How to compute matrices in Einstein notation:

I would like to compute $ r_{ii'} = \sum_{kk'} A_{ii'}^{kk'} r_{kk'} $ where all indices vary from 0 to 1 to yield a vector / matrix.
9
votes
1answer
156 views

Nice use case for symbolic tensors?

I come from before the times of symbolic tensors in Mathematica, and am used to working with concrete tensors and custom commands to contract them using Transpose, Dot, etc. I recently realized that ...
0
votes
0answers
64 views

Can I speed up my tensor calculations?

I am running this code now for hours, which is not even that hard actually, but Mathematica seems to have troubles with it: ...
0
votes
2answers
85 views

Problems calculating scalar curvature of sphere

I'm not that great at using Mathematica so please bear with me. What I'm trying to do here is compute the coefficients of the metric tensor in 3D spherical coordinates, from which I'll construct the ...
1
vote
0answers
62 views

Implementing the symbolic identity matrix $I$

I am working with symbolic tensors within Mathematica and I wanted to ask if there is a way to have a symbolic identity tensor.
2
votes
0answers
78 views

Need help with symbolic tensor calculus using Kronecker products

I am quite new with Mathematica. I need to do symbolic tensor calculations but what I try does not seem to work. I have found similar questions to mine, but I need a generalization Specifically, if <...
0
votes
0answers
33 views

Doubt regarding the creation of a symbolic 2nd rank symmetric tensor in Mathematica

I would like to ask the following: In a previous post it was asked how to create a 2nd-order symbolic tensor in Mathematica. Given the following notation ...
0
votes
0answers
49 views

How To Define An Outer Product (in xAct)?

I am working with xAct / xCoba / xTras and I would like to construct a matrix out of a vector. So, I have a vector V on a manifold ...
0
votes
0answers
17 views

ToCTensor does not respect symmetry of tensor

If I try to convert a tensor object to a CTensor DefTensor[F[i, j], M, Antisymmetric[{i, j}]]; Fc = ToCTensor[F, {ch, ch}] The output is ...
1
vote
1answer
61 views

Contracting a Tensor with a CTensor in xAct

I'm trying to contract two tensors that I made in xAct to get a simple result. First I set up a Cartesian space ...
4
votes
4answers
118 views

Double contraction between 2nd and 4th rank tensor

I would like to compute the double dot product between a 2nd and 4th rank tensor in mathematica $A_{kl}A_{ijkl}$ $if \, A_{kl}=\begin{pmatrix} 1& 0 & 0\\ 0 & 1 & 0\\ 0&0 & 1 \...
6
votes
1answer
115 views

Undefined Indexed Variable

I searched already a lot about indexed Variables, and it tends to be the most applicable way to use tensor notation. But I am having a hard time to solve for undefined indexed variables: Here my ...
1
vote
1answer
65 views

Symmetric part of a 4th rank tensor in mathematica

I am quite new to Mathematica and would like to know how to compute the symmetric part of a 4th order tensor $A_{ijkl}$. Since there are 4 indices (i,j,k,l), we have 4!=24 permutations. The symmetric ...
0
votes
1answer
39 views

Replace Table with a fast matrix operation to create for matrices A, B the tensor (b_{ij}A) and similar questions

I have two (nxn)-matrices A=(a_{ij}) and B=(b_{ij}) and I'd like to create the (nxnxnxn)-List C=(b_{ij}*A) so e.g. ...
0
votes
1answer
47 views

How to do tensor product between non-rectangular tensors?

For example, if I have a non-rectangular tensor t = Table[2, {l, 0, 1}, {m, -l, l}] To tensor product 't' with itself will fail, because 't' is not a rectangluar ...
1
vote
1answer
78 views

How to compute k'th tensor power of matrix

Is there a 1-liner to compute $M^{\otimes k}$ where $M$ is some matrix and $\otimes$ is the Kronecker product? The documentation says I can write ...
3
votes
1answer
53 views

TensorExpand, TensorProduct and Distribution over Scalars

Consider: TensorExpand[( b1 x )\[TensorProduct] (b1 x + b2), Assumptions -> x ∈ Reals] (*x^2 b1\[TensorProduct]b1 + x b1\[TensorProduct]b2*) This works as ...
7
votes
3answers
315 views

Tensor transformation

Consider the following tensor in coordinate basis $T=T^{\mu}_{\nu\lambda} \partial_{\mu}\otimes dx^\nu \otimes dx^\lambda$ in two dimensions with coordinates $x^1 = x$ and $x^2 = y$. We take $T^{\mu}...
4
votes
3answers
96 views

Table over array indices

I want to generalize the following table to a summation over $s[1], \ldots, s[N]$ and $t[1], \ldots t[N]$, where each variable sums over $\{-1, 1\}$. ...
0
votes
0answers
89 views

3D plot of a tensor

How to plot a tensor in three dimensions. For example, let us take a dielectric constant tensor of rank two. ...
0
votes
1answer
127 views

How to Contract Indices Using Feyncalc

I am slowly learning how to use Feyncalc, and I have a quick question. I have a third rank tensor B[mu,nu,tao] and I also have a four-vector FV[W,mu]. I would like to contract the first two indices ...
0
votes
0answers
50 views

Weird behavior of ℏ (\[HBar]) symbol on TensorExpand

I was trying to implement some tools to do commutators on quantum mechanics, just for fun. Then I noted a peculiarity: ...
0
votes
0answers
26 views

Kretschmann scalar computation with xCoba not giving result

I am using the following code to calculate the Kretschmann scalar with xTensor pack, but it doesn't give me any result and I haven't detected any error, I dont know what's wrong with it. The code is ...

1
2 3 4 5
9