# mathlib3documentation

linear_algebra.affine_space.basis

# Affine bases and barycentric coordinates #

THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.

Suppose P is an affine space modelled on the module V over the ring k, and p : ι → P is an affine-independent family of points spanning P. Given this data, each point q : P may be written uniquely as an affine combination: q = w₀ p₀ + w₁ p₁ + ⋯ for some (finitely-supported) weights wᵢ. For each i : ι, we thus have an affine map P →ᵃ[k] k, namely q ↦ wᵢ. This family of maps is known as the family of barycentric coordinates. It is defined in this file.

## The construction #

Fixing i : ι, and allowing j : ι to range over the values j ≠ i, we obtain a basis bᵢ of V defined by bᵢ j = p j -ᵥ p i. Let fᵢ j : V →ₗ[k] k be the corresponding dual basis and let fᵢ = ∑ j, fᵢ j : V →ₗ[k] k be the corresponding "sum of all coordinates" form. Then the ith barycentric coordinate of q : P is 1 - fᵢ (q -ᵥ p i).

## Main definitions #

• affine_basis: a structure representing an affine basis of an affine space.
• affine_basis.coord: the map P →ᵃ[k] k corresponding to i : ι.
• affine_basis.coord_apply_eq: the behaviour of affine_basis.coord i on p i.
• affine_basis.coord_apply_ne: the behaviour of affine_basis.coord i on p j when j ≠ i.
• affine_basis.coord_apply: the behaviour of affine_basis.coord i on p j for general j.
• affine_basis.coord_apply_combination: the characterisation of affine_basis.coord i in terms of affine combinations, i.e., affine_basis.coord i (w₀ p₀ + w₁ p₁ + ⋯) = wᵢ.

## TODO #

• Construct the affine equivalence between P and { f : ι →₀ k | f.sum = 1 }.
structure affine_basis (ι : Type u₁) (k : Type u₂) {V : Type u₃} (P : Type u₄) [ P] [ring k] [ V] :
Type (max u₁ u₄)

An affine basis is a family of affine-independent points whose span is the top subspace.

Instances for affine_basis
@[protected, instance]
def affine_basis.inhabited {k : Type u_3} [ring k] :

The unique point in a single-point space is the simplest example of an affine basis.

Equations
@[protected, instance]
def affine_basis.fun_like {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] :
fun_like k P) ι (λ (_x : ι), P)
Equations
@[ext]
theorem affine_basis.ext {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] {b₁ b₂ : k P} (h : b₁ = b₂) :
b₁ = b₂
theorem affine_basis.ind {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) :
theorem affine_basis.tot {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) :
@[protected]
theorem affine_basis.nonempty {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) :
def affine_basis.reindex {ι : Type u_1} {ι' : Type u_2} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) (e : ι ι') :
k P

Composition of an affine basis and an equivalence of index types.

Equations
@[simp, norm_cast]
theorem affine_basis.coe_reindex {ι : Type u_1} {ι' : Type u_2} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) (e : ι ι') :
@[simp]
theorem affine_basis.reindex_apply {ι : Type u_1} {ι' : Type u_2} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) (e : ι ι') (i' : ι') :
(b.reindex e) i' = b ((e.symm) i')
@[simp]
theorem affine_basis.reindex_refl {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) :
noncomputable def affine_basis.basis_of {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) (i : ι) :
basis {j // j i} k V

Given an affine basis for an affine space P, if we single out one member of the family, we obtain a linear basis for the model space V.

The linear basis corresponding to the singled-out member i : ι is indexed by {j : ι // j ≠ i} and its jth element is b j -ᵥ b i. (See basis_of_apply.)

Equations
@[simp]
theorem affine_basis.basis_of_apply {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) (i : ι) (j : {j // j i}) :
(b.basis_of i) j = b j -ᵥ b i
@[simp]
theorem affine_basis.basis_of_reindex {ι : Type u_1} {ι' : Type u_2} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) (e : ι ι') (i : ι') :
noncomputable def affine_basis.coord {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) (i : ι) :

The ith barycentric coordinate of a point.

Equations
@[simp]
theorem affine_basis.linear_eq_sum_coords {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) (i : ι) :
@[simp]
theorem affine_basis.coord_reindex {ι : Type u_1} {ι' : Type u_2} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) (e : ι ι') (i : ι') :
(b.reindex e).coord i = b.coord ((e.symm) i)
@[simp]
theorem affine_basis.coord_apply_eq {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) (i : ι) :
(b.coord i) (b i) = 1
@[simp]
theorem affine_basis.coord_apply_ne {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) {i j : ι} (h : i j) :
(b.coord i) (b j) = 0
theorem affine_basis.coord_apply {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) [decidable_eq ι] (i j : ι) :
(b.coord i) (b j) = ite (i = j) 1 0
@[simp]
theorem affine_basis.coord_apply_combination_of_mem {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) {s : finset ι} {i : ι} (hi : i s) {w : ι k} (hw : s.sum w = 1) :
(b.coord i) ( b) w) = w i
@[simp]
theorem affine_basis.coord_apply_combination_of_not_mem {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) {s : finset ι} {i : ι} (hi : i s) {w : ι k} (hw : s.sum w = 1) :
(b.coord i) ( b) w) = 0
@[simp]
theorem affine_basis.sum_coord_apply_eq_one {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) [fintype ι] (q : P) :
finset.univ.sum (λ (i : ι), (b.coord i) q) = 1
@[simp]
theorem affine_basis.affine_combination_coord_eq_self {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) [fintype ι] (q : P) :
(λ (i : ι), (b.coord i) q) = q
@[simp]
theorem affine_basis.linear_combination_coord_eq_self {ι : Type u_1} {k : Type u_3} {V : Type u_4} [ring k] [ V] [fintype ι] (b : k V) (v : V) :
finset.univ.sum (λ (i : ι), (b.coord i) v b i) = v

A variant of affine_basis.affine_combination_coord_eq_self for the special case when the affine space is a module so we can talk about linear combinations.

theorem affine_basis.ext_elem {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) [finite ι] {q₁ q₂ : P} (h : (i : ι), (b.coord i) q₁ = (b.coord i) q₂) :
q₁ = q₂
@[simp]
theorem affine_basis.coe_coord_of_subsingleton_eq_one {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) [subsingleton ι] (i : ι) :
(b.coord i) = 1
theorem affine_basis.surjective_coord {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) [nontrivial ι] (i : ι) :
noncomputable def affine_basis.coords {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) :
P →ᵃ[k] ι k

Barycentric coordinates as an affine map.

Equations
@[simp]
theorem affine_basis.coords_apply {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ring k] [ V] (b : k P) (q : P) (i : ι) :
(b.coords) q i = (b.coord i) q
@[simp]
theorem affine_basis.coord_apply_centroid {ι : Type u_1} {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ V] [char_zero k] (b : k P) {s : finset ι} {i : ι} (hi : i s) :
(b.coord i) s b) = ((s.card))⁻¹
theorem affine_basis.exists_affine_subbasis {k : Type u_3} {V : Type u_4} {P : Type u_5} [ P] [ V] {t : set P} (ht : t = ) :
(s : set P) (H : s t) (b : P),
theorem affine_basis.exists_affine_basis (k : Type u_3) (V : Type u_4) (P : Type u_5) [ P] [ V] :
(s : set P) (b : P),