/-
Copyright (c) 2023 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Yury Kudryashov
-/
module
public import Mathlib.Analysis.Calculus.Deriv.Comp
import Mathlib.Analysis.Calculus.Deriv.Mul
/-!
# Derivatives of `x ↦ x⁻¹` and `f x / g x`
In this file we prove `(x⁻¹)' = -1 / x ^ 2`, `((f x)⁻¹)' = -f' x / (f x) ^ 2`, and
`(f x / g x)' = (f' x * g x - f x * g' x) / (g x) ^ 2` for different notions of derivative.
For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of
`Analysis/Calculus/Deriv/Basic`.
## Keywords
derivative
-/
public section
universe u
open scoped Topology
open Filter Asymptotics Set
open ContinuousLinearMap (toSpanSingleton)
variable { : Type u} [NontriviallyNormedField ] {x : } {s : Set }
section Inverse
/-! ### Derivative of `x ↦ x⁻¹` -/
theorem hasStrictDerivAt_inv (hx : x ≠ 0) : HasStrictDerivAt Inv.inv (-(x ^ 2)⁻¹) x := by
suffices
(fun p : × => (p.1 - p.2) * ((x * x)⁻¹ - (p.1 * p.2)⁻¹)) =o[ (x, x)] fun p =>
(p.1 - p.2) * 1 by
refine .of_isLittleO <| this.congr' ?_ (Eventually.of_forall fun _ => mul_one _)
refine Eventually.mono ((isOpen_ne.prod isOpen_ne).mem_nhds ⟨hx, hx⟩) ?_
rintro ⟨y, z⟩ ⟨hy, hz⟩
simp only [mem_ofPred_eq] at hy hz
simp [field]
ring
refine (isBigO_refl (fun p : × => p.1 - p.2) _).mul_isLittleO ((isLittleO_one_iff ).2 ?_)
rw [← sub_self (x * x)⁻¹]
exact tendsto_const_nhds.sub ((continuous_mul.tendsto (x, x)).inv₀ <| mul_ne_zero hx hx)
theorem hasDerivAt_inv (x_ne_zero : x ≠ 0) : HasDerivAt (fun y => y⁻¹) (-(x ^ 2)⁻¹) x :=
(hasStrictDerivAt_inv x_ne_zero).hasDerivAt
theorem hasDerivWithinAt_inv (x_ne_zero : x ≠ 0) (s : Set ) :
HasDerivWithinAt (fun x => x⁻¹) (-(x ^ 2)⁻¹) s x :=
(hasDerivAt_inv x_ne_zero).hasDerivWithinAt
theorem differentiableAt_inv_iff : DifferentiableAt (fun x => x⁻¹) x ↔ x ≠ 0 :=
⟨fun H => NormedField.continuousAt_inv.1 H.continuousAt, fun H =>
(hasDerivAt_inv H).differentiableAt⟩
theorem deriv_inv : deriv (fun x => x⁻¹) x = -(x ^ 2)⁻¹ := by
rcases eq_or_ne x 0 with (rfl | hne)
· rw [deriv_zero_of_not_differentiableAt (mt differentiableAt_inv_iff.1 (not_not.2 rfl))]
simp
· exact (hasDerivAt_inv hne).deriv
@[simp]
theorem deriv_inv' : (deriv fun x : => x⁻¹) = fun x => -(x ^ 2)⁻¹ :=
funext fun _ => deriv_inv
theorem derivWithin_inv (x_ne_zero : x ≠ 0) (hxs : UniqueDiffWithinAt s x) :
derivWithin (fun x => x⁻¹) s x = -(x ^ 2)⁻¹ := by
rw [DifferentiableAt.derivWithin (differentiableAt_inv x_ne_zero) hxs]
exact deriv_inv
theorem hasFDerivAt_inv (x_ne_zero : x ≠ 0) :
HasFDerivAt (fun x => x⁻¹) (toSpanSingleton (-(x ^ 2)⁻¹) : →L[] ) x :=
hasDerivAt_inv x_ne_zero
theorem hasStrictFDerivAt_inv (x_ne_zero : x ≠ 0) :
HasStrictFDerivAt (fun x => x⁻¹) (toSpanSingleton (-(x ^ 2)⁻¹) : →L[] ) x :=
hasStrictDerivAt_inv x_ne_zero
theorem hasFDerivWithinAt_inv (x_ne_zero : x ≠ 0) :
HasFDerivWithinAt (fun x => x⁻¹) (toSpanSingleton (-(x ^ 2)⁻¹) : →L[] ) s x :=
(hasFDerivAt_inv x_ne_zero).hasFDerivWithinAt
theorem fderiv_inv : fderiv (fun x => x⁻¹) x = toSpanSingleton (-(x ^ 2)⁻¹) := by
rw [← toSpanSingleton_deriv, deriv_inv]
theorem fderivWithin_inv (x_ne_zero : x ≠ 0) (hxs : UniqueDiffWithinAt s x) :
fderivWithin (fun x => x⁻¹) s x = toSpanSingleton (-(x ^ 2)⁻¹) := by
rw [DifferentiableAt.fderivWithin (differentiableAt_inv x_ne_zero) hxs]
exact fderiv_inv
variable {' : Type*} [NontriviallyNormedField '] [NormedAlgebra ']
variable {c : → '} {c' : '}
@[to_fun]
theorem HasDerivWithinAt.inv (hc : HasDerivWithinAt c c' s x) (hx : c x ≠ 0) :
HasDerivWithinAt (c⁻¹) (-c' / c x ^ 2) s x := by
convert! (hasDerivAt_inv hx).comp_hasDerivWithinAt x hc using 1
ring
@[to_fun]
theorem HasDerivAt.inv (hc : HasDerivAt c c' x) (hx : c x ≠ 0) :
HasDerivAt (c⁻¹) (-c' / c x ^ 2) x := by
rw [← hasDerivWithinAt_univ] at *
exact hc.inv hx
theorem derivWithin_fun_inv' (hc : DifferentiableWithinAt c s x) (hx : c x ≠ 0) :
derivWithin (fun x => (c x)⁻¹) s x = -derivWithin c s x / c x ^ 2 := by
by_cases hsx : UniqueDiffWithinAt s x
· exact (hc.hasDerivWithinAt.inv hx).derivWithin hsx
· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx]
theorem derivWithin_inv' (hc : DifferentiableWithinAt c s x) (hx : c x ≠ 0) :
derivWithin (c⁻¹) s x = -derivWithin c s x / c x ^ 2 :=
derivWithin_fun_inv' hc hx
@[simp]
theorem deriv_fun_inv'' (hc : DifferentiableAt c x) (hx : c x ≠ 0) :
deriv (fun x => (c x)⁻¹) x = -deriv c x / c x ^ 2 :=
(hc.hasDerivAt.inv hx).deriv
@[simp]
theorem deriv_inv'' (hc : DifferentiableAt c x) (hx : c x ≠ 0) :
deriv (c⁻¹) x = -deriv c x / c x ^ 2 :=
(hc.hasDerivAt.inv hx).deriv
end Inverse
section Division
/-! ### Derivative of `x ↦ c x / d x` -/
variable {' : Type*} [NontriviallyNormedField '] [NormedAlgebra '] {c d : → '} {c' d' : '}
theorem HasDerivWithinAt.fun_div (hc : HasDerivWithinAt c c' s x) (hd : HasDerivWithinAt d d' s x)
(hx : d x ≠ 0) :
HasDerivWithinAt (fun y => c y / d y) ((c' * d x - c x * d') / d x ^ 2) s x := by
convert hc.fun_mul ((hasDerivAt_inv hx).comp_hasDerivWithinAt x hd)
· simp only [div_eq_mul_inv, (· ∘ ·)]
· simp [field]
ring
theorem HasDerivWithinAt.div (hc : HasDerivWithinAt c c' s x) (hd : HasDerivWithinAt d d' s x)
(hx : d x ≠ 0) :
HasDerivWithinAt (c / d) ((c' * d x - c x * d') / d x ^ 2) s x :=
hc.fun_div hd hx
theorem HasStrictDerivAt.fun_div (hc : HasStrictDerivAt c c' x) (hd : HasStrictDerivAt d d' x)
(hx : d x ≠ 0) : HasStrictDerivAt (fun y => c y / d y) ((c' * d x - c x * d') / d x ^ 2) x := by
convert hc.fun_mul ((hasStrictDerivAt_inv hx).comp x hd)
· simp only [div_eq_mul_inv, (· ∘ ·)]
· simp [field]
ring
theorem HasStrictDerivAt.div (hc : HasStrictDerivAt c c' x) (hd : HasStrictDerivAt d d' x)
(hx : d x ≠ 0) : HasStrictDerivAt (c / d) ((c' * d x - c x * d') / d x ^ 2) x :=
hc.fun_div hd hx
theorem HasDerivAt.fun_div (hc : HasDerivAt c c' x) (hd : HasDerivAt d d' x) (hx : d x ≠ 0) :
HasDerivAt (fun y => c y / d y) ((c' * d x - c x * d') / d x ^ 2) x := by
rw [← hasDerivWithinAt_univ] at *
exact hc.div hd hx
theorem HasDerivAt.div (hc : HasDerivAt c c' x) (hd : HasDerivAt d d' x) (hx : d x ≠ 0) :
HasDerivAt (c / d) ((c' * d x - c x * d') / d x ^ 2) x :=
hc.fun_div hd hx
theorem DifferentiableWithinAt.fun_div (hc : DifferentiableWithinAt c s x)
(hd : DifferentiableWithinAt d s x) (hx : d x ≠ 0) :
DifferentiableWithinAt (fun x => c x / d x) s x :=
(hc.hasDerivWithinAt.div hd.hasDerivWithinAt hx).differentiableWithinAt
theorem DifferentiableWithinAt.div (hc : DifferentiableWithinAt c s x)
(hd : DifferentiableWithinAt d s x) (hx : d x ≠ 0) :
DifferentiableWithinAt (c / d) s x :=
hc.fun_div hd hx
@[to_fun (attr := simp, fun_prop)]
theorem DifferentiableAt.div (hc : DifferentiableAt c x) (hd : DifferentiableAt d x)
(hx : d x ≠ 0) : DifferentiableAt (c / d) x :=
(hc.hasDerivAt.div hd.hasDerivAt hx).differentiableAt
@[to_fun (attr := fun_prop)]
theorem DifferentiableOn.div (hc : DifferentiableOn c s) (hd : DifferentiableOn d s)
(hx : ∀ x ∈ s, d x ≠ 0) : DifferentiableOn (c / d) s := fun x h =>
(hc x h).div (hd x h) (hx x h)
@[to_fun (attr := simp, fun_prop)]
theorem Differentiable.div (hc : Differentiable c) (hd : Differentiable d) (hx : ∀ x, d x ≠ 0) :
Differentiable (c / d) := fun x => (hc x).div (hd x) (hx x)
theorem derivWithin_fun_div
(hc : DifferentiableWithinAt c s x) (hd : DifferentiableWithinAt d s x) (hx : d x ≠ 0) :
derivWithin (fun x => c x / d x) s x =
(derivWithin c s x * d x - c x * derivWithin d s x) / d x ^ 2 := by
by_cases hsx : UniqueDiffWithinAt s x
· exact (hc.hasDerivWithinAt.div hd.hasDerivWithinAt hx).derivWithin hsx
· simp [derivWithin_zero_of_not_uniqueDiffWithinAt hsx]
theorem derivWithin_div (hc : DifferentiableWithinAt c s x) (hd : DifferentiableWithinAt d s x)
(hx : d x ≠ 0) :
derivWithin (c / d) s x = (derivWithin c s x * d x - c x * derivWithin d s x) / d x ^ 2 :=
derivWithin_fun_div hc hd hx
@[simp]
theorem deriv_fun_div (hc : DifferentiableAt c x) (hd : DifferentiableAt d x) (hx : d x ≠ 0) :
deriv (fun x => c x / d x) x = (deriv c x * d x - c x * deriv d x) / d x ^ 2 :=
(hc.hasDerivAt.div hd.hasDerivAt hx).deriv
@[simp]
theorem deriv_div (hc : DifferentiableAt c x) (hd : DifferentiableAt d x) (hx : d x ≠ 0) :
deriv (c / d) x = (deriv c x * d x - c x * deriv d x) / d x ^ 2 :=
(hc.hasDerivAt.div hd.hasDerivAt hx).deriv
theorem deriv_const_div (c : ') (hd : DifferentiableAt d x) (hx : d x ≠ 0) :
deriv (fun x => c / d x) x = - c * deriv d x / d x ^ 2 := by
simp [deriv_fun_div (differentiableAt_const c) hd hx]
@[simp]
theorem deriv_const_div_id (c : ) :
deriv (fun x => c / x) x = - c / x ^ 2 := by
simp [div_eq_mul_inv]
end Division
¤ Dauer der Verarbeitung: 0.9 Sekunden
¤
*© Formatika GbR, Deutschland