---
title: "Simplex"
language: "en"
type: "Symbol"
summary: "Simplex[{p1, ..., pk}] represents the simplex spanned by points pi."
keywords: 
- line segment
- triangle
- tetrahedron
- tetrahedra
- pentachoron
- hyperpyramid
- simplex
- simplex region
- Kuhn simplex
- standard simplex
canonical_url: "https://reference.wolfram.com/language/ref/Simplex.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Graphics Objects"
    link: "https://reference.wolfram.com/language/guide/GraphicsObjects.en.md"
  - 
    title: "Basic Geometric Regions"
    link: "https://reference.wolfram.com/language/guide/GeometricSpecialRegions.en.md"
  - 
    title: "Geometric Computation"
    link: "https://reference.wolfram.com/language/guide/GeometricComputation.en.md"
  - 
    title: "Solid Geometry"
    link: "https://reference.wolfram.com/language/guide/SolidGeometry.en.md"
  - 
    title: "Polygons"
    link: "https://reference.wolfram.com/language/guide/Polygons.en.md"
  - 
    title: "Polyhedra"
    link: "https://reference.wolfram.com/language/guide/Polyhedra.en.md"
related_functions: 
  - 
    title: "Point"
    link: "https://reference.wolfram.com/language/ref/Point.en.md"
  - 
    title: "Line"
    link: "https://reference.wolfram.com/language/ref/Line.en.md"
  - 
    title: "Triangle"
    link: "https://reference.wolfram.com/language/ref/Triangle.en.md"
  - 
    title: "Polygon"
    link: "https://reference.wolfram.com/language/ref/Polygon.en.md"
  - 
    title: "Tetrahedron"
    link: "https://reference.wolfram.com/language/ref/Tetrahedron.en.md"
  - 
    title: "Polyhedron"
    link: "https://reference.wolfram.com/language/ref/Polyhedron.en.md"
  - 
    title: "MeshRegion"
    link: "https://reference.wolfram.com/language/ref/MeshRegion.en.md"
---
# Simplex

Simplex[{p1, …, pk}] represents the simplex spanned by points pi.

## Details and Options

* ``Simplex`` is also known as point, line segment, triangle, tetrahedron, pentachoron, hexateron, etc.

* ``Simplex`` represents all convex combinations of the given points ${Subscript[λ, 1] Subscript[p, 1] + ⋯ + Subscript[λ, k] Subscript[p, k] | Subscript[λ, i] ≥ 0∧Subscript[λ, 1] + ⋯ + Subscript[λ, k]=1}$. The region is $k - 1$ dimensional when $Subscript[p, i]∈\[DoubleStruckCapitalR]^n$ are affinely independent and $n ≥ k - 1$.

* Example simplices where rows correspond to embedding dimension:

[image]

* ``Simplex````[n]`` for integer ``n`` is equivalent to ``Simplex[{{0, …, 0}, {1, 0, …, 0}, …, {0, …, 0, 1}}]``, the unit standard simplex in $\[DoubleStruckCapitalR]^n$.

* ``Simplex`` can be used as a geometric region and graphics primitive.

* In graphics, the points ``pi`` can be ``Scaled`` and ``Dynamic`` expressions.

* Graphics rendering is affected by directives such as ``FaceForm``, ``EdgeForm``, ``Opacity``, and color.

## Examples (33)

### Basic Examples (3)

A ``Simplex`` in 3D:

```wl
In[1]:= Graphics3D[Simplex[{{0, 0, 1}, {1, 0, 0}, {1, 0, 1}, {1, 1, 1}}]]

Out[1]= [image]
```

And in 2D:

```wl
In[2]:= Graphics[Simplex[{{0, 0}, {1, 1}, {2, 0}}]]

Out[2]= [image]
```

---

Different styles applied to a simplex:

```wl
In[1]:= ℛ = Simplex[3];

In[2]:= {Graphics3D[{Pink, ℛ}], Graphics3D[{EdgeForm[Thick], ℛ}], Graphics3D[{Opacity[0.25], Blue, ℛ}], Graphics3D[{EdgeForm[Directive[Thick, Dotted]], FaceForm[None], ℛ}]}

Out[2]= {[image], [image], [image], [image]}
```

---

Volume and centroid:

