# 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.

506 questions
Filter by
Sorted by
Tagged with
62 views

### A code to calculate Einstein tensor [duplicate]

I use the following MA code to calculate Einstein’s tensor. I’m asking about the zero component of the Einstein’s tensor, is it correct? Because I think $G_{00}$ should contains the terms in the zero ...
• 209
71 views

• 147
131 views

### Simplifying the Einstein tensor in case of a perturbed FRW metric

I use the code in this thread's answer: (Calculating Einstein tensor components in Kaluza-Klein model) to get the Einstein tensor components of a four-dimensional Kaluza Klein model. But instead of ...
• 209
33 views

### Cannot symmetrize products involving tensors with specified symmetry?

I am trying to check some manipulations with tensors with Mathematica (13.3 on Windows), but was stuck on an error from TensorTranspose. I isolated my problem to the following simple case: ...
• 387
91 views

### How would you find the metric tensor for this formula?

I have a metric formula that does some interesting things for me. It's excellent at predicting the luminosity of Sne 1a. I'd like to see what the EFE solutions are, but I need to convert it from ...
1 vote
130 views

148 views

### Lorentz indices contraction

I have a complex expression involving second-rank tensors and Kronecker Deltas. How can I instruct Mathematica to utilize the Kronecker Deltas and perform proper index replacements? For example, ...
• 173
1 vote
88 views

### Multiplying abstract tensors in Mathematica

I want to do an operation like $$AA \otimes BB \times AA' \otimes BB'$$ and have $$AA \times AA' \otimes BB \times BB'$$ without specifying the elements of $AA$s and $BB$s (and so are their primes)....
• 121
47 views

### Variation of Lagrangian with respect to components of inverse of metric tensor

I am super new to Mathematica, so I apologize if the question is trivial. I have defined metric tensor (4x4 matrix), inverse metric and Lagrangian: ...
28 views

### Symmetric expression not recognized

Why the following symmetric tensor is not recognized by TensorSymmetry? ...
• 1,054
1 vote
48 views

### Operations on symbolic tensors

I have recently discovered the set of functions related to symbolic tensors, namely TensorProduct, TensorContract, ...
• 1,054
1 vote
104 views

### Product involving Kronecker Deltas

I am trying to do some products involving some objects made out of Kronecker deltas. For example, taking an object like $x_{abcd}=\delta_{ab}\delta_{cd}$, where all the indices run from $1$ to $N$, I ...
• 15
97 views

### How to define a Kerr-Schild metric in xAct?

A Kerr-Schild can be expressed as $g_{ab}=\eta_{ab}+\phi k_a k_b$, where $\eta_{ab}$ is Minkowski metric, $\phi$ is a scalar function and $k_a$ is a (co)vector field which is null and geodetic with ...
• 21
1 vote
68 views

### Finding Petrov type of a metric

Is there a subpackage in xAct (or another Mathematica package for general relativity calculations) to determine the Petrov type of a metric? I understand that xAct has a lot of subpackages for ...
83 views

### How to write the metric tensor in n-dimensions using xAct?

I am trying to reproduce some calculations from a paper, where they express the angular part of the metric as a solid angle in (d-2) dimensions: where I know how to calculate the metric tensor using ...
169 views

### Efficient way to MapApply for Tensor

I need to Map a function with certain arguments $f(\alpha,\beta,\gamma,\delta)$ onto a whole tensor. My current approach looks like ...
• 124
115 views

### Implementing symmetry assumptions in FullSimplify

I want to symmetrise a long expression, M, that involves a function of 4 arguments, f[u1,u2,d1,d2], and its products (for ...
• 389
1 vote
69 views

### Calculating the orthonormal frame of a metric in Mathematica

Let us have a given a general metric (like say Kerr metric) of which I want to find the orthonormal coordinates by developing a general code in Mathematica. One of the reliable method to do this (by ...
• 175
1 vote
70 views

### What is the right way to simplify a tensor expression (with many indices, but no derivatives) in Mathematica?

After not finding the desired capabilities in base Mathematica, I am trying to use xAct`xTensor package. It appears that I do not need most of it capabilities ...
• 166
91 views

### Simplification of Momentums in FeynCalc

I have a little problem involving the following contraction in FeynCalc: $$\frac{k^{\delta}k^{\sigma}}{k^2}$$ By hand one would lower $\sigma$ and contract with the other momentum to cancel $k^2$, ...
607 views

### How can I "multiply" nested lists?

Given two nested lists alist={{a,b,c},{d,e,f}} blist={{r,s,t},{x,y,z}} How can I get ...
• 747
1 vote
63 views

### How to multiply five tensors of different ranks (contravariant, covariant and mixed) in Mathematica?

How to compute the following multiplication of five different tensors of different ranks in Mathematica ...
• 135
107 views

### Symbolic matrix tensor an identity without specifying the dimension?

I want to calculate an expression like $\left( M_1\otimes I+I\otimes M_2 \right) ^l$ with $M_i$'s symbolic matrices and $I$ the identity matrix with Mathematica. $M_i$'s are of the same dimension and ...
• 261
1 vote
107 views

### TensoriaCalc does not display the correct output

I am trying to use TensoriaCalc to calculate the components of the Ricci and the Riemann tensor of the following metric: $R^{2} \left(d\theta^{2} + \sin^{2}\left(\theta \right)d\phi^{2} \right)$; ...
• 113
1 vote
93 views

### Mathematica, ML and TensorFlow

I am currently studying a specialization on Coursera in Machine Learning and am investigating various tools to help me out with the maths and with visualisations and so on. Although I have many ...
• 111
45 views

### How to access row of a 6 dimensional tensor fast?

I have a data set in 2D array form ...
• 403
59 views

### Quickly summing matrix elements

I have a pair of rank-4 tensors, (T,V), where each index takes four values. I want to quickly contract these with the rank-4 antisymmetric tensor using the following operation: ...
• 647
51 views

### Polar to Cartesian coordinate transformations [duplicate]

I'm trying to plot the energy boundary function EBminus[r, \theta, LL, S, BB] using Polar to Cartesian coordinate transformations. The plot should be a closed curve....
• 87
120 views

### Pathological expression for field strength contractions in a curved background

I am trying to define in Mathematica the quantity $\star F^{\mu}=\frac{1}{2}\epsilon^{\mu\alpha\beta}F_{\alpha\beta}$, where $F_{\mu\nu}=\nabla_\mu A_\nu-\nabla_\nu A_\mu+\left[A_\mu,A_\nu\right]$. ...
35 views

### Simulation of Quantum pseudo-telepathy

I would like to mathematically simulate Quantum pseudo-telepathy on The magic square game from Wikipedia. In section Pseudo-telepathic strategies we can read: The trick is for Alice and Bob to share ...
• 9,653
38 views

### Why is TensorContract[x, {}] not always x?

If I use TensorTranspose on an undefined symbol, nothing happens unless the permutation is the identity. For instance, ...
• 228
1 vote
68 views

### Tensor equation problem (xact package)

So i want to solve the tensor equation P1[-μ,-ν]=0 with respect to A[r] and then B[r] but the problem is when hitting shift-enter the tensor given is way too long (if i press "show all" my ...
• 11
124 views

How can one do a fast sparse tensor addition? Below, I have the following code: We first generate 3 random sparse 1000x1000x1000 tensors with 10^6 entries each. Then, I want to add them. But the usual ...
1 vote
190 views

### How to define a traceless tensor with xAct

I would like to define a tensor $A_i^j$ which is traceless ($A_i^i = 0$) and to obtain $A_i^j \delta^i_j = 0$ with xAct / xTensor / xCoba. I first tried defining an antisymmetric tensor, since they ...
• 386
502 views

### Code for Tensor decomposition

I would like to know if there is a package or some MMA code to perform tensor decomposition as e.g. defined in a paper by Robeva "Orthogonal decomposition of symmetric tensors" or some ...
76 views

### "Symmetrize" shall symmetrize only tensor values $\ne 0$

Using Symmetrize I want to transform a tensor to be symmetric under all index permutations for all original entries $\ne 0$. However each entry is normalized by the ...
181 views

• 167
78 views

### Certain block matrix

A block matrix like $$m_{(ij),(kl)}=\delta_{ik}\delta_{jl}$$ can be constructed as L=3; id=IdentityMatrix[L]; m=KroneckerProduct[id, id]; But how to construct m_{...
• 17.7k
1 vote