/-- The polar coordinates local homeomorphism in `ℝ^2`, mapping `(r cos θ, r sin θ)` to `(r, θ)`.
It is a homeomorphism between `ℝ^2 - (-∞, 0]` and `(0, +∞) × (-π, π)`. -/
@[simps]
def polarCoord : PartialHomeomorph (ℝ × ℝ) (ℝ × ℝ) where
  toFun q := (Real.sqrt (q.1 ^ 2 + q.2 ^ 2), Complex.arg (Complex.equivRealProd.symm q))
  invFun p := (p.1 * cos p.2, p.1 * sin p.2)
  source := {q | 0 < q.1} ∪ {q | q.2 ≠ 0}
  target := Ioi (0 : ℝ) ×ˢ Ioo (-π) π
  map_target' := by
    rintro ⟨r, θ⟩ ⟨hr, hθ⟩
    dsimp at hr hθ
    rcases eq_or_ne θ 0 with (rfl | h'θ)
    · simpa using hr
    · right
      simp at hr
      simpa only [ne_of_gt hr, Ne.def, mem_setOf_eq, mul_eq_zero, false_or_iff,
        sin_eq_zero_iff_of_lt_of_lt hθ.1 hθ.2] using h'θ
  map_source' := by
    rintro ⟨x, y⟩ hxy
    simp only [prod_mk_mem_set_prod_eq, mem_Ioi, sqrt_pos, mem_Ioo, Complex.neg_pi_lt_arg,
      true_and_iff, Complex.arg_lt_pi_iff]
    constructor
    · cases' 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]
    · cases' hxy with hxy hxy
      · exact Or.inl (le_of_lt hxy)
      · exact Or.inr hxy
  right_inv' := by
    rintro ⟨r, θ⟩ ⟨hr, hθ⟩
    dsimp at hr hθ
    simp only [Prod.mk.inj_iff]
    constructor
    · conv_rhs => rw [← sqrt_sq (le_of_lt hr), ← one_mul (r ^ 2), ← sin_sq_add_cos_sq θ]
      congr 1
      ring
    · convert Complex.arg_mul_cos_add_sin_mul_I hr ⟨hθ.1, hθ.2.le⟩
      simp only [Complex.equivRealProd_symm_apply, Complex.ofReal_mul, Complex.ofReal_cos,
        Complex.ofReal_sin]
      ring
  left_inv' := by
    rintro ⟨x, y⟩ _
    have A : sqrt (x ^ 2 + y ^ 2) = Complex.abs (x + y * Complex.I) := by
      rw [Complex.abs_apply, Complex.normSq_add_mul_I]
    have Z := Complex.abs_mul_cos_add_sin_mul_I (x + y * Complex.I)
    simp only [← Complex.ofReal_cos, ← Complex.ofReal_sin, mul_add, ← Complex.ofReal_mul, ←
      mul_assoc] at Z
    simp [A]
  open_target := isOpen_Ioi.prod isOpen_Ioo
  open_source :=
    (isOpen_lt continuous_const continuous_fst).union
      (isOpen_ne_fun continuous_snd continuous_const)
  continuousOn_invFun :=
    ((continuous_fst.mul (continuous_cos.comp continuous_snd)).prod_mk
        (continuous_fst.mul (continuous_sin.comp continuous_snd))).continuousOn
  continuousOn_toFun := by
    apply ((continuous_fst.pow 2).add (continuous_snd.pow 2)).sqrt.continuousOn.prod
    have A : MapsTo Complex.equivRealProd.symm ({q : ℝ × ℝ | 0 < q.1} ∪ {q : ℝ × ℝ | q.2 ≠ 0})
        {z | 0 < z.re ∨ z.im ≠ 0} := by
      rintro ⟨x, y⟩ hxy; simpa only using hxy
    refine' ContinuousOn.comp (f := Complex.equivRealProd.symm)
      (g := Complex.arg) (fun z hz => _) _ A
    · exact (Complex.continuousAt_arg hz).continuousWithinAt
    · 

Proof state:
case refine'_2
A : MapsTo (⇑Complex.equivRealProd.symm) ({q | 0 < q.1} ∪ {q | q.2 ≠ 0}) {z | 0 < z.re ∨ z.im ≠ 0}
⊢ ContinuousOn ⇑Complex.equivRealProd.symm
    { toFun := fun q => (sqrt (q.1 ^ 2 + q.2 ^ 2), Complex.arg (Complex.equivRealProd.symm q)),
        invFun := fun p => (p.1 * cos p.2, p.1 * sin p.2), source := {q | 0 < q.1} ∪ {q | q.2 ≠ 0},
        target := Ioi 0 ×ˢ Ioo (-π) π,
        map_source' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0} →
                (fun q => (sqrt (q.1 ^ 2 + q.2 ^ 2), Complex.arg (Complex.equivRealProd.symm q))) x ∈
                  Ioi 0 ×ˢ Ioo (-π) π),
        map_target' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π → (fun p => (p.1 * cos p.2, p.1 * sin p.2)) x ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0}),
        left_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ {q | 0 < q.1} ∪ {q | q.2 ≠ 0} →
                (fun p => (p.1 * cos p.2, p.1 * sin p.2))
                    ((fun q => (sqrt (q.1 ^ 2 + q.2 ^ 2), Complex.arg (Complex.equivRealProd.symm q))) x) =
                  x),
        right_inv' :=
          (_ :
            ∀ ⦃x : ℝ × ℝ⦄,
              x ∈ Ioi 0 ×ˢ Ioo (-π) π →
                (fun q => (sqrt (q.1 ^ 2 + q.2 ^ 2), Complex.arg (Complex.equivRealProd.symm q)))
                    ((fun p => (p.1 * cos p.2, p.1 * sin p.2)) x) =
                  x) }.source

Next tactic:
exact Complex.equivRealProdClm.symm.continuous.continuousOn