-
Notifications
You must be signed in to change notification settings - Fork 251
/
Inv.lean
236 lines (186 loc) Β· 9.82 KB
/
Inv.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/-
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
-/
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Comp
#align_import analysis.calculus.deriv.inv from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
/-!
# 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
-/
universe u v w
open scoped Classical
open Topology Filter ENNReal
open Filter Asymptotics Set
open ContinuousLinearMap (smulRight smulRight_one_eq_iff)
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 : Filter π}
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 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_setOf_eq] at hy hz
-- hy : y β 0, hz : z β 0
field_simp [hx, hy, hz]
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)
#align has_strict_deriv_at_inv hasStrictDerivAt_inv
theorem hasDerivAt_inv (x_ne_zero : x β 0) : HasDerivAt (fun y => yβ»ΒΉ) (-(x ^ 2)β»ΒΉ) x :=
(hasStrictDerivAt_inv x_ne_zero).hasDerivAt
#align has_deriv_at_inv hasDerivAt_inv
theorem hasDerivWithinAt_inv (x_ne_zero : x β 0) (s : Set π) :
HasDerivWithinAt (fun x => xβ»ΒΉ) (-(x ^ 2)β»ΒΉ) s x :=
(hasDerivAt_inv x_ne_zero).hasDerivWithinAt
#align has_deriv_within_at_inv hasDerivWithinAt_inv
theorem differentiableAt_inv : DifferentiableAt π (fun x => xβ»ΒΉ) x β x β 0 :=
β¨fun H => NormedField.continuousAt_inv.1 H.continuousAt, fun H =>
(hasDerivAt_inv H).differentiableAtβ©
#align differentiable_at_inv differentiableAt_inv
theorem differentiableWithinAt_inv (x_ne_zero : x β 0) :
DifferentiableWithinAt π (fun x => xβ»ΒΉ) s x :=
(differentiableAt_inv.2 x_ne_zero).differentiableWithinAt
#align differentiable_within_at_inv differentiableWithinAt_inv
theorem differentiableOn_inv : DifferentiableOn π (fun x : π => xβ»ΒΉ) { x | x β 0 } := fun _x hx =>
differentiableWithinAt_inv hx
#align differentiable_on_inv differentiableOn_inv
theorem deriv_inv : deriv (fun x => xβ»ΒΉ) x = -(x ^ 2)β»ΒΉ := by
rcases eq_or_ne x 0 with (rfl | hne)
Β· simp [deriv_zero_of_not_differentiableAt (mt differentiableAt_inv.1 (not_not.2 rfl))]
Β· exact (hasDerivAt_inv hne).deriv
#align deriv_inv deriv_inv
@[simp]
theorem deriv_inv' : (deriv fun x : π => xβ»ΒΉ) = fun x => -(x ^ 2)β»ΒΉ :=
funext fun _ => deriv_inv
#align deriv_inv' 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.2 x_ne_zero) hxs]
exact deriv_inv
#align deriv_within_inv derivWithin_inv
theorem hasFDerivAt_inv (x_ne_zero : x β 0) :
HasFDerivAt (fun x => xβ»ΒΉ) (smulRight (1 : π βL[π] π) (-(x ^ 2)β»ΒΉ) : π βL[π] π) x :=
hasDerivAt_inv x_ne_zero
#align has_fderiv_at_inv hasFDerivAt_inv
theorem hasFDerivWithinAt_inv (x_ne_zero : x β 0) :
HasFDerivWithinAt (fun x => xβ»ΒΉ) (smulRight (1 : π βL[π] π) (-(x ^ 2)β»ΒΉ) : π βL[π] π) s x :=
(hasFDerivAt_inv x_ne_zero).hasFDerivWithinAt
#align has_fderiv_within_at_inv hasFDerivWithinAt_inv
theorem fderiv_inv : fderiv π (fun x => xβ»ΒΉ) x = smulRight (1 : π βL[π] π) (-(x ^ 2)β»ΒΉ) := by
rw [β deriv_fderiv, deriv_inv]
#align fderiv_inv fderiv_inv
theorem fderivWithin_inv (x_ne_zero : x β 0) (hxs : UniqueDiffWithinAt π s x) :
fderivWithin π (fun x => xβ»ΒΉ) s x = smulRight (1 : π βL[π] π) (-(x ^ 2)β»ΒΉ) := by
rw [DifferentiableAt.fderivWithin (differentiableAt_inv.2 x_ne_zero) hxs]
exact fderiv_inv
#align fderiv_within_inv fderivWithin_inv
variable {c : π β π} {h : E β π} {c' : π} {z : E} {S : Set E}
theorem HasDerivWithinAt.inv (hc : HasDerivWithinAt c c' s x) (hx : c x β 0) :
HasDerivWithinAt (fun y => (c y)β»ΒΉ) (-c' / c x ^ 2) s x := by
convert (hasDerivAt_inv hx).comp_hasDerivWithinAt x hc using 1
field_simp
#align has_deriv_within_at.inv HasDerivWithinAt.inv
theorem HasDerivAt.inv (hc : HasDerivAt c c' x) (hx : c x β 0) :
HasDerivAt (fun y => (c y)β»ΒΉ) (-c' / c x ^ 2) x := by
rw [β hasDerivWithinAt_univ] at *
exact hc.inv hx
#align has_deriv_at.inv HasDerivAt.inv
theorem DifferentiableWithinAt.inv (hf : DifferentiableWithinAt π h S z) (hz : h z β 0) :
DifferentiableWithinAt π (fun x => (h x)β»ΒΉ) S z :=
(differentiableAt_inv.mpr hz).comp_differentiableWithinAt z hf
#align differentiable_within_at.inv DifferentiableWithinAt.inv
@[simp]
theorem DifferentiableAt.inv (hf : DifferentiableAt π h z) (hz : h z β 0) :
DifferentiableAt π (fun x => (h x)β»ΒΉ) z :=
(differentiableAt_inv.mpr hz).comp z hf
#align differentiable_at.inv DifferentiableAt.inv
theorem DifferentiableOn.inv (hf : DifferentiableOn π h S) (hz : β x β S, h x β 0) :
DifferentiableOn π (fun x => (h x)β»ΒΉ) S := fun x h => (hf x h).inv (hz x h)
#align differentiable_on.inv DifferentiableOn.inv
@[simp]
theorem Differentiable.inv (hf : Differentiable π h) (hz : β x, h x β 0) :
Differentiable π fun x => (h x)β»ΒΉ := fun x => (hf x).inv (hz x)
#align differentiable.inv Differentiable.inv
theorem derivWithin_inv' (hc : DifferentiableWithinAt π c s x) (hx : c x β 0)
(hxs : UniqueDiffWithinAt π s x) :
derivWithin (fun x => (c x)β»ΒΉ) s x = -derivWithin c s x / c x ^ 2 :=
(hc.hasDerivWithinAt.inv hx).derivWithin hxs
#align deriv_within_inv' derivWithin_inv'
@[simp]
theorem deriv_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
#align deriv_inv'' deriv_inv''
end Inverse
section Division
/-! ### Derivative of `x β¦ c x / d x` -/
variable {π' : Type*} [NontriviallyNormedField π'] [NormedAlgebra π π'] {c d : π β π'} {c' d' : π'}
theorem HasDerivWithinAt.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.mul ((hasDerivAt_inv hx).comp_hasDerivWithinAt x hd) using 1
Β· simp only [div_eq_mul_inv, (Β· β Β·)]
Β· field_simp
ring
#align has_deriv_within_at.div HasDerivWithinAt.div
theorem HasStrictDerivAt.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.mul ((hasStrictDerivAt_inv hx).comp x hd) using 1
Β· simp only [div_eq_mul_inv, (Β· β Β·)]
Β· field_simp
ring
#align has_strict_deriv_at.div HasStrictDerivAt.div
theorem HasDerivAt.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
#align has_deriv_at.div HasDerivAt.div
theorem DifferentiableWithinAt.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
#align differentiable_within_at.div DifferentiableWithinAt.div
@[simp]
theorem DifferentiableAt.div (hc : DifferentiableAt π c x) (hd : DifferentiableAt π d x)
(hx : d x β 0) : DifferentiableAt π (fun x => c x / d x) x :=
(hc.hasDerivAt.div hd.hasDerivAt hx).differentiableAt
#align differentiable_at.div DifferentiableAt.div
theorem DifferentiableOn.div (hc : DifferentiableOn π c s) (hd : DifferentiableOn π d s)
(hx : β x β s, d x β 0) : DifferentiableOn π (fun x => c x / d x) s := fun x h =>
(hc x h).div (hd x h) (hx x h)
#align differentiable_on.div DifferentiableOn.div
@[simp]
theorem Differentiable.div (hc : Differentiable π c) (hd : Differentiable π d) (hx : β x, d x β 0) :
Differentiable π fun x => c x / d x := fun x => (hc x).div (hd x) (hx x)
#align differentiable.div Differentiable.div
theorem derivWithin_div (hc : DifferentiableWithinAt π c s x) (hd : DifferentiableWithinAt π d s x)
(hx : d x β 0) (hxs : UniqueDiffWithinAt π s x) :
derivWithin (fun x => c x / d x) s x =
(derivWithin c s x * d x - c x * derivWithin d s x) / d x ^ 2 :=
(hc.hasDerivWithinAt.div hd.hasDerivWithinAt hx).derivWithin hxs
#align deriv_within_div derivWithin_div
@[simp]
theorem deriv_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
#align deriv_div deriv_div
end Division