Documentation

CslibFrontier.Foundations.Data.Nat.LogTwoRpow

Powers at logarithms versus real powers #

For b ≥ 2 and a ≥ 1, the integer powers a ^ ⌈log_b n⌉ and a ^ ⌊log_b n⌋ are within a factor a of the real power n ^ log_b a:

The base-2 cases are Nat.pow_clog_two_le_mul_rpow_logb and Nat.rpow_logb_le_mul_pow_log_two. They turn the solutions of halving recurrences, such as Nat.add_mul_two_pow_clog_le_of_halving, into O(n ^ log₂ a) and Ω(n ^ log₂ a) bounds. The master theorem (CslibFrontier.Foundations.Data.Nat.MasterTheoremAsymptotics) uses the general base, together with ⌈log_b n⌉ ≤ 2 log_b n for n ≥ b (Nat.clog_le_two_mul_logb).

Main results #

theorem Nat.pow_clog_le_mul_rpow_logb {a b n : ℕ} (hb : 1 < b) (ha : 1 ≤ a) (hn : n ≠ 0) :
↑(a ^ clog b n) ≤ ↑a * ↑n ^ Real.logb ↑b ↑a

a ^ ⌈log_b n⌉ ≤ a n ^ log_b a for b ≥ 2, a ≥ 1 and n ≠ 0.

theorem Nat.rpow_logb_le_mul_pow_log {a b : ℕ} (hb : 1 < b) (ha : 1 ≤ a) (n : ℕ) :
↑n ^ Real.logb ↑b ↑a ≤ ↑a * ↑a ^ log b n

n ^ log_b a ≤ a a ^ ⌊log_b n⌋ for b ≥ 2 and a ≥ 1, including n = 0.

theorem Nat.pow_clog_two_le_mul_rpow_logb {a n : ℕ} (ha : 1 ≤ a) (hn : n ≠ 0) :
↑(a ^ clog 2 n) ≤ ↑a * ↑n ^ Real.logb 2 ↑a

a ^ ⌈log₂ n⌉ ≤ a n ^ log₂ a for n ≠ 0 and a ≥ 1.

theorem Nat.rpow_logb_le_mul_pow_log_two {a : ℕ} (ha : 1 ≤ a) (n : ℕ) :
↑n ^ Real.logb 2 ↑a ≤ ↑a * ↑a ^ log 2 n

n ^ log₂ a ≤ a a ^ ⌊log₂ n⌋ for a ≥ 1, including n = 0.

theorem Nat.clog_le_two_mul_logb {b n : ℕ} (hb : 1 < b) (hn : b ≤ n) :
↑(clog b n) ≤ 2 * Real.logb ↑b ↑n

⌈log_b n⌉ ≤ 2 log_b n for b ≥ 2 and n ≥ b.