pith. machine review for the scientific record. sign in
theorem

bigO_add_subset

proved
show as:
view math explainer →
module
IndisputableMonolith.Relativity.Analysis.Landau
domain
Relativity
line
24 · github
papers citing
none yet

open explainer

Read the cached plain-language explainer.

open lean source

IndisputableMonolith.Relativity.Analysis.Landau on GitHub at line 24.

browse module

All declarations in this module, on Recognition.

explainer page

A cached Ask Recognition explainer exists for this declaration.

open explainer

depends on

formal source

  21    Use IsBigO and IsLittleO directly. -/
  22
  23/-- O(f) + O(g) ⊆ O(max(f,g)). -/
  24theorem bigO_add_subset (f g : ℝ → ℝ) (a : ℝ) :
  25  ∀ h₁ h₂, IsBigO h₁ f a → IsBigO h₂ g a →
  26    IsBigO (fun x => h₁ x + h₂ x) (fun x => max (|f x|) (|g x|)) a := by
  27  intro h₁ h₂ hf hg
  28  rcases hf with ⟨C₁, hC₁pos, M₁, hM₁pos, hf⟩
  29  rcases hg with ⟨C₂, hC₂pos, M₂, hM₂pos, hg⟩
  30  refine ⟨C₁ + C₂, by linarith, min M₁ M₂, lt_min hM₁pos hM₂pos, ?_⟩
  31  intro x hx
  32  have hx₁ : |x - a| < M₁ := lt_of_lt_of_le hx (min_le_left _ _)
  33  have hx₂ : |x - a| < M₂ := lt_of_lt_of_le hx (min_le_right _ _)
  34  have hf' := hf x hx₁
  35  have hg' := hg x hx₂
  36  -- Triangle inequality and bounds
  37  have hmax_nonneg : 0 ≤ max (|f x|) (|g x|) := le_max_of_le_left (abs_nonneg _)
  38  calc |h₁ x + h₂ x|
  39      ≤ |h₁ x| + |h₂ x| := abs_add_le _ _
  40    _ ≤ C₁ * |f x| + C₂ * |g x| := add_le_add hf' hg'
  41    _ ≤ C₁ * max (|f x|) (|g x|) + C₂ * max (|f x|) (|g x|) := by
  42        have h1 : C₁ * |f x| ≤ C₁ * max (|f x|) (|g x|) :=
  43          mul_le_mul_of_nonneg_left (le_max_left _ _) (le_of_lt hC₁pos)
  44        have h2 : C₂ * |g x| ≤ C₂ * max (|f x|) (|g x|) :=
  45          mul_le_mul_of_nonneg_left (le_max_right _ _) (le_of_lt hC₂pos)
  46        exact add_le_add h1 h2
  47    _ = (C₁ + C₂) * max (|f x|) (|g x|) := by ring
  48    _ = (C₁ + C₂) * |max (|f x|) (|g x|)| := by rw [abs_of_nonneg hmax_nonneg]
  49
  50/-- O(f) · O(g) ⊆ O(f·g). -/
  51theorem bigO_mul_subset (f g : ℝ → ℝ) (a : ℝ) :
  52  ∀ h₁ h₂, IsBigO h₁ f a → IsBigO h₂ g a →
  53    IsBigO (fun x => h₁ x * h₂ x) (fun x => f x * g x) a := by
  54  intro h₁ h₂ hf hg