23 votes
Accepted

What is the definition of Curl in Mathematica?

The definition used (motivated by exterior calculus) is as follows: Given a rectangular array $a$ of depth $n$, with dimensions $\{d, ..., d\}$ (so there are $n$ $d$'s) and a list $x = \{x_1, ..., ...
jose's user avatar
  • 6,328
22 votes
Accepted

Python's einsum equivalent in Mathematica?

You can implement most of your einsum functionality using TensorContract/TensorTranspose. ...
Carl Woll's user avatar
  • 131k
12 votes

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

Since Version 9, functions to do this have been built into Mathematica but not documented. They live in the SymbolicTensors package which underlies ...
Itai Seggev's user avatar
  • 14.1k
12 votes
Accepted

Fast Sparse Tensor Addition

Mathematica uses a modified CSR format for SparseArrays of dimension two or higher. But the CSR format was actually only developed for matrices (dimension equal to ...
Henrik Schumacher's user avatar
12 votes
Accepted

How can I "multiply" nested lists?

Times @@@ Tuples @ {alist, blist} {{a r, b s, c t}, {a x, b y, c z}, {d r, e s, f t}, {d x, e y, f z}}
kglr's user avatar
  • 395k
11 votes
Accepted

A comprehensive list of all correct input formats for [[experimental]] Neural Net functions?

Ok, you've got yourself a bit confused here, but that's okay. Going through the three different errors: For a simple net like the one you gave, which has one input and one output, what ...
Taliesin Beynon's user avatar
11 votes
Accepted

Cartesian tensor gradient

Perhaps something like the following will suffice? ...
Carl Woll's user avatar
  • 131k
11 votes
Accepted

Expand wedge product

One idea is to use TensorReduce. I will assume that r is real, and that Dt[r] and ...
Carl Woll's user avatar
  • 131k
11 votes

What is the definition of Curl in Mathematica?

I fail to find a reference for the definition used by Curl, but manage to figure out how the Curl is defined. I'll use Einstein ...
xzczd's user avatar
  • 66k
11 votes

Make symbols atomic, without losing their type

Perhaps what you want is symbolic tensors: http://reference.wolfram.com/language/tutorial/SymbolicTensors.html ...
Szabolcs's user avatar
  • 235k
11 votes
Accepted

Make symbols atomic, without losing their type

You could use my TensorSimplify package help with this. Install the paclet with: ...
Carl Woll's user avatar
  • 131k
11 votes
Accepted

Speeding up tensor contractions and multiplication

You seem to be coming from Matlab as you try to transpose a vector, a concept that is not that useful in Mathematica. We will see in a second why that is. Dense tensor example ...
Henrik Schumacher's user avatar
11 votes
Accepted

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

You can use TensorContract instead of Sum: ...
Carl Woll's user avatar
  • 131k
11 votes
Accepted

Undefined Indexed Variable

The variable i is a dummy one. The evaluated expression: ...
Alexei Boulbitch's user avatar
10 votes

Compute covariant derivative in Mathematica

There is undocumented functionality in the SymbolicTensors package, which underlies CoordinateChartData, CoordinateTransformData,...
Itai Seggev's user avatar
  • 14.1k
10 votes
Accepted

Dot Product of Block Matrices

One way is to turn them into ordinary matrices, take the dot product, and then ArrayReshape them into the form you want. ...
aardvark2012's user avatar
  • 5,424
10 votes
Accepted

How to implement Einstein summation convention with differential operators

Aha, simpler than I thought. Assuming all I guessed in the comments is correct: ...
xzczd's user avatar
  • 66k
10 votes

How to rewrite a tensor as a matrix

mat = {TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]/Sqrt[2]}; FixedPoint[ArrayFlatten, mat] // MatrixForm $\left( \begin{array}{cccccccc} 0 & 0 &...
Suba Thomas's user avatar
  • 8,741
9 votes

SymmetrizedArray of stiffness/compliance tensor

This is very late to the party, but someone might still be interested. You can do what you want by solving the conditions of the material symmetry group. My answer is organized in 1) Background ...
Mauricio Fernández's user avatar
9 votes
Accepted

How to simplify tensor expression with symbolic coeficients?

$Assumptions = {(a | b | c) ∈ Vectors[3], g ∈ Reals} TensorReduce[g b.a\[Cross]c - g c.b\[Cross]a] 0
kglr's user avatar
  • 395k
9 votes

Summation of Kronecker deltas should give the dimension

You could just do: Sum[KroneckerDelta[μ, ν] KroneckerDelta[μ, ν], {ν, d}, {μ, d}, Assumptions->d>1] d Although it might make sense to use symbolic ...
Carl Woll's user avatar
  • 131k
9 votes

How to implement Einstein summation convention with differential operators

Let me try to partially answer. Partially for the following reason: I know how to implement index vector and tensor notations and how to work with them. I also wanted to implement the Einstein ...
Alexei Boulbitch's user avatar
9 votes

Array reshaping without explicitly specifying one dimension

ArrayReshape doesn't let you do this, but ReshapeLayer does: ...
Sjoerd Smit's user avatar
  • 23.5k
8 votes

Higher order SVD

I worked on this topic today as I'm interested in it for an interpolation problem. I followed the interlaced computation from the Wikipedia link in the other answers (corresponding paper is here), ...
faysou's user avatar
  • 11k
8 votes
Accepted

How to create simple (tensor) product spaces?

Here is the basic method, illustrated with the combination of two spin-1/2 particles. (Hopefully, the physics language is familiar or accessible; I don't really have an idea of where else this kind of ...
march's user avatar
  • 23.4k
8 votes
Accepted

Symbolic calculation with generators and relations

Edit. Based on the comments, here is a more concrete answer to what I think you'd like. My previous answer can be found below. Defining a ring symbolically. Let's consider some ring (or algebra) ...
Jules Lamers's user avatar
  • 1,074
8 votes
Accepted

Tensor analysis - Index Notation

In Mathematica, symbolic tensors don't necessarily use indices. Instead, tensors are declared to have a certain number of indices (rank): ...
Carl Woll's user avatar
  • 131k
8 votes
Accepted

How can I automate this tensor computation?

You can write it directly as you see it ...
yarchik's user avatar
  • 18.2k
8 votes
Accepted

TensorContract and TensorProduct problem

Mathematica contracts indices assuming flat Euclidean metric. You have to lower/raise the indices yourself. ...
Vasily Mitch's user avatar
8 votes

How to rewrite a tensor as a matrix

mat = {TensorProduct[{1, 0}, {0, 1}, {0, 1}, {0, 1}, {0, 1}]/ Sqrt[2]}; ArrayFlatten[ArrayFlatten /@ mat] // MatrixForm $\left( \begin{array}{cccccccc} 0 & ...
OkkesDulgerci's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible