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.

learn more… | top users | synonyms

1
vote
2answers
88 views

Output the tensor product of two matrix as a matrix

How do I output the matrix form like the RHS without the tensor product sign remaining $\otimes$? I need it for display purpose where I can see easily what the form of the whole product matrix is.
0
votes
0answers
59 views

Scalar from tensor contraction

I'm trying to calculate the Kretschmann scalar in mathematica, it is given by: $c = R^{abcd} R_{abcd}$ Where $R^{abcd}$ is the Riemann tensor. I'm following this MSE post so I modified it to ...
0
votes
1answer
57 views

How to multiply two tensor with arbitrary ranks, on one index only (like GR)?

I am writing a function which take two tensors with the same dimensions but with arbitrary ranks and multiplies them over one index, just like this example from GR: See, I couldn't use ...
0
votes
1answer
20 views

Dynamically constructing symbolic tensors

Is there any way to construct tensor of any given dimension d and rank r with symbolic entries? i.e., instead of manually constructing one as Table[T[i,j,k],{i,1,10},{i,1,10},{i,1,10}] for d=3 and r=...
3
votes
1answer
52 views

Constructing tensors with arbitrary rank and dimension [closed]

How can I create a tensor with arbitrary rank n and m components in each dimension? I am looking for a command in which I insert n and m and it spits out the corresponding tensor with random entries (...
2
votes
1answer
72 views

Working with tensor algebra

My question is really easy for experienced users. In my tensor equations I have an unknown tensor Q (symmetric and traceless): $Q=\begin{pmatrix} n1(x,y) & n2(x,y) \\ n2(x,y) & -n1(x,y) \end{...
1
vote
0answers
97 views

Outer product using the quantum mathematica package

I am using the quantum Mathematica package and am trying to do computations that require me to use the outer (tensor) products of Pauli matrices. I would define this as, for example, ...
3
votes
2answers
89 views

Perform matrix/tensor contractions more efficiently

Problem: explicit index contractions for matrices using the Sum command take too long, and I want to improve the performance for complicated computations. Let me ...
8
votes
0answers
161 views

Efficient way to flatten or transpose-arrayreshape tensors

I have a tensor of dimensions $(2, 100, 100, 2, 100, 100)$ and I want to reshape it to a form of $(2*100*100,2*100*100)$, e.g. Flatten[A,{{1,5,6},{4,2,3}}]. If I ...
0
votes
1answer
100 views

How to create simple (tensor) product spaces?

Is it possible to work with simple tensor product spaces, like multiplying product states from quantum mechanics? I basically have a simple two dimensional vector space, whose elements are ...
15
votes
2answers
1k views

Higher order SVD

Does anyone know how to do a higher order SVD in Mathematica ? A good reference seems to be here http://www.sandia.gov/~tgkolda/pubs/pubfiles/SAND2007-6702.pdf but I don't understand their formalism ...
3
votes
2answers
79 views

Find most general 3-tensor under given constraint?

Consider A to be a general $2\times 2\times 2$ tensor: A = Table[ a[i,j,k], {i, 1, 2}, {j, 1, 2}, {k, 1, 2}]; pictorially one ...
4
votes
1answer
67 views

Creating a tensor from matrices

I have 3 nxn matrices that I'd like to combine into a nxnx3 tensor. Basically, I want a new nxn matrix where each element is a 3 tuple of the elements of the other 3 matrices at that same position. ...
1
vote
2answers
121 views

Update: Calculate Tensor products and traces with Mathematica

My goal is to algebraically simplify expressions involving tensor products and taking the trace. That is, I would like to compute $\operatorname{Tr}\left( \prod_i(id+a_i \otimes b_i) \right)$, using ...
2
votes
0answers
57 views
4
votes
1answer
42 views

What do I need to know about simplifying expressions involving Symbolic Tensors?

I want to use Mathematica to show that the inner product of a vector with itself is equal to the square of its norm. This is what I tried: ...
0
votes
1answer
82 views
3
votes
1answer
108 views

Expanding the Riemann tensor (perturbation)

I am trying to expand the following term (via the perturbation expansion $g_{\mu\nu} = \eta_{\mu\nu} + \kappa h_{\mu\nu}$): $$ \frac12 \epsilon^{abcd}R^e_{fcd}R^f_{eab} $$ Where $R$ is the Riemann ...
2
votes
0answers
95 views

Fast construction and reshaping of large tensors

I'm trying to construct a large matrix which is derived from some higher rank tensor (the rank of interest to me changes case by case, so it needs to be a general method). Currently, the process of ...
2
votes
1answer
115 views

Explicit Contraction of Tensor Indices [duplicate]

Is there any easy way to explicitly contract indices of several given tensors. For example, ...
6
votes
1answer
83 views

Issue with TensorWedge and TensorReduce?

Bug introduced in 10.0.0 and fixed in 10.3.1 If I use TensorReduce on the result of TensorWedge: ...
3
votes
1answer
62 views

How to fill a tensor with matrices one by one?

I have this tensor: nn = 4; tableToFill = Table[x, {p, 1, nn}, {q, 1, nn}, {i, 1, nn}, {j, 1, nn}]; that I want to fill with a matrix one by one with a matrix ...
0
votes
0answers
319 views

Symbolic tensor product calculation

I am trying to calculate the a symbolic tensor product $\langle \nabla f\otimes f,\nabla g\otimes g\rangle ^2+(\langle \nabla f\otimes g,\nabla f\otimes g\rangle +\langle \nabla g\otimes f,\nabla g\...
6
votes
1answer
71 views

Matrix Multiplication after “Flatten”

Say we originally had two matrices, $A$ and $B$, both $n \times n$, whose product $$ C= A.B $$ Now I flatten $A$. I can obtain a flatten $C$, from the following multiplication $$ C_{flat}=A_{flat}....
5
votes
1answer
501 views

Linearized Einstein Equations with Mathematica

I need to compute the linearised Einstein Equations around a fixed metric $g_{\mu \nu}$ which is not the flat metric. Someone knows any Mathematica package or a review that can help me?
0
votes
1answer
173 views

Nonrectangular tensor encountered [closed]

I am trying to solve a system of equations which characteristic matrix: ...
1
vote
2answers
91 views

Displaying tensors

I want to display the values of a table with superscirpts and subscripts in a list as bellow. ...
3
votes
0answers
57 views

Nested TensorContract bug

Bug introduced in version 9.0.0 or 9.0.1 and fixed in 10.1 or 10.2 When nesting TensorContract the result I get is wrong. Input: ...
1
vote
1answer
89 views

Calculation of tensor structure

I would like to calculate following type of contraction: $$ P_{ij}^{p-k} P_{lm}^{k} ((p_l - k_l) \delta_{ij} + k_j \delta_{il}) (k_n \delta_{im} - p_m\delta_{in}) = ? $$ where p,k are d-...
1
vote
0answers
83 views

Ricci tensor with Mathematica [closed]

I'm trying for first time to write a Ricci tensor with Mathematica. The code I've written is this: ...
2
votes
2answers
85 views

Syntax for higher rank tensor multiplication

I am trying to do some matrix multiplication in Mathematica but I just cannot figure out the correct syntax for my problem. I want to write the following: $$ A\pmatrix{a & b\\c & d}+B\pmatrix{...
7
votes
2answers
980 views

Perturbation theory in general relativity using xAct

I'm trying to use the xAct Mathematica package for manipulating tensors, and I'd like to plug in a metric into the perturbation equations to first order in general relativity, and have everything ...
11
votes
5answers
2k views

Ways to compute inner products of tensors

One way to evaluate the following sums is combining Table and Sum: $u_{abcd} = \sum_{e=1}^3 v_{aeb}w_{ced}$ $q_{ab} = \sum_{d,e=1}^3 v_{d e a}w_{deb}$ It will look like ...
1
vote
2answers
374 views

Compute a double dot product between two tensors of rank 3 and 2

I would need help to calculate a double dot product between a rank 3 tensor A and a rank 2 tensor B (A:B) using mathematica. Does someone know how to do that? Thank you for your help!
2
votes
0answers
57 views

Simplifying symbolic expressions using TensorExpand

Following my previous question I have this issue using TensorExpand: KroneckerProduct[x, y].(KroneckerProduct[2 z, w]) // TensorExpand results in ...
4
votes
0answers
71 views

How to write Coordinate Chart in Xcoba in index form?

I am using xCoba for manipulating tensors. I do the usual, defining my metric, manifold, chart etc. ...
2
votes
1answer
93 views

Choosing Minkowski metric in Feyncalc

This is related to the Mathematica package FeynCalc. Is there a way to simplify the metric? I mean in the sense that when I evaluate something and I get a long expression involving lots of $$g^{12}$$...
1
vote
1answer
106 views

Curl of a second-order tensor

In Mathematica 9.0, the documentation for the Curl function states that in n-dimensions "the resulting curl is an array with depth n-k-1 of dimensions". Accordingly, if a 2-dimensional array is feeded ...
2
votes
0answers
56 views

Arrays with two different types of indices

Is there a way of having arrays which have, so to speak, two different depths $m,n$? From the point of view of memory usage, it would be the same as an array of depth $m+n$, but I would like to ...
3
votes
1answer
44 views

Simplifying nested KroneckerProducts

Any suggestion how to bring a nested KroneckerProduct form into just one? I mean some how converting ...
1
vote
0answers
60 views

Continuous integration of a tensor function using discrete density values

Hei, I am wondering is it possible to implement continuous integration using Integrate() of a fourth order tensor with discrete density values. ...
12
votes
1answer
230 views

Nearest Kronecker Product

Some people (see The ubiquitous Kronecker product by Van Loan) have worked on finding two matrices $\mathbf A$,$\mathbf B$ of specified size whose tensor product $\mathbf A\otimes\mathbf B$ is closest ...
6
votes
3answers
264 views

How to simplify symbolic expressions with KroneckerProduct

Having $X,Y$ being symbols for matrices, I was wondering if there is a way to simplify expressions like KroneckerProduct[X, X] + KroneckerProduct[-X, X] to ...
5
votes
2answers
143 views

The fastest way of raising indices of high rank tensor

I have some high dimensional high rank tensors, let's say $$F_{ijkl}$$ and I need to find $$F^{abcd}=g^{ai}g^{bj}g^{ck}g^{dl}F_{ijkl}.$$ Here $g^{ij}$ is the contravariant metric. Simple summation ...
1
vote
1answer
78 views

Issue with Differentiation over a tensor

I am new user in Mathematica. I am working with liquid crystal theory, and one of the notation there is the tensor: $ \Pi_{ij} = \frac {\partial {F_{el}}} { \partial ( \partial {n_i} / \partial { x_j}...
1
vote
1answer
79 views

Is there a package that can calculate the Ricci tensor from a numerically given metric?

There are many packages about general relativity or differential geometry, and they can calculate the Ricci tensor from a symbolically given metric, for example, $g_{tt}=-f(r)$, $g_{rr}=h(r)$, etc. ...
25
votes
4answers
11k views

How to calculate scalar curvature Ricci tensor and Christoffel symbols in Mathematica?

I am seeking a convenient and effective way to calculate such geometric quantities. I've used packages like TensoriaCalc, but they don't work at all time. Sometimes,...
2
votes
1answer
141 views

How to swap tensor indices without permutation?

Say I have a tensor of rank R, How to swap $i^{th}$ and $j^{th}$ tensor index? I do not want to use TensorTranspose because it requires to write down the entire permutation, i.e. TensorTranspose[T,{1,...
9
votes
2answers
299 views

How to read off coefficients of tensor-like expression in a speedy way?

I am considering identities involving t[a, b, c, d, ...], where number of indices is fixed. t has the cyclic property so that <...