-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
/-
Copyright (c) 2025 Anthony Wang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anthony Wang
-/
import Mathlib
/-!
# Spherical coordinates
We define spherical coordinates similarly to polar coordinates, as an open partial homeomorphism
in `ℝ^3` between `ℝ^3 - (-∞, 0]` and `(0, +∞) × (-π, π) × (0, π)`. Its inverse is given by
`(r, θ, φ) ↦ (r sin φ cos θ, r sin φ sin θ, r cos φ)`. TODO
It satisfies the following change of variables formula (see `integral_comp_sphericalCoord_symm`):
`∫ p in sphericalCoord.target, p.1 • f (sphericalCoord.symm p) = ∫ p, f p`
-/
theorem arg_of_im_pos' {z : ℂ} (hz : 0 < z.im) : 0 < Complex.arg z := by
have h₀ : z ≠ 0 := Ne.symm (mt (congr_arg Complex.im) hz.ne)
suffices 0 < Real.sin z.arg by
contrapose! this
exact Real.sin_nonpos_of_nonnpos_of_neg_pi_le this (by linarith [Complex.neg_pi_lt_arg z])
simp only [Complex.sin_arg, lt_div_iff₀ (norm_pos_iff.mpr h₀), zero_mul, hz]
noncomputable section Real
open Real Set MeasureTheory
open scoped ENNReal Real Topology
/-- The spherical coordinates are an open partial homeomorphism in `ℝ^3`, mapping `(r sin φ cos θ, r sin φ sin θ, r cos φ)` to
`(r, θ, φ)`. It is a homeomorphism between `ℝ^3 - (-∞, 0]` and `(0, +∞) × (-π, π) × (0, π)`. TODO -/
def sphericalCoord : PartialHomeomorph (ℝ × ℝ × ℝ) (ℝ × ℝ × ℝ) where
toFun q := (√(q.1 ^ 2 + q.2.1 ^ 2 + q.2.2 ^ 2), Complex.arg (Complex.equivRealProd.symm (q.1, q.2.1)), Complex.arg (Complex.equivRealProd.symm (q.2.2, √(q.1 ^ 2 + q.2.1 ^ 2))))
invFun p := (p.1 * sin p.2.2 * cos p.2.1, p.1 * sin p.2.2 * sin p.2.1, p.1 * cos p.2.2)
source := {q | 0 < q.1} ∪ {q | q.2.1 ≠ 0}
target := Ioi (0 : ℝ) ×ˢ Ioo (-π) π ×ˢ Ioo 0 π
map_target' := by
rintro ⟨r, θ, φ⟩ ⟨hr, hθ, hφ⟩
dsimp at hr hθ hφ
rcases eq_or_ne θ 0 with (rfl | h'θ)
· simp only [ne_eq, cos_zero, mul_one, sin_zero, mul_zero, mem_union, mem_setOf_eq]
left
exact Left.mul_pos hr (sin_pos_of_mem_Ioo hφ)
· simp only [ne_eq, mem_union, mem_setOf_eq, mul_eq_zero, not_or]
right
and_intros
· linarith [mem_Ioi.mp hr]
· linarith [sin_pos_of_mem_Ioo hφ]
· simp [sin_eq_zero_iff_of_lt_of_lt hθ.1 hθ.2, h'θ]
map_source' := by
rintro ⟨x, y, z⟩ hxy
simp only [prodMk_mem_set_prod_eq, mem_Ioi, sqrt_pos, mem_Ioo, Complex.neg_pi_lt_arg,
true_and, Complex.arg_lt_pi_iff]
simp
have hpos : 0 < x ^ 2 + y ^ 2 := by
rcases hxy with hxy | hxy
· dsimp at hxy; linarith [sq_pos_of_ne_zero hxy.ne', sq_nonneg y]
· linarith [sq_nonneg x, sq_pos_of_ne_zero hxy]
and_intros
· rcases hxy with hxy | hxy
· dsimp at hxy; linarith [sq_pos_of_ne_zero hxy.ne', sq_nonneg y, sq_nonneg z]
· linarith [sq_nonneg x, sq_pos_of_ne_zero hxy, sq_nonneg z]
· rcases hxy with hxy | hxy
· exact Or.inl (le_of_lt hxy)
· exact Or.inr hxy
· apply arg_of_im_pos'
simp [hpos]
· exact Or.inr (by simp only [sqrt_ne_zero', hpos])
right_inv' := by
rintro ⟨r, θ, φ⟩ ⟨hr, hθ, hφ⟩
ext <;> dsimp at hr hθ hφ ⊢
· conv_rhs => rw [← sqrt_sq (le_of_lt hr), ← one_mul (r ^ 2), ← sin_sq_add_cos_sq φ, ← one_mul (sin φ ^ 2), ← sin_sq_add_cos_sq θ]
congr 1
ring
· convert Complex.arg_mul_cos_add_sin_mul_I (Left.mul_pos hr (sin_pos_of_mem_Ioo hφ)) ⟨hθ.1, hθ.2.le⟩
simp only [Complex.equivRealProd_symm_apply, Complex.ofReal_mul, Complex.ofReal_sin,
Complex.ofReal_cos]
ring
· have : -π < φ := by linarith [pi_pos, hφ.1]
convert Complex.arg_mul_cos_add_sin_mul_I hr ⟨this, hφ.2.le⟩
have : √((r * sin φ * cos θ) ^ 2 + (r * sin φ * sin θ) ^ 2) = r * sin φ := by
conv_rhs => rw [← sqrt_sq (le_of_lt (Left.mul_pos hr (sin_pos_of_mem_Ioo hφ))), ← one_mul ((r * sin φ) ^ 2), ← sin_sq_add_cos_sq θ]
congr 1
ring
simp only [this, Complex.equivRealProd_symm_apply, Complex.ofReal_mul, Complex.ofReal_cos,
Complex.ofReal_sin]
ring
left_inv' := by
rintro ⟨x, y, z⟩ _
-- have A : √(x ^ 2 + y ^ 2) = ‖x + y * Complex.I‖ := by
-- rw [Complex.norm_def, Complex.normSq_add_mul_I]
-- have B : √(x ^ 2 + y ^ 2 + z ^ 2) = ‖z + √(x ^ 2 + y ^ 2) * Complex.I‖ := by
-- rw [Complex.norm_def, Complex.normSq_add_mul_I]
simp -- [Complex.sin_arg]
and_intros
· sorry
· sorry
· sorry
open_target := isOpen_Ioi.prod (isOpen_Ioo.prod isOpen_Ioo)
open_source :=
(isOpen_lt continuous_const continuous_fst).union
(isOpen_ne_fun (Continuous.fst continuous_snd) continuous_const)
continuousOn_invFun := by fun_prop
continuousOn_toFun := by
sorry