Theorem: deriv2_sqrt_mul_log
File: Mathlib/Analysis/Convex/SpecificFunctions/Deriv.lean

tactic: simp only [Nat.iterate, deriv_sqrt_mul_log']
state_before: x : ℝ
⊢ deriv^[2] (fun x => √x * log x) x = -log x / (4 * √x ^ 3)
state_after: x : ℝ
⊢ deriv (fun x => (2 + log x) / (2 * √x)) x = -log x / (4 * √x ^ 3)

tactic: rcases le_or_lt x 0 with hx | hx
state_before: x : ℝ
⊢ deriv (fun x => (2 + log x) / (2 * √x)) x = -log x / (4 * √x ^ 3)
state_after: case inl
x : ℝ
hx : x ≤ 0
⊢ deriv (fun x => (2 + log x) / (2 * √x)) x = -log x / (4 * √x ^ 3)

case inr
x : ℝ
hx : 0 < x
⊢ deriv (fun x => (2 + log x) / (2 * √x)) x = -log x / (4 * √x ^ 3)

tactic: rw [sqrt_eq_zero_of_nonpos hx, zero_pow three_ne_zero, mul_zero, div_zero]
state_before: case inl
x : ℝ
hx : x ≤ 0
⊢ deriv (fun x => (2 + log x) / (2 * √x)) x = -log x / (4 * √x ^ 3)
state_after: case inl
x : ℝ
hx : x ≤ 0
⊢ deriv (fun x => (2 + log x) / (2 * √x)) x = 0

tactic: refine HasDerivWithinAt.deriv_eq_zero ?_ (uniqueDiffOn_Iic 0 x hx)
state_before: case inl
x : ℝ
hx : x ≤ 0
⊢ deriv (fun x => (2 + log x) / (2 * √x)) x = 0
state_after: case inl
x : ℝ
hx : x ≤ 0
⊢ HasDerivWithinAt (fun x => (2 + log x) / (2 * √x)) 0 (Iic 0) x

tactic: refine (hasDerivWithinAt_const _ _ 0).congr_of_mem (fun x hx => ?_) hx
state_before: case inl
x : ℝ
hx : x ≤ 0
⊢ HasDerivWithinAt (fun x => (2 + log x) / (2 * √x)) 0 (Iic 0) x
state_after: case inl
x✝ : ℝ
hx✝ : x✝ ≤ 0
x : ℝ
hx : x ∈ Iic 0
⊢ (2 + log x) / (2 * √x) = 0

tactic: rw [sqrt_eq_zero_of_nonpos hx, mul_zero, div_zero]
state_before: case inl
x✝ : ℝ
hx✝ : x✝ ≤ 0
x : ℝ
hx : x ∈ Iic 0
⊢ (2 + log x) / (2 * √x) = 0
state_after: no goals

tactic: have h₀ : √x ≠ 0 := sqrt_ne_zero'.2 hx
state_before: case inr
x : ℝ
hx : 0 < x
⊢ deriv (fun x => (2 + log x) / (2 * √x)) x = -log x / (4 * √x ^ 3)
state_after: case inr
x : ℝ
hx : 0 < x
h₀ : √x ≠ 0
⊢ deriv (fun x => (2 + log x) / (2 * √x)) x = -log x / (4 * √x ^ 3)

tactic: convert (((hasDerivAt_log hx.ne').const_add 2).div ((hasDerivAt_sqrt hx.ne').const_mul 2) <|
  mul_ne_zero two_ne_zero h₀).deriv using 1
state_before: case inr
x : ℝ
hx : 0 < x
h₀ : √x ≠ 0
⊢ deriv (fun x => (2 + log x) / (2 * √x)) x = -log x / (4 * √x ^ 3)
state_after: case h.e'_3
x : ℝ
hx : 0 < x
h₀ : √x ≠ 0
⊢ -log x / (4 * √x ^ 3) = (x⁻¹ * (2 * √x) - (2 + log x) * (2 * (1 / (2 * √x)))) / (2 * √x) ^ 2

tactic: nth_rw 3 [← mul_self_sqrt hx.le]
state_before: case h.e'_3
x : ℝ
hx : 0 < x
h₀ : √x ≠ 0
⊢ -log x / (4 * √x ^ 3) = (x⁻¹ * (2 * √x) - (2 + log x) * (2 * (1 / (2 * √x)))) / (2 * √x) ^ 2
state_after: case h.e'_3
x : ℝ
hx : 0 < x
h₀ : √x ≠ 0
⊢ -log x / (4 * √x ^ 3) = ((√x * √x)⁻¹ * (2 * √x) - (2 + log x) * (2 * (1 / (2 * √x)))) / (2 * √x) ^ 2

tactic: generalize √x = sqx at h₀
state_before: case h.e'_3
x : ℝ
hx : 0 < x
h₀ : √x ≠ 0
⊢ -log x / (4 * √x ^ 3) = ((√x * √x)⁻¹ * (2 * √x) - (2 + log x) * (2 * (1 / (2 * √x)))) / (2 * √x) ^ 2
state_after: case h.e'_3
x : ℝ
hx : 0 < x
sqx : ℝ
h₀ : sqx ≠ 0
⊢ -log x / (4 * sqx ^ 3) = ((sqx * sqx)⁻¹ * (2 * sqx) - (2 + log x) * (2 * (1 / (2 * sqx)))) / (2 * sqx) ^ 2

tactic: field_simp
state_before: case h.e'_3
x : ℝ
hx : 0 < x
sqx : ℝ
h₀ : sqx ≠ 0
⊢ -log x / (4 * sqx ^ 3) = ((sqx * sqx)⁻¹ * (2 * sqx) - (2 + log x) * (2 * (1 / (2 * sqx)))) / (2 * sqx) ^ 2
state_after: case h.e'_3
x : ℝ
hx : 0 < x
sqx : ℝ
h₀ : sqx ≠ 0
⊢ -(log x * (sqx * sqx * (2 * sqx) * (2 * sqx) ^ 2)) =
    (2 * sqx * (2 * sqx) - sqx * sqx * ((2 + log x) * 2)) * (4 * sqx ^ 3)

tactic: ring
state_before: case h.e'_3
x : ℝ
hx : 0 < x
sqx : ℝ
h₀ : sqx ≠ 0
⊢ -(log x * (sqx * sqx * (2 * sqx) * (2 * sqx) ^ 2)) =
    (2 * sqx * (2 * sqx) - sqx * sqx * ((2 + log x) * 2)) * (4 * sqx ^ 3)
state_after: no goals