File: Mathlib/Analysis/SpecialFunctions/Bernstein.lean

full_name: bernstein
code: /-- The Bernstein polynomials, as continuous functions on `[0,1]`.
-/
def bernstein (n ν : ℕ) : C(I, ℝ) 
goal: C(↑I, ℝ)

full_name: bernstein_apply
code: @[simp]
theorem bernstein_apply (n ν : ℕ) (x : I) :
    bernstein n ν x = (n.choose ν : ℝ) * (x : ℝ) ^ ν * (1 - (x : ℝ)) ^ (n - ν) 
goal: (bernstein n ν) x = ↑(n.choose ν) * ↑x ^ ν * (1 - ↑x) ^ (n - ν)

full_name: bernstein_nonneg
code: theorem bernstein_nonneg {n ν : ℕ} {x : I} : 0 ≤ bernstein n ν x 
goal: 0 ≤ (bernstein n ν) x

full_name: Mathlib.Meta.Positivity.evalBernstein
code: /-- Extension of the `positivity` tactic for Bernstein polynomials: they are always non-negative. -/
@[positivity DFunLike.coe _ _]
def evalBernstein : PositivityExt 
goal: Mathlib.Meta.Positivity.PositivityExt

full_name: bernstein.z
code: /-- Send `k : Fin (n+1)` to the equally spaced points `k/n` in the unit interval.
-/
def z {n : ℕ} (k : Fin (n + 1)) : I 
goal: ↑I

full_name: bernstein.«_aux_Mathlib_Analysis_SpecialFunctions_Bernstein___macroRules_bernstein_term_/ₙ_1»
code: local postfix:90 "/ₙ" => z
goal: Lean.Macro

full_name: bernstein._aux_Mathlib_Analysis_SpecialFunctions_Bernstein___unexpand_bernstein_z_1
code: local postfix:90 "/ₙ" => z
goal: Lean.PrettyPrinter.Unexpander

full_name: bernstein.probability
code: theorem probability (n : ℕ) (x : I) : (∑ k : Fin (n + 1), bernstein n k x) = 1 
goal: ∑ k : Fin (n + 1), (bernstein n ↑k) x = 1

full_name: bernstein.variance
code: theorem variance {n : ℕ} (h : 0 < (n : ℝ)) (x : I) :
    (∑ k : Fin (n + 1), (x - k/ₙ : ℝ) ^ 2 * bernstein n k x) = (x : ℝ) * (1 - x) / n 
goal: ∑ k : Fin (n + 1), (↑x - ↑k/ₙ) ^ 2 * (bernstein n ↑k) x = ↑x * (1 - ↑x) / ↑n

full_name: _aux_Mathlib_Analysis_SpecialFunctions_Bernstein___unexpand_bernstein_z_1
code: local postfix:1024 "/ₙ" => z
goal: Lean.PrettyPrinter.Unexpander

full_name: «_aux_Mathlib_Analysis_SpecialFunctions_Bernstein___macroRules_term_/ₙ_1»
code: local postfix:1024 "/ₙ" => z
goal: Lean.Macro

full_name: bernsteinApproximation
code: /-- The `n`-th approximation of a continuous function on `[0,1]` by Bernstein polynomials,
given by `∑ k, f (k/n) * bernstein n k x`.
-/
def bernsteinApproximation (n : ℕ) (f : C(I, ℝ)) : C(I, ℝ) 
goal: C(↑I, ℝ)

full_name: bernsteinApproximation.apply
code: @[simp]
theorem apply (n : ℕ) (f : C(I, ℝ)) (x : I) :
    bernsteinApproximation n f x = ∑ k : Fin (n + 1), f k/ₙ * bernstein n k x 
goal: (bernsteinApproximation n f) x = ∑ k : Fin (n + 1), f k/ₙ * (bernstein n ↑k) x

full_name: bernsteinApproximation.δ
code: /-- The modulus of (uniform) continuity for `f`, chosen so `|f x - f y| < ε/2` when `|x - y| < δ`.
-/
def δ (f : C(I, ℝ)) (ε : ℝ) (h : 0 < ε) : ℝ 
goal: ℝ

full_name: bernsteinApproximation.δ_pos
code: theorem δ_pos {f : C(I, ℝ)} {ε : ℝ} {h : 0 < ε} : 0 < δ f ε h 
goal: 0 < bernsteinApproximation.δ f ε h

full_name: bernsteinApproximation.S
code: /-- The set of points `k` so `k/n` is within `δ` of `x`.
-/
def S (f : C(I, ℝ)) (ε : ℝ) (h : 0 < ε) (n : ℕ) (x : I) : Finset (Fin (n + 1)) 
goal: Finset (Fin (n + 1))

full_name: bernsteinApproximation.lt_of_mem_S
code: /-- If `k ∈ S`, then `f(k/n)` is close to `f x`.
-/
theorem lt_of_mem_S {f : C(I, ℝ)} {ε : ℝ} {h : 0 < ε} {n : ℕ} {x : I} {k : Fin (n + 1)}
    (m : k ∈ S f ε h n x) : |f k/ₙ - f x| < ε / 2 
goal: |f k/ₙ - f x| < ε / 2

full_name: bernsteinApproximation.le_of_mem_S_compl
code: /-- If `k ∉ S`, then as `δ ≤ |x - k/n|`, we have the inequality `1 ≤ δ^-2 * (x - k/n)^2`.
This particular formulation will be helpful later.
-/
theorem le_of_mem_S_compl {f : C(I, ℝ)} {ε : ℝ} {h : 0 < ε} {n : ℕ} {x : I} {k : Fin (n + 1)}
    (m : k ∈ (S f ε h n x)ᶜ) : (1 : ℝ) ≤ δ f ε h ^ (-2 : ℤ) * ((x : ℝ) - k/ₙ) ^ 2 
goal: 1 ≤ bernsteinApproximation.δ f ε h ^ (-2) * (↑x - ↑k/ₙ) ^ 2

full_name: bernsteinApproximation_uniform
code: /-- The Bernstein approximations
```
∑ k : Fin (n+1), f (k/n : ℝ) * n.choose k * x^k * (1-x)^(n-k)
```
for a continuous function `f : C([0,1], ℝ)` converge uniformly to `f` as `n` tends to infinity.

This is the proof given in [Richard Beals' *Analysis, an introduction*][beals-analysis], §7D,
and reproduced on wikipedia.
-/
theorem bernsteinApproximation_uniform (f : C(I, ℝ)) :
    Tendsto (fun n : ℕ => bernsteinApproximation n f) atTop (𝓝 f) 
goal: Filter.Tendsto (fun n => bernsteinApproximation n f) Filter.atTop (𝓝 f)