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
1 answer
41 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
0 votes
0 answers
48 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$, ...
  • 1
8 votes
4 answers
583 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 ...
  • 717
1 vote
0 answers
57 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 ...
2 votes
2 answers
82 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 ...
  • 135
1 vote
1 answer
67 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)$; ...
  • 111
1 vote
0 answers
53 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
0 votes
0 answers
40 views

How to access row of a 6 dimensional tensor fast?

I have a data set in 2D array form ...
  • 403
4 votes
1 answer
56 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
0 votes
0 answers
49 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
2 votes
1 answer
111 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]$. ...
2 votes
0 answers
31 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 ...
  • 5,915
3 votes
0 answers
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
0 answers
35 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
7 votes
1 answer
107 views

Fast Sparse Tensor Addition

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
1 answer
88 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 ...
1 vote
2 answers
411 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 ...
3 votes
2 answers
69 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 ...
0 votes
1 answer
93 views

Is there a way of calculating Expectation Values of tensor operators in Mathematica?

This Wikipedia article in on Bell's Theorem lists a whole bunch of expectation values for Bell states: $$\langle A_0 \otimes B_0 \rangle = \frac{1}{\sqrt{2}}, \langle A_0 \otimes B_1 \rangle = \frac{1}...
  • 243
4 votes
2 answers
325 views

Torch-like permutation for arrays?

Update: edited to clarify my confusion. In Mathematica Transpose[] operates like this: ...
  • 73
4 votes
2 answers
124 views

Symmetric product

