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:
a ^ ⌈log_b n⌉ ≤ a n ^ log_b aforn ≠ 0(Nat.pow_clog_le_mul_rpow_logb);n ^ log_b a ≤ a a ^ ⌊log_b n⌋(Nat.rpow_logb_le_mul_pow_log).
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 #
Nat.pow_clog_le_mul_rpow_logb:a ^ ⌈log_b n⌉ ≤ a n ^ log_b aforn ≠ 0.Nat.rpow_logb_le_mul_pow_log:n ^ log_b a ≤ a a ^ ⌊log_b n⌋, includingn = 0.Nat.pow_clog_two_le_mul_rpow_logb,Nat.rpow_logb_le_mul_pow_log_two: the base-2cases.Nat.clog_le_two_mul_logb:⌈log_b n⌉ ≤ 2 log_b nforn ≥ b.