# 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
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: <...
• 36.1k
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 ...
• 598
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: \tag{1}\frac{\delta{}g^{\alpha\beta}_{\;{},\gamma}\left(x\right)}{\delta{}g^{\mu\...
• 61
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 ...
• 51
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 ...
119 views

### TensorContract applied twice

I have a very simple question about TensorContract command: I'm declaring ...
• 909
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. ...
• 143
69 views

### speed up tensor expand

I am using the following code ...
• 63
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. ...
• 41
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 ...
• 131
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, ...
• 260
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 ...
• 7,823
145 views

• 299
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, ...
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 ...
• 165
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: ...
• 131
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'(...
• 967
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. ...
1 vote
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 ...
1 vote
77 views

### Operations on symbolic tensors

I have recently discovered the set of functions related to symbolic tensors, namely TensorProduct, TensorContract, ...
• 1,094
1 vote
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 ...
• 43
1 vote
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 ...
• 135
1 vote
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 ...
• 111
1 vote