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
1answer
27 views

Tensor contraction

How do I let mathematica compute a tensor contraction like $\delta_{ab}\delta_{bc}$ with an output $\delta_{ac}$ efficiently? I tried TensorContract and TensorReduce but they were not helpful. ...
0
votes
0answers
41 views

How do I apply assumptions to a table of functions

I have a table, really its a tensor but anyways I would like to apply an assumption to it, i.e. 1 - 2 phi[t,x,y,z] == 1 and have it print the tensor after it has ...
0
votes
0answers
39 views

Use Mathematica to draw a tensor-like network

What are the Mathematica ways to draw this seemly delicate figure? Such that we can output a PDF file in the end.
2
votes
1answer
27 views

xAct working with an unspecified function

I am trying to use xCoba with a diagonal metric depending on an unspecified function f[r], but I get the errors: CTensor::...
4
votes
2answers
125 views

How to understand the symmetry of MMA's tensor

tensor = {{{2, 9}, {9, 2}}, {{9, 2}, {2, 4}}}; TensorDimensions[tensor] TensorSymmetry[tensor] How can I understand the symmetry of the output ...
1
vote
0answers
83 views

3d plot of young's modulus for anisotropic material

can anyone can help me in plotting 3d plot of young's modulus for anisotropic material. For input i have 6*6 stiffness tensor matrix and hydrostatic pressure value. I am trying with the following ...
1
vote
1answer
40 views

The Matrix formula of this hamilton is different from that found in the paper

I am trying to rewrite the following Hamiltonian in the matrix form, but I get different results. In this article, the Hamiltonian that represents a three-qubit Heisenberg spin chain and its matrix ...
2
votes
1answer
40 views

Defining a tensor from an expression of other tensors in xAct

There's been a number of people asking how to set a tensor-valued variable in xAct; equivalently, how to define a new tensor from an expression of existing tensors. For example, a very simple ...
2
votes
1answer
60 views

How to compute functional derivative against vector in xAct, xTensor or xTras?

