Theorem: expNegInvGlue.hasDerivAt_polynomial_eval_inv_mul
File: Mathlib/Analysis/Calculus/BumpFunctionInner.lean

tactic: rcases lt_trichotomy x 0 with hx | rfl | hx
state_before: p : ℝ[X]
x : ℝ
⊢ HasDerivAt (fun x => Polynomial.eval x⁻¹ p * expNegInvGlue x)
    (Polynomial.eval x⁻¹ (X ^ 2 * (p - ↑derivative p)) * expNegInvGlue x) x

tactic: rw [zero_of_nonpos hx.le, mul_zero]
state_before: case inl
p : ℝ[X]
x : ℝ
hx : x < 0
⊢ HasDerivAt (fun x => Polynomial.eval x⁻¹ p * expNegInvGlue x)
    (Polynomial.eval x⁻¹ (X ^ 2 * (p - ↑derivative p)) * expNegInvGlue x) x

tactic: refine (hasDerivAt_const _ 0).congr_of_eventuallyEq ?_
state_before: case inl
p : ℝ[X]
x : ℝ
hx : x < 0
⊢ HasDerivAt (fun x => Polynomial.eval x⁻¹ p * expNegInvGlue x) 0 x

tactic: filter_upwards [gt_mem_nhds hx] with y hy
state_before: case inl
p : ℝ[X]
x : ℝ
hx : x < 0
⊢ (fun x => Polynomial.eval x⁻¹ p * expNegInvGlue x) =ᶠ[𝓝 x] fun x => 0

tactic: rw [zero_of_nonpos hy.le, mul_zero]
state_before: case h
p : ℝ[X]
x : ℝ
hx : x < 0
y : ℝ
hy : y < 0
⊢ Polynomial.eval y⁻¹ p * expNegInvGlue y = 0

tactic: rw [expNegInvGlue.zero, mul_zero, hasDerivAt_iff_tendsto_slope]
state_before: case inr.inl
p : ℝ[X]
⊢ HasDerivAt (fun x => Polynomial.eval x⁻¹ p * expNegInvGlue x)
    (Polynomial.eval 0⁻¹ (X ^ 2 * (p - ↑derivative p)) * expNegInvGlue 0) 0

tactic: refine ((tendsto_polynomial_inv_mul_zero (p * X)).mono_left inf_le_left).congr fun x ↦ ?_
state_before: case inr.inl
p : ℝ[X]
⊢ Tendsto (slope (fun x => Polynomial.eval x⁻¹ p * expNegInvGlue x) 0) (𝓝[{0}ᶜ] 0) (𝓝 0)

tactic: simp [slope_def_field, div_eq_mul_inv, mul_right_comm]
state_before: case inr.inl
p : ℝ[X]
x : ℝ
⊢ Polynomial.eval x⁻¹ (p * X) * expNegInvGlue x = slope (fun x => Polynomial.eval x⁻¹ p * expNegInvGlue x) 0 x

tactic: have := ((p.hasDerivAt x⁻¹).mul (hasDerivAt_neg _).exp).comp x (hasDerivAt_inv hx.ne')
state_before: case inr.inr
p : ℝ[X]
x : ℝ
hx : 0 < x
⊢ HasDerivAt (fun x => Polynomial.eval x⁻¹ p * expNegInvGlue x)
    (Polynomial.eval x⁻¹ (X ^ 2 * (p - ↑derivative p)) * expNegInvGlue x) x

tactic: convert this.congr_of_eventuallyEq _ using 1
state_before: case inr.inr
p : ℝ[X]
x : ℝ
hx : 0 < x
this :
  HasDerivAt ((fun y => Polynomial.eval y p * exp (-y)) ∘ Inv.inv)
    ((Polynomial.eval x⁻¹ (↑derivative p) * exp (-x⁻¹) + Polynomial.eval x⁻¹ p * (exp (-x⁻¹) * -1)) * -(x ^ 2)⁻¹) x
⊢ HasDerivAt (fun x => Polynomial.eval x⁻¹ p * expNegInvGlue x)
    (Polynomial.eval x⁻¹ (X ^ 2 * (p - ↑derivative p)) * expNegInvGlue x) x

tactic: simp [expNegInvGlue, hx.not_le]
state_before: case h.e'_7
p : ℝ[X]
x : ℝ
hx : 0 < x
this :
  HasDerivAt ((fun y => Polynomial.eval y p * exp (-y)) ∘ Inv.inv)
    ((Polynomial.eval x⁻¹ (↑derivative p) * exp (-x⁻¹) + Polynomial.eval x⁻¹ p * (exp (-x⁻¹) * -1)) * -(x ^ 2)⁻¹) x
⊢ Polynomial.eval x⁻¹ (X ^ 2 * (p - ↑derivative p)) * expNegInvGlue x =
    (Polynomial.eval x⁻¹ (↑derivative p) * exp (-x⁻¹) + Polynomial.eval x⁻¹ p * (exp (-x⁻¹) * -1)) * -(x ^ 2)⁻¹

tactic: ring
state_before: case h.e'_7
p : ℝ[X]
x : ℝ
hx : 0 < x
this :
  HasDerivAt ((fun y => Polynomial.eval y p * exp (-y)) ∘ Inv.inv)
    ((Polynomial.eval x⁻¹ (↑derivative p) * exp (-x⁻¹) + Polynomial.eval x⁻¹ p * (exp (-x⁻¹) * -1)) * -(x ^ 2)⁻¹) x
⊢ (x ^ 2)⁻¹ * (Polynomial.eval x⁻¹ p - Polynomial.eval x⁻¹ (↑derivative p)) * exp (-x⁻¹) =
    -((Polynomial.eval x⁻¹ (↑derivative p) * exp (-x⁻¹) + -(Polynomial.eval x⁻¹ p * exp (-x⁻¹))) * (x ^ 2)⁻¹)

tactic: filter_upwards [lt_mem_nhds hx] with y hy
state_before: case inr.inr.convert_2
p : ℝ[X]
x : ℝ
hx : 0 < x
this :
  HasDerivAt ((fun y => Polynomial.eval y p * exp (-y)) ∘ Inv.inv)
    ((Polynomial.eval x⁻¹ (↑derivative p) * exp (-x⁻¹) + Polynomial.eval x⁻¹ p * (exp (-x⁻¹) * -1)) * -(x ^ 2)⁻¹) x
⊢ (fun x => Polynomial.eval x⁻¹ p * expNegInvGlue x) =ᶠ[𝓝 x] (fun y => Polynomial.eval y p * exp (-y)) ∘ Inv.inv

tactic: simp [expNegInvGlue, hy.not_le]
state_before: case h
p : ℝ[X]
x : ℝ
hx : 0 < x
this :
  HasDerivAt ((fun y => Polynomial.eval y p * exp (-y)) ∘ Inv.inv)
    ((Polynomial.eval x⁻¹ (↑derivative p) * exp (-x⁻¹) + Polynomial.eval x⁻¹ p * (exp (-x⁻¹) * -1)) * -(x ^ 2)⁻¹) x
y : ℝ
hy : 0 < y
⊢ Polynomial.eval y⁻¹ p * expNegInvGlue y = ((fun y => Polynomial.eval y p * exp (-y)) ∘ Inv.inv) y