Coordinates of Regular Simplex in M Dimensions

**SIMPLEX_COORDINATES**
is a Python library which
computes the Cartesian coordinates of the vertices of
a regular simplex in M dimensions.

Note that the unit simplex, formed by the origin and the M unit coordinate axes, is not a regular simplex, because some sides have length 1 while other sides have length sqrt(2).

There is a straightforward but tedious method for computing these coordinates, coded in SIMPLEX_COORDINATES1, based on the idea of selecting the first coordinate to be (1,0,0,...0), and noting that the dot product with vectors 2 through N+1 must be -1/N, which means the first row and first column of the coordinate matrix are done. We can then move to entry (2,2), assume the coordinates below it are 0, and set its value by requiring that the sum of the squares of the (2,1) and (2,2) entries must be 1. Setting the (2,2) entry then allows us to determine the rest of row 2 by the same dot product criterion, and we proceed in this way til we have completed the matrix.

A simpler algorithm, in SIMPLEX_COORDINATES2, notes that the identity matrix will almost work for the first N vertices. Choose the last vertex by assuming all its entries are equal to some constant A, and that its distance from any other vertex must be sqrt ( 2 ). This determines that (A-1)^2 + (N-1)*A^2 = 2, from which we get the value of A as (1-sqrt(N+1))/N. To clean things up, we compute the centroid C of these vertices, and recenter the simplex around the origin. Then we determine the distance S of one vertex to the origin, and rescale so that this becomes 1. The coding is simpler, and there is much less chance for the accumulation of numerical error. Plus I thought of this one myself.

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

**SIMPLEX_COORDINATES** is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version and
a Python version.

SIMPLEX_GRID, a Python library which generates a regular grid of points over the interior of an arbitrary simplex in M dimensions.

SIMPLEX_MONTE_CARLO, a Python library which uses the Monte Carlo method to estimate integrals over the interior of the unit simplex in M dimensions.

- r8_factorial.py, computes the factorial of N.
- r8_factorial_values.py, returns selected values of the factorial function.
- r8mat_transpose_print.py, prints an R8MAT, transposed.
- simplex_coordinates1.py, computes the Cartesian coordinates of simplex vertices.
- simplex_coordinates2.py, computes the Cartesian coordinates of simplex vertices.
- simplex_volume.py, computes the volume of a simplex.
- simplex_volume01.py, computes the volume of a unit simplex.
- timestamp.py, prints the current YMDHMS date as a time stamp.

- simplex_coordinates_test.py, calls all the tests.
- simplex_coordinates_test.sh, runs all the tests.
- simplex_coordinates_test.txt, the output file.

You can go up one level to the Python source codes.