Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat(data/complex/exponential): bound on exp for arbitrary arguments #8667

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1c953dc
pull in exponential file from bertrand-2 branch
BoltonBailey Aug 14, 2021
a0725aa
pull in factorial file
BoltonBailey Aug 14, 2021
e01eb7e
feat(src/data/complex/exponential): bound on exp for arbitrary arguments
BoltonBailey Aug 14, 2021
8182b64
fix line too long
BoltonBailey Aug 14, 2021
6619c90
remove unneded argument
BoltonBailey Aug 14, 2021
b6677a5
cleanup
BoltonBailey Aug 14, 2021
663b2a6
cleanup
BoltonBailey Aug 14, 2021
34b247e
cleanup
BoltonBailey Aug 14, 2021
513e535
Update src/data/nat/factorial.lean
BoltonBailey Aug 15, 2021
b6a3e25
fix sorry
BoltonBailey Aug 15, 2021
d72eb66
rename lemma
BoltonBailey Aug 15, 2021
7901d9e
golfing
BoltonBailey Aug 15, 2021
2d78f5c
fix mul_comm
BoltonBailey Aug 15, 2021
6adce3f
remove nested calcs
BoltonBailey Aug 15, 2021
bb5a5b8
cleanup
BoltonBailey Aug 15, 2021
a265470
rewrote lemma with add rather than sub
BoltonBailey Aug 16, 2021
5b363fc
cleanup
BoltonBailey Aug 16, 2021
9cbe2bb
proved sum_range_add_sub_sum_range
BoltonBailey Aug 16, 2021
b6e3ab6
Update src/data/complex/exponential.lean
BoltonBailey Aug 16, 2021
a0b3cd1
Unicodify <-
BoltonBailey Aug 16, 2021
49b8e43
delimit exp_bound proof branches
BoltonBailey Aug 16, 2021
3f4a653
remove begin-end block from sum_range_add_sub_sum_range
BoltonBailey Aug 16, 2021
f9cde2b
move range lemma to big_operators, and make to_additive
BoltonBailey Aug 16, 2021
4bcf42a
golf
BoltonBailey Aug 16, 2021
fa626cf
add todo for other sum lemma
BoltonBailey Aug 16, 2021
348f9fa
generalize lemma to div_eq_of_eq_mul'
BoltonBailey Aug 16, 2021
eafa56e
add todos
BoltonBailey Aug 16, 2021
77c4876
correct arguments
BoltonBailey Aug 17, 2021
975076f
changed lemma to have implicit arguments
BoltonBailey Aug 17, 2021
35a6b30
Update src/algebra/big_operators/basic.lean
BoltonBailey Aug 18, 2021
51a5dfe
Update src/data/complex/exponential.lean
BoltonBailey Aug 18, 2021
3014db2
golf proof to one rw
BoltonBailey Aug 18, 2021
5adb678
rename summation variable
jcommelin Aug 19, 2021
c443962
golf
jcommelin Aug 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/algebra/big_operators/basic.lean
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,16 @@ begin
{ rw [nat.add_succ, prod_range_succ, hm, prod_range_succ, mul_assoc], },
end

@[to_additive]
lemma prod_range_add_div_prod_range {α : Type*} [comm_group α] (f : ℕ → α)
(n m : ℕ) : (∏ k in range (n + m), f k ) / (∏ k in range n, f k) =
∏ k in finset.range m, f (n + k) :=
BoltonBailey marked this conversation as resolved.
Show resolved Hide resolved
begin
rw [prod_range_add f n m, div_eq_mul_inv],
simp,
end


@[to_additive]
lemma prod_range_zero (f : ℕ → β) :
∏ k in range 0, f k = 1 :=
Expand Down
67 changes: 63 additions & 4 deletions src/data/complex/exponential.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1279,17 +1279,76 @@ begin
refine sum_le_sum (λ m hm, _),
rw [abs_mul, abv_pow abs, abs_div, abs_cast_nat],
refine mul_le_mul_of_nonneg_left ((div_le_div_right _).2 _) _,
exact nat.cast_pos.2 (nat.factorial_pos _),
rw abv_pow abs,
exact (pow_le_one _ (abs_nonneg _) hx),
exact pow_nonneg (abs_nonneg _) _
{ exact nat.cast_pos.2 (nat.factorial_pos _),},
{ rw abv_pow abs,
exact (pow_le_one _ (abs_nonneg _) hx),},
{ exact pow_nonneg (abs_nonneg _) _},
BoltonBailey marked this conversation as resolved.
Show resolved Hide resolved
end
... = abs x ^ n * (∑ m in (range j).filter (λ k, n ≤ k), (1 / m! : ℝ)) :
by simp [abs_mul, abv_pow abs, abs_div, mul_sum.symm]
... ≤ abs x ^ n * (n.succ * (n! * n)⁻¹) :
mul_le_mul_of_nonneg_left (sum_div_factorial_le _ _ hn) (pow_nonneg (abs_nonneg _) _)
end

