Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit ddc016c

Browse files
feat(*): polar co-ordinates, de moivre, trig identities, quotient group for angles (#745)
* feat(algebra/group_power): re-PRing polar co-ords * Update group_power.lean * feat(analysis/exponential): re-PRing polar stuff * feat(data.complex.exponential): re-PR polar stuff * fix(analysis.exponential): stylistic * fix(data.complex.exponential): stylistic * fix(analysis/exponential.lean): angle_eq_iff_two_pi_dvd_sub * fix(analysis/exponential): angle_eq_iff_two_pi_dvd_sub
1 parent 63fa61d commit ddc016c

File tree

3 files changed

+147
-3
lines changed

3 files changed

+147
-3
lines changed

src/algebra/group_power.lean

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,24 @@ theorem pow_nonneg {a : α} (H : 0 ≤ a) : ∀ (n : ℕ), 0 ≤ a ^ n
521521
| 0 := zero_le_one
522522
| (n+1) := mul_nonneg H (pow_nonneg _)
523523

524+
theorem pow_lt_pow_of_lt_left {x y : α} {n : ℕ} (Hxy : x < y) (Hxpos : 0 ≤ x) (Hnpos : 0 < n) : x ^ n < y ^ n :=
525+
begin
526+
cases lt_or_eq_of_le Hxpos,
527+
{ rw ←nat.sub_add_cancel Hnpos,
528+
induction (n - 1), { simpa only [pow_one] },
529+
rw [pow_add, pow_add, nat.succ_eq_add_one, pow_one, pow_one],
530+
apply mul_lt_mul ih (le_of_lt Hxy) h (le_of_lt (pow_pos (lt_trans h Hxy) _)) },
531+
{ rw [←h, zero_pow Hnpos], apply pow_pos (by rwa ←h at Hxy : 0 < y),}
532+
end
533+
534+
theorem pow_right_inj {x y : α} {n : ℕ} (Hxpos : 0 ≤ x) (Hypos : 0 ≤ y) (Hnpos : 0 < n) (Hxyn : x ^ n = y ^ n) : x = y :=
535+
begin
536+
rcases lt_trichotomy x y with hxy | rfl | hyx,
537+
{ exact absurd Hxyn (ne_of_lt (pow_lt_pow_of_lt_left hxy Hxpos Hnpos)) },
538+
{ refl },
539+
{ exact absurd Hxyn (ne_of_gt (pow_lt_pow_of_lt_left hyx Hypos Hnpos)) },
540+
end
541+
524542
theorem one_le_pow_of_one_le {a : α} (H : 1 ≤ a) : ∀ (n : ℕ), 1 ≤ a ^ n
525543
| 0 := le_refl _
526544
| (n+1) := by simpa only [mul_one] using mul_le_mul H (one_le_pow_of_one_le n)

src/analysis/exponential.lean

Lines changed: 112 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/-
22
Copyright (c) 2018 Chris Hughes. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: Chris Hughes
4+
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo
55
-/
6-
import topology.instances.complex tactic.linarith data.complex.exponential
6+
import topology.instances.complex tactic.linarith data.complex.exponential group_theory.quotient_group
77

88
open finset filter metric
99

@@ -309,6 +309,15 @@ by rw [← mul_self_eq_one_iff (cos x), ← sin_pow_two_add_cos_pow_two x,
309309
pow_two, pow_two, ← sub_eq_iff_eq_add, sub_self];
310310
exact ⟨λ h, by rw [h, mul_zero], eq_zero_of_mul_self_eq_zero ∘ eq.symm⟩
311311

312+
theorem sin_sub_sin (θ ψ : ℝ) : sin θ - sin ψ = 2 * sin((θ - ψ)/2) * cos((θ + ψ)/2) :=
313+
begin
314+
have s1 := sin_add ((θ + ψ) / 2) ((θ - ψ) / 2),
315+
have s2 := sin_sub ((θ + ψ) / 2) ((θ - ψ) / 2),
316+
rw [div_add_div_same, add_sub, add_right_comm, add_sub_cancel, add_self_div_two] at s1,
317+
rw [div_sub_div_same, ←sub_add, add_sub_cancel', add_self_div_two] at s2,
318+
rw [s1, s2, ←sub_add, add_sub_cancel', ← two_mul, ← mul_assoc, mul_right_comm]
319+
end
320+
312321
lemma cos_eq_one_iff (x : ℝ) : cos x = 1 ↔ ∃ n : ℤ, (n : ℝ) * (2 * π) = x :=
313322
⟨λ h, let ⟨n, hn⟩ := sin_eq_zero_iff.1 (sin_eq_zero_iff_cos_eq.2 (or.inl h)) in
314323
⟨n / 2, (int.mod_two_eq_zero_or_one n).elim
@@ -320,6 +329,18 @@ lemma cos_eq_one_iff (x : ℝ) : cos x = 1 ↔ ∃ n : ℤ, (n : ℝ) * (2 * π)
320329
exact absurd h (by norm_num))⟩,
321330
λ ⟨n, hn⟩, hn ▸ cos_int_mul_two_pi _⟩
322331

332+
theorem cos_eq_zero_iff {θ : ℝ} : cos θ = 0 ↔ ∃ k : ℤ, θ = (2 * k + 1) * pi / 2 :=
333+
begin
334+
rw [←real.sin_pi_div_two_sub, sin_eq_zero_iff],
335+
split,
336+
{ rintro ⟨n, hn⟩, existsi -n,
337+
rw [int.cast_neg, add_mul, add_div, mul_assoc, mul_div_cancel_left _ two_ne_zero,
338+
one_mul, ←neg_mul_eq_neg_mul, hn, neg_sub, sub_add_cancel] },
339+
{ rintro ⟨n, hn⟩, existsi -n,
340+
rw [hn, add_mul, one_mul, add_div, mul_assoc, mul_div_cancel_left _ two_ne_zero,
341+
sub_add_eq_sub_sub_swap, sub_self, zero_sub, neg_mul_eq_neg_mul, int.cast_neg] }
342+
end
343+
323344
lemma cos_eq_one_iff_of_lt_of_lt {x : ℝ} (hx₁ : -(2 * π) < x) (hx₂ : x < 2 * π) : cos x = 1 ↔ x = 0 :=
324345
⟨λ h, let ⟨n, hn⟩ := (cos_eq_one_iff x).1 h in
325346
begin
@@ -332,6 +353,11 @@ lemma cos_eq_one_iff_of_lt_of_lt {x : ℝ} (hx₁ : -(2 * π) < x) (hx₂ : x <
332353
end,
333354
λ h, by simp [h]⟩
334355

356+
theorem cos_sub_cos (θ ψ : ℝ) : cos θ - cos ψ = -2 * sin((θ + ψ)/2) * sin((θ - ψ)/2) :=
357+
by rw [← sin_pi_div_two_sub, ← sin_pi_div_two_sub, sin_sub_sin, sub_sub_sub_cancel_left,
358+
add_sub, sub_add_eq_add_sub, add_halves, sub_sub, sub_div π, cos_pi_div_two_sub,
359+
← neg_sub, neg_div, sin_neg, ← neg_mul_eq_mul_neg, neg_mul_eq_neg_mul, mul_right_comm]
360+
335361
lemma cos_lt_cos_of_nonneg_of_le_pi_div_two {x y : ℝ} (hx₁ : 0 ≤ x) (hx₂ : x ≤ π / 2)
336362
(hy₁ : 0 ≤ y) (hy₂ : y ≤ π / 2) (hxy : x < y) : cos y < cos x :=
337363
calc cos y = cos x * cos (y - x) - sin x * sin (y - x) :
@@ -400,6 +426,90 @@ lemma exists_sin_eq {x : ℝ} (hx₁ : -1 ≤ x) (hx₂ : x ≤ 1) : ∃ y, -(π
400426
(by rwa [sin_neg, sin_pi_div_two]) (by rwa sin_pi_div_two)
401427
(le_trans (neg_nonpos.2 (le_of_lt pi_div_two_pos)) (le_of_lt pi_div_two_pos))
402428

429+
namespace angle
430+
431+
/-- The type of angles -/
432+
def angle : Type :=
433+
quotient_add_group.quotient (gmultiples (2 * π))
434+
435+
instance angle.add_comm_group : add_comm_group angle :=
436+
quotient_add_group.add_comm_group _
437+
438+
instance angle.has_coe : has_coe ℝ angle :=
439+
⟨quotient.mk'⟩
440+
441+
instance angle.is_add_group_hom : is_add_group_hom (coe : ℝ → angle) :=
442+
@quotient_add_group.is_add_group_hom _ _ _ (normal_add_subgroup_of_add_comm_group _)
443+
444+
@[simp] lemma coe_zero : ↑(0 : ℝ) = (0 : angle) := rfl
445+
@[simp] lemma coe_add (x y : ℝ) : ↑(x + y : ℝ) = (↑x + ↑y : angle) := rfl
446+
@[simp] lemma coe_neg (x : ℝ) : ↑(-x : ℝ) = -(↑x : angle) := rfl
447+
@[simp] lemma coe_sub (x y : ℝ) : ↑(x - y : ℝ) = (↑x - ↑y : angle) := rfl
448+
@[simp] lemma coe_gsmul (x : ℝ) (n : ℤ) : ↑(gsmul n x : ℝ) = gsmul n (↑x : angle) := is_add_group_hom.gsmul _ _ _
449+
@[simp] lemma coe_two_pi : ↑(2 * π : ℝ) = (0 : angle) :=
450+
quotient.sound' ⟨-1, by dsimp only; rw [neg_one_gsmul, add_zero]⟩
451+
452+
lemma angle_eq_iff_two_pi_dvd_sub {ψ θ : ℝ} : (θ : angle) = ψ ↔ ∃ k : ℤ, θ - ψ = 2 * π * k :=
453+
by simp only [quotient_add_group.eq, gmultiples, set.mem_range, gsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm]
454+
455+
theorem cos_eq_iff_eq_or_eq_neg {θ ψ : ℝ} : cos θ = cos ψ ↔ (θ : angle) = ψ ∨ (θ : angle) = -ψ :=
456+
begin
457+
split,
458+
{ intro Hcos,
459+
rw [←sub_eq_zero, cos_sub_cos, mul_eq_zero, mul_eq_zero, neg_eq_zero, eq_false_intro two_ne_zero,
460+
false_or, sin_eq_zero_iff, sin_eq_zero_iff] at Hcos,
461+
rcases Hcos with ⟨n, hn⟩ | ⟨n, hn⟩,
462+
{ right,
463+
rw [eq_div_iff_mul_eq _ _ two_ne_zero, ← sub_eq_iff_eq_add] at hn,
464+
rw [← hn, coe_sub, eq_neg_iff_add_eq_zero, sub_add_cancel, mul_assoc,
465+
← gsmul_eq_mul, coe_gsmul, mul_comm, coe_two_pi, gsmul_zero] },
466+
{ left,
467+
rw [eq_div_iff_mul_eq _ _ two_ne_zero, eq_sub_iff_add_eq] at hn,
468+
rw [← hn, coe_add, mul_assoc,
469+
← gsmul_eq_mul, coe_gsmul, mul_comm, coe_two_pi, gsmul_zero, zero_add] } },
470+
{ rw [angle_eq_iff_two_pi_dvd_sub, ← coe_neg, angle_eq_iff_two_pi_dvd_sub],
471+
rintro (⟨k, H⟩ | ⟨k, H⟩),
472+
rw [← sub_eq_zero_iff_eq, cos_sub_cos, H, mul_assoc 2 π k, mul_div_cancel_left _ two_ne_zero,
473+
mul_comm π _, sin_int_mul_pi, mul_zero],
474+
rw [←sub_eq_zero_iff_eq, cos_sub_cos, ← sub_neg_eq_add, H, mul_assoc 2 π k,
475+
mul_div_cancel_left _ two_ne_zero, mul_comm π _, sin_int_mul_pi, mul_zero, zero_mul] }
476+
end
477+
478+
theorem sin_eq_iff_eq_or_add_eq_pi {θ ψ : ℝ} : sin θ = sin ψ ↔ (θ : angle) = ψ ∨ (θ : angle) + ψ = π :=
479+
begin
480+
split,
481+
{ intro Hsin, rw [← cos_pi_div_two_sub, ← cos_pi_div_two_sub] at Hsin,
482+
cases cos_eq_iff_eq_or_eq_neg.mp Hsin with h h,
483+
{ left, rw coe_sub at h, exact sub_left_inj.1 h },
484+
right, rw [coe_sub, coe_sub, eq_neg_iff_add_eq_zero, add_sub,
485+
sub_add_eq_add_sub, ← coe_add, add_halves, sub_sub, sub_eq_zero] at h,
486+
exact h.symm },
487+
{ rw [angle_eq_iff_two_pi_dvd_sub, ←eq_sub_iff_add_eq, ←coe_sub, angle_eq_iff_two_pi_dvd_sub],
488+
rintro (⟨k, H⟩ | ⟨k, H⟩),
489+
rw [← sub_eq_zero_iff_eq, sin_sub_sin, H, mul_assoc 2 π k, mul_div_cancel_left _ two_ne_zero,
490+
mul_comm π _, sin_int_mul_pi, mul_zero, zero_mul],
491+
have H' : θ + ψ = (2 * k) * π + π := by rwa [←sub_add, sub_add_eq_add_sub, sub_eq_iff_eq_add,
492+
mul_assoc, mul_comm π _, ←mul_assoc] at H,
493+
rw [← sub_eq_zero_iff_eq, sin_sub_sin, H', add_div, mul_assoc 2 _ π, mul_div_cancel_left _ two_ne_zero,
494+
cos_add_pi_div_two, sin_int_mul_pi, neg_zero, mul_zero] }
495+
end
496+
497+
theorem cos_sin_inj {θ ψ : ℝ} (Hcos : cos θ = cos ψ) (Hsin : sin θ = sin ψ) : (θ : angle) = ψ :=
498+
begin
499+
cases cos_eq_iff_eq_or_eq_neg.mp Hcos with hc hc, { exact hc },
500+
cases sin_eq_iff_eq_or_add_eq_pi.mp Hsin with hs hs, { exact hs },
501+
rw [eq_neg_iff_add_eq_zero, hs] at hc,
502+
cases quotient.exact' hc with n hn, dsimp only at hn,
503+
rw [← neg_one_mul, add_zero, ← sub_eq_zero_iff_eq, gsmul_eq_mul, ← mul_assoc, ← sub_mul,
504+
mul_eq_zero, eq_false_intro (ne_of_gt pi_pos), or_false, sub_neg_eq_add,
505+
← int.cast_zero, ← int.cast_one, ← int.cast_bit0, ← int.cast_mul, ← int.cast_add, int.cast_inj] at hn,
506+
have : (n * 2 + 1) % (2:ℤ) = 0 % (2:ℤ) := congr_arg (%(2:ℤ)) hn,
507+
rw [add_comm, int.add_mul_mod_self] at this,
508+
exact absurd this one_ne_zero
509+
end
510+
511+
end angle
512+
403513
/-- Inverse of the `sin` function, returns values in the range `-π / 2 ≤ arcsin x` and `arcsin x ≤ π / 2`.
404514
If the argument is not between `-1` and `1` it defaults to `0` -/
405515
noncomputable def arcsin (x : ℝ) : ℝ :=

src/data/complex/exponential.lean

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/-
22
Copyright (c) 2018 Chris Hughes. All rights reserved.
33
Released under Apache 2.0 license as described in the file LICENSE.
4-
Authors: Chris Hughes
4+
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir
55
-/
66
import algebra.archimedean
77
import data.nat.choose data.complex.basic
@@ -394,6 +394,10 @@ by rw lim_mul_lim;
394394
exact eq.symm (lim_eq_lim_of_equiv (by dsimp; simp only [hj];
395395
exact cauchy_product (is_cau_abs_exp x) (is_cau_exp y)))
396396

397+
lemma exp_nat_mul (x : ℂ) : ∀ n : ℕ, exp(n*x) = (exp x)^n
398+
| 0 := by rw [nat.cast_zero, zero_mul, exp_zero, pow_zero]
399+
| (nat.succ n) := by rw [pow_succ', nat.cast_add_one, add_mul, exp_add, ←exp_nat_mul, one_mul]
400+
397401
lemma exp_ne_zero : exp x ≠ 0 :=
398402
λ h, @zero_ne_one ℂ _ $
399403
by rw [← exp_zero, ← add_neg_self x, exp_add, h]; simp
@@ -556,6 +560,14 @@ by rw [exp_add, exp_mul_I]
556560
lemma exp_eq_exp_re_mul_sin_add_cos : exp x = exp x.re * (cos x.im + sin x.im * I) :=
557561
by rw [← exp_add_mul_I, re_add_im]
558562

563+
theorem cos_add_sin_mul_I_pow (n : ℕ) (z : ℂ) : (cos z + sin z * I) ^ n = cos (↑n * z) + sin (↑n * z) * I :=
564+
begin
565+
rw [← exp_mul_I, ← exp_mul_I],
566+
induction n with n ih,
567+
{ rw [pow_zero, nat.cast_zero, zero_mul, zero_mul, exp_zero] },
568+
{ rw [pow_succ', ih, nat.cast_succ, add_mul, add_mul, one_mul, exp_add] }
569+
end
570+
559571
@[simp] lemma sinh_zero : sinh 0 = 0 := by simp [sinh]
560572

561573
@[simp] lemma sinh_neg : sinh (-x) = -sinh x :=
@@ -658,6 +670,10 @@ by simp [real.exp]
658670
lemma exp_add : exp (x + y) = exp x * exp y :=
659671
by simp [exp_add, exp]
660672

673+
lemma exp_nat_mul (x : ℝ) : ∀ n : ℕ, exp(n*x) = (exp x)^n
674+
| 0 := by rw [nat.cast_zero, zero_mul, exp_zero, pow_zero]
675+
| (nat.succ n) := by rw [pow_succ', nat.cast_add_one, add_mul, exp_add, ←exp_nat_mul, one_mul]
676+
661677
lemma exp_ne_zero : exp x ≠ 0 :=
662678
λ h, exp_ne_zero x $ by rw [exp, ← of_real_inj] at h; simp * at *
663679

0 commit comments

Comments
 (0)