```wl
In[1]:= ℛ = Simplex[{{1, 0, 0}, {1, 0, 1}, {1, 1, 1}, {0, 0, 1}}];

In[2]:= Volume[ℛ]

Out[2]= (1/6)

In[3]:= RegionCentroid[ℛ]

Out[3]= {(3/4), (1/4), (3/4)}
```

### Scope (20)

#### Graphics (9)

##### Specification (3)

---

A standard unit ``Simplex`` in 3D:

```wl
In[1]:= Graphics3D[Simplex[3]]

Out[1]= [image]
```

---

A 2D simplex spanning three points:

```wl
In[1]:= Graphics[Simplex[{{0, 0}, {1, 1}, {2, 0}}]]

Out[1]= [image]
```

---

A simplex in $n$ dimensions is specified by at most $n + 1$ points:

```wl
In[1]:= pts = {{0, 0, 1}, {1, 0, 0}, {1, 0, 1}, {1, 1, 1}};

In[2]:= Table[Graphics3D[Simplex[Take[pts, n]]], {n, 4}]

Out[2]= {[image], [image], [image], [image]}
```

##### Styling (3)

---

Different styles applied to a simplex:

```wl
In[1]:= ℛ = Simplex[3];

In[2]:= {Graphics3D[{Pink, ℛ}], Graphics3D[{EdgeForm[Thick], ℛ}], Graphics3D[{Opacity[0.25], Blue, ℛ}], Graphics3D[{EdgeForm[Directive[Thick, Dotted]], FaceForm[None], ℛ}]}

Out[2]= {[image], [image], [image], [image]}
```

---

Color directives specify the face color:

```wl
In[1]:= Table[Graphics3D[{c, Simplex[3]}], {c, {Red, Green, Blue, Yellow}}]

Out[1]= {[image], [image], [image], [image]}
```

---

``FaceForm`` and ``EdgeForm`` can be used to specify the styles of the faces and edges:

```wl
In[1]:= Graphics3D[{FaceForm[Pink], EdgeForm[Directive[Thick, Dashed, Blue]], Simplex[3]}]

Out[1]= [image]
```

##### Coordinates (3)

---

Specify coordinates by fractions of the plot range:

```wl
In[1]:= Graphics3D[Simplex[{Scaled[{0, 0, 0}], Scaled[{0.5, 0, 0}], Scaled[{0, 0.5, 0}], Scaled[{0, 0, 0.5}]}], PlotRange -> {{0, 10}, {0, 10}, {0, 10}}, Axes -> True]

Out[1]= [image]
```

---

Specify scaled offsets from the ordinary coordinates:

```wl
In[1]:= Graphics3D[Simplex[{Scaled[{0, 0, 0.5}, {0, 0, 0}], Scaled[{0, 0, 0.5}, {1, 0, 0}], Scaled[{0, 0, 0.5}, {0, 1, 0}], Scaled[{0, 0, 0.5}, {0, 0, 1}]}], PlotRange -> {{0, 2}, {0, 2}, {0, 2}}, Axes -> True]

Out[1]= [image]
```

---

Points can be ``Dynamic`` :

```wl
In[1]:= DynamicModule[{x}, {Slider[Dynamic[x], {0, 1}], Graphics3D[Simplex[{Dynamic[{1, 1, 1}x], {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}]]}]

Out[1]= DynamicModule[«3»]
```

#### Regions (11)

Embedding dimension is the dimension of the space in which the simplex lives:

```wl
In[1]:= RegionEmbeddingDimension[Simplex[{{0, 0}, {1, 0}, {0, 1}}]]

Out[1]= 2

In[2]:= RegionEmbeddingDimension[Simplex[{{0, 0, 0}, {1, 0, 0}, {0, 1, 1}}]]

Out[2]= 3

In[3]:= Table[RegionEmbeddingDimension[Simplex[d]], {d, 5}]

Out[3]= {1, 2, 3, 4, 5}
```

---

Geometric dimension is the dimension of the shape itself:

```wl
In[1]:= RegionDimension[Simplex[{{0, 0}, {1, 0}, {0, 1}}]]

Out[1]= 2

In[2]:= RegionDimension[Simplex[{{0, 0, 0}, {1, 0, 0}, {0, 1, 1}}]]

Out[2]= 2

In[3]:= Table[RegionDimension[Simplex[d]], {d, 5}]

Out[3]= {1, 2, 3, 4, 5}
```

