Theorem: EuclideanGeometry.hasFDerivAt_inversion
File: Mathlib/Geometry/Euclidean/Inversion/Calculus.lean

Proof steps:
state_before: E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d x y z : F
r R : ℝ
hx : x ≠ c
⊢ HasFDerivAt (inversion c R)
    ((R / dist x c) ^ 2 •
      ↑{ toLinearEquiv := (reflection (Submodule.span ℝ {x - c})ᗮ).toLinearEquiv, continuous_toFun := ⋯,
          continuous_invFun := ⋯ })
    x
state_after: case intro
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
⊢ HasFDerivAt (inversion c R)
    ((R / dist ((fun x => c + x) x) c) ^ 2 •
      ↑{ toLinearEquiv := (reflection (Submodule.span ℝ {(fun x => c + x) x - c})ᗮ).toLinearEquiv,
          continuous_toFun := ⋯, continuous_invFun := ⋯ })
    ((fun x => c + x) x)
tactic: rcases add_left_surjective c x with ⟨x, rfl⟩
state_before: case intro
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
⊢ HasFDerivAt (inversion c R)
    ((R / dist ((fun x => c + x) x) c) ^ 2 •
      ↑{ toLinearEquiv := (reflection (Submodule.span ℝ {(fun x => c + x) x - c})ᗮ).toLinearEquiv,
          continuous_toFun := ⋯, continuous_invFun := ⋯ })
    ((fun x => c + x) x)
state_after: case intro.refine_2
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
this :
  HasFDerivAt (inversion c R)
    ((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
      (R ^ 2 •
            -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
              2 • ((innerSL ℝ) (_root_.id (c + x) - c)).comp (ContinuousLinearMap.id ℝ F)).smulRight
        (_root_.id (c + x) - c))
    (c + x)
⊢ HasFDerivAt (inversion c R)
    ((R / dist ((fun x => c + x) x) c) ^ 2 •
      ↑{ toLinearEquiv := (reflection (Submodule.span ℝ {(fun x => c + x) x - c})ᗮ).toLinearEquiv,
          continuous_toFun := ⋯, continuous_invFun := ⋯ })
    ((fun x => c + x) x)
tactic: have : HasFDerivAt (inversion c R) (?_ : F →L[ℝ] F) (c + x) := by
    #adaptation_note /-- nightly-2024-03-16: simp was
    simp (config := { unfoldPartialApp := true }) only [inversion] -/
    simp only [inversion_def]
    simp_rw [dist_eq_norm, div_pow, div_eq_mul_inv]
    have A := (hasFDerivAt_id (𝕜 := ℝ) (c + x)).sub_const c
    have B := ((hasDerivAt_inv <| by simpa using hx).comp_hasFDerivAt _ A.norm_sq).const_mul
      (R ^ 2)
    exact (B.smul A).add_const c
state_before: case intro.refine_2
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
this :
  HasFDerivAt (inversion c R)
    ((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
      (R ^ 2 •
            -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
              2 • ((innerSL ℝ) (_root_.id (c + x) - c)).comp (ContinuousLinearMap.id ℝ F)).smulRight
        (_root_.id (c + x) - c))
    (c + x)
⊢ HasFDerivAt (inversion c R)
    ((R / dist ((fun x => c + x) x) c) ^ 2 •
      ↑{ toLinearEquiv := (reflection (Submodule.span ℝ {(fun x => c + x) x - c})ᗮ).toLinearEquiv,
          continuous_toFun := ⋯, continuous_invFun := ⋯ })
    ((fun x => c + x) x)
state_after: case intro.refine_2.refine_1
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
this :
  HasFDerivAt (inversion c R)
    ((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
      (R ^ 2 •
            -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
              2 • ((innerSL ℝ) (_root_.id (c + x) - c)).comp (ContinuousLinearMap.id ℝ F)).smulRight
        (_root_.id (c + x) - c))
    (c + x)
⊢ EqOn
    ⇑((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
        (R ^ 2 •
              -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
                2 • ((innerSL ℝ) (_root_.id (c + x) - c)).comp (ContinuousLinearMap.id ℝ F)).smulRight
          (_root_.id (c + x) - c))
    ⇑((R / dist ((fun x => c + x) x) c) ^ 2 •
        ↑{ toLinearEquiv := (reflection (Submodule.span ℝ {(fun x => c + x) x - c})ᗮ).toLinearEquiv,
            continuous_toFun := ⋯, continuous_invFun := ⋯ })
    {x}

case intro.refine_2.refine_2
E : Type u_1
F : Type u_2
inst✝³ : NormedAddCommGroup E
inst✝² : NormedSpace ℝ E
inst✝¹ : NormedAddCommGroup F
inst✝ : InnerProductSpace ℝ F
a b c d y✝ z : F
r R : ℝ
x : F
hx : (fun x => c + x) x ≠ c
this :
  HasFDerivAt (inversion c R)
    ((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
      (R ^ 2 •
            -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
              2 • ((innerSL ℝ) (_root_.id (c + x) - c)).comp (ContinuousLinearMap.id ℝ F)).smulRight
        (_root_.id (c + x) - c))
    (c + x)
y : F
hy : y ∈ ↑(Submodule.span ℝ {x})ᗮ
⊢ ((R ^ 2 * ((fun y => y⁻¹) ∘ fun x => ‖_root_.id x - c‖ ^ 2) (c + x)) • ContinuousLinearMap.id ℝ F +
        (R ^ 2 •
              -((‖_root_.id (c + x) - c‖ ^ 2) ^ 2)⁻¹ •
                2 • ((innerSL ℝ) (_root_.id (c + x) - c)).comp (ContinuousLinearMap.id ℝ F)).smulRight
          (_root_.id (c + x) - c))
      y =
    ((R / dist ((fun x => c + x) x) c) ^ 2 •
        ↑{ toLinearEquiv := (reflection (Submodule.span ℝ {(fun x => c + x) x - c})ᗮ).toLinearEquiv,
            continuous_toFun := ⋯, continuous_invFun := ⋯ })
      y
tactic: refine this.congr_fderiv (LinearMap.ext_on_codisjoint
    (Submodule.isCompl_orthogonal_of_completeSpace (K := ℝ ∙ x)).codisjoint
    (LinearMap.eqOn_span' ?_) fun y hy ↦ ?_)