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
0
votes
0answers
34 views

Converting Tensor product to Matrix

I have a basic question regarding matrices and tensor product forms. Given $N > 0$, I am interested in the tensor product series $\sum_{i}^{N} X_i$, where $X_i$ is the Pauli $X$ spin operator at ...
3
votes
1answer
95 views

Generate C code from symbolic computation in Mathematica

I am doing some tensor multiplication operations and would like to have Mathematica generate C code so that I can use it later. I want to supply two 2nd order tensors(A and B) and get the entries of a ...
3
votes
1answer
86 views

How to compute matrices in Einstein notation:

I would like to compute $ r_{ii'} = \sum_{kk'} A_{ii'}^{kk'} r_{kk'} $ where all indices vary from 0 to 1 to yield a vector / matrix.
9
votes
1answer
130 views

Nice use case for symbolic tensors?

I come from before the times of symbolic tensors in Mathematica, and am used to working with concrete tensors and custom commands to contract them using Transpose, Dot, etc. I recently realized that ...
0
votes
0answers
58 views

Can I speed up my tensor calculations?

I am running this code now for hours, which is not even that hard actually, but Mathematica seems to have troubles with it: ...
0
votes
2answers
73 views

Problems calculating scalar curvature of sphere

I'm not that great at using Mathematica so please bear with me. What I'm trying to do here is compute the coefficients of the metric tensor in 3D spherical coordinates, from which I'll construct the ...
1
vote
0answers
54 views

Implementing the symbolic identity matrix $I$

I am working with symbolic tensors within Mathematica and I wanted to ask if there is a way to have a symbolic identity tensor.
2
votes
0answers
71 views

Need help with symbolic tensor calculus using Kronecker products

I am quite new with Mathematica. I need to do symbolic tensor calculations but what I try does not seem to work. I have found similar questions to mine, but I need a generalization Specifically, if <...
0
votes
0answers
32 views

Doubt regarding the creation of a symbolic 2nd rank symmetric tensor in Mathematica

I would like to ask the following: In a previous post it was asked how to create a 2nd-order symbolic tensor in Mathematica. Given the following notation ...
0
votes
0answers
31 views

How To Define An Outer Product (in xAct)?

I am working with xAct / xCoba / xTras and I would like to construct a matrix out of a vector. So, I have a vector V on a manifold ...
0
votes
0answers
13 views

ToCTensor does not respect symmetry of tensor

If I try to convert a tensor object to a CTensor DefTensor[F[i, j], M, Antisymmetric[{i, j}]]; Fc = ToCTensor[F, {ch, ch}] The output is ...
1
vote
1answer
24 views

Contracting a Tensor with a CTensor in xAct

I'm trying to contract two tensors that I made in xAct to get a simple result. First I set up a Cartesian space ...
4
votes
4answers
65 views

Double contraction between 2nd and 4th rank tensor

I would like to compute the double dot product between a 2nd and 4th rank tensor in mathematica $A_{kl}A_{ijkl}$ $if \, A_{kl}=\begin{pmatrix} 1& 0 & 0\\ 0 & 1 & 0\\ 0&0 & 1 \...
6
votes
1answer
85 views

Undefined Indexed Variable

I searched already a lot about indexed Variables, and it tends to be the most applicable way to use tensor notation. But I am having a hard time to solve for undefined indexed variables: Here my ...
1
vote
1answer
51 views

Symmetric part of a 4th rank tensor in mathematica

I am quite new to Mathematica and would like to know how to compute the symmetric part of a 4th order tensor $A_{ijkl}$. Since there are 4 indices (i,j,k,l), we have 4!=24 permutations. The symmetric ...
0
votes
1answer
37 views

Replace Table with a fast matrix operation to create for matrices A, B the tensor (b_{ij}A) and similar questions

I have two (nxn)-matrices A=(a_{ij}) and B=(b_{ij}) and I'd like to create the (nxnxnxn)-List C=(b_{ij}*A) so e.g. ...
0
votes
1answer
40 views

How to do tensor product between non-rectangular tensors?

For example, if I have a non-rectangular tensor t = Table[2, {l, 0, 1}, {m, -l, l}] To tensor product 't' with itself will fail, because 't' is not a rectangluar ...
1
vote
1answer
57 views

How to compute k'th tensor power of matrix

Is there a 1-liner to compute $M^{\otimes k}$ where $M$ is some matrix and $\otimes$ is the Kronecker product? The documentation says I can write ...
3
votes
1answer
47 views

TensorExpand, TensorProduct and Distribution over Scalars

Consider: TensorExpand[( b1 x )\[TensorProduct] (b1 x + b2), Assumptions -> x ∈ Reals] (*x^2 b1\[TensorProduct]b1 + x b1\[TensorProduct]b2*) This works as ...
7
votes
3answers
241 views

Tensor transformation

Consider the following tensor in coordinate basis $T=T^{\mu}_{\nu\lambda} \partial_{\mu}\otimes dx^\nu \otimes dx^\lambda$ in two dimensions with coordinates $x^1 = x$ and $x^2 = y$. We take $T^{\mu}...
4
votes
3answers
94 views

Table over array indices

I want to generalize the following table to a summation over $s[1], \ldots, s[N]$ and $t[1], \ldots t[N]$, where each variable sums over $\{-1, 1\}$. ...
0
votes
0answers
51 views

3D plot of a tensor

How to plot a tensor in three dimensions. For example, let us take a dielectric constant tensor of rank two. ...
0
votes
1answer
81 views

How to Contract Indices Using Feyncalc

I am slowly learning how to use Feyncalc, and I have a quick question. I have a third rank tensor B[mu,nu,tao] and I also have a four-vector FV[W,mu]. I would like to contract the first two indices ...
0
votes
0answers
46 views

Weird behavior of ℏ (\[HBar]) symbol on TensorExpand

I was trying to implement some tools to do commutators on quantum mechanics, just for fun. Then I noted a peculiarity: ...
0
votes
0answers
18 views

Kretschmann scalar computation with xCoba not giving result

I am using the following code to calculate the Kretschmann scalar with xTensor pack, but it doesn't give me any result and I haven't detected any error, I dont know what's wrong with it. The code is ...
1
vote
0answers
58 views

How can I make NDSolve aware of vectorial nature of an ODE?

I am trying to solve the equilibrium equation $\text{DIV } \mathbf P(\textbf{u}(x,y)) = \mathbf{f}$, where $\mathbf P$ is the stress tensor defined by $$ \mathbf P = \mathbf F + (1-\det\mathbf F)^...
3
votes
1answer
71 views

execute a summation involving a differential operator

Below is an operator $\hat{D}=\sum_{i,j}^2 \frac{\partial}{\partial u^i}\sqrt{g}g^{ij}\frac{\partial}{\partial u^j}$ where $g_{ij}=\begin{pmatrix}p(x,y) & q(x,y)\\\ q(x,y) & r(x,y)\end{pmatrix}...
4
votes
2answers
110 views

Commutation, symmetrizer and duplication matrices

The following 3 matrices are useful when viewing matrices as vectors, known as commutation $K_n$, symmetrizer $N_n$ and duplication $G_n$. They are usually defined by their matrix relations below. $$ \...
0
votes
0answers
66 views

Transforming a tensor expression

I have the expression $\qquad\sqrt{\det[\gamma^{\mu \nu} F_{\mu \nu}]}$ Basiclly, I need to expand this expression in some form like : $trF^4 + (trF^2)^2 + \sqrt{\det[F_{\mu \nu}]}$, where $\gamma^{\...
2
votes
1answer
89 views

Tensor Algebra Problem

I am just getting started with tensor algebra using Mathematica. I could use some help with a simple problem I am starting with at my website: http://www.tifis.org/mathematicaproblem.pdf An ...
1
vote
0answers
42 views

diagonalisation of tensors [closed]

$$H_{(ab),(cd)} =p_{lmno}F_{lm}^{ab}G_{no}^{cd}$$ $$=p_{lmno} \left(n_{do}n_{nc}+\delta_{do}\delta_{nc}\right)\left(n_{bm}\delta_{la}-\delta_{bm}n_{la}\right)$$ Is there a way to diagonalize the above ...
0
votes
0answers
39 views

Shorten a sum of many terms by introducing a rule for scalar product and Kronecker deltas and using repeated replacements

There is a sum of many terms that I would like to simplify by introducing a notation for scalar product of two vectors. Each term is a product of constants and of several components of 3D vectors: <...
3
votes
1answer
85 views

Implementing Tensors

Please see the below question. This is what I need to implement in Mathematica.
4
votes
0answers
43 views

Pair-wise antisymmetric tensor

I am trying to define a tensor $T$ which is antisymmetric under pair-wise exchange of its indices: $T = \delta_{a],[b}\,\delta_{c],[d}\,\delta_{e],[f}\,\delta_{g],[h}$ where $T$ is antisymmetric under ...
0
votes
0answers
37 views

What is a good way to describe all kinds of basic equations in elasticity by tensor [duplicate]

I see here that we can use tensors to represent the fundamental equations in elasticity. But I don't know how to use the tensor operation in MMA to reproduce these equations. If you can, please ...
0
votes
0answers
31 views

Coordinate transformation on the Christoffel tensor Xcoba

I have to compute the Christoffel Symbols on a basis which is not the coordinate basis of the chart in mathematica. I should do this contraction: ...
1
vote
1answer
99 views

How to associate a tetrad as a basis of a metric mathematica

It's my first time here, and it's the first time that I try to work with Mathematica, so I am a bit lost! If somebody could help me I'll always be grateful! I need to define a generale basis for a ...
5
votes
2answers
160 views

Array reshaping without explicitly specifying one dimension

In NumPy a function numpy.reshape can leave at most one dimensional specification unspecified and it will be automatically calculated. So is there a similar functionality in MMA? As a simplest example ...
0
votes
0answers
41 views

Write Tensor Product in Matrix Form

I want to write the tensor product A $\otimes$ B in matrix form, where\begin{equation} A= \left[ {\begin{array}{cc} 1 & 2 & 3\\ 4 & 5 &6 \\ 7 & 8 &9 \\ \end{array} } \...
2
votes
0answers
50 views

How to define tensors similar to Riemann tensor in xAct xTensor xTras

I'm working on a project where we deal with objects very similar to Riemann tensor. In fact they are Christoffel symbols for higher spins. I'm using xTras for modeling problems in wolfram mathematica. ...
12
votes
4answers
750 views

How to rewrite a tensor as a matrix

I put {TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]}/Sqrt[2]//MatrixForm and I got $$ \left( \begin{array}{cc} \left( \begin{array}{cc} \left( \begin{...
6
votes
1answer
149 views

Derivative of real antisymmetric matrix in mathematica

Is it possible to find the derivative of components of a real antisymmetric matrix using index notation? Eg: I have a very large real antisymmetric matrix. Then from Matrix Cookbook, we know the ...
2
votes
1answer
46 views

Fancy Indexing of a 4D array (tensor)

I'm trying to mimic the CoefficientArrays function, which I can't get to work for my symbolic equations. The CoefficientList ...
3
votes
2answers
122 views

Klein-Gordon Equation: how can I write the summation?

I would like to write a program that gives me the Klein Gordon Equations given a metric. I will explain. My code is in the following: I) Standard Quantities I have no doubt here the first part is ...
8
votes
3answers
323 views

How is Grad defined for array particularly in non-Cartesian coordinates?

This question can be viewed as a follow-up of What is the definition of Curl in Mathematica? First argument of Grad can be an array, but what definition does ...
0
votes
1answer
33 views

Building an array of T NxM matrices where one item in each matrix changes

As I do not use Mathematica often enough, I am a bit rusty. I need to work on an array of T matrices and each of those NxM matrices has the following pattern: $$ \begin{equation} A(t):= \left( ...
1
vote
1answer
77 views

Tensorial functions

I need to solve a system of ODEs for a function that has a complicated tensorial structure. I believe that NDSolve can deal with this scenario since version 9. Yet, ...
2
votes
1answer
78 views

How to identify specific Christoffel symbols and Riemann Tensor components from a general solution [closed]

I want to learn how to identify specific Christoffel Symbols and Riemman Tensor components from the general solution provided by Mathematica. Let us work out an example to see what I mean clearly. ...
4
votes
1answer
167 views

Computing Christoffel symbols of the second kind [duplicate]

I want to compute the Christoffel-symbol for a given metric. I am using the code here, but I am missing something. The Chrisfoffel-symbol formula is $\Gamma^{\mu}_{\phantom{\mu}\nu\sigma}=\frac{1}{2}g^...
2
votes
1answer
88 views

Best way to work with Tensor Networks

I have to write a script in which I have to work with a very simple tensor network but I can't find a nice scalable way to make this work. The basic object I am working with is a tensor more or less ...

1
2 3 4 5
8