Theorem: integral_comp_polarCoord_symm
File: Mathlib/Analysis/SpecialFunctions/PolarCoord.lean

tactic: set B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ := fun p =>
  LinearMap.toContinuousLinearMap (Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ)
    !![cos p.2, -p.1 * sin p.2; sin p.2, p.1 * cos p.2])
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
⊢ (∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p)) = ∫ (p : ℝ × ℝ), f p

tactic: have A : ∀ p ∈ polarCoord.symm.source, HasFDerivAt polarCoord.symm (B p) p := fun p _ =>
  hasFDerivAt_polarCoord_symm p
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
⊢ (∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p)) = ∫ (p : ℝ × ℝ), f p

tactic: have B_det : ∀ p, (B p).det = p.1 := by
  intro p
  conv_rhs => rw [← one_mul p.1, ← cos_sq_add_sin_sq p.2]
  simp only [neg_mul, LinearMap.det_toContinuousLinearMap, LinearMap.det_toLin,
    Matrix.det_fin_two_of, sub_neg_eq_add]
  ring
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
⊢ (∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p)) = ∫ (p : ℝ × ℝ), f p

tactic: symm
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ (∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p)) = ∫ (p : ℝ × ℝ), f p

tactic: calc
  (∫ p, f p) = ∫ p in polarCoord.source, f p := by
    rw [← integral_univ]
    apply set_integral_congr_set_ae
    exact polarCoord_source_ae_eq_univ.symm
  _ = ∫ p in polarCoord.target, abs (B p).det • f (polarCoord.symm p) := by
    apply integral_target_eq_integral_abs_det_fderiv_smul volume A
  _ = ∫ p in polarCoord.target, p.1 • f (polarCoord.symm p) := by
    apply set_integral_congr polarCoord.open_target.measurableSet fun x hx => ?_
    rw [B_det, abs_of_pos]
    exact hx.1
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ (∫ (p : ℝ × ℝ), f p) = ∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p)

tactic: intro p
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
⊢ ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst

tactic: conv_rhs => rw [← one_mul p.1, ← cos_sq_add_sin_sq p.2]
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
p : ℝ × ℝ
⊢ ContinuousLinearMap.det (B p) = p.fst

tactic: simp only [neg_mul, LinearMap.det_toContinuousLinearMap, LinearMap.det_toLin,
  Matrix.det_fin_two_of, sub_neg_eq_add]
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
p : ℝ × ℝ
⊢ ContinuousLinearMap.det (B p) = (cos p.snd ^ 2 + sin p.snd ^ 2) * p.fst

tactic: ring
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
p : ℝ × ℝ
⊢ cos p.snd * (p.fst * cos p.snd) + p.fst * sin p.snd * sin p.snd = (cos p.snd ^ 2 + sin p.snd ^ 2) * p.fst

tactic: rw [← integral_univ]
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ (∫ (p : ℝ × ℝ), f p) = ∫ (p : ℝ × ℝ) in polarCoord.source, f p

tactic: apply set_integral_congr_set_ae
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ (∫ (x : ℝ × ℝ) in univ, f x) = ∫ (p : ℝ × ℝ) in polarCoord.source, f p

tactic: exact polarCoord_source_ae_eq_univ.symm
state_before: case hst
E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ univ =ᵐ[volume] polarCoord.source

tactic: apply integral_target_eq_integral_abs_det_fderiv_smul volume A
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ (∫ (p : ℝ × ℝ) in polarCoord.source, f p) =
    ∫ (p : ℝ × ℝ) in polarCoord.target, abs (ContinuousLinearMap.det (B p)) • f (↑(LocalHomeomorph.symm polarCoord) p)

tactic: apply set_integral_congr polarCoord.open_target.measurableSet fun x hx => ?_
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
⊢ (∫ (p : ℝ × ℝ) in polarCoord.target, abs (ContinuousLinearMap.det (B p)) • f (↑(LocalHomeomorph.symm polarCoord) p)) =
    ∫ (p : ℝ × ℝ) in polarCoord.target, p.fst • f (↑(LocalHomeomorph.symm polarCoord) p)

tactic: rw [B_det, abs_of_pos]
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
x : ℝ × ℝ
hx : x ∈ polarCoord.target
⊢ abs (ContinuousLinearMap.det (B x)) • f (↑(LocalHomeomorph.symm polarCoord) x) =
    x.fst • f (↑(LocalHomeomorph.symm polarCoord) x)

tactic: exact hx.1
state_before: E : Type u_1
inst✝² : NormedAddCommGroup E
inst✝¹ : NormedSpace ℝ E
inst✝ : CompleteSpace E
f : ℝ × ℝ → E
B : ℝ × ℝ → ℝ × ℝ →L[ℝ] ℝ × ℝ :=
  fun p =>
    ↑LinearMap.toContinuousLinearMap
      (↑(Matrix.toLin (Basis.finTwoProd ℝ) (Basis.finTwoProd ℝ))
        (↑Matrix.of ![![cos p.snd, -p.fst * sin p.snd], ![sin p.snd, p.fst * cos p.snd]]))
A :
  ∀ (p : ℝ × ℝ),
    p ∈ (LocalHomeomorph.symm polarCoord).toLocalEquiv.source → HasFDerivAt (↑(LocalHomeomorph.symm polarCoord)) (B p) p
B_det : ∀ (p : ℝ × ℝ), ContinuousLinearMap.det (B p) = p.fst
x : ℝ × ℝ
hx : x ∈ polarCoord.target
⊢ 0 < x.fst