Introduction to Real Analysis, Volume I (Jiri Lebl, 2025) -- Chapter 04 -- Section 01

section Chap04section Section01open Filter Topology

Definition 4.1.1: For an interval failed to synthesize HasSubset Type Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.Unknown identifier `I`I , a function , and Unknown identifier `c`sorry sorry : Propc Unknown identifier `I`I, if the limit exists, then Unknown identifier `f`f is differentiable at Unknown identifier `c`c, Unknown identifier `L`L is the derivative Unknown identifier `f'`f' c, and the quotient (sorry - sorry) / (sorry - sorry) : ?m.15(Unknown identifier `f`f x - Unknown identifier `f`f c) / (Unknown identifier `x`x - Unknown identifier `c`c) is the difference quotient. If the limit exists at every Unknown identifier `c`sorry sorry : Propc Unknown identifier `I`I, then Unknown identifier `f`f is differentiable on Unknown identifier `I`I and yields a derivative function .

noncomputable def differenceQuotient (f : ) (c x : ) : := (f x - f c) / (x - c)

The book's notion of differentiability on a subset of : Type via the limit of the difference quotient.

def DifferentiableAtOn (I : Set ) (f : ) (c : ) : Prop := c I L : , Tendsto (fun x => differenceQuotient f c x) (nhdsWithin c {x | x c}) (𝓝 L)

The derivative value provided by the existence of the difference-quotient limit.

noncomputable def derivativeAtOn (I : Set ) (f : ) (c : ) (h : DifferentiableAtOn I f c) : := Classical.choose h.2

The book's differentiability notion agrees with mathlib's HasDerivAt.{u, v} {𝕜 : Type u} [NontriviallyNormedField 𝕜] {F : Type v} [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F] [ContinuousSMul 𝕜 F] (f : 𝕜 F) (f' : F) (x : 𝕜) : PropHasDerivAt formulation.

lemma differentiableAtOn_iff_hasDerivAt {I : Set } {f : } {c : } : DifferentiableAtOn I f c c I L : , HasDerivAt f L c := by constructor · rintro hcI, L, hL refine hcI, L, ?_ apply (hasDerivAt_iff_tendsto_slope).2 simpa [differenceQuotient, slope_fun_def_field] using hL · rintro hcI, L, hL refine hcI, L, ?_ have hL' : Tendsto (slope f c) (𝓝[≠] c) (𝓝 L) := (hasDerivAt_iff_tendsto_slope).1 hL simpa [differenceQuotient, slope_fun_def_field] using hL'

If a function is differentiable at every point of an interval, the derivative defines a function Unknown identifier `I`sorry : Sort (max 1 u_1)I .

noncomputable def derivativeOn (I : Set ) (f : ) (h : c I, DifferentiableAtOn I f c) : I := fun x => derivativeAtOn I f x.1 (h x.1 x.property)

Example 4.1.2: For Unknown identifier `f`sorry = sorry ^ 2 : Propf x = Unknown identifier `x`x^2 on : Type, the derivative at any Unknown identifier `c`c satisfies , since the difference quotient simplifies to Unknown identifier `x`sorry + sorry : ?m.5x + Unknown identifier `c`c and its limit as Unknown identifier `x`sorry sorry : Sort (imax u_1 u_2)x Unknown identifier `c`c is .

lemma hasDerivAt_sq (c : ) : HasDerivAt (fun x => x ^ 2) (2 * c) c := by -- Derivative of `x ↦ x` is `1`, so apply the product rule to `fun x ↦ x * x`. have h_id : HasDerivAt (fun x : => x) 1 c := by simpa using (hasDerivAt_id c) simpa [pow_two, two_mul] using h_id.mul h_id

Example 4.1.3: For an affine function Unknown identifier `f`sorry = sorry * sorry + sorry : Propf x = Unknown identifier `a`a * Unknown identifier `x`x + Unknown identifier `b`b with real coefficients, the difference quotient simplifies to Unknown identifier `a`a, so the derivative at any point Unknown identifier `c`c is the constant slope Unknown identifier `a`a.

lemma hasDerivAt_affine (a b c : ) : HasDerivAt (fun x => a * x + b) a c := by -- Derivative of the linear part is the constant slope `a`. have h_linear : HasDerivAt (fun x => a * x) a c := by simpa [mul_one] using (hasDerivAt_id c).const_mul a -- Adding a constant does not affect the derivative. simpa using h_linear.add_const b

Example 4.1.4: The square-root function Unknown identifier `f`sorry = sorry : Propf x = Unknown identifier `x`x is differentiable for Unknown identifier `x`sorry > 0 : Propx > 0, and for each Unknown identifier `c`sorry > 0 : Propc > 0 its derivative is .

lemma hasDerivAt_sqrt_pos {c : } (hc : 0 < c) : HasDerivAt Real.sqrt (1 / (2 * Real.sqrt c)) c := by have hc' : c 0 := ne_of_gt hc simpa using Real.hasDerivAt_sqrt hc'

Example 4.1.5: The absolute-value function is not differentiable at the origin, since the difference quotient is 1 : 1 for Unknown identifier `x`sorry > 0 : Propx > 0 and -1 : -1 for Unknown identifier `x`sorry < 0 : Propx < 0.

lemma differenceQuotient_abs_pos {x : } (hx : 0 < x) : differenceQuotient (fun x : => |x|) 0 x = 1 := by have hx_ne : x 0 := ne_of_gt hx simp [differenceQuotient, abs_zero, abs_of_pos hx, hx_ne]
lemma differenceQuotient_abs_neg {x : } (hx : x < 0) : differenceQuotient (fun x : => |x|) 0 x = -1 := by have hx_ne : x 0 := ne_of_lt hx have hx_div : (-x) / x = -1 := by have hx_self : x / x = (1 : ) := by simpa using div_self hx_ne simp [neg_div, hx_self] simp [differenceQuotient, abs_zero, abs_of_neg hx, hx_div]lemma abs_not_differentiable_at_zero : ¬ DifferentiableAt (fun x : => |x|) 0 := by simp [not_differentiableAt_abs_zero]

Proposition 4.1.6: If a real function is differentiable at a point of an interval, then it is continuous at that point.

theorem differentiableAt_real_continuousAt {f : } {c : } (h : DifferentiableAt f c) : ContinuousAt f c := by simpa using h.continuousAt

Proposition 4.1.7 (Linearity): Let Unknown identifier `I`I be an interval and let be differentiable at Unknown identifier `c`sorry sorry : Propc Unknown identifier `I`I, with . (i) For Unknown identifier `h`sorry = sorry * sorry : Proph x = Unknown identifier `α`α * Unknown identifier `f`f x, the derivative satisfies deriv sorry sorry = sorry * deriv sorry sorry : Propderiv Unknown identifier `h`h Unknown identifier `c`c = Unknown identifier `α`α * deriv Unknown identifier `f`f Unknown identifier `c`c. (ii) For Unknown identifier `h`sorry = sorry + sorry : Proph x = Unknown identifier `f`f x + Unknown identifier `g`g x, the derivative satisfies deriv sorry sorry = deriv sorry sorry + deriv sorry sorry : Propderiv Unknown identifier `h`h Unknown identifier `c`c = deriv Unknown identifier `f`f Unknown identifier `c`c + deriv Unknown identifier `g`g Unknown identifier `c`c.

theorem deriv_const_mul_at {f : } {c α : } (hf : DifferentiableAt f c) : DifferentiableAt (fun x => α * f x) c deriv (fun x => α * f x) c = α * deriv f c := by classical have h := (hf.hasDerivAt.const_mul α : HasDerivAt (fun x => α * f x) (α * deriv f c) c) exact h.differentiableAt, h.deriv
theorem deriv_add_at {f g : } {c : } (hf : DifferentiableAt f c) (hg : DifferentiableAt g c) : DifferentiableAt (fun x => f x + g x) c deriv (fun x => f x + g x) c = deriv f c + deriv g c := by classical have h := (hf.hasDerivAt.add hg.hasDerivAt : HasDerivAt (fun x => f x + g x) (deriv f c + deriv g c) c) exact h.differentiableAt, h.deriv

Proposition 4.1.8 (Product rule): For an interval Unknown identifier `I`I and functions differentiable at Unknown identifier `c`sorry sorry : Propc Unknown identifier `I`I, the product Unknown identifier `h`sorry = sorry * sorry : Proph x = Unknown identifier `f`f x * Unknown identifier `g`g x is differentiable at Unknown identifier `c`c, and its derivative satisfies deriv sorry sorry = sorry * deriv sorry sorry + deriv sorry sorry * sorry : Propderiv Unknown identifier `h`h Unknown identifier `c`c = Unknown identifier `f`f c * deriv Unknown identifier `g`g Unknown identifier `c`c + deriv Unknown identifier `f`f Unknown identifier `c`c * Unknown identifier `g`g c.

theorem deriv_mul_at {I : Set } {f g : } {c : } (_hc : c I) (hf : DifferentiableAt f c) (hg : DifferentiableAt g c) : DifferentiableAt (fun x => f x * g x) c deriv (fun x => f x * g x) c = f c * deriv g c + deriv f c * g c := by classical have h := (hf.hasDerivAt.mul hg.hasDerivAt : HasDerivAt (fun x => f x * g x) (deriv f c * g c + f c * deriv g c) c) refine h.differentiableAt, ?_ simpa [add_comm] using h.deriv

Proposition 4.1.9 (Quotient rule): For an interval Unknown identifier `I`I and functions differentiable at Unknown identifier `c`sorry sorry : Propc Unknown identifier `I`I, with Unknown identifier `g`sorry 0 : Propg x 0 for all Unknown identifier `x`sorry sorry : Propx Unknown identifier `I`I, the quotient Unknown identifier `h`sorry = sorry / sorry : Proph x = Unknown identifier `f`f x / Unknown identifier `g`g x is differentiable at Unknown identifier `c`c, and its derivative satisfies deriv sorry sorry = (deriv sorry sorry * sorry - sorry * deriv sorry sorry) / sorry ^ 2 : Propderiv Unknown identifier `h`h Unknown identifier `c`c = (deriv Unknown identifier `f`f Unknown identifier `c`c * Unknown identifier `g`g c - Unknown identifier `f`f c * deriv Unknown identifier `g`g Unknown identifier `c`c) / (Unknown identifier `g`g c)^2.

theorem deriv_div_at {I : Set } {f g : } {c : } (hc : c I) (hf : DifferentiableAt f c) (hg : DifferentiableAt g c) (hgnz : x I, g x 0) : DifferentiableAt (fun x => f x / g x) c deriv (fun x => f x / g x) c = (deriv f c * g c - f c * deriv g c) / (g c) ^ 2 := by classical have hgnz' : g c 0 := hgnz c hc have h : HasDerivAt (fun x => f x / g x) ((deriv f c * g c - f c * deriv g c) / (g c) ^ 2) c := by simpa using (hf.hasDerivAt.div hg.hasDerivAt hgnz') exact h.differentiableAt, h.deriv

Helper lemma for Proposition 4.1.10: differentiability of the composition arises from the chain rule for HasDerivAt.{u, v} {𝕜 : Type u} [NontriviallyNormedField 𝕜] {F : Type v} [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F] [ContinuousSMul 𝕜 F] (f : 𝕜 F) (f' : F) (x : 𝕜) : PropHasDerivAt.

lemma hasDerivAt_comp_at {f g : } {c : } (hgd : DifferentiableAt g c) (hfd : DifferentiableAt f (g c)) : HasDerivAt (fun x => f (g x)) (deriv f (g c) * deriv g c) c := by classical simpa using (hfd.hasDerivAt.comp c hgd.hasDerivAt)

Proposition 4.1.10 (Chain rule): Let be intervals, with differentiable at Unknown identifier `c`sorry sorry : Propc Unknown identifier `I₁`I₁ and taking values in Unknown identifier `I₂`I₂, and differentiable at Unknown identifier `g`g c. If Unknown identifier `h`sorry = sorry : Proph x = Unknown identifier `f`f (g x), then Unknown identifier `h`h is differentiable at Unknown identifier `c`c with derivative deriv sorry sorry * deriv sorry sorry : ?m.15deriv Unknown identifier `f`f (Unknown identifier `g`g c) * deriv Unknown identifier `g`g Unknown identifier `c`c.

theorem deriv_comp_at {f g : } {c : } (hgd : DifferentiableAt g c) (hfd : DifferentiableAt f (g c)) : DifferentiableAt (fun x => f (g x)) c deriv (fun x => f (g x)) c = deriv f (g c) * deriv g c := by classical have h := hasDerivAt_comp_at hgd hfd exact h.differentiableAt, h.deriv
end Section01end Chap04