---

Point membership test:

```wl
In[1]:= RegionMember[Simplex[{{0, 0}, {1, 0}, {0, 1}}], {1 / 2, 1 / 2}]

Out[1]= True

In[2]:= RegionMember[Simplex[{{0, 0}, {1, 0}, {0, 1}}], {1, 1}]

Out[2]= False
```

Get conditions for point membership:

```wl
In[3]:= RegionMember[Simplex[2], {x, y}]

Out[3]= (x | y)∈ℝ && x ≥ 0 && y ≥ 0 && x + y ≤ 1
```

---

Measure and centroid:

```wl
In[1]:= RegionMeasure[Simplex[3]]

Out[1]= (1/6)

In[2]:= RegionCentroid[Simplex[3]]

Out[2]= {(1/4), (1/4), (1/4)}
```

The measure for a standard simplex in dimension $d$ is $1 / d!$ :

```wl
In[3]:= Table[RegionMeasure[Simplex[d]], {d, 5}]

Out[3]= {1, (1/2), (1/6), (1/24), (1/120)}
```

---

Distance from a point:

```wl
In[1]:= ℛ = Simplex[{{0, 0}, {1, 1}, {2, 0}}];

In[2]:= {RegionDistance[ℛ, {2, 2}], RegionDistance[ℛ, {1 / 2, 1 / 2}]}

Out[2]= {Sqrt[2], 0}
```

Visualize it:

```wl
In[3]:= {Plot3D[Evaluate@RegionDistance[ℛ, {x, y}], {x, -1, 3}, {y, -1, 2}, MeshFunctions -> {#3&}, Mesh -> 5], ContourPlot[Evaluate@RegionDistance[ℛ, {x, y}], {x, -2, 4}, {y, -2, 3}, Contours -> {{0.5, Red}, {1, Green}, {1.5, Blue}}]}

Out[3]= {[image], [image]}
```

---

Signed distance from a point:

```wl
In[1]:= ℛ = Simplex[{{0, 0}, {1, 1}, {2, 0}}];

In[2]:= {SignedRegionDistance[ℛ, {2, 2}], SignedRegionDistance[ℛ, {1 / 2, 1 / 2}]}

Out[2]= {Sqrt[2], 0}

In[3]:= Plot3D[SignedRegionDistance[ℛ, {x, y}], {x, -1, 3}, {y, -1, 2}, MeshFunctions -> {#3&}, Mesh -> {{0}}, MeshShading -> {Red, Green}]

Out[3]= [image]
```

---

Nearest point to the region:

```wl
In[1]:= ℛ = Simplex[{{0, 0}, {1, 1}, {2, 0}}];

In[2]:= {RegionNearest[ℛ, {2, 2}], RegionNearest[ℛ, {1 / 3, 1 / 3}]}

Out[2]= {{1, 1}, {(1/3), (1/3)}}
```

Visualize it:

```wl
In[3]:=
pts = Table[{1, 0.25} + 1.5{Cos[k 2 π / 16], Sin[k 2 π / 16]}, {k, 0, 15}];
nst = RegionNearest[ℛ, #]& /@ pts;

In[4]:= Legended[Graphics[{{Gray, ℛ}, {Thin, Gray, Line[Transpose[{pts, nst}]]}, {Red, Point[pts]}, {Blue, Point[nst]}}], PointLegend[{Red, Blue}, {"start", "nearest"}]]

Out[4]= [image]
```

---

A simplex is bounded:

```wl
In[1]:= ℛ = Simplex[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}];

In[2]:= BoundedRegionQ[ℛ]

Out[2]= True
```

Find its range:

```wl
In[3]:= r = RegionBounds[ℛ]

Out[3]= {{0, 1}, {0, 1}, {0, 1}}

In[4]:= Graphics3D[{{EdgeForm[White], Opacity[0.2, Yellow], Cuboid@@Transpose[r]}, ℛ}, Boxed -> False]

Out[4]= [image]
```

---

``Integrate`` over a simplex:

```wl
In[1]:= Integrate[1, {x, y, z}∈Simplex[3]]

Out[1]= (1/6)

In[2]:= Integrate[x y z, {x, y, z}∈Simplex[3]]

Out[2]= (1/720)
```

