Hot answers tagged

23 votes
Accepted

Nearest Kronecker Product

The Pitsianis-Van Loan algorithm turns out to be surprisingly easy to implement in Mathematica: ...
user avatar
21 votes
Accepted

Python's einsum equivalent in Mathematica?

You can implement most of your einsum functionality using TensorContract/TensorTranspose. ...
user avatar
  • 123k
20 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, ..., ...
user avatar
  • 5,505
15 votes
Accepted

How can I define or use a new coordinate system?

Thank you for your interest. I would strongly recommend against trying to modify SymbolicTensors`CoordinateChartDataDump`mappingInfo. It is a very low level ...
user avatar
  • 13.3k
11 votes
Accepted

How to get rid of nested matrices

Depends on what dimension your final matrix is supposed to have. When I should make a guess, I would say you want this ...
user avatar
  • 111k
11 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 ...
user avatar
  • 13.3k
11 votes
Accepted

FindFit returns "tensors have incompatible shapes"

Some errors corrected and a few tricks Using memoization, "Precomputing" the solutions by using Reduce once instead of NSolve each time, Rewriting the functions in a compact and more ...
user avatar
11 votes
Accepted

How to simplify symbolic expressions with KroneckerProduct

There is another option, using the relatively new tensor capabilities of Mathematica. This is pretty much copied from another answer by jose, but I don't need any assumptions here: ...
user avatar
  • 95k
11 votes

Make symbols atomic, without losing their type

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

Make symbols atomic, without losing their type

You could use my TensorSimplify package help with this. Install the paclet with: ...
user avatar
  • 123k
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 ...
user avatar
11 votes
Accepted

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

You can use TensorContract instead of Sum: ...
user avatar
  • 123k
11 votes
Accepted

Undefined Indexed Variable

The variable i is a dummy one. The evaluated expression: ...
user avatar
10 votes

Using the epsilon tensor in Mathematica

The symbol $\epsilon$ is called the Levi-Civita tensor, it is usually written in terms of its components $\epsilon_{i j k}$. Having defined two vectors (i.e. first order contravariant tensors): <...
user avatar
  • 54k
10 votes

Ways to compute inner products of tensors

Since the question "Efficient tensor product followed by contraction" asking for an efficient solution to this problem has been marked as a duplicate, I find it appropriate to add here an encapsulated ...
user avatar
  • 321
10 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 ...
user avatar
10 votes
Accepted

Cartesian tensor gradient

Perhaps something like the following will suffice? ...
user avatar
  • 123k
10 votes
Accepted

Expand wedge product

One idea is to use TensorReduce. I will assume that r is real, and that Dt[r] and ...
user avatar
  • 123k
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: ...
user avatar
  • 51.5k
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 &...
user avatar
  • 8,373
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 ...
user avatar
9 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. ...
user avatar
  • 5,354
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 ...
user avatar
  • 123k
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 ...
user avatar
9 votes

Array reshaping without explicitly specifying one dimension

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

Symbolic tensor simplifications and the identity matrix

I agree that it's a bit odd that Mathematica doesn't simplify these expressions with its built-in functions, especially in the symbolic tensor language (i.e. using ...
user avatar
  • 5,921
8 votes
Accepted

How to define an orthogonal basis in the right way?

You can combine the best of both worlds: symbolic tensors and vectors on one hand, and explicit vectors on the other. Explicit vectors are necessary in most vector algebra operations, unless you want ...
user avatar
  • 95k
8 votes

Compute a double dot product between two tensors of rank 3 and 2

The double dot product is also known as the Frobenius inner product--in other words, it is the result of flattening the matrices and treating them as vectors. So, here is another way to write it: <...
user avatar
  • 22.5k
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 ...
user avatar
  • 21.5k
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) ...
user avatar
  • 1,032

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