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
import Mathlib.Tactic
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Deriv
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Analysis.Calculus.MeanValue

open Set Filter
open Topology Filter Classical Real

noncomputable section

open Real

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

example (x : ) : DifferentiableAt  sin x :=
  (hasDerivAt_sin x).differentiableAt

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

example {f :   } {x : } (h : ¬DifferentiableAt  f x) : deriv f x = 0 :=
  deriv_zero_of_not_differentiableAt h

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

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

open Set

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

example (f :   ) {a b : } (hab : a < b) (hf : ContinuousOn f (Icc a b))
    (hf' : DifferentiableOn  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 (fun x :   x ^ 5) 6 = 5 * 6 ^ 4 := by simp

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