Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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.

298 questions
Filter by
Sorted by
Tagged with
20 views

Derivatives with dummy indices not commutative after 3d derivative?

Recently I've encountered the following issue in xAct. I've defined the Manifold and tensors in the following manner Then consider the following expressions. In the case where there are 2 ...
15 views

Hamiltonian Analysis in xAct: Variation wrt time derivative of fields

I'd like to use the xAct package to perform the Hamiltonian analysis of a complicated action. To that end, it would be useful to introduce a chart and split indices into "temporal" and "spatial" parts....
66 views

Reduce memory cost with three matrices multiplication

My program is eating up all my RAM and the operation is related to 3 matrices multiplication, as the code shown below. example code: ...
38 views

FromTensor + TensorContract gives unexpected result for a tensor product of vectors and a matrix

I have written a larger code that uses the TensorSimplify package written by Carl Woll for tensor manipulations. The code, however, produces unexpected results, ...
112 views

50 views

How to multiply the elements of each site of tensor products to each other while using symbolic representation?

If I have, say three sites in a symbolic operator which is of the form A = a⊗1⊗c and I want it to act on another operator B = a1⊗b⊗1 in order to find the commutator A.B - B....
24 views

Contracting the KroneckerDelta should bring it back

I would like to define a function $$V[\phi] = \sum_{1\leq i,j,k,l\leq dim}\lambda_{ijkl} \phi_i\phi_j\phi_k\phi_l,$$ with $\lambda_{ijkl}$ defined by contractions of the type $\delta_{ij}\delta_{kl}$...
33 views

Computing Higher Order Tensor of Variable Rank

The following code takes a vector x of variable length, computes the outer product of the vector with itself to form the matrix $\rho$ of dimension $2^n \times 2^n$....
60 views

How to Creat a Symbolic Rank 4 Symmetric tensor

I would like to create a rank 4 symbolic tensor with this symmetries (1) C_ijkl = C_jikl (2) C_ijkl = C_ijlk (3) C_ijkl = C_klij is there any way to apply symmetry (3)? symmetry (1) and (2) can ...
40 views

Higher Order Tensor of Variable Rank

I would like to write a function, that matricizes a higher order tensor according to the following rule: Let $\mathcal{A} \in \mathbb{C}^{I_{1} \times I_{2} \times \ldots \times I_{N}}$ be a tensor ...
41 views

Independent permutation symmetry of a tensor [Using TensorSymmetry command]

Suppose I have this tensor $A_{ijkl} = \epsilon_{ik} \epsilon_{jl}+\epsilon_{il} \epsilon_{jk}$. Now I want to find all the independent permutation symmetries of the indices of this tensor. The answer ...
72 views

How do I force this simplification?

I am trying to calculate:$$\epsilon_{ijk}n^iM1^j\epsilon^{lmk}n_lM2_m$$ Defining the vectors as: M1={M1x,M1y,M1z} M2={M2x,M2y,M2z} n={nx,ny,nz} and using ...
52 views

How to define commutative covariant derivatives in xTensor

I'm new with working xAct package and got stuck defining covariant derivatives that commute with each other. I want to simulate flat space-time. And here is my code ...
52 views

How do I prove this formula with LeviCivitaTensor?

How do I prove that $$\epsilon_{ijk}\epsilon^{ijm}=2\delta_k^m ?$$ If I use ...
374 views

How can I automate this tensor computation?

I am doing this work by hand, but it takes a lot of time and I make several calculation errors, so I was thinking to make Mathematica to calculate this for me, but I am stuck at the very beginning. I ...
98 views

Symbolic multiplication of tensors

I am trying to do symbolic calculations on Pauli Matrix Algebra. I want to find some way of making CircleTimes[a,b] ** CircleTimes[c,d] map to CircleTimes[a.c,b.d] for every a,b,c,d. I would also like ...
131 views

26 views

Inverse fuction of TensorExpand

Is there a way in mathematica to factorize/simplify a dot product? I.e. I have something like a.b + a.c (obviously more complicated expressions) and I would like to factorize terms like ...
559 views

Make symbols atomic, without losing their type

So, I'd like to define a matrix M, that does not decompose into it's constituents when I do things like Tr[M], but I also want it's type to be retained. (By type, ...
49 views

Print 4x4x4x4 tensor as 4x4 matrix of 4x4 matrices [closed]

I'd like to print the LeviCivitaTensor tensor as 4x4 block matrix of 4x4 matrices The following code works to display the LeviCivitaTensor tensor as a 3x1 vector of 3x3 matrices. ...
56 views

CompiledFunction::ctfa - Argument should be a rank 4 tensor of machine-size real number

Dear Mathematica community, I got the following error line: CompiledFunction::ctfa "Argument {<<1>>} at position 1 should be a rank 4 tensor of machine-size real number" This is my function:...
99 views

xAct, xTensor: How to avoid clash of indices?

Please refer to the picture below. In the first line, I define the angular momentum vector $\vec{L} = \vec{R} \times \vec{P}$ using the Levi-Civita tensor $\epsilon^{i}_{jk}$. The definition relies on ...
53 views

Lie-algebra valued non-abelian differential forms in Mathematica

I am trying to implement wedge product of Lie-algebra valued differential forms in the non-abelian case. Concretely, I am intereste in 1- and 2-forms, that is, $A$ and $F$. Is there a way of doing ...
84 views

Outer (dyadic) product between vectors of the same index in two lists

I have two lists of vectors and I want to take the outer product between elements in the lists of the same index. Using either Outer or TensorProduct works for e.g. the first two indices: ...
32 views

TensorReduce causes “inhomogeneous dimensions” error [on hold]

I want to use TensorReduce to realize the following property of wedge: ...
47 views

How to keep the form of tensor wedge, instead of using tensor product?

Why is an expression with full form of TensorProduct[TensorWedge[v1, v2], w1] changed into ...
67 views

Efficient computation of matrices involving large sums of KroneckerDelta's

I was wondering if one could benefit from Mathematica's rich linear algebra methods for diagonalizing 2nd rank tensors. Namely, in the context of systems (fluids) comprised of capsule-like particles, ...
107 views

How to construct — based on physics-type notation — a magical simplex $\mathcal{W}$ of bipartite qutrits?

I have a short Mathematica program: ...
37 views

Maximally expand tensor series?

I am trying to obtain a power series expansion in some real parameter, but all the terms are arbitrary products of tensors. I.e. I want to expand an expression containing sums/products/powers of this ...
56 views

Contraction of square tensors

Let there be tensors A and B A = Outer[Times, {1, 0}, {2, 0}] B = Grad[{f[x, y], g[x, y]}, {x, y}] with output ...
118 views

43 views

How to save a multidimensional matrix in separated files for each dimension

I need to export to a file a multidimensional matrix, each dimension to a file. For example: ...
96 views

Exporting a tensor

I have a complicated and large tensor what can be shown in the simplest form as follows How can I export it in this form?
86 views

Lowering the index of the Riemann curvature tensor in Mathematica

I am looking to do some calculations in GR. For a given metric, I can calculate the affine connection and the Riemann tensor as, ...
85 views

I want to perform a simple tensorial contraction

I want to perform a simple tensorial contraction like, if KroneckerDelta[i, j] is contracted with some arbitrary tensor A_{lkj} (not-necessarily symmetric) it should give the answer as A_{lki}. Is ...
161 views

How does one plot a 3 dimensional table of numbers?

I've just spent three hours searching the documentation and this website for an answer. I have a rank 3 tensor: t = {{{1, 2}, {3, 4}}, {{5, 6}, {7, 8}}} How ...
46 views

\[CircleTimes] (tensor symbol use) in infix conversion (solved)

Reformulated problem. I am using the code: ...
871 views

What is the definition of Curl in Mathematica?

I have a usual mathematical background in vector and tensor calculus. I was trying to use the differential operators of Mathematica, namely Grad, ...
88 views

Evaluating covariant derivative for perturbed metric given background metric

I want to use Mathematica to evaluate an expression like; $h^{\alpha\beta}_{\,\,\,\,\,|\mu}h_{\alpha\beta\,|\nu} +\mbox{similar}$ where $h_{\alpha\beta}$ is the perturbation to a specified metric (...
131 views

How to apply Partial differentiation w.r.t. tensors?

Let's say I have an expression like $\,a^{I}=2b^{I}+3c^{I}$ where $I$ stands for an arbitrarily large set of indices. It's known that $\,\frac{\partial a^K}{\partial c^{L}}=3\,\delta^K_L$ (equals a ...
42 views

Why doesn't this Kronecker Product work with columns, but with rows?

Using the formula given in this math.stackexchange answer by the user greg \eqalign{ vec(M\otimes dK) &= \left(\pmatrix{I_T\otimes (M \cdot e_1)\cr I_T\otimes (M \cdot e_2)\cr \vdots \cr I_T \...
47 views

Typography of Mixed Tensor Index Notation

How can one properly and quickly write a mixed "tensor" such as $\Gamma{}_{1}{}^{2}{}_{3}$? Shortcuts such as esc Gamma esc, Ctrl+^, Ctrl+_ are prefered. I intendd to use this in an inline equation ...
36 views

Obtain argument of tensor product

I want to obtain the argument of a TensorProduct as a list of elements by applying another function. For example, I wish to write a function h which, when applied to a tensor product, produces the ...
I have a scalar function defined on a $n$-dimensional manifold: $f(x_1, x_2, ..., x_n)$, where $n$ is undefined, and $x_i$ are the coordinates. How to define something like "$∂_af∂^af$"? (I'm ...