Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Lean/Mathlib/Mathlib/Topology/Homotopy/TopCat/     Datei vom 15.10.2026 mit Größe 2 kB image not shown  

Quelle  ZPow.lean   Sprache: Lean

 

/-
Copyright (c) 2020 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.Inv
public import Mathlib.Analysis.Calculus.Deriv.Shift

import Mathlib.Analysis.Calculus.Deriv.Pow

/-!
# Derivatives of `x ^ m`, `m : ℤ`

In this file we prove theorems about (iterated) derivatives of `x ^ m`, `m : ℤ`.

For a more detailed overview of one-dimensional derivatives in mathlib, see the module docstring of
`Mathlib/Analysis/Calculus/Deriv/Basic.lean`.

## Keywords

derivative, power
-/


public section

universe u v w

open Set
open scoped Nat

variable {�� : Type u} [NontriviallyNormedField ��]
variable {E : Type v} [NormedAddCommGroup E] [NormedSpace �� E]
variable {x : ��}
variable {s : Set ��}
variable {m : ℤ}

/-! ### Derivative of `x ↦ x^m` for `m : ℤ` -/

theorem hasStrictDerivAt_zpow (m : ℤ) (x : ��) (h : x ≠ 0 ∨ 0 ≤ m) :
    HasStrictDerivAt (fun x => x ^ m) ((m : ��) * x ^ (m - 1)) x := by
  have : ∀ m : ℤ, 0 < m → HasStrictDerivAt (· ^ m) ((m : ��) * x ^ (m - 1)) x := fun m hm ↦ by
    lift m to ℕ using hm.le
    simp only [zpow_natCast, Int.cast_natCast]
    convert hasStrictDerivAt_pow m x
    rw [← Int.ofNat_one, ← Int.ofNat_sub, zpow_natCast]
    norm_cast at hm
  rcases lt_trichotomy m 0 with (hm | hm | hm)
  · have hx : x ≠ 0 := h.resolve_right hm.not_ge
    have := (hasStrictDerivAt_inv ?_).scomp _ (this (-m) (neg_pos.2 hm)) <;>
      [skip; exact zpow_ne_zero _ hx]
    simp only [Function.comp_def, zpow_neg, inv_inv, smul_eq_mul] at this
    convert this using 1
    rw [sq, mul_inv, inv_inv, Int.cast_neg, neg_mul, neg_mul_neg, ← zpow_add₀ hx, mul_assoc, ←
      zpow_add₀ hx]
    congr
    abel
  · simp only [hm, zpow_zero, Int.cast_zero, zero_mul, hasStrictDerivAt_const]
  · exact this m hm

theorem hasDerivAt_zpow (m : ℤ) (x : ��) (h : x ≠ 0 ∨ 0 ≤ m) :
    HasDerivAt (fun x => x ^ m) ((m : ��) * x ^ (m - 1)) x :=
  (hasStrictDerivAt_zpow m x h).hasDerivAt

theorem hasDerivWithinAt_zpow (m : ℤ) (x : ��) (h : x ≠ 0 ∨ 0 ≤ m) (s : Set ��) :
    HasDerivWithinAt (fun x => x ^ m) ((m : ��) * x ^ (m - 1)) s x :=
  (hasDerivAt_zpow m x h).hasDerivWithinAt

theorem differentiableAt_zpow : DifferentiableAt �� (fun x => x ^ m) x ↔ x ≠ 0 ∨ 0 ≤ m :=
  ⟨fun H => NormedField.continuousAt_zpow.1 H.continuousAt, fun H =>
    (hasDerivAt_zpow m x H).differentiableAt⟩

theorem differentiableWithinAt_zpow (m : ℤ) (x : ��) (h : x ≠ 0 ∨ 0 ≤ m) :
    DifferentiableWithinAt �� (fun x => x ^ m) s x :=
  (differentiableAt_zpow.mpr h).differentiableWithinAt

theorem differentiableOn_zpow (m : ℤ) (s : Set ��) (h : (0 : ��) ∉ s ∨ 0 ≤ m) :
    DifferentiableOn �� (fun x => x ^ m) s := fun x hxs =>
  differentiableWithinAt_zpow m x <| h.imp_left <| ne_of_mem_of_not_mem hxs

theorem deriv_zpow (m : ℤ) (x : ��) : deriv (fun x => x ^ m) x = m * x ^ (m - 1) := by
  by_cases H : x ≠ 0 ∨ 0 ≤ m
  · exact (hasDerivAt_zpow m x H).deriv
  · rw [deriv_zero_of_not_differentiableAt (mt differentiableAt_zpow.1 H)]
    push Not at H
    rcases H with ⟨rfl, hm⟩
    rw [zero_zpow _ ((sub_one_lt _).trans hm).ne, mul_zero]

@[simp]
theorem deriv_zpow' (m : ℤ) : (deriv fun x : �� => x ^ m) = fun x => (m : ��) * x ^ (m - 1) :=
  funext <| deriv_zpow m

theorem derivWithin_zpow (hxs : UniqueDiffWithinAt �� s x) (h : x ≠ 0 ∨ 0 ≤ m) :
    derivWithin (fun x => x ^ m) s x = (m : ��) * x ^ (m - 1) :=
  (hasDerivWithinAt_zpow m x h s).derivWithin hxs

@[simp]
theorem iter_deriv_zpow' (m : ℤ) (k : ℕ) :
    (deriv^[k] fun x : �� => x ^ m) =
      fun x => (∏ i ∈ Finset.range k, ((m : ��) - i)) * x ^ (m - k) := by
  induction k with
  | zero =>
    simp only [one_mul, Int.ofNat_zero, id, sub_zero, Finset.prod_range_zero, Function.iterate_zero]
  | succ k ihk =>
    simp only [Function.iterate_succ_apply', ihk, deriv_const_mul_field', deriv_zpow',
      Finset.prod_range_succ, Int.natCast_succ, ← sub_sub, Int.cast_sub, Int.cast_natCast,
      mul_assoc]

