mathematics_in_lean

My solutions for this book

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
import analysis.special_functions.trigonometric.deriv
import analysis.calculus.mean_value

open set filter
open_locale topological_space filter classical real

noncomputable theory

open real

/-- The sin function has derivative 1 at 0. -/
example : has_deriv_at sin 1 0 :=
by simpa using has_deriv_at_sin 0

example (x : ) : differentiable_at  sin x :=
(has_deriv_at_sin x).differentiable_at

example {f :   } {x a : } (h : has_deriv_at f a x) : deriv f x = a :=
h.deriv

example {f :   } {x : } (h : ¬ differentiable_at  f x) : deriv f x = 0 :=
deriv_zero_of_not_differentiable_at h

example {f g :   } {x : } (hf : differentiable_at  f x) (hg : differentiable_at  g x) :
  deriv (f + g) x = deriv f x + deriv g x :=
deriv_add hf hg

example {f :   } {a : } (h : is_local_min f a) : deriv f a = 0 :=
h.deriv_eq_zero

example {f :   } {a b : } (hab : a < b)
  (hfc : continuous_on f (Icc a b)) (hfI : f a = f b) :
   c  Ioo a b, deriv f c = 0 :=
exists_deriv_eq_zero f hab hfc hfI

example (f :   ) {a b : } (hab : a < b) (hf : continuous_on f (Icc a b))
 (hf' : differentiable_on  f (Ioo a b)) :
  c  Ioo a b, deriv f c = (f b - f a) / (b - a) :=
exists_deriv_eq_slope f hab hf hf'

example : deriv (λ x : , x^5) 6 = 5 * 6^4 := by simp

example (x₀ : ) (h₀ : x₀  0) : deriv (λ x : , 1 / x) x₀ = -(x₀^2)⁻¹ := by simp

example : deriv sin π = -1 := by simp

example (x₀ : ) (h : x₀  0) :
  deriv (λ x : , exp(x^2) / x^5) x₀ = (2 * x₀^2 - 5) * exp (x₀^2) / x₀^6 :=
begin
  have : x₀^5  0, { exact pow_ne_zero 5 h, },
  field_simp,
  ring,
end

example (y : ) : has_deriv_at (λ x : , 2 * x + 5) 2 y :=
begin
  have := ((has_deriv_at_id y).const_mul 2).add_const 5,
  rwa [mul_one] at this,
end

example (y : ) : deriv (λ x : , 2 * x + 5) y = 2 := by simp