---

Optimize over a simplex:

```wl
In[1]:= MinValue[{x y - x, {x, y}∈Simplex[2]}, {x, y}]

Out[1]= -1

In[2]:= MaxValue[{Exp[x y], {x, y}∈Simplex[2]}, {x, y}]

Out[2]= E^1 / 4
```

---

Solve equations constrained by a simplex:

```wl
In[1]:= Reduce[(x - 1)(x - 2) == 0 && {x}∈Simplex[1], {x}]

Out[1]= x == 1

In[2]:= Reduce[4x^2 + 4y^2 + 4z^2 == 1 && {x, y, z}∈Simplex[3], {x, y, z}]

Out[2]= 0 ≤ x ≤ (1/2) && ((0 ≤ y < (1/2) Sqrt[1 - 4 x^2] && z == (1/2) Sqrt[1 - 4 x^2 - 4 y^2]) || (y == (1/2) Sqrt[1 - 4 x^2] && z == -(1/2) Sqrt[1 - 4 x^2 - 4 y^2]))
```

### Applications (1)

Define the Kuhn simplex for dimension $n$:

```wl
In[1]:= KuhnSimplex[n_] := Simplex@Table[If[j < i, 1, 0], {i, 1, n + 1}, {j, n}]
```

The 2D Kuhn simplex:

```wl
In[2]:= KuhnSimplex[2]

Out[2]= Simplex[{{0, 0}, {1, 0}, {1, 1}}]

In[3]:= Graphics[%]

Out[3]= [image]
```

The 3D Kuhn simplex:

```wl
In[4]:= KuhnSimplex[3]

Out[4]= Simplex[{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {1, 1, 1}}]

In[5]:= Graphics3D[%]

Out[5]= [image]
```

The measure in dimension $n$ is $1 / n!$ :

```wl
In[6]:= Table[RegionMeasure[KuhnSimplex[n]], {n, 5}]

Out[6]= {1, (1/2), (1/6), (1/24), (1/120)}
```

The centroid in dimension $n$ is ${n, n - 1, …, 1} / (n + 1)$:

```wl
In[7]:= Table[RegionCentroid[KuhnSimplex[n]], {n, 5}]

Out[7]= {{(1/2)}, {(2/3), (1/3)}, {(3/4), (1/2), (1/4)}, {(4/5), (3/5), (2/5), (1/5)}, {(5/6), (2/3), (1/2), (1/3), (1/6)}}
```

### Properties & Relations (8)

``TriangulateMesh`` can be used to decompose a volume mesh into simplices:

```wl
In[1]:= {ℛ2 = DiscretizeGraphics[Rectangle[]], TriangulateMesh[ℛ2]}

Out[1]= {[image], [image]}

In[2]:= {ℛ3 = DiscretizeGraphics[Cuboid[]], TriangulateMesh[ℛ3]}

Out[2]= {[image], [image]}
```

Use options such as ``MaxCellMeasure`` to control the number of simplices:

```wl
In[3]:= {TriangulateMesh[ℛ2, MaxCellMeasure -> 1], TriangulateMesh[ℛ3, MaxCellMeasure -> 1]}

Out[3]= {[image], [image]}
```

---

``Point`` is a special case of ``Simplex``:

```wl
In[1]:= RegionMember[Point[{{0, 0}}], {x, y}]

Out[1]= (x | y)∈ℝ && x == 0 && y == 0

In[2]:= RegionMember[Simplex[{{0, 0}}], {x, y}]

Out[2]= (x | y)∈ℝ && x == 0 && y == 0
```

---

``Line`` is a special case of ``Simplex``:

```wl
In[1]:=
Subscript[ℛ, 1] = Line[{{0, 0}, {1, 1}}];
Subscript[ℛ, 2] = Simplex[{{0, 0}, {1, 1}}];

In[2]:= RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]

Out[2]= True
```

---

``Triangle`` is a special case of ``Simplex`` :

```wl
In[1]:=
Subscript[ℛ, 1] = Triangle[{{0, 0}, {0, 1}, {1, 0}}];
Subscript[ℛ, 2] = Simplex[{{0, 0}, {0, 1}, {1, 0}}];

In[2]:= RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]

Out[2]= True
```

---

``Tetrahedron`` is a special case of ``Simplex``:

```wl
In[1]:=
Subscript[ℛ, 1] = Tetrahedron[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}];
Subscript[ℛ, 2] = Simplex[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}];

In[2]:= RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]

Out[2]= True
```

---

``Polygon`` is a generalization of ``Simplex`` in dimension 2:

```wl
In[1]:=
Subscript[ℛ, 1] = Polygon[{{0, 0}, {0, 1}, {1, 0}}];
Subscript[ℛ, 2] = Simplex[{{0, 0}, {0, 1}, {1, 0}}];

In[2]:= RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]

Out[2]= True
```

---

``ImplicitRegion`` can represent any ``Simplex``:

```wl
In[1]:=
Subscript[ℛ, 1] = ImplicitRegion[Subscript[t, 1] ≥ 0 && Subscript[t, 2] ≥ 0 && Subscript[t, 3] ≥ 0 && Subscript[t, 4] ≥ 0  && Subscript[t, 1] + Subscript[t, 2] + Subscript[t, 3] + Subscript[t, 4] ≤ 1, {Subscript[t, 1], Subscript[t, 2], Subscript[t, 3], Subscript[t, 4]}];
Subscript[ℛ, 2] = Simplex[{{0, 0, 0, 0}, {1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}];

In[2]:= RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]

Out[2]= True
```

---

``Simplex`` is the set of convex combinations of its vertices:

```wl
In[1]:=
{Subscript[p, 1], Subscript[p, 2], Subscript[p, 3], Subscript[p, 4]} = {{1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}};
Subscript[ℛ, 1] = ParametricRegion[{Subscript[t, 1]Subscript[p, 1] + Subscript[t, 2]Subscript[p, 2] + Subscript[t, 3]Subscript[p, 3] + Subscript[t, 4]Subscript[p, 4], Subscript[t, 1] ≥ 0 && Subscript[t, 2] ≥ 0 && Subscript[t, 3] ≥ 0 && Subscript[t, 4] ≥ 0  && Subscript[t, 1] + Subscript[t, 2] + Subscript[t, 3] + Subscript[t, 4] == 1}, {Subscript[t, 1], Subscript[t, 2], Subscript[t, 3], Subscript[t, 4]}];
Subscript[ℛ, 2] = Simplex[{Subscript[p, 1], Subscript[p, 2], Subscript[p, 3], Subscript[p, 4]}];

In[2]:= RegionEqual[Subscript[ℛ, 1], Subscript[ℛ, 2]]

Out[2]= True
```

### Neat Examples (1)

Random collection of simplices:

```wl
In[1]:= Graphics[Table[{Hue[RandomReal[]], Simplex[RandomReal[1, {3, 2}]]}, {10}]]

Out[1]= [image]

In[2]:= Graphics3D[Table[{Hue[RandomReal[]], Simplex[RandomReal[1, {4, 3}]]}, {10}]]

Out[2]= [image]
```

## See Also

* [`Point`](https://reference.wolfram.com/language/ref/Point.en.md)
* [`Line`](https://reference.wolfram.com/language/ref/Line.en.md)
* [`Triangle`](https://reference.wolfram.com/language/ref/Triangle.en.md)
* [`Polygon`](https://reference.wolfram.com/language/ref/Polygon.en.md)
* [`Tetrahedron`](https://reference.wolfram.com/language/ref/Tetrahedron.en.md)
* [`Polyhedron`](https://reference.wolfram.com/language/ref/Polyhedron.en.md)
* [`MeshRegion`](https://reference.wolfram.com/language/ref/MeshRegion.en.md)

## Related Guides

* [Graphics Objects](https://reference.wolfram.com/language/guide/GraphicsObjects.en.md)
* [Basic Geometric Regions](https://reference.wolfram.com/language/guide/GeometricSpecialRegions.en.md)
* [Geometric Computation](https://reference.wolfram.com/language/guide/GeometricComputation.en.md)
* [Solid Geometry](https://reference.wolfram.com/language/guide/SolidGeometry.en.md)
* [`Polygons`](https://reference.wolfram.com/language/guide/Polygons.en.md)
* [`Polyhedra`](https://reference.wolfram.com/language/guide/Polyhedra.en.md)

## History

* [Introduced in 2014 (10.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn100.en.md)