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
2 votes
1 answer
78 views

How to transform a tensor (for example, the second order identity tensor) or matrix from cartesian coordinates to cylindrical coordinates?

First, I believe the unit tensor is a diagonal tensor with diagonal elements of 1, regardless of whether it is in Cartesian coordinates or cylindrical coordinates. Then, I wanted to verify this using ...
xinxin guo's user avatar
  • 1,323
0 votes
1 answer
64 views

Gradient of tensor expressions

I would like to compute gradients of tensor expressions without having to instantiate particular tensors and for arbitrary sizes. Example 1 : For example, let's say I want to minimize $C=\sum_j(\sum_i ...
Nichola's user avatar
  • 101
0 votes
0 answers
43 views

Christoffel symbol of 2nd kind [duplicate]

How to calculate Christoffel symbol of 2nd kind for a given metric tensor in Mathematica ? I tried a few programming but I'm not getting desired output .
Biswajit Deka's user avatar
1 vote
1 answer
51 views

NonCommutativeMultiply in Matrix Multiplication

Is there a way to preserve the order of elements in the multiplication of matrices when the elements themselves are matrices? For example, if I have: ...
Matthew Crawford's user avatar
0 votes
1 answer
40 views

A problem with indices in tensor

I want to create a tensor similar to the one shown in the first picture, but I'm encountering some issues with indices. Could anybody assist me? Here's my code: ...
Ali Bizhanpour's user avatar
2 votes
0 answers
49 views

Defining a tensor in terms of its trace and other tensors

I'm starting to learn xAct for tensor operations. So I am dealing with 3 tensors: $T_{abc}$, $Q_{abc}$ and a metric tensor $g_{ab}$; with these tensors I have an equation like $$T_{abc} = Q_{abc} + ...
ayberk çakmak's user avatar
0 votes
0 answers
50 views

Tensor product with zero

I am calculating the huge sums, that include tensor products and I noticed that Mathematica does not simplify the tensor products of the form $A \otimes 0 \otimes C$, and also it does not simplify the ...
Norton's user avatar
  • 1
0 votes
0 answers
41 views

Perturbing a tensorial expression

I am new to Mathematica. I am trying to simplify an expression of the some form like: $$ n_i \sigma_{ij} n_j - \gamma n_i \hat{\sigma_{ij}} n_j = 2 + v_i x_i + \kappa E_{ij} \chi_{ji} $$ There are ...
fiarast11's user avatar
0 votes
0 answers
64 views

How to find linearly dependent eigenvectors of non-diagonalizable matrix (with exceptions)?

Here is the code to produce a $9\times9$ matrix: ...
ZHENGYAO HUANG's user avatar
2 votes
1 answer
59 views

Handling different kind of indices in single tensor equation

