Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit b0071f3

Browse files
committed
feat(analysis/special_functions): sqrt is infinitely smooth at x ≠ 0 (#6255)
Also move lemmas about differentiability of `sqrt` out from `special_functions/pow` to a new file.
1 parent 8a43163 commit b0071f3

File tree

3 files changed

+177
-63
lines changed

3 files changed

+177
-63
lines changed

src/analysis/calculus/times_cont_diff.lean

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,20 @@ lemma times_cont_diff.pow {n : with_top ℕ} {f : E → 𝕜}
22702270
| 0 := by simpa using times_cont_diff_const
22712271
| (m + 1) := hf.mul (times_cont_diff.pow m)
22722272

2273+
lemma times_cont_diff_at.pow {n : with_top ℕ} {f : E → 𝕜} (hf : times_cont_diff_at 𝕜 n f x)
2274+
(m : ℕ) : times_cont_diff_at 𝕜 n (λ y, f y ^ m) x :=
2275+
(times_cont_diff_id.pow m).times_cont_diff_at.comp x hf
2276+
2277+
lemma times_cont_diff_within_at.pow {n : with_top ℕ} {f : E → 𝕜}
2278+
(hf : times_cont_diff_within_at 𝕜 n f s x) (m : ℕ) :
2279+
times_cont_diff_within_at 𝕜 n (λ y, f y ^ m) s x :=
2280+
(times_cont_diff_id.pow m).times_cont_diff_at.comp_times_cont_diff_within_at x hf
2281+
2282+
lemma times_cont_diff_on.pow {n : with_top ℕ} {f : E → 𝕜}
2283+
(hf : times_cont_diff_on 𝕜 n f s) (m : ℕ) :
2284+
times_cont_diff_on 𝕜 n (λ y, f y ^ m) s :=
2285+
λ y hy, (hf y hy).pow m
2286+
22732287
/-! ### Scalar multiplication -/
22742288

22752289
/- The scalar multiplication is smooth. -/

src/analysis/special_functions/pow.lean

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -713,69 +713,6 @@ lemma deriv_within_rpow_of_one_le (hf : differentiable_within_at ℝ f s x) (hp
713713
deriv (λx, (f x)^p) x = (deriv f x) * p * (f x)^(p-1) :=
714714
(hf.has_deriv_at.rpow_of_one_le hp).deriv
715715

716-
/- Differentiability statements for the square root of a function, when the function does not
717-
vanish -/
718-
719-
lemma has_deriv_within_at.sqrt (hf : has_deriv_within_at f f' s x) (hx : f x ≠ 0) :
720-
has_deriv_within_at (λ y, sqrt (f y)) (f' / (2 * sqrt (f x))) s x :=
721-
begin
722-
simp only [sqrt_eq_rpow],
723-
convert hf.rpow (1/2) hx,
724-
rcases lt_trichotomy (f x) 0 with H|H|H,
725-
{ have A : (f x)^((1:ℝ)/2) = 0,
726-
{ rw rpow_def_of_neg H,
727-
have : cos (1/2 * π) = 0, by { convert cos_pi_div_two using 2, ring },
728-
rw [this],
729-
simp },
730-
have B : f x ^ ((1:ℝ) / 2 - 1) = 0,
731-
{ rw rpow_def_of_neg H,
732-
have : cos (π/2 - π) = 0, by simp [cos_sub],
733-
have : cos (((1:ℝ)/2 - 1) * π) = 0, by { convert this using 2, ring },
734-
rw this,
735-
simp },
736-
rw [A, B],
737-
simp },
738-
{ exact (hx H).elim },
739-
{ have A : 0 < (f x)^((1:ℝ)/2) := rpow_pos_of_pos H _,
740-
have B : (f x) ^ (-(1:ℝ)) = (f x)^(-((1:ℝ)/2)) * (f x)^(-((1:ℝ)/2)),
741-
{ rw [← rpow_add H],
742-
congr,
743-
norm_num },
744-
rw [sub_eq_add_neg, rpow_add H, B, rpow_neg (le_of_lt H)],
745-
field_simp }
746-
end
747-
748-
lemma has_deriv_at.sqrt (hf : has_deriv_at f f' x) (hx : f x ≠ 0) :
749-
has_deriv_at (λ y, sqrt (f y)) (f' / (2 * sqrt(f x))) x :=
750-
begin
751-
rw ← has_deriv_within_at_univ at *,
752-
exact hf.sqrt hx
753-
end
754-
755-
lemma differentiable_within_at.sqrt (hf : differentiable_within_at ℝ f s x) (hx : f x ≠ 0) :
756-
differentiable_within_at ℝ (λx, sqrt (f x)) s x :=
757-
(hf.has_deriv_within_at.sqrt hx).differentiable_within_at
758-
759-
@[simp] lemma differentiable_at.sqrt (hf : differentiable_at ℝ f x) (hx : f x ≠ 0) :
760-
differentiable_at ℝ (λx, sqrt (f x)) x :=
761-
(hf.has_deriv_at.sqrt hx).differentiable_at
762-
763-
lemma differentiable_on.sqrt (hf : differentiable_on ℝ f s) (hx : ∀ x ∈ s, f x ≠ 0) :
764-
differentiable_on ℝ (λx, sqrt (f x)) s :=
765-
λx h, (hf x h).sqrt (hx x h)
766-
767-
@[simp] lemma differentiable.sqrt (hf : differentiable ℝ f) (hx : ∀ x, f x ≠ 0) :
768-
differentiable ℝ (λx, sqrt (f x)) :=
769-
λx, (hf x).sqrt (hx x)
770-
771-
lemma deriv_within_sqrt (hf : differentiable_within_at ℝ f s x) (hx : f x ≠ 0)
772-
(hxs : unique_diff_within_at ℝ s x) :
773-
deriv_within (λx, sqrt (f x)) s x = (deriv_within f s x) / (2 * sqrt (f x)) :=
774-
(hf.has_deriv_within_at.sqrt hx).deriv_within hxs
775-
776-
@[simp] lemma deriv_sqrt (hf : differentiable_at ℝ f x) (hx : f x ≠ 0) :
777-
deriv (λx, sqrt (f x)) x = (deriv f x) / (2 * sqrt (f x)) :=
778-
(hf.has_deriv_at.sqrt hx).deriv
779716

780717
end differentiability
781718

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
/-
2+
Copyright (c) 2021 Yury G. Kudryashov. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Author: Yury G. Kudryashov
5+
-/
6+
import data.real.sqrt
7+
import analysis.calculus.inverse
8+
import measure_theory.borel_space
9+
10+
/-!
11+
# Smoothness of `real.sqrt`
12+
13+
In this file we prove that `real.sqrt` is infinitely smooth at all points `x ≠ 0` and provide some
14+
dot-notation lemmas.
15+
16+
## Tags
17+
18+
sqrt, differentiable
19+
-/
20+
21+
open set
22+
open_locale topological_space
23+
24+
namespace real
25+
26+
/-- Local homeomorph between `(0, +∞)` and `(0, +∞)` with `to_fun = λ x, x ^ 2` and
27+
`inv_fun = sqrt`. -/
28+
noncomputable def sq_local_homeomorph : local_homeomorph ℝ ℝ :=
29+
{ to_fun := λ x, x ^ 2,
30+
inv_fun := sqrt,
31+
source := Ioi 0,
32+
target := Ioi 0,
33+
map_source' := λ x hx, mem_Ioi.2 (pow_pos hx _),
34+
map_target' := λ x hx, mem_Ioi.2 (sqrt_pos.2 hx),
35+
left_inv' := λ x hx, sqrt_sqr (le_of_lt hx),
36+
right_inv' := λ x hx, sqr_sqrt (le_of_lt hx),
37+
open_source := is_open_Ioi,
38+
open_target := is_open_Ioi,
39+
continuous_to_fun := (continuous_pow 2).continuous_on,
40+
continuous_inv_fun := continuous_on_id.sqrt }
41+
42+
lemma deriv_sqrt_aux {x : ℝ} (hx : x ≠ 0) :
43+
has_strict_deriv_at sqrt (1 / (2 * sqrt x)) x ∧ ∀ n, times_cont_diff_at ℝ n sqrt x :=
44+
begin
45+
cases hx.lt_or_lt with hx hx,
46+
{ rw [sqrt_eq_zero_of_nonpos hx.le, mul_zero, div_zero],
47+
have : sqrt =ᶠ[𝓝 x] (λ _, 0) := (gt_mem_nhds hx).mono (λ x hx, sqrt_eq_zero_of_nonpos hx.le),
48+
exact ⟨(has_strict_deriv_at_const x (0 : ℝ)).congr_of_eventually_eq this.symm,
49+
λ n, times_cont_diff_at_const.congr_of_eventually_eq this⟩ },
50+
{ have : ↑2 * sqrt x ^ (2 - 1) ≠ 0, by simp [(sqrt_pos.2 hx).ne', @two_ne_zero ℝ],
51+
split,
52+
{ simpa using sq_local_homeomorph.has_strict_deriv_at_symm hx this
53+
(has_strict_deriv_at_pow 2 _) },
54+
{ exact λ n, sq_local_homeomorph.times_cont_diff_at_symm_deriv this hx
55+
(has_deriv_at_pow 2 (sqrt x)) (times_cont_diff_at_id.pow 2) } }
56+
end
57+
58+
lemma has_strict_deriv_at_sqrt {x : ℝ} (hx : x ≠ 0) :
59+
has_strict_deriv_at sqrt (1 / (2 * sqrt x)) x :=
60+
(deriv_sqrt_aux hx).1
61+
62+
lemma times_cont_diff_at_sqrt {x : ℝ} {n : with_top ℕ} (hx : x ≠ 0) :
63+
times_cont_diff_at ℝ n sqrt x :=
64+
(deriv_sqrt_aux hx).2 n
65+
66+
lemma has_deriv_at_sqrt {x : ℝ} (hx : x ≠ 0) : has_deriv_at sqrt (1 / (2 * sqrt x)) x :=
67+
(has_strict_deriv_at_sqrt hx).has_deriv_at
68+
69+
end real
70+
71+
open real
72+
73+
lemma measurable.sqrt {α : Type*} [measurable_space α] {f : α → ℝ} (hf : measurable f) :
74+
measurable (λ x, sqrt (f x)) :=
75+
continuous_sqrt.measurable.comp hf
76+
77+
section deriv
78+
79+
variables {f : ℝ → ℝ} {s : set ℝ} {f' x : ℝ}
80+
81+
lemma has_deriv_within_at.sqrt (hf : has_deriv_within_at f f' s x) (hx : f x ≠ 0) :
82+
has_deriv_within_at (λ y, sqrt (f y)) (f' / (2 * sqrt (f x))) s x :=
83+
by simpa only [(∘), div_eq_inv_mul, mul_one]
84+
using (has_deriv_at_sqrt hx).comp_has_deriv_within_at x hf
85+
86+
lemma has_deriv_at.sqrt (hf : has_deriv_at f f' x) (hx : f x ≠ 0) :
87+
has_deriv_at (λ y, sqrt (f y)) (f' / (2 * sqrt(f x))) x :=
88+
by simpa only [(∘), div_eq_inv_mul, mul_one] using (has_deriv_at_sqrt hx).comp x hf
89+
90+
lemma has_strict_deriv_at.sqrt (hf : has_strict_deriv_at f f' x) (hx : f x ≠ 0) :
91+
has_strict_deriv_at (λ t, sqrt (f t)) (f' / (2 * sqrt (f x))) x :=
92+
by simpa only [(∘), div_eq_inv_mul, mul_one] using (has_strict_deriv_at_sqrt hx).comp x hf
93+
94+
lemma deriv_within_sqrt (hf : differentiable_within_at ℝ f s x) (hx : f x ≠ 0)
95+
(hxs : unique_diff_within_at ℝ s x) :
96+
deriv_within (λx, sqrt (f x)) s x = (deriv_within f s x) / (2 * sqrt (f x)) :=
97+
(hf.has_deriv_within_at.sqrt hx).deriv_within hxs
98+
99+
@[simp] lemma deriv_sqrt (hf : differentiable_at ℝ f x) (hx : f x ≠ 0) :
100+
deriv (λx, sqrt (f x)) x = (deriv f x) / (2 * sqrt (f x)) :=
101+
(hf.has_deriv_at.sqrt hx).deriv
102+
103+
end deriv
104+
105+
section fderiv
106+
107+
variables {E : Type*} [normed_group E] [normed_space ℝ E] {f : E → ℝ} {n : with_top ℕ}
108+
{s : set E} {x : E} {f' : E →L[ℝ] ℝ}
109+
110+
lemma has_fderiv_at.sqrt (hf : has_fderiv_at f f' x) (hx : f x ≠ 0) :
111+
has_fderiv_at (λ y, sqrt (f y)) ((1 / (2 * sqrt (f x))) • f') x :=
112+
(has_deriv_at_sqrt hx).comp_has_fderiv_at x hf
113+
114+
lemma has_strict_fderiv_at.sqrt (hf : has_strict_fderiv_at f f' x) (hx : f x ≠ 0) :
115+
has_strict_fderiv_at (λ y, sqrt (f y)) ((1 / (2 * sqrt (f x))) • f') x :=
116+
(has_strict_deriv_at_sqrt hx).comp_has_strict_fderiv_at x hf
117+
118+
lemma has_fderiv_within_at.sqrt (hf : has_fderiv_within_at f f' s x) (hx : f x ≠ 0) :
119+
has_fderiv_within_at (λ y, sqrt (f y)) ((1 / (2 * sqrt (f x))) • f') s x :=
120+
(has_deriv_at_sqrt hx).comp_has_fderiv_within_at x hf
121+
122+
lemma differentiable_within_at.sqrt (hf : differentiable_within_at ℝ f s x) (hx : f x ≠ 0) :
123+
differentiable_within_at ℝ (λ y, sqrt (f y)) s x :=
124+
(hf.has_fderiv_within_at.sqrt hx).differentiable_within_at
125+
126+
lemma differentiable_at.sqrt (hf : differentiable_at ℝ f x) (hx : f x ≠ 0) :
127+
differentiable_at ℝ (λ y, sqrt (f y)) x :=
128+
(hf.has_fderiv_at.sqrt hx).differentiable_at
129+
130+
lemma differentiable_on.sqrt (hf : differentiable_on ℝ f s) (hs : ∀ x ∈ s, f x ≠ 0) :
131+
differentiable_on ℝ (λ y, sqrt (f y)) s :=
132+
λ x hx, (hf x hx).sqrt (hs x hx)
133+
134+
lemma differentiable.sqrt (hf : differentiable ℝ f) (hs : ∀ x, f x ≠ 0) :
135+
differentiable ℝ (λ y, sqrt (f y)) :=
136+
λ x, (hf x).sqrt (hs x)
137+
138+
lemma fderiv_within_sqrt (hf : differentiable_within_at ℝ f s x) (hx : f x ≠ 0)
139+
(hxs : unique_diff_within_at ℝ s x) :
140+
fderiv_within ℝ (λx, sqrt (f x)) s x = (1 / (2 * sqrt (f x))) • fderiv_within ℝ f s x :=
141+
(hf.has_fderiv_within_at.sqrt hx).fderiv_within hxs
142+
143+
@[simp] lemma fderiv_sqrt (hf : differentiable_at ℝ f x) (hx : f x ≠ 0) :
144+
fderiv ℝ (λx, sqrt (f x)) x = (1 / (2 * sqrt (f x))) • fderiv ℝ f x :=
145+
(hf.has_fderiv_at.sqrt hx).fderiv
146+
147+
lemma times_cont_diff_at.sqrt (hf : times_cont_diff_at ℝ n f x) (hx : f x ≠ 0) :
148+
times_cont_diff_at ℝ n (λ y, sqrt (f y)) x :=
149+
(times_cont_diff_at_sqrt hx).comp x hf
150+
151+
lemma times_cont_diff_within_at.sqrt (hf : times_cont_diff_within_at ℝ n f s x) (hx : f x ≠ 0) :
152+
times_cont_diff_within_at ℝ n (λ y, sqrt (f y)) s x :=
153+
(times_cont_diff_at_sqrt hx).comp_times_cont_diff_within_at x hf
154+
155+
lemma times_cont_diff_on.sqrt (hf : times_cont_diff_on ℝ n f s) (hs : ∀ x ∈ s, f x ≠ 0) :
156+
times_cont_diff_on ℝ n (λ y, sqrt (f y)) s :=
157+
λ x hx, (hf x hx).sqrt (hs x hx)
158+
159+
lemma times_cont_diff.sqrt (hf : times_cont_diff ℝ n f) (h : ∀ x, f x ≠ 0) :
160+
times_cont_diff ℝ n (λ y, sqrt (f y)) :=
161+
times_cont_diff_iff_times_cont_diff_at.2 $ λ x, (hf.times_cont_diff_at.sqrt (h x))
162+
163+
end fderiv

0 commit comments

Comments
 (0)