« Archives in August, 2011

## Levi-Civita Matlab Function

I banged out a quick matlab script for implementing something that has turned up quite a bit lately in my mathematical investigations: The Levi-Civita symbol.

The Levi-Civita symbol turns up in certain definitions of the determinant (including some definitions of partial determinants), and also in Grassman and Clifford Algebra (the branch of linear algebra dealing with the construction of higher order geometric objects from vectors through an operator called the Wedge Product). Evaluating these requires the ability to call on this pseudo-tensor.

So, what is it, and what does it do? The Levi-Civita pseudo-tensor takes a certain group of indices and returns +1 if these are arranged in ascending order, or an order that can be composed as ascending with an even number of swaps. It returns -1, if the permutation is an odd number of swaps away from ascending order. It returns 0 in all cases where there is a repeated index. In general, the levi-civita symbol can be defined for any number of dimensions (number of indices given), and returns values for incomplete lists of indices (such as [3,4,5]) as if the elements not given in that list were prepended in ascending order e_3,4,5 = e_1,2,3,4,5 = 1

Here it is:

LeviCivita.m

Here is how to call it in Matlab:

>> LeviCivita([1,2,3])

ans =

1

>> LeviCivita([2,3,4])

ans =

1

>> LeviCivita([2,4,3,1])

ans =

1

>> LeviCivita([1,4,3,2])

ans =

-1

>> LeviCivita([1,4,3,2,18,91,128])

ans =

-1

Hope this helps anyone else out there who is exploring tensor calculus!