Skip to content

Commit

Permalink
feat(analysis/special_functions/trigonometric): range_{exp,cos,sin} (#…
Browse files Browse the repository at this point in the history
…4595)

Co-authored-by: Patrick Massot <patrickmassot@free.fr>
  • Loading branch information
jcommelin and PatrickMassot committed Oct 18, 2020
1 parent fee2dfa commit 93b7e63
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/algebra/ordered_ring.lean
Expand Up @@ -357,10 +357,7 @@ begin
end

lemma exists_le_mul_self (a : α) : ∃ x : α, a ≤ x * x :=
begin
obtain ⟨x, hx⟩ := exists_lt_mul_self a,
exact ⟨x, le_of_lt hx⟩
end
let ⟨x, hx⟩ := exists_lt_mul_self a in ⟨x, le_of_lt hx⟩

@[priority 100] -- see Note [lower instance priority]
instance linear_ordered_semiring.to_nontrivial {α : Type*} [linear_ordered_semiring α] :
Expand Down
2 changes: 1 addition & 1 deletion src/algebra/quadratic_discriminant.lean
Expand Up @@ -18,7 +18,7 @@ This file defines the discriminant of a quadratic and gives the solution to a qu
## Main statements
- `quadratic_eq_zero_iff`: roots of a quadratic can be written as
`(-b + s) / (2 * a)` or `(-b - s) / (2 * a)`, where `s` is the square root of the discriminant.
`(-b + s) / (2 * a)` or `(-b - s) / (2 * a)`, where `s` is a square root of the discriminant.
- `quadratic_ne_zero_of_discrim_ne_square`: if the discriminant has no square root,
then the corresponding quadratic has no root.
- `discrim_le_zero`: if a quadratic is always non-negative, then its discriminant is non-positive.
Expand Down
9 changes: 9 additions & 0 deletions src/analysis/special_functions/exp_log.lean
Expand Up @@ -216,12 +216,21 @@ by { rw [log, dif_pos hx], exact classical.some_spec (exists_exp_eq_of_pos ((abs
lemma exp_log (hx : 0 < x) : exp (log x) = x :=
by { rw exp_log_eq_abs (ne_of_gt hx), exact abs_of_pos hx }

lemma range_exp : set.range exp = {x | 0 < x} :=
set.ext $ λ x, ⟨by { rintro ⟨x, rfl⟩, exact exp_pos x }, λ hx, ⟨log x, exp_log hx⟩⟩

lemma exp_log_of_neg (hx : x < 0) : exp (log x) = -x :=
by { rw exp_log_eq_abs (ne_of_lt hx), exact abs_of_neg hx }

@[simp] lemma log_exp (x : ℝ) : log (exp x) = x :=
exp_injective $ exp_log (exp_pos x)

lemma log_surjective : function.surjective log :=
λ x, ⟨exp x, log_exp x⟩

@[simp] lemma range_log : set.range log = set.univ :=
log_surjective.range_eq

@[simp] lemma log_zero : log 0 = 0 :=
by simp [log]

Expand Down
58 changes: 57 additions & 1 deletion src/analysis/special_functions/trigonometric.lean
Expand Up @@ -4,6 +4,8 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson
-/
import analysis.special_functions.exp_log
import data.set.intervals.infinite
import algebra.quadratic_discriminant

/-!
# Trigonometric functions
Expand Down Expand Up @@ -835,6 +837,12 @@ begin
exact ⟨y, hy⟩ }
end

lemma range_cos_infinite : (range real.cos).infinite :=
by { rw real.range_cos, exact Icc.infinite (by norm_num) }

lemma range_sin_infinite : (range real.sin).infinite :=
by { rw real.range_sin, exact Icc.infinite (by norm_num) }

lemma sin_lt {x : ℝ} (h : 0 < x) : sin x < x :=
begin
cases le_or_gt x 1 with h' h',
Expand Down Expand Up @@ -1632,6 +1640,9 @@ by rw [log, exp_add_mul_I, ← of_real_sin, sin_arg, ← of_real_cos, cos_arg hx
mul_div_cancel' _ (of_real_ne_zero.2 (mt abs_eq_zero.1 hx)), ← mul_assoc,
mul_div_cancel' _ (of_real_ne_zero.2 (mt abs_eq_zero.1 hx)), re_add_im]

lemma range_exp : range exp = {x | x ≠ 0} :=
set.ext $ λ x, ⟨by { rintro ⟨x, rfl⟩, exact exp_ne_zero x }, λ hx, ⟨log x, exp_log hx⟩⟩

lemma exp_inj_of_neg_pi_lt_of_le_pi {x y : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π)
(hy₁ : - π < y.im) (hy₂ : y.im ≤ π) (hxy : exp x = exp y) : x = y :=
by rw [exp_eq_exp_re_mul_sin_add_cos, exp_eq_exp_re_mul_sin_add_cos y] at hxy;
Expand Down Expand Up @@ -1664,6 +1675,21 @@ lemma log_I : log I = π / 2 * I := by simp [log]

lemma log_neg_I : log (-I) = -(π / 2) * I := by simp [log]

lemma exists_pow_nat_eq (x : ℂ) {n : ℕ} (hn : 0 < n) : ∃ z, z ^ n = x :=
begin
by_cases hx : x = 0,
{ use 0, simp only [hx, zero_pow_eq_zero, hn] },
{ use exp (log x / n),
rw [← exp_nat_mul, mul_div_cancel', exp_log hx],
exact_mod_cast (nat.pos_iff_ne_zero.mp hn) }
end

lemma exists_eq_mul_self (x : ℂ) : ∃ z, x = z * z :=
begin
obtain ⟨z, rfl⟩ := exists_pow_nat_eq x zero_lt_two,
exact ⟨z, pow_two z⟩
end

lemma two_pi_I_ne_zero : (2 * π * I : ℂ) ≠ 0 :=
by norm_num [real.pi_ne_zero, I_ne_zero]

Expand Down Expand Up @@ -1867,8 +1893,38 @@ continuous_on_sin.div continuous_on_cos $ λ x, id
lemma continuous_tan : continuous (λ x : {x | cos x ≠ 0}, tan x) :=
continuous_on_iff_continuous_restrict.1 continuous_on_tan

end complex
lemma cos_surjective : function.surjective cos :=
begin
intro x,
obtain ⟨w, hw⟩ : ∃ w, 1 * w * w + (-2 * x) * w + 1 = 0,
{ exact exists_quadratic_eq_zero one_ne_zero (exists_eq_mul_self _) },
have hw' : exp (log w / I * I) = w,
{ rw [div_mul_cancel _ I_ne_zero, exp_log],
rintro rfl,
simpa only [zero_add, one_ne_zero, mul_zero] using hw },
obtain ⟨z, hz⟩ : ∃ z : ℂ, (exp (z * I)) ^ 2 - 2 * x * exp (z * I) + 1 = 0,
{ use log w / I, rw [hw', ← hw], ring },
use z,
delta cos,
rw ← mul_left_inj' (exp_ne_zero (z * I)),
rw [sub_add_eq_add_sub, sub_eq_zero, pow_two, ← exp_add, mul_comm _ x, mul_right_comm] at hz,
field_simp [add_mul, ← exp_add, hz]
end

@[simp] lemma range_cos : range cos = set.univ :=
cos_surjective.range_eq

lemma sin_surjective : function.surjective sin :=
begin
intro x,
rcases cos_surjective x with ⟨z, rfl⟩,
exact ⟨z+π/2, sin_add_pi_div_two z⟩
end

@[simp] lemma range_sin : range sin = set.univ :=
sin_surjective.range_eq

end complex

namespace real
open_locale real
Expand Down
4 changes: 4 additions & 0 deletions src/data/set/finite.lean
Expand Up @@ -241,6 +241,10 @@ by haveI := classical.dec_eq β; exact ⟨by apply_instance⟩
theorem finite.image {s : set α} (f : α → β) : finite s → finite (f '' s)
| ⟨h⟩ := ⟨@set.fintype_image _ _ (classical.dec_eq β) _ _ h⟩

theorem infinite_of_infinite_image (f : α → β) {s : set α} (hs : (f '' s).infinite) :
s.infinite :=
mt (finite.image f) hs

lemma finite.dependent_image {s : set α} (hs : finite s) {F : Π i ∈ s, β} {t : set β}
(H : ∀ y ∈ t, ∃ x (hx : x ∈ s), y = F x hx) : set.finite t :=
begin
Expand Down

0 comments on commit 93b7e63

Please sign in to comment.