lemma exp_bound' {x : ℂ} {n : ℕ} (hx : abs x / (n.succ) ≤ 1 / 2) :
abs (exp x - ∑ m in range n, x ^ m / m!) ≤ abs x ^ n / (n!) * 2 :=
begin
rw [← lim_const (∑ m in range n, _), exp, sub_eq_add_neg, ← lim_neg, lim_add, ← lim_abs],
refine lim_le (cau_seq.le_of_exists ⟨n, λ j hj, _⟩),
simp_rw ← sub_eq_add_neg,
show abs (∑ m in range j, x ^ m / m! - ∑ m in range n, x ^ m / m!)
≤ abs x ^ n / (n!) * 2,
let k := j - n,
have hj : j = n + k,
exact (nat.add_sub_of_le hj).symm,
rw hj,
rw sum_range_add_sub_sum_range,
calc abs (∑ (k : ℕ) in range k, x ^ (n + k) / ((n + k)! : ℂ))
≤ ∑ (k : ℕ) in range k, abs (x ^ (n + k) / ((n + k)! : ℂ)) : abv_sum_le_sum_abv _ _
... ≤ ∑ (k : ℕ) in range k, (abs x) ^ (n + k) / (n + k)! :
begin
refine sum_le_sum (λ m hm, _),
simp only [complex.abs_cast_nat, complex.abs_div],
rw [abv_pow abs],
end
... ≤ ∑ (k : ℕ) in range k, (abs x) ^ (n + k) / (n! * n.succ ^ k) :
begin
refine sum_le_sum (λ m hm, _),
apply div_le_div (pow_nonneg (abs_nonneg x) (n + m)) (le_refl _),
{ apply mul_pos,
{ rw nat.cast_pos,
exact nat.factorial_pos n,},
{ apply pow_pos,
rw nat.cast_pos,
exact nat.succ_pos n,},},
{ rw [←nat.cast_pow, ←nat.cast_mul, nat.cast_le],
exact (nat.factorial_mul_pow_le_factorial),},
end
... = ∑ (k : ℕ) in range k, (abs x) ^ (n) / (n!) * ((abs x)^k / n.succ ^ k) :
begin
congr,
funext,
simp only [pow_add, div_eq_inv_mul, mul_inv'],
ring,
end
... ≤ abs x ^ n / (↑n!) * 2 :
begin
rw ←mul_sum,
apply mul_le_mul_of_nonneg_left,
{ simp_rw [←div_pow],
rw [←geom_sum_def, geom_sum_eq, div_le_iff_of_neg],
{ transitivity (-1 : ℝ),
{ linarith,},
{ simp only [neg_le_sub_iff_le_add, div_pow,
nat.cast_succ, le_add_iff_nonneg_left],
apply div_nonneg (pow_nonneg (abs_nonneg x) k)
(pow_nonneg (nat.cast_nonneg (n + 1)) k),},},
{ linarith,},
{ linarith,},},
{ exact div_nonneg (pow_nonneg (abs_nonneg x) n) (nat.cast_nonneg (n!)),},
end,
end

lemma abs_exp_sub_one_le {x : ℂ} (hx : abs x ≤ 1) :
abs (exp x - 1) ≤ 2 * abs x :=
calc abs (exp x - 1) = abs (exp x - ∑ m in range 1, x ^ m / m!) :
Expand Down
12 changes: 12 additions & 0 deletions src/data/nat/factorial.lean
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ begin
exact add_factorial_succ_le_factorial_add_succ i h,
end

lemma factorial_mul_pow_sub_le_factorial {n m : ℕ} (hnm : n ≤ m) : n! * n ^ (m - n) ≤ m! :=
begin
suffices : n! * (n + 1) ^ (m - n) ≤ m!,
{ apply trans _ this,
rw mul_le_mul_left,
apply pow_le_pow_of_le_left (zero_le n) (le_succ n),
exact factorial_pos n,},
convert nat.factorial_mul_pow_le_factorial,
exact (nat.add_sub_of_le hnm).symm,
end


end factorial

/-! ### Ascending and descending factorials -/
Expand Down