theorem iter_deriv_zpow (m : ℤ) (x : ��) (k : ℕ) :
    deriv^[k] (fun y => y ^ m) x = (∏ i ∈ Finset.range k, ((m : ��) - i)) * x ^ (m - k) :=
  congr($(iter_deriv_zpow' m k) x)

theorem iter_deriv_pow (n : ℕ) (x : ��) (k : ℕ) :
    deriv^[k] (fun x : �� => x ^ n) x = (∏ i ∈ Finset.range k, ((n : ��) - i)) * x ^ (n - k) := by
  simp only [← zpow_natCast, iter_deriv_zpow, Int.cast_natCast]
  rcases le_or_gt k n with hkn | hnk
  · rw [Int.ofNat_sub hkn]
  · have : (∏ i ∈ Finset.range k, (n - i : ��)) = 0 :=
      Finset.prod_eq_zero (Finset.mem_range.2 hnk) (sub_self _)
    simp only [this, zero_mul]

@[simp]
theorem iter_deriv_pow' (n k : ℕ) :
    (deriv^[k] fun x : �� => x ^ n) =
      fun x => (∏ i ∈ Finset.range k, ((n : ��) - i)) * x ^ (n - k) :=
  funext fun x => iter_deriv_pow n x k

theorem iter_deriv_inv (k : ℕ) (x : ��) :
    deriv^[k] Inv.inv x = (-1) ^ k * k ! * x ^ (-1 - k : ℤ) := calc
  deriv^[k] Inv.inv x = deriv^[k] (· ^ (-1 : ℤ)) x := by simp
  _ = (∏ i ∈ Finset.range k, (-1 - i : ��)) * x ^ (-1 - k : ℤ) := mod_cast iter_deriv_zpow (-1) x k
  _ = (-1) ^ k * k ! * x ^ (-1 - k : ℤ) := by
    simp only [← neg_add', Finset.prod_neg, ← Finset.prod_Ico_id_eq_factorial,
      Finset.prod_Ico_eq_prod_range]
    simp

@[simp]
theorem iter_deriv_inv' (k : ℕ) :
    deriv^[k] Inv.inv = fun x : �� => (-1) ^ k * k ! * x ^ (-1 - k : ℤ) :=
  funext (iter_deriv_inv k)

open Nat Function in
theorem iter_deriv_inv_linear (k : ℕ) (c d : ��) :
    deriv^[k] (fun x ↦ (c * x + d)⁻¹) =
    (fun x : �� ↦ (-1) ^ k * k ! * c ^ k * (c * x + d) ^ (-1 - k : ℤ)) := by
  induction k with
  | zero => simp
  | succ k ihk =>
    rw [factorial_succ, add_comm k 1, iterate_add_apply, ihk]
    ext z
    simp only [Int.reduceNeg, iterate_one, deriv_const_mul_field', cast_add, cast_one]
    by_cases hd : c = 0
    · simp [hd]
    · have := deriv_comp_add_const (fun x ↦ (c * x) ^ (-1 - k : ℤ)) (d / c) z
      have h0 : (fun x ↦ (c * (x + d / c)) ^ (-1 - (k : ℤ))) =
        (fun x ↦ (c * x + d) ^ (-1 - (k : ℤ))) := by
        ext y
        field_simp
      rw [h0, deriv_comp_mul_left c (fun x ↦ (x) ^ (-1 - k : ℤ)) (z + d / c)] at this
      simp [this]
      field_simp
      ring_nf

theorem iter_deriv_inv_linear_sub (k : ℕ) (c d : ��) :
    deriv^[k] (fun x ↦ (c * x - d)⁻¹) =
    (fun x : �� ↦ (-1) ^ k * k ! * c ^ k * (c * x - d) ^ (-1 - k : ℤ)) := by
  simpa [sub_eq_add_neg] using iter_deriv_inv_linear k c (-d)

variable {f : E → ��} {t : Set E} {a : E}

@[fun_prop]
theorem DifferentiableWithinAt.zpow (hf : DifferentiableWithinAt �� f t a) (h : f a ≠ 0 ∨ 0 ≤ m) :
    DifferentiableWithinAt �� (fun x => f x ^ m) t a :=
  (differentiableAt_zpow.2 h).comp_differentiableWithinAt a hf

@[fun_prop]
theorem DifferentiableAt.zpow (hf : DifferentiableAt �� f a) (h : f a ≠ 0 ∨ 0 ≤ m) :
    DifferentiableAt �� (fun x => f x ^ m) a :=
  (differentiableAt_zpow.2 h).comp a hf

@[fun_prop]
theorem DifferentiableOn.zpow (hf : DifferentiableOn �� f t) (h : (∀ x ∈ t, f x ≠ 0) ∨ 0 ≤ m) :
    DifferentiableOn �� (fun x => f x ^ m) t := fun x hx =>
  (hf x hx).zpow <| h.imp_left fun h => h x hx

@[fun_prop]
theorem Differentiable.zpow (hf : Differentiable �� f) (h : (∀ x, f x ≠ 0) ∨ 0 ≤ m) :
    Differentiable �� fun x => f x ^ m := fun x => (hf x).zpow <| h.imp_left fun h => h x

Messung
CHZG
9210010097

¤ Dauer der Verarbeitung: 0.45 Sekunden  ¤

*© Formatika GbR, Deutschland