Function Repository Resource:

SimplexVolume

Source Notebook

Compute the area, volume or content of a simplex

Contributed by: Ed Pegg Jr

ResourceFunction["SimplexVolume"][simp]

computes the content of simplex simp.

Details

In two dimensions, the area is returned.
In three dimensions, the volume is returned.
In four dimensions and higher, the content is returned.
The simp can be provided as either a list of vertices or a Simplex.
The resource function SimplexMeasure is slower but more powerful.
ResourceFunction["SimplexVolume"] uses a variety of a Cayley-Menger matrix.

Examples

Basic Examples (3) 

Find the area of a triangle:

In[1]:=
ResourceFunction["SimplexVolume"][{{0, 0}, {4, 0}, {0, 3}}]
Out[1]=

Find the volume of a tetrahedron:

In[2]:=
ResourceFunction[
 "SimplexVolume"][{{0, 0, 0}, {4, 0, 0}, {0, 3, 0}, {0, 0, 3}}]
Out[2]=

Find the content of a 5-cell or 4-simplex:

In[3]:=
ResourceFunction[
 "SimplexVolume"][{{0, 0, 0, 0}, {4, 0, 0, 0}, {0, 3, 0, 0}, {0, 0, 3,
    0}, {0, 0, 0, 4}}]
Out[3]=

Scope (4) 

Compare SimplexVolume and SimplexMeasure:

In[4]:=
ResourceFunction[
 "SimplexVolume"][{{0, 0, 0, 0}, {4, 0, 0, 0}, {0, 3, 0, 0}, {0, 0, 3,
    0}, {0, 0, 0, 4}}]
Out[4]=
In[5]:=
ResourceFunction["SimplexMeasure"][
 Simplex[{{0, 0, 0, 0}, {4, 0, 0, 0}, {0, 3, 0, 0}, {0, 0, 3, 0}, {0, 0, 0, 4}}]]
Out[5]=

Find the area of a triangle provided as a Simplex:

In[6]:=
ResourceFunction["SimplexVolume"][Simplex[{{0, 0}, {4, 0}, {0, 3}}]]
Out[6]=

Compare timings for tetrahedra:

In[7]:=
simplexes = RandomInteger[{-9, 9}, {1000, 4, 3}];
{Timing[sv = ResourceFunction["SimplexVolume"] /@ simplexes;], Timing[sm = ResourceFunction["SimplexMeasure"][Simplex[#]] & /@ simplexes;],
 Timing[rm = RegionMeasure[Tetrahedron[#]] & /@ simplexes;]}
Out[8]=

Compare timings for 5-cells:

In[9]:=
simplexes = RandomInteger[{-9, 9}, {1000, 5, 4}];
{Timing[sv = ResourceFunction["SimplexVolume"] /@ simplexes;], Timing[sm = ResourceFunction["SimplexMeasure"][Simplex[#]] & /@ simplexes;]}
Out[10]=

Check equality:

In[11]:=
sv == sm
Out[11]=

Requirements

Wolfram Language 12.3 (May 2021) or above

Version History

  • 1.0.0 – 20 October 2023

Related Resources

License Information