Skip to content

Commit

Permalink
feat: port Analysis.Calculus.Deriv.Pow (#4441)
Browse files Browse the repository at this point in the history
  • Loading branch information
urkud committed May 29, 2023
1 parent cfaaf51 commit b5b6fb2
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
1 change: 1 addition & 0 deletions Mathlib.lean
Expand Up @@ -421,6 +421,7 @@ import Mathlib.Analysis.Calculus.Deriv.Comp
import Mathlib.Analysis.Calculus.Deriv.Inverse
import Mathlib.Analysis.Calculus.Deriv.Linear
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Analysis.Calculus.Deriv.Prod
import Mathlib.Analysis.Calculus.Deriv.Slope
import Mathlib.Analysis.Calculus.Deriv.Support
Expand Down
125 changes: 125 additions & 0 deletions Mathlib/Analysis/Calculus/Deriv/Pow.lean
@@ -0,0 +1,125 @@
/-
Copyright (c) 2019 SΓ©bastien GouΓ«zel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: SΓ©bastien GouΓ«zel
! This file was ported from Lean 3 source module analysis.calculus.deriv.pow
! leanprover-community/mathlib commit 3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe
! Please do not edit these lines, except to modify the commit id
! if you have ported upstream changes.
-/
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Comp

/-!
# Derivative of `(f x) ^ n`, `n : β„•`
In this file we prove that `(x ^ n)' = n * x ^ (n - 1)`, where `n` is a natural number.
For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of
`Analysis/Calculus/Deriv/Basic`.
## Keywords
derivative, power
-/

universe u v w

open Classical Topology BigOperators Filter ENNReal

open Filter Asymptotics Set

variable {π•œ : Type u} [NontriviallyNormedField π•œ]

variable {F : Type v} [NormedAddCommGroup F] [NormedSpace π•œ F]

variable {E : Type w} [NormedAddCommGroup E] [NormedSpace π•œ E]

variable {f fβ‚€ f₁ g : π•œ β†’ F}

variable {f' fβ‚€' f₁' g' : F}

variable {x : π•œ}

variable {s t : Set π•œ}

variable {L L₁ Lβ‚‚ : Filter π•œ}

/-! ### Derivative of `x ↦ x^n` for `n : β„•` -/

variable {c : π•œ β†’ π•œ} {c' : π•œ}

variable (n : β„•)

theorem hasStrictDerivAt_pow :
βˆ€ (n : β„•) (x : π•œ), HasStrictDerivAt (fun x : π•œ ↦ x ^ n) ((n : π•œ) * x ^ (n - 1)) x
| 0, x => by simp [hasStrictDerivAt_const]
| 1, x => by simpa using hasStrictDerivAt_id x
| n + 1 + 1, x => by
simpa [pow_succ', add_mul, mul_assoc] using
(hasStrictDerivAt_pow (n + 1) x).mul (hasStrictDerivAt_id x)
#align has_strict_deriv_at_pow hasStrictDerivAt_pow

theorem hasDerivAt_pow (n : β„•) (x : π•œ) :
HasDerivAt (fun x : π•œ => x ^ n) ((n : π•œ) * x ^ (n - 1)) x :=
(hasStrictDerivAt_pow n x).hasDerivAt
#align has_deriv_at_pow hasDerivAt_pow

theorem hasDerivWithinAt_pow (n : β„•) (x : π•œ) (s : Set π•œ) :
HasDerivWithinAt (fun x : π•œ => x ^ n) ((n : π•œ) * x ^ (n - 1)) s x :=
(hasDerivAt_pow n x).hasDerivWithinAt
#align has_deriv_within_at_pow hasDerivWithinAt_pow

theorem differentiableAt_pow : DifferentiableAt π•œ (fun x : π•œ => x ^ n) x :=
(hasDerivAt_pow n x).differentiableAt
#align differentiable_at_pow differentiableAt_pow

theorem differentiableWithinAt_pow :
DifferentiableWithinAt π•œ (fun x : π•œ => x ^ n) s x :=
(differentiableAt_pow n).differentiableWithinAt
#align differentiable_within_at_pow differentiableWithinAt_pow

theorem differentiable_pow : Differentiable π•œ fun x : π•œ => x ^ n := fun _ => differentiableAt_pow n
#align differentiable_pow differentiable_pow

theorem differentiableOn_pow : DifferentiableOn π•œ (fun x : π•œ => x ^ n) s :=
(differentiable_pow n).differentiableOn
#align differentiable_on_pow differentiableOn_pow

theorem deriv_pow : deriv (fun x : π•œ => x ^ n) x = (n : π•œ) * x ^ (n - 1) :=
(hasDerivAt_pow n x).deriv
#align deriv_pow deriv_pow

@[simp]
theorem deriv_pow' : (deriv fun x : π•œ => x ^ n) = fun x => (n : π•œ) * x ^ (n - 1) :=
funext fun _ => deriv_pow n
#align deriv_pow' deriv_pow'

theorem derivWithin_pow (hxs : UniqueDiffWithinAt π•œ s x) :
derivWithin (fun x : π•œ => x ^ n) s x = (n : π•œ) * x ^ (n - 1) :=
(hasDerivWithinAt_pow n x s).derivWithin hxs
#align deriv_within_pow derivWithin_pow

theorem HasDerivWithinAt.pow (hc : HasDerivWithinAt c c' s x) :
HasDerivWithinAt (fun y => c y ^ n) ((n : π•œ) * c x ^ (n - 1) * c') s x :=
(hasDerivAt_pow n (c x)).comp_hasDerivWithinAt x hc
#align has_deriv_within_at.pow HasDerivWithinAt.pow

theorem HasDerivAt.pow (hc : HasDerivAt c c' x) :
HasDerivAt (fun y => c y ^ n) ((n : π•œ) * c x ^ (n - 1) * c') x := by
rw [← hasDerivWithinAt_univ] at *
exact hc.pow n
#align has_deriv_at.pow HasDerivAt.pow

theorem derivWithin_pow' (hc : DifferentiableWithinAt π•œ c s x) (hxs : UniqueDiffWithinAt π•œ s x) :
derivWithin (fun x => c x ^ n) s x = (n : π•œ) * c x ^ (n - 1) * derivWithin c s x :=
(hc.hasDerivWithinAt.pow n).derivWithin hxs
#align deriv_within_pow' derivWithin_pow'

@[simp]
theorem deriv_pow'' (hc : DifferentiableAt π•œ c x) :
deriv (fun x => c x ^ n) x = (n : π•œ) * c x ^ (n - 1) * deriv c x :=
(hc.hasDerivAt.pow n).deriv
#align deriv_pow'' deriv_pow''

0 comments on commit b5b6fb2

Please sign in to comment.