Skip to main content

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.

111 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
14 votes
0 answers
514 views

Can I use symbolic tensors for simple linear algebra and calculus?

As an example, I'd like to calculate this symbolic derivative: $\frac{\partial}{\partial b}(x-A.b)^{\mathsf{T}}.(x-A.b)$ where $x$ and $b$ are vectors and $A$ is a matrix. What I tried is this: <...
Niki Estner's user avatar
  • 36.1k
9 votes
0 answers
184 views

Performance improvements by using Activate and Inactivate

In a question about improving performance of a TensorContract of a TensorProduct, user jose suggested replacing ...
AndreasP's user avatar
  • 598
6 votes
0 answers
479 views

Variating the derivative of the metric using xTensor

I would like Mathematica to be able to use the following expression in a more complicated computation: \begin{equation} \tag{1}\frac{\delta{}g^{\alpha\beta}_{\;{},\gamma}\left(x\right)}{\delta{}g^{\mu\...
Ottavia's user avatar
  • 61
5 votes
0 answers
350 views

Manipulating tensorial terms with xAct, ToCanonical is not perfoming well

I am trying to calculate perturbations of some complicated Lagrangians. Using xAct and more specifically VarD to perform the perturbations the expressions become ...
Rapha's user avatar
  • 51
5 votes
0 answers
137 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 ...
Alonso Perez-Lona's user avatar
5 votes
0 answers
119 views

TensorContract applied twice

I have a very simple question about TensorContract command: I'm declaring ...
MaPo's user avatar
  • 909
5 votes
0 answers
1k views

Tensor product involving Levi Civita symbol

I'm working with xAct package. I've defined the tensor component values and my issue is that I want an expression involving Levi Civita symbols and tensor components, I don't know how to deal with it. ...
user25578's user avatar
  • 143
4 votes
0 answers
69 views

speed up tensor expand

I am using the following code ...
Franzi's user avatar
  • 63
4 votes
0 answers
389 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. ...
P DEY's user avatar
  • 41
3 votes
1 answer
82 views

Make the ```*``` operation the Kronecker product by default for Kets?

So given two "Ket" objects, u = Ket[{-1/2}]; d = Ket[{1/2}]; Is there a way to define multiplication, *, so that by ...
AlkaKadri's user avatar
  • 131
3 votes
0 answers
39 views

Why is TensorContract[x, {}] not always x?

If I use TensorTranspose on an undefined symbol, nothing happens unless the permutation is the identity. For instance, ...
srossd's user avatar
  • 260
3 votes
0 answers
135 views

Implementing einsum in Mathematica

I've been using Carl Woll's einsum function, but it's missing the ability to handle repeated indices. For instance np.einsum('i,i->i',w, w) will perform a ...
Yaroslav Bulatov's user avatar
3 votes
0 answers
145 views

How can I simplify a symbolic tensor expression?

My question is about simplifying tensor expressions. If I have $(a+b)\otimes (c+d)$ The function TensorExpand gives $a\otimes c + a\otimes d + b\otimes c + b\otimes ...
Physor's user avatar
  • 153
3 votes
0 answers
599 views

Spin Connection using Mathematica

Hello I want to use Mathematica in order to calculate the spin connection of a metric, specifically of the metric \begin{equation} \left(\begin{array}{cccc} -1 & 0 & 0 & 0 \\ 0 & \...
lastgunslinger's user avatar
3 votes
0 answers
309 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, ...
user1887919's user avatar
3 votes
0 answers
207 views

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

I have two manifolds: M and M1 with metrics g and g1. ...
JuanC97's user avatar
  • 612
3 votes
0 answers
208 views

Determinant of 2-forms

I have matrix 4x4 and elements of the matrix are 2-forms. How to calculate determinant (in Mathematica 11) if this matrix using external product instead of normal product? I use components of Riemann ...
nail's user avatar
  • 189
3 votes
0 answers
224 views

How can I perform tensor contractions without first storing an unnecessarily large tensor?

I'm performing a calculation which requires me to start with a collection of tensors and contract out their indices according to a pattern that I've written down. Right now, if I have a pair of two ...
miggle's user avatar
  • 657
3 votes
0 answers
271 views

How does HodgeDual work?

The Hodge dual of a $p$-form is explicitly metric dependent, but the function HodgeDual[] doesn't seem to ask for the metric as an argument. How does that work? ...
Alex Wang's user avatar
3 votes
0 answers
86 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: ...
Friedrich's user avatar
  • 403
3 votes
0 answers
923 views

how to associate a metric for tensor contraction operations?

I see that Version 9 now has some built in tensor support (which was missing back when previously asked How to represent and manipulate abstract indexed vector (or tensor) expressions?). The docs ...
Peeter Joot's user avatar
  • 6,418
2 votes
0 answers
56 views

Defining a tensor in terms of its trace and other tensors

I'm starting to learn xAct for tensor operations. So I am dealing with 3 tensors: $T_{abc}$, $Q_{abc}$ and a metric tensor $g_{ab}$; with these tensors I have an equation like $$T_{abc} = Q_{abc} + ...
ayberk çakmak's user avatar
2 votes
0 answers
63 views

Calculating the strength tensor of a vector field

I'm trying to calculate $$T_{ab} = g_{ab}F_{gd}F^{gd} - F_a^g F_{bg},$$ where $$F_{ab} = \partial_a A_b-\partial_b A_a$$ So I define $F_{ab}$ by: ...
Dr. phy's user avatar
  • 287
2 votes
0 answers
143 views

How to define a Kerr-Schild metric in xAct?

A Kerr-Schild can be expressed as $g_{ab}=\eta_{ab}+\phi k_a k_b$, where $\eta_{ab}$ is Minkowski metric, $\phi$ is a scalar function and $k_a$ is a (co)vector field which is null and geodetic with ...
Dongba's user avatar
  • 21
2 votes
0 answers
37 views

Simulation of Quantum pseudo-telepathy

I would like to mathematically simulate Quantum pseudo-telepathy on The magic square game from Wikipedia. In section Pseudo-telepathic strategies we can read: The trick is for Alice and Bob to share ...
azerbajdzan's user avatar
  • 17.5k
2 votes
0 answers
280 views

The Weyl Scalar: does anyone here knows a code to calculate it?

From pure differential geometry we have an important tensor called Weyl Tensor. Its components are given by: $$C_{ijkl} = R_{ijkl} - \frac{2}{n-2}(g_{ik}R_{jl} + g_{jl}R_{ik} - g_{il}R_{jk} - g_{jk}...
M.N.Raia's user avatar
  • 503
2 votes
0 answers
144 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.
relativeentropy's user avatar
2 votes
0 answers
109 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 <...
relativeentropy's user avatar
2 votes
0 answers
121 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)^...
rmk236's user avatar
  • 21
2 votes
0 answers
376 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. ...
Melik Karapetyan's user avatar
2 votes
0 answers
62 views

Optimising tensor operations under memory constraints

Let riem is a free variable with riem ∈ Arrays[{4, 4, 4, 4} as assumption. Let: ...
user3257842's user avatar
2 votes
0 answers
59 views

Parallelize and tensor calculus

Is it possible to use Parallelize with tensor calculus functions like TensorContract and ...
mattiav27's user avatar
  • 6,727
2 votes
0 answers
153 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 ...
Perfect Fluid's user avatar
2 votes
0 answers
65 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 ...
Siddhartha Morales's user avatar
2 votes
0 answers
116 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 ...
Miladiouss's user avatar
  • 1,883
2 votes
0 answers
275 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},...
user1058860's user avatar
2 votes
0 answers
462 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 ...
davidivadful's user avatar
2 votes
0 answers
721 views

Solving Relaxed Einstein Equation with xAct and xTensor packages

First time question, involving tensor calculus. I am entirely new to Mathematica and don't understand most of its conventions or jargon. I'm trying to do tensor calculations in GR. I've ...
RBoston's user avatar
  • 85
2 votes
0 answers
127 views

complex tensor expression with Pauli matrices

I attempt to understand is it possible whether to calculate the next expression by means of mathematica: $\varepsilon^{\mu\nu\rho\sigma}tr(\{\partial_{\mu}L_{\nu},L_{\rho}\}(\partial_{\sigma}H)H^{\...
illuminato's user avatar
2 votes
0 answers
656 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, ...
user39257's user avatar
2 votes
0 answers
123 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 ...
geodude's user avatar
  • 165
2 votes
0 answers
519 views

Derivative with respect to a tensor

I am trying to differentiate a tensor with respect to another one in Mathematica, but I can't do it. Down below is the code I am using: ...
Shawn Wang's user avatar
2 votes
0 answers
215 views

How to solve system of differential equations of arbitrary order (symbolic tensors)?

I am interested in solving systems of ODEs symbolicly, keeping things with arbitrary dimensions for clarity. For example, assume that $x, f(x) \in R^N$ and $A \in R^{N \times N}$, how do I solve $f'(...
jlperla's user avatar
  • 967
2 votes
0 answers
184 views

Smooth Max and Abs

I'm trying to implement smooth approximations of Max and Abs functions. Moreover I want the functions to map element-wise on tensors. Here's my code. ...
Ishan Arora's user avatar
1 vote
0 answers
27 views

TensorProduct in a FunctionLayer cannot compile correctly

My network can output an array of 6x512x512 size at the end, now I want to multiply an array of length 3 for each of these 6 channels to get the color of the different channels, I am using the ...
Schwarzer's user avatar
1 vote
0 answers
77 views

Operations on symbolic tensors

I have recently discovered the set of functions related to symbolic tensors, namely TensorProduct, TensorContract, ...
enzotib's user avatar
  • 1,094
1 vote
0 answers
78 views

Finding Petrov type of a metric

Is there a subpackage in xAct (or another Mathematica package for general relativity calculations) to determine the Petrov type of a metric? I understand that xAct has a lot of subpackages for ...
jay121's user avatar
  • 43
1 vote
0 answers
68 views

How to multiply five tensors of different ranks (contravariant, covariant and mixed) in Mathematica?

How to compute the following multiplication of five different tensors of different ranks in Mathematica ...
Sangeeta Dey's user avatar
1 vote
0 answers
126 views

Mathematica, ML and TensorFlow

I am currently studying a specialization on Coursera in Machine Learning and am investigating various tools to help me out with the maths and with visualisations and so on. Although I have many ...
serlingpa's user avatar
  • 111
1 vote
0 answers
89 views

Tensor equation problem (xact package)

So i want to solve the tensor equation P1[-μ,-ν]=0 with respect to A[r] and then B[r] but the problem is when hitting shift-enter the tensor given is way too long (if i press "show all" my ...
Stelios's user avatar
  • 11