So I would like to be able to do operations on vectors, while leaving the dimension $N$ of the vector space unspecified.

As a simple example, I would like to be able to define the unit vector $e_i = (0,\dots 1,\dots,0)$ which has as its only non-vanishing entry a $1$ in the $i$th slot. Then I would like to be able to let Mathematica compute the inner product $e_i\cdot e_j$; the output of Mathematica should be something like $\delta_{ij}$ (which equals $1$ if $i=j$ and $0$ if $i\neq j$).

When the dimension $N$ is defined as an explicit number, one can of course just define the explicit vectors $e_i$ and $e_j$ and compute the inner product, which will again be an explicit vector. But I would like to do the calculation for general $N$.

Is there a way in Mathematica to achieve this?

  • $\begingroup$ Related: How to define an orthogonal basis in the right way and How do I simplify a vector expression $\endgroup$ – Jens Aug 15 '18 at 16:12
  • $\begingroup$ It looks like you're talking about Euclidean vector spaces. If you're interested in other operations beyond dot products, please specify with an example of what you have tried. $\endgroup$ – Jens Aug 15 '18 at 16:24
  • $\begingroup$ @Jens In the end what I want to do is calculate commutators between $N\times N$ matrices, where $N$ is again unspecified. But I imagine this will be easy to do once I understand how to implement the simple example in my question. $\endgroup$ – Sjorszini Aug 15 '18 at 18:11
  • $\begingroup$ Actually, the way it's current written it could also be a duplicate of Defining quantum-mechanical Bra and Ket operations. You'll need additional definitions for outer products (or dual vectors) to generate matrices in your basis, but it can be done analogously, using TagSetDelayed. It would be easier to help if you gave a more complete example. $\endgroup$ – Jens Aug 15 '18 at 18:24
  • $\begingroup$ Concerning commutators: if that's what you ultimately want, the relevant link may be Defining a non-commutative operator algebra in Mathematica $\endgroup$ – Jens Aug 16 '18 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.