I want to compute the functional derivative against vectors. For example, I have an object that looks like this $R = h_{ijkl}a^i a^j a^k a^l$ I need to compute $\frac{\delta R}{\delta a^p}= 4 h_{...
0
votes
1answer
68 views

How does Indexed work in terms of sparse array

I want to use indexed given that s is an element [0,500] but I am unsure how to write that without getting a format error or a tensor error. ...
0
votes
1answer
33 views

How to make a tensor product into matrix?

TensorProduct[PauliMatrix[1], DiagonalMatrix[{1, 1}]] // TableForm created a tensor, which could be flatten to table form. However, how to make the tensor into a ...
2
votes
1answer
70 views

Kretschmann scalar in xTensor and xCoba

How do I calculate the Kretschmann scalar $K=R_{abcd}R^{abcd}$ with xTensor and xCoba? I have found the functions Kretschmann and ...
2
votes
2answers
107 views

Speeding up the evaluation of a product of 64 matrices, each 16x16, which takes 30 minutes

I need to calculate a very large product of matrices, (64 terms, each a 16x16 matrix). Specifically, ...
2
votes
0answers
41 views

Parallelize and tensor calculus

Is it possible to use Parallelize with tensor calculus functions like TensorContract and ...
3
votes
1answer
62 views

Rewriting a large product of 42 (13x13) matrices with MatrixExp

I am trying to perform a product of a large number of terms of the form MaxtrixExp[...], for example, something like this ...
0
votes
1answer
40 views

Trying to find the double dot product of a Rank 4 and Rank 2 tensor

I understand this question has been asked before, or something very similar to what I'm trying to accomplish at the very least, however I didn't understand much of what was happening in the other ...
6
votes
2answers
423 views

Speeding up sums involving 16x16 matrices and 16x16x16x16 antisymmetric tensor

I need to perform the following contraction involving four 16x16 matrices and a tensor $\theta$ that is 16x16x16x16. ...
4
votes
1answer
102 views

TensorContract and TensorProduct problem

I am trying the calculate the Kretschmann scalar $K$ of a metric $$K=R^{abcd}R_{abcd}$$ where $R$ is the Riemann tensor. If I do ...
0
votes
1answer
45 views

How can I take the divergence of a symbolic vector? [duplicate]

I would like to compute expressions that have the following form: $$\left(\partial_{p_1} - \partial_{p_2}\right)^2 \left(\partial_{p_1} - \partial_{p_2}\right)^2 \frac{(p_1-p_2)\cdot(p_3-p_4)}{p_1^...
1
vote
1answer
55 views

How to work with Levi civita tensor in xAxt?

Is there any command to work with the Levici vita tensor? In fact, I found LeviCivitaTensor, however, in calculations it doesn't seem practical. see the example: <...
0
votes
1answer
71 views

How to flatten a tensor product

Say I have a tensor product of four two dimensional spaces $\Lambda = S\otimes S\otimes S\otimes S$. The basis of $S$ is CB={{1,0},{0,1}} . I generate the ...
3
votes
1answer
47 views

unexpected `False` for `SymmetricMatrixQ`

Why does the following evaluate to False? ...
1
vote
0answers
23 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 ...
0
votes
0answers
22 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....
4
votes
1answer
67 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: ...
0
votes
1answer
42 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, ...
-1
votes
1answer
119 views

Can I numerically solve these equation in Mathematica? [closed]

I have this couple of equations : $ \partial_\mu \partial^\mu z^i + G^{i\bar{p}} (\partial_j G_{k\bar{p}} ) \partial_\mu z^j \partial^\mu z^k + G^{i\bar{j}} (\partial_{\bar{j}} G_{k\bar{l}} ) \...
0
votes
0answers
51 views

Solving differential forms equations

I have this couple of equations in differential forms language: $ \Delta z^i \star {\bf{1}}+ G^{i\bar{p}} (\partial_j G_{k\bar{p}} ) dz^j \wedge \star dz^k + G^{i\bar{j}} (\partial_{\bar{j}} G_{k\bar{...
0
votes
1answer
59 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....
0
votes
0answers
27 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}$...
2
votes
0answers
75 views

How to remove the Riemann tensor derivatives using Bianchi identity?

For the third-order Lovelock gravity, after varying the Lagrangian versus the metric, I found some derivatives of the Riemann tensor which should not be appeared. How can I remove them? Maybe using ...
4
votes
1answer
47 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$....
4
votes
1answer
74 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 ...
1
vote
1answer
41 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 ...
2
votes
1answer
51 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 ...
2
votes
1answer
73 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 ...
1
vote
1answer
86 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 ...
3
votes
1answer
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 ...
8
votes
4answers
379 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 ...
4
votes
1answer
100 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 ...
6
votes
1answer
146 views

Speeding up tensor contractions and multiplication

Consider a tensor $T\in\mathbb{R}^{N\times N\times N\times M}$ and two vectors $x,y\in\mathbb{R}^N$. I want to compute the $N\times M$ vector defined by $X_{ij}=\operatorname{tr}(x^\top T_{:,:,i,j}y)=\...
0
votes
0answers
33 views

Doubt about tensor producto of two columns vectors

I want to get the tensor product of two columns vectors for example: a={1,2,3} b={2,3,1} psi0 = ArrayFlatten[TensorProduct[a, b]]; The size of psi0 is 3x3 but it ...
0
votes
0answers
46 views

How to compute gauge variation of expression?

Suppose I have a symmetric tensor field $h_{\mu\nu}$ I want to implement somehow the following gauge variation of this tensor field as follows $\delta h_{\mu\nu} = \nabla_{\mu}\epsilon_{\nu} + \...
1
vote
0answers
33 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 ...
10
votes
2answers
575 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
56 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
82 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:...
2
votes
1answer
165 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
59 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
140 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 2 3 4 5 7