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

Commit 8b5ff9c

Browse files
feat(analysis/special_functions/integrals): integral_log (#7732)
The integral of the (real) logarithmic function over the interval `[a, b]`, provided that `0 ∉ interval a b`.
1 parent 0b09858 commit 8b5ff9c

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

src/analysis/special_functions/integrals.lean

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import measure_theory.interval_integral
99
# Integration of specific interval integrals
1010
1111
This file contains proofs of the integrals of various specific functions. This includes:
12-
* Integrals of simple functions, such as `id`, `pow`, `exp`, `inv`
12+
* Integrals of simple functions, such as `id`, `pow`, `inv`, `exp`, `log`
1313
* Integrals of some trigonometric functions, such as `sin`, `cos`, `1 / (1 + x^2)`
1414
* The integral of `cos x ^ 2 - sin x ^ 2`
1515
* Reduction formulae for the integrals of `sin x ^ n` and `cos x ^ n` for `n ≥ 2`
@@ -195,10 +195,6 @@ by simpa using integral_pow 1
195195
lemma integral_one : ∫ x in a..b, (1 : ℝ) = b - a :=
196196
by simp only [mul_one, smul_eq_mul, integral_const]
197197

198-
@[simp]
199-
lemma integral_exp : ∫ x in a..b, exp x = exp b - exp a :=
200-
by rw integral_deriv_eq_sub'; norm_num [continuous_on_exp]
201-
202198
@[simp]
203199
lemma integral_inv (h : (0:ℝ) ∉ interval a b) : ∫ x in a..b, x⁻¹ = log (b / a) :=
204200
begin
@@ -225,6 +221,30 @@ by simp only [one_div, integral_inv_of_pos ha hb]
225221
lemma integral_one_div_of_neg (ha : a < 0) (hb : b < 0) : ∫ x : ℝ in a..b, 1/x = log (b / a) :=
226222
by simp only [one_div, integral_inv_of_neg ha hb]
227223

224+
@[simp]
225+
lemma integral_exp : ∫ x in a..b, exp x = exp b - exp a :=
226+
by rw integral_deriv_eq_sub'; norm_num [continuous_on_exp]
227+
228+
@[simp]
229+
lemma integral_log (h : (0:ℝ) ∉ interval a b) :
230+
∫ x in a..b, log x = b * log b - a * log a - b + a :=
231+
begin
232+
obtain ⟨h', heq⟩ := ⟨λ x hx, ne_of_mem_of_not_mem hx h, λ x hx, mul_inv_cancel (h' x hx)⟩,
233+
convert integral_mul_deriv_eq_deriv_mul (λ x hx, has_deriv_at_log (h' x hx))
234+
(λ x hx, has_deriv_at_id x) (continuous_on_inv'.mono $ subset_compl_singleton_iff.mpr h)
235+
continuous_on_const using 1; simp [integral_congr heq, mul_comm, ← sub_add],
236+
end
237+
238+
@[simp]
239+
lemma integral_log_of_pos (ha : 0 < a) (hb : 0 < b) :
240+
∫ x in a..b, log x = b * log b - a * log a - b + a :=
241+
integral_log $ not_mem_interval_of_lt ha hb
242+
243+
@[simp]
244+
lemma integral_log_of_neg (ha : a < 0) (hb : b < 0) :
245+
∫ x in a..b, log x = b * log b - a * log a - b + a :=
246+
integral_log $ not_mem_interval_of_gt ha hb
247+
228248
@[simp]
229249
lemma integral_sin : ∫ x in a..b, sin x = cos a - cos b :=
230250
by rw integral_deriv_eq_sub' (λ x, -cos x); norm_num [continuous_on_sin]

test/integration.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ example : ∫ x in 0..π, cos x ^ 2 - sin x ^ 2 = 0 := by simp [integral_cos_sq_
3737
/- the exponential function -/
3838
example : ∫ x in 0..2, -exp x = 1 - exp 2 := by simp
3939

40+
/- the logarithmic function -/
41+
example : ∫ x in 1..2, log x = 2 * log 2 - 1 := by { norm_num, ring }
42+
4043
/- linear combinations (e.g. polynomials) -/
4144
example : ∫ x : ℝ in 0..2, 6*x^5 + 3*x^4 + x^3 - 2*x^2 + x - 7 = 1048 / 15 := by norm_num
4245
example : ∫ x : ℝ in 0..1, exp x + 9 * x^8 + x^3 - x/2 + (1 + x^2)⁻¹ = exp 1 + π / 4 := by norm_num

0 commit comments

Comments
 (0)