We changed our privacy policy. Read more.

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
1
vote
1answer
73 views

Matlab code to Mathemtica, Tensor

I am trying to convert a Matlab code to Mathematica. I have a tensor, RF (a,b,c,d) which is constructed from Hamiltonian (Hs) and 2x2 identity matrix (DS): ...
1
vote
0answers
24 views

Combining TensorProduct with NonCommutativeMultiply

I'd like to compute tensor products of lists that contain Grassmann variables, i.e. I'd like TensorProduct[] to use NonCommutativeMultiply when multiplying elements rather than the standard ...
3
votes
1answer
67 views

Performing matrix tensor product and getting a sum of its negative entries

I am given a $3 \times 3$ matrix $M$, which only has real entries. Is there an efficient way to do the following two operations with $M$? For a given input $n$, compute the $n$-fold tensor product $M^...
0
votes
0answers
38 views

How to define the covariant derivative of third order tensor in Mathematica? Such as perturbed christoffel symbols

In my work, I should calculated the perturbed Ricci tensor. The expression of perturbed ricci is: , where , and the is the covariant derivative. My question is: Is the a tensor? So that I can ...
1
vote
2answers
50 views

Overwrite a tensor product notation a_\[TensorProduct]b_ := KroneckerProduct[a, b]

I noticed that the definition of KroneckerProduct and For example TensorProduct[({ {0, 1}, {1, 0} }), ({ {0, 1}, {1, 0} })] Output: {{{{0,0},{0,0}}...
0
votes
1answer
46 views

Define Matrix Function in a For loop

Let $g\in\mathcal R^{3\times 3}$ be a given known rank 2 tensor function, $gInv$ its inverse, and $dg\in\mathcal R^{3\times 3\times 3}$ its gradiant: ...
0
votes
0answers
47 views

Upper triangular part of tensor

I have created a random real antisymmetric matrix as ...
-1
votes
1answer
69 views

Generalizing the code for tensor

$ f $ is a real antisymmetric matrix (here for simplicity I have considered $ d = 2 $), where $ 2*d $ is the dimension of the matrix. $$f=\begin{bmatrix}0 & f_{12} & f_{13} & f_{14}\\ -f_{...
1
vote
0answers
49 views

Perturbation of Einstein tensor around a fixed background in Xact [duplicate]

I want to compute Ricci tensor expansion around a fixed curved background. It is easy to find the formal expansion around the background metric, but I have a reference metric with known components and ...
2
votes
1answer
66 views

Equivalence between tensor and matrix

I need have to create a real antisymmetric tensor whose elements are given as $p_{abcd}$ $${\displaystyle p_{abcd}={\begin{cases} +p_{\sigma\left(abcd\right)} & {\text{if }}\sigma(a,b,c,d){\text{ ...
5
votes
3answers
98 views

Find transformations for two non-square matrices $A$ and $B$

Given two matrices $A$ and $B$: What transformation needs to be applied to transform matrix $A$ into matrix $B$? ...
0
votes
1answer
68 views

Derivative matrix by vector in Mathematica

This is an excerpt from the article https://www.sciencedirect.com/science/article/abs/pii/S0094114X10000418. How do I write this using vector-matrix operations (...
1
vote
0answers
35 views

Use xTensor to do the Ricci decomposition

I am new to xTensor. I would like to perform the Ricci decomposition with xTensor, but I do not have any clue. I want to replace the full expression $R_{i,j,k,l}=S_{i,j,k,l}+E_{i,j,k,l}+W_{i,j,k,l}$ ...
1
vote
0answers
67 views

four-dimensional Levi-Civita

Consider we have these four vectors $p^{\mu}$, $q^{\nu}$, $k^{\rho}$, and $k'^{\sigma}$. How can we calculate $$ \epsilon_{\mu\nu\rho\sigma} p^{\mu} q^{\nu} k^{\rho} k′^{\sigma}$$ in Mathematica, ...
8
votes
2answers
219 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
18 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
101 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
158 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: ...
1
vote
1answer
133 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
50 views

Differential not returning the answer

I have the following set of rules for differentiation. ...
4
votes
1answer
81 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
128 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
146 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
69 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
32 views

Simplifying cross product expressions II

This is related to Simplifying cross product expressions Consider the following: ...
0
votes
0answers
23 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 ...
3
votes
1answer
52 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
81 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
139 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
87 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
112 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
69 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
128 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
45 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
122 views

Covariant derivative of a vector [duplicate]

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
261 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
396 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
54 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
104 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
99 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
159 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
67 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
98 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
64 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
82 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
37 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
55 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
20 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 ...
2
votes
1answer
80 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
151 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 \...

1
2 3 4 5
9