Let define the full symmetrization of a tensor $e_1 \otimes ... \otimes e_N$ by $$ Sym : e_1 \otimes ... \otimes e_N \rightarrow \frac{1}{N!} \sum_{\pi \in S_N} e_{\pi^{-1} (1)} \otimes ... \otimes e_{...
  • 167
2 votes
1 answer
76 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_{...
  • 17k
1 vote
0 answers
74 views

Error message installing Ricci

I just started using Mathematica. With the goal of solving a Loop integrals over a scalar gravity interaction. For the tensor calculus necessary i wanted to use, Ricci. https://sites.math.washington....
2 votes
1 answer
56 views

How to generate a tensor by a given list, which specifies the ranges and dimensions of the tensor?

I am trying to create a function that generates a tensor according to a list, each of whose elements specifies the range of the corresponding dimension of the tensor and whose length specifies the ...
  • 23
2 votes
1 answer
114 views

Reshape a tensor to a matrix

I have a tensor T = Array[Subscript[K, ##] &, {2, 2, 2, 2}] And its matrix form is $$ \left( \begin{array}{cc} \left( \begin{array}{cc} ...
  • 23
4 votes
1 answer
67 views

xAct define normalization

I'm trying to get out some equations in the xAct suite. I would like to somehow define that the norm of a vector is a constant. ...
  • 438
4 votes
3 answers
159 views

Using Flatten inside NDSolve

I'm using Flatten to contract a rank 4 tensor and a matrix (rank 2 tensor) inside NDSolve and there seems to be error. Here is ...
  • 65
0 votes
0 answers
29 views

Using Manipulate to both change tensor elements and select different tensors

I want to display three different tensors after I transform them within the manipulate function I have three tensors that I want to transform, C1, C1h, and C2, then change through with a PopUpMenu to ...
  • 27
1 vote
1 answer
84 views

How to produce plots determined by tensor element manipulate function

I want to produce plots within the manipulate function, with the functions determined by the values that I use in the manipulate function. I've gotten the tensor elements to work fine in producing the ...
  • 27
0 votes
1 answer
56 views

Symbolic re-assignment of products

Suppose I have some symbolic tensors $X,Y$ and I want to assign X.Y into something else without specifying what $Y$ is. For example, I may want $Y$ to serve as ...
  • 242
0 votes
0 answers
19 views

How to get simplified output of tensor mode product [duplicate]

The code PolarizationiC1 = MatrixForm[chiprimeC1 . Epin] . Esin; The result If I run the result, then I get the simplified answer of ...
  • 27
1 vote
1 answer
75 views

How to make an inverse operation to `KroneckerProduct[A, IdentityMatrix[m]]` (simplify matrix)?

The operation KroneckerProduct[A, IdentityMatrix[m]] expands the matrix A in the following way (depending on order of ...
  • 3,399
0 votes
1 answer
90 views

How to untensor a tensor?

What should I do to convert a matrix of matrices to a non-nested matrix? $\left( \begin{array}{cc} \left( \begin{array}{cc} {a_1} & {b_1} \\ {c_1} & {d_1} \\ \end{array} \right) & \left(...
  • 3,399
1 vote
3 answers
107 views

How can I realize this matrix product (dot product of matrices of different orders)?

The matrix multiplication of square matrices of different order is often claimed to be impossible. Yet, if the order of one matrix is divisible by the order of the other, a natural multiplication rule ...
  • 3,399
3 votes
1 answer
161 views

How to define a Tensor with the symmetries like Riemann tensor?

I want to define a tensor that has the first two symmetries of Riemann tensor or maybe the last two. The symmetries of Riemann tensor are: 1) $ R_{\alpha\beta\gamma\lambda}=R_{\gamma\lambda\alpha\beta}...
  • 111
9 votes
3 answers
164 views

Doing ArrayReshape in Mathematica doesn't give desired results

I have an array like this for example, a = ArrayReshape[Range[16], {4, 4}] \begin{align} \left( \begin{array}{cccc} 1 & 2 & 3 & 4 \\ 5 & 6 & ...
  • 549
0 votes
0 answers
43 views

Output of expressions unable to have operations be performed on the expression

I am currently trying to use the code linked in the catalog of spacetimes pdf to calculate chirstoffel symbols for a metric which follows as n := 4 ...
  • 119
0 votes
1 answer
189 views

Covariant Derivative

I'm trying to create a function which receives as inputs a coordinate system $x^\mu$, metric tensor $g_{\mu\nu}$, a general tensor $T$ of rank $n$, and a list $I$ of length $n$ that looks like this: $$...
  • 123
0 votes
0 answers
104 views

Variation with respect to inverse metric in a Lagrangian density

I am trying to vary the following Lagrangian density with respect to the inverse metric appearing in the equation, but I am having trouble with how to write the right code in Mathematica. I have ...
  • 1
3 votes
2 answers
134 views

Set of quadratic forms and linear algebra

I have a set of quadratic forms. $L_{1}=u_1^TJ_{1}u_1$ $L_{2}=u_2^TJ_{2}u_2$ $L_{3}=u_3^TJ_{3}u_3$ where $u_{i=1,2,3}$ - 3$\times$1 vector; where $J_{i=1,2,3}$ - 3$\times$3 matrix; I need to pack ...
  • 2,304
4 votes
1 answer
142 views

Tensorial calculus: A question about free and summed indices

I have to start with a full disclosure that I'm new to Mathematica, so this might be easy to resolve in a way that I don't know. I have to implement a triple contraction of an order three tensor $$d^{...
  • 243
4 votes
2 answers
159 views

Create a tensor with a well defined symmetry

I want to create a symmetric rank four tensor with this kind of symmetry: {1,2} and {3,4}. How can I implement this using "Array"? ...
1 vote
1 answer
130 views

How to compute the divergence of a four-vector?

I have a quadri-vector which is given by u = {(E^(-φ0[r]))*(1 - ε δφ[t, r]), (E^(-φ0[r])) D[ε ξ[t, r], t], 0, 0} and a quantity n which is given by <...
0 votes
1 answer
183 views

Mathematica: Partial derivative with respect to tensors

Anyone know how to do the partial derivative of a tensor in d dimensions on Mathematica ? I want to implement something which will calculate directly like that :
0 votes
4 answers
86 views

How to sum over a two tensor with a simple constraint of the form $i<j$?

I am trying to write a sum of the form $$\sum_{i<j}f_{ij}$$ where $i,j\in \{1,2,3,4\}.$ I want to write something like Sum[f[[i,j]], {j,1,4},{i,1,j}] but then ...
  • 93
4 votes
0 answers
176 views

Manipulating tensorial terms with xAct, ToCanonical is not perfoming well

I am trying to calculate perturbations of some complicated Lagrangians. Using xAct and more specifically VarD to perform the perturbations the expressions become ...
  • 41
3 votes
1 answer
192 views

Creating a rank 4 tensor

I am struggling with creating the rank-4 matrix T in Mathematica. The matric is defined as $T_{i,j,k,l}= n_i n_j n_k n_l-(\delta_{i,j} n_k n_l +\delta_{i,k} n_j n_l+\delta_{i,l} n_k n_j+\delta_{j,l} ...
  • 131
1 vote
2 answers
699 views

How do I get the Schwarzschild solution from the Einstein Equations?

Consider the Schwartzchild-like metric $$ds^2=-A(r)dt^2+B(r)dr^2+r^2(d\theta^2+\sin^2\theta d\phi^2).$$ The Einstein field equations for this metric reduce to $$R_{\mu\nu}=0,$$ which is also known as ...
  • 119
0 votes
1 answer
497 views

How to do Einstein Summation in Mathematica?

I am working with the de Sitter metric which takes the form $$g=\tau^{-2}\left(-\left(\Lambda / 3-\tau^{2}\right)^{-1} d \tau^{2}+\left(\Lambda / 3-\tau^{2}\right) d t^{2}+g_{\mathbb{S}^{2}}\right)$$ ...
  • 93
1 vote
1 answer
102 views

Simple and efficient construction of tensor product operators

Problem Description I'm using mathematica to study a problem in quantum mechanics, which is naturally understood in terms of vector spaces. In the simplest example, suppose we have a 16-dimensional ...
  • 647

1
2 3 4 5
10