1
1
/-
2
2
Copyright (c) 2018 Chris Hughes. All rights reserved.
3
3
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
5
5
-/
6
- import topology.instances.complex tactic.linarith data.complex.exponential
6
+ import topology.instances.complex tactic.linarith data.complex.exponential group_theory.quotient_group
7
7
8
8
open finset filter metric
9
9
@@ -309,6 +309,15 @@ by rw [← mul_self_eq_one_iff (cos x), ← sin_pow_two_add_cos_pow_two x,
309
309
pow_two, pow_two, ← sub_eq_iff_eq_add, sub_self];
310
310
exact ⟨λ h, by rw [h, mul_zero], eq_zero_of_mul_self_eq_zero ∘ eq.symm⟩
311
311
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
+
312
321
lemma cos_eq_one_iff (x : ℝ) : cos x = 1 ↔ ∃ n : ℤ, (n : ℝ) * (2 * π) = x :=
313
322
⟨λ h, let ⟨n, hn⟩ := sin_eq_zero_iff.1 (sin_eq_zero_iff_cos_eq.2 (or.inl h)) in
314
323
⟨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 * π)
320
329
exact absurd h (by norm_num))⟩,
321
330
λ ⟨n, hn⟩, hn ▸ cos_int_mul_two_pi _⟩
322
331
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
+
323
344
lemma cos_eq_one_iff_of_lt_of_lt {x : ℝ} (hx₁ : -(2 * π) < x) (hx₂ : x < 2 * π) : cos x = 1 ↔ x = 0 :=
324
345
⟨λ h, let ⟨n, hn⟩ := (cos_eq_one_iff x).1 h in
325
346
begin
@@ -332,6 +353,11 @@ lemma cos_eq_one_iff_of_lt_of_lt {x : ℝ} (hx₁ : -(2 * π) < x) (hx₂ : x <
332
353
end ,
333
354
λ h, by simp [h]⟩
334
355
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
+
335
361
lemma cos_lt_cos_of_nonneg_of_le_pi_div_two {x y : ℝ} (hx₁ : 0 ≤ x) (hx₂ : x ≤ π / 2 )
336
362
(hy₁ : 0 ≤ y) (hy₂ : y ≤ π / 2 ) (hxy : x < y) : cos y < cos x :=
337
363
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, -(π
400
426
(by rwa [sin_neg, sin_pi_div_two]) (by rwa sin_pi_div_two)
401
427
(le_trans (neg_nonpos.2 (le_of_lt pi_div_two_pos)) (le_of_lt pi_div_two_pos))
402
428
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
+
403
513
/-- Inverse of the `sin` function, returns values in the range `-π / 2 ≤ arcsin x` and `arcsin x ≤ π / 2`.
404
514
If the argument is not between `-1` and `1` it defaults to `0` -/
405
515
noncomputable def arcsin (x : ℝ) : ℝ :=
0 commit comments