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.

0
votes
0answers
6 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 ...
9
votes
2answers
526 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, ...
1
vote
0answers
34 views

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

I'd like to print the LeviCivitaTensor[4] tensor as 4x4 block matrix of 4x4 matrices The following code works to display the LeviCivitaTensor[3] tensor as a 3x1 vector of 3x3 matrices. ...
0
votes
0answers
20 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:...
1
vote
1answer
39 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 ...
3
votes
0answers
48 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 ...
2
votes
1answer
51 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: ...
1
vote
0answers
36 views

How to solve a linear transform given part of the input and output vectors [migrated]

Lets say $v,w \in \mathbb{R}^n $ and $v = A w$, where $A \in M_{n \times n}$. We are given all entries of $A$. Now, If I am given all the components of $w$ it is very easy to find $v$, and if I am ...
0
votes
1answer
27 views

TensorReduce causes “inhomogeneous dimensions” error

I want to use TensorReduce to realize the following property of wedge: ...
1
vote
1answer
33 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 ...
2
votes
1answer
62 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, ...
0
votes
1answer
92 views

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

I have a short Mathematica program: ...
2
votes
1answer
30 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 ...
2
votes
1answer
48 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 ...
0
votes
0answers
81 views

How can I define another metric (disformal transformation) in xAct?

I'm using the xAct package. I want to define two metrics with the disformal transformation relation $\qquad \bar{g}_{\mu\nu}=A(\phi) g_{\mu\nu}+B(\phi)\nabla_\mu \phi\nabla_\mu \phi ,$ where $g_{\...
2
votes
2answers
73 views

How to define an antisymmetric symbol?

I want to work with linear expressions involving the formal symbol $w[a_1,...,a_n]$, and I would like Mathematica to know that expressions such as ...
0
votes
1answer
40 views

Performing a simple operation with operators [closed]

I have a map defined as $\qquad \Phi(X) = a^2\, Tr[X] |0\rangle \langle 0| + b^2\, Tr[X] |1\rangle \langle 1| + a\,b\, Tr[\sigma_z X] |0\rangle \langle 1| + a\,b\, Tr[\sigma_z X] |1\rangle \langle ...
0
votes
0answers
37 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: ...
0
votes
1answer
80 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?
3
votes
0answers
58 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, ...
1
vote
1answer
65 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 ...
2
votes
2answers
134 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
42 views

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

Reformulated problem. I am using the code: ...
20
votes
4answers
846 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
59 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
95 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
35 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
40 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
31 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
87 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
65 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
145 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 ...
1
vote
1answer
98 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
71 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
93 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
51 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
86 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
170 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
124 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
109 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
153 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
46 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
221 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
69 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
92 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
218 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
79 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
64 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
59 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
27 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\...