I want to solve the following differential equation, $$\partial_a (\sqrt{h} \, h^{a b} \partial_b X^{i}) = 0$$ where $$X^i \equiv \{X^1(\sigma^1, \sigma^2), X^2(\sigma^1, \sigma^2), X^3(\sigma^1, \...
Physics Moron's user avatar
3 votes
1 answer
80 views

Make the ```*``` operation the Kronecker product by default for Kets?

So given two "Ket" objects, u = Ket[{-1/2}]; d = Ket[{1/2}]; Is there a way to define multiplication, *, so that by ...
AlkaKadri's user avatar
  • 131
0 votes
1 answer
56 views

Optimized and compact code for tensor product

I am calculating products like in mathematica. In the given relations eta's are four vectors, $\gamma$'s are the Dirac matrices, $\sigma^{\mu\nu}$ is the anticommutation of the gamma matrices and ...
Zohaib Aarfi's user avatar
0 votes
1 answer
57 views

Permute subsystems of a matrix?

Suppose I have a matrix $M$ acts on the space $\mathbb C^4\otimes \mathbb C^2\otimes \mathbb C^4\otimes \mathbb C^3$. Is there a method to permute the 2nd subsystem of $M$ and the 4th subsystem of $M$?...
narip's user avatar
  • 381
0 votes
1 answer
114 views

How to calculate this covariant derivative?

I try to calculate the covariant derivative: $ \nabla_\beta \partial_\alpha~ \phi = \partial_\beta \partial_\alpha~ \phi + \Gamma^\sigma_{\beta\alpha} ~\partial_\sigma~ \phi $ Where $\phi$ is a ...
Dr. phy's user avatar
  • 285
3 votes
0 answers
139 views

Using ChatGPT to write Mathematica code with the Ricci package [closed]

I generally use ChatGPT to write mathematica code for me. However, now I want to use a Mathematica package called Ricci. Whenever I try to ask ChatGPT to write me mathematica code using that package, ...
matilda's user avatar
  • 39
1 vote
1 answer
76 views

Metric tensor coordinate transformation with off-diagonal components

I know there is already an answer for this type of question given here: Computing the metric tensor under a coordinate transformation but the answer is not satisfactory as it is not clear to me how I ...
MathZilla's user avatar
  • 123
0 votes
1 answer
75 views

Adding a symbolic tensor and a specific one

I need to add a symbolic tensor and a specific one, but it seems the symbolic tensor is always treated as a number and is added in very components of the specific tensor. Firsts I give assumptions <...
DarkGlimmer's user avatar
0 votes
1 answer
102 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 ...
Dr. phy's user avatar
  • 285
0 votes
0 answers
53 views

Calculating and collecting the terms of the zero component of the Einstein’s tensor

I try to calculate the $G_{00}$ of the Einstein tensor $G_{\mu\nu}= R_{\mu\nu} -\frac{1}{2} g_{\mu\nu} R$ for the metric: $g_{00}=-a^2(\tau)\left( 1+2 \phi^{(n)}\right),$ $g_{0i} = a^2(\tau)\left( \...
Dr. phy's user avatar
  • 285
0 votes
0 answers
71 views

How to calculate Einstein tensor components for this metric?

I try to calculate the Einstein tensor compenents from the eqution: $ G_{\alpha\beta} = \frac{\nabla_\beta (\partial_\alpha \phi)}{\phi} - \frac{1}{2\phi^2} \left[ \frac{\partial_4 \phi \partial_4 g_{\...
Dr. phy's user avatar
  • 285
2 votes
1 answer
86 views

How to create a vector as a tensor object for different euclidean bases?

The components of a tensor are always displayed with respect to one or multiple basis vectors. For a tensor of rank 1, a vector, in 3D-euclidean space, we resort to three orthonormal basis vectors. ...
ango4's user avatar
  • 45
2 votes
0 answers
60 views

Calculating the strength tensor of a vector field

I'm trying to calculate $$T_{ab} = g_{ab}F_{gd}F^{gd} - F_a^g F_{bg},$$ where $$F_{ab} = \partial_a A_b-\partial_b A_a$$ So I define $F_{ab}$ by: ...
Dr. phy's user avatar
  • 285
0 votes
1 answer
117 views

Is there a good package for solving the Einstein field equations given a metric tensor?

I have a very simple metric tensor. I've built a notebook to calculate the EFE solutions based on this metric. Does anyone know of a good package in the Mathematica library that takes a metric tensor ...
The Shepard's user avatar
0 votes
0 answers
102 views

Metric pertubation in xAct

I start to learn xAct. Following this thread: expanding-the-riemann-tensor-perturbation I noticed that xAct set a default perturbation to the metric by: ...
Dr. phy's user avatar
  • 285
1 vote
1 answer
103 views

Which Slots Are Which? Tensors

I'm trying to verify a calculation in Mathematica and I'm confused about how Mathematica arranges tensor "slots" for contractions. I have the matrix $$J_1 = \begin{pmatrix} 0 & -ih & ...
mijucik's user avatar
  • 157
0 votes
0 answers
149 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 ...
Dr. phy's user avatar
  • 285
0 votes
0 answers
36 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: ...
Sooner's user avatar
  • 387
0 votes
1 answer
127 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 ...
The Shepard's user avatar
1 vote
1 answer
184 views

Calculating Einstein tensor components in Kaluza-Klein model

I try to calculate the Einstein tensor of Kaluza-Klein model from this paper. It is given by Equation (55) $ G_{\alpha\beta} = \frac{\nabla_\beta (\partial_\alpha \phi)}{\phi} - \frac{1}{2\phi^2} \...
Dr. phy's user avatar
  • 285
4 votes
1 answer
726 views

What are some Mathematica packages used for general relativity?

Could you suggest any Mathematica packages that are used for General relativity calculations? Id like to write code to solve the Schwarzchild Lagrangian equation.
Rishabh sharma's user avatar
0 votes
0 answers
33 views

Tensor Algebra of Symmetric Algebra with Symoblic Tensors

Given $V=\mathbb{R}^3,$ I would like to work symbolically with elements of $\mathrm{T}^{(k_1,\dotsc,k_n)}(\mathrm{S} V),$ i.e. vectors of the form $$\phi = \phi_1 \otimes \cdots \otimes \phi_n$$ with $...
Marvin Dippell's user avatar
2 votes
2 answers
185 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, ...
Hawi's user avatar
  • 173
1 vote
1 answer
92 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)....
Tom's user avatar
  • 121
0 votes
0 answers
69 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: ...
DanielP's user avatar
0 votes
0 answers
28 views

Symmetric expression not recognized

Why the following symmetric tensor is not recognized by TensorSymmetry? ...
enzotib's user avatar
  • 1,094
1 vote
0 answers
72 views

Operations on symbolic tensors

I have recently discovered the set of functions related to symbolic tensors, namely TensorProduct, TensorContract, ...
enzotib's user avatar
  • 1,094
1 vote
3 answers
137 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 ...
dorrel's user avatar
  • 49
2 votes
0 answers
139 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 ...
Dongba's user avatar
  • 21
1 vote
0 answers
77 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 ...
jay121's user avatar
  • 43
0 votes
0 answers
136 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 ...
Matheus Macêdo's user avatar
2 votes
1 answer
184 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 ...
mathetronaut's user avatar
5 votes
3 answers
121 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 ...
jms547's user avatar
  • 399
1 vote
1 answer
78 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 ...
SCh's user avatar
  • 175
1 vote
1 answer
85 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 ...
fiktor's user avatar
  • 166
0 votes
0 answers
115 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$, ...
bocchi's user avatar
  • 1
8 votes
4 answers
614 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 ...
1729taxi's user avatar
  • 767
1 vote
0 answers
68 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 ...
Sangeeta Dey's user avatar
2 votes
2 answers
122 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 ...
narip's user avatar
  • 381
1 vote
1 answer
124 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)$; ...
RKerr's user avatar
  • 113
1 vote
0 answers
122 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 ...
serlingpa's user avatar
  • 111

1
2 3 4 5
11