Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
2answers
101 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 ...
0
votes
1answer
37 views

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

Reformulated problem. I am using the code: ...
16
votes
3answers
643 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, ...
1
vote
0answers
14 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 (...
2
votes
1answer
52 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 ...
3
votes
1answer
27 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 \...
1
vote
0answers
34 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 ...
2
votes
1answer
28 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 ...
1
vote
0answers
50 views

Solving the values of Christoffel symbols from a given metric tensor

Is there any easy mathematica package by which I can solve the Christoffel symbols from a given metric tensor?
0
votes
1answer
57 views

Derivative of a function in undefined dimension

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 ...
2
votes
2answers
95 views

Kronecker product $ n $ matrices

I would like to write code to realize the Kronecker Product of $ n $ matrices, for instance when $ n=4 $ and the matrices are Pauli matrices ...
0
votes
1answer
56 views

Define tensor as a derivative

I have the tensor which is expressed in terms of coordinate vector. I want to define tensor which is the derivative of the former tensor with respect to the coordinate axis: $$ X = (x_1, x_2, x_3) ...
1
vote
0answers
56 views

Tensor Contraction Speed Up (Matrix Product States)

I'm recently trying to implement some tensor contractions in Mathematica for use in Matrix Product State algorithms. Here's the operation I want to perform $$ M^{\sigma_{i}\sigma_{i}'[i]}_{(b_{i-1},...
2
votes
0answers
56 views

Exterior products of differential forms

In $ \mathbb{R}^4 $ I have the forms $ \omega_1=z\;\mathrm dx+t\;\mathrm dy+x\;\mathrm dz+y\;\mathrm dt $ and $ \omega_2=t\;\mathrm dx+z\;\mathrm dy+y\;\mathrm dz+x\;\mathrm dt$. I want to compute ...
1
vote
0answers
44 views

Calculating Christoffel Symbols [duplicate]

I am totally new in the astrophysics field and I need to calculate Christoffel symbols for a model. The line element for the FLRW metric and the geodesic equation is given below: ...
3
votes
1answer
77 views

Symbolic decomposition of a tensor given an assumption

I am relatively new to Mathematica. Suppose I have a matrix M = {{a^2, a b, 0}, {a b, b^2, 0}, {0, 0, 0}} How can I get Mathematica to decompose this into an ...
3
votes
4answers
160 views

Fast way to create $[ I_4\otimes e_1,\ \dots ,\ I_4 \otimes e_T]$?

Is there a fast way to construct this matrix? $\left[\begin{array}{c} I_4\otimes e_1\\ \vdots \\ I_4 \otimes e_T \end{array}\right]$ $e_i$ is the $i$-th column of the matrix $I_T$, $\otimes$ is the ...
2
votes
2answers
122 views

Problem verifying expression with 3D vectors

I am unable to verify that my vector expressions are equivalent. I want it to say true or false. ...
4
votes
2answers
87 views

Explicitly construct tensor quantities with given symmetries

I am trying to use mathematica to generate explicitely a tensor. I know multiple thing about it. Let's call it $C_{\mu\nu\lambda\sigma}$. This guy has to be symmetric in the two first indices ${\mu,\...
4
votes
1answer
146 views

Summation of Kronecker deltas should give the dimension

I have a really simple problem but I don't know how to solve it. Basically, I am doing vecor manipulation and I am summing a lot of Kronecker delta here and there. How can I teach Mathematica that for ...
1
vote
1answer
45 views

Speed up construction of large matrix with if statements

I am constructing a matrix of the form $$ T_{i_aj_ak_al_a,i_bj_bk_bl_b} = T_{i_ai_b}\delta_{j_aj_b}\delta_{k_ak_b}\delta_{l_al_b} + T_{j_aj_b}\delta_{i_ai_b}\delta_{k_ak_b}\delta_{l_al_b} + T_{k_ak_b}\...
2
votes
1answer
218 views

Multidimensional MATLAB conversion

I try to convert this MATLAB code: From: https://github.com/gpeyre/2013-SIIMS-ot-splitting/blob/master/code/toolbox/%40staggered/interp.m https://github.com/gpeyre/2013-SIIMS-ot-splitting/blob/master/...
3
votes
2answers
61 views

Manipulation of 3D matrix

Assume that we have a 3D array x, and we would like to split it into 2D slices then cut every slice into some small patches and get all patches in single list ...
4
votes
1answer
75 views

Manipulations with tensors that keep so(3,1) symmetry manifest

I am doing some manipulations with tensors in curved background. There are, however, coordinates, where Lorentz symmetry is manifest. So, on one hand, I am dealing with particular coordinates and, on ...
2
votes
2answers
193 views

Solving an equation with vector coefficients

I want to solve $(ct)^2 = d(t)\cdot d(t)$ for $t$, where $ d(t) = \frac{1}{2}at^2 + vt + r$ Where$ a, v$, and $r$ are all 3-dimensional vectors in Cartesian coordinates. How can I do this?
3
votes
1answer
67 views

Question regarding exterior products and differential forms

I'm trying to compute the following differential form $\omega = x(dy\wedge dz) + y(dx \wedge dz) + z(dx \wedge dy)$ but using a change of coordinates into spherical coords. So far, this is my code: ...
1
vote
1answer
62 views

Evaluating the 1st argument of Set

I want to assign a certain value to an element of a tensor. This element is identified by an array obtained from some evaluations, so we fix it. Here i present an oversimplified core part of my code: ...
2
votes
2answers
44 views

Symbolic reduce of augmented matrices with TensorReduce

I am trying to reduce a symbolic matrix expression containing augmented/concatenated matrices using TensorReduce, but it does not behave as expected when transposing an augmented matrix. I assume the ...
0
votes
0answers
25 views

How to define custom operator for working with tensors with multiple indices?

I've symmetric tensor $h(z)$ with rank $s$. Instead of writing symmetric tensor with its components I use the following notation $h^{(s)}(z;a) = \sum_{\mu_i}(\prod_{i=1}^{s}a^{\mu_i})h^{(s)}_{\mu_1\...
4
votes
1answer
124 views

How to do $ \bigotimes_{i=1}^n A_i $ where $ A_i $ is a $ m \times m $ matrix?

$$ \bigotimes_{i=1}^n A_i $$ where $ A_i $ is a $ m \times m $ matrix. I want to do above operation, however KroneckerProduct in Mathematica must list all $ A_i $...
3
votes
2answers
82 views

Is there a Collect for TensorProduct?

I would like Mathematica to use the property that the TensorProduct is distributive to simplify expressions like $A\otimes B+A\otimes C = A\otimes(B+C)$ Unfortunately neither Collect nor Simplify do ...
2
votes
0answers
28 views

How to make TensorProduct distributive? [closed]

Usually the tensorproduct is distributive: $A\otimes(B+C) = A\otimes B+A\otimes C$ But the Mathematica function TensorProduct does not seem to have this property. Both ...
0
votes
0answers
84 views

Cosmological perturbation using xPand - metric's signature error

I need to construct the Ricci Tensor, $R_{\mu \nu}$, using the following metric: $ds^{2}=-N^{2}dt^{2}+a^{2}(t)dx^{i}dx^{i}$ and I need to perturbe it using the following pertubed metric: $ds^{2} = -...
1
vote
0answers
21 views

keep variables in the correct position when TensorExpand

I would like to expand a tensor expression of 3-d vectors. However, the code runs really slow, the problem is asked here: Why is TensorExpand so slow for vector operations? However, I found that by ...
1
vote
1answer
72 views

Abstract vector algebra with scalars

I am interested in expanding a vector expression in terms of the scalar parameter, but it doesn't give the expected result ...
3
votes
2answers
117 views

Why is TensorExpand so slow for vector operations?

I would like to expand the following tensor expression: ...
7
votes
2answers
148 views

How to simplify tensor expression with symbolic coeficients?

I can use Vectors to simplify the following expression: ...
2
votes
0answers
69 views

How to define a constraint implying covariant derivatives in XTensor/XAct?

I have two manifolds: M and M1 with metrics g and g1. ...
2
votes
1answer
64 views

How to change the dimension of a tensor inside a loop using XAct/XTensor?

I'd like to define a function CDOrder[k] to compute the k-th order covariant derivative of a vector ...
4
votes
1answer
52 views

How to generate computationally a harmonic tensor?

A $n$-th-rank tensor $T_n$ based on $\mathbb{R}^3$ is referred here to as harmonic if it is symmetric in all indices and the linear map of the identity on vectors $I_2$ vanished, denoted as $T_n[I_2] =...
5
votes
1answer
110 views

Why won't Mathematica simplify tensor products fully?

I am working on a project and part of the output of my code is the following: $$ \text{a1}\otimes\text{a2}+\text{a1}\otimes(\text{a1}\otimes\text{a1}-\text{a2})-\text{a1}\otimes\text{a1}\otimes\text{...
1
vote
0answers
125 views
0
votes
1answer
87 views
6
votes
2answers
244 views

Voigt notation in Mathematica

In the computational mechanics software (Abaqus, Ansys, Comsol, etc), Voigt notation is always used to represent a symmetric tensor by reducing its order. Now I would ask How can we get the Voigt ...
3
votes
1answer
68 views

Creat a matrix with boundary condition

I would creat a symmetric matrix, but how can I set the boundary in Subscript? ...
0
votes
1answer
80 views

How do I do tensor integrals? [closed]

I am reading hydrodynamics and tensor integrals appear very often in this topic. So I want to learn how do I do these tensor integrals in Mathematica. In the following, I am writing the simplest ...
1
vote
1answer
65 views

Define rank-3 tensor (structure constant of Lie group) with split indices

I am trying to define this tensor: $f^\Gamma_{\Lambda\Sigma} = (g_1 \epsilon_{ABC}, g_2 \epsilon_{i+3, j+3, k+3}), \hspace{3mm} \epsilon = \text{Levi-Civita}$ I'm stuck on a particular point: The ...
2
votes
2answers
85 views

Creating 15x15 matrix out of two 6x6 matrices (by antisymmetrization)

I would like to create the following $15\times 15$ matrix $A_{ij} = \Lambda^{[I}_{[J} \delta^{M]}_{N]}$ It is tricky because $A$ is a $15\times 15$ whose entries $ij$ are labeled by antisymmetric ...
1
vote
1answer
52 views

fourth rank tensor in 6x6 matrix

Is there a Command in Mathematica that fourth rank tensor can be represented as 6 by 6 matrix?
2
votes
1answer
156 views

Tensor analysis - Index Notation

Are there some good tutorials (.nb files) about Tensor analysis using index notation built in to Mathematica? An example of a typical index notation: $$C_{i j k l} = \lambda \delta_{i j} \delta_{k l}...