simplex_coordinates, an Octave code which computes the Cartesian coordinates of the vertices of a regular simplex in M dimensions with barycenter at the origin.
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 MIT license
simplex_coordinates is available in a C version and a C++ version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.