Skip to content

Commit

Permalink
feat(analysis/special_functions/integrals): integral of `cos x ^ 2 - …
Browse files Browse the repository at this point in the history
…sin x ^ 2` (#7012)

An example of a direct application of integration by parts.
  • Loading branch information
benjamindavidson committed Apr 9, 2021
1 parent 92ec949 commit 505ffa9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/analysis/special_functions/integrals.lean
Expand Up @@ -14,6 +14,7 @@ This file contains proofs of the integrals of various simple functions, includin
There are also facts about more complicated integrals:
* `sin x ^ n`: We prove a recursive formula for `sin x ^ (n + 2)` in terms of `sin x ^ n`,
along with explicit product formulas for even and odd `n`.
* `cos x ^ 2 - sin x ^ 2`
With these lemmas, many simple integrals can be computed by `simp` or `norm_num`.
See `test/integration.lean` for specific examples.
Expand Down Expand Up @@ -222,6 +223,11 @@ end
lemma integral_cos : ∫ x in a..b, cos x = sin b - sin a :=
by rw integral_deriv_eq_sub'; norm_num [continuous_on_cos]

lemma integral_cos_sq_sub_sin_sq :
∫ x in a..b, cos x ^ 2 - sin x ^ 2 = sin b * cos b - sin a * cos a :=
by simpa only [pow_two, sub_eq_add_neg, neg_mul_eq_mul_neg] using integral_deriv_mul_eq_sub
(λ x hx, has_deriv_at_sin x) (λ x hx, has_deriv_at_cos x) continuous_on_cos continuous_on_sin.neg

@[simp]
lemma integral_inv_one_add_sq : ∫ x : ℝ in a..b, (1 + x^2)⁻¹ = arctan b - arctan a :=
begin
Expand Down
1 change: 1 addition & 0 deletions test/integration.lean
Expand Up @@ -28,6 +28,7 @@ example : ∫ x in 0..π/4, cos x = sqrt 2 / 2 := by simp
example : ∫ x in 0..π, 2 * sin x = 4 := by norm_num
example : ∫ x in 0..π/2, cos x / 2 = 1 / 2 := by simp
example : ∫ x : ℝ in 0..1, 1 / (1 + x ^ 2) = π/4 := by simp
example : ∫ x in 0..π, cos x ^ 2 - sin x ^ 2 = 0 := by simp [integral_cos_sq_sub_sin_sq]

/-- the exponential function -/
example : ∫ x in 0..2, -exp x = 1 - exp 2 := by simp
Expand Down

0 comments on commit 505ffa9

Please sign in to comment.