Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Game/Lemmas/Derivatives/DiffAt.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Mathlib.Tactic
import Mathlib.Analysis.SpecialFunctions.Pow.Real

macro "differentiability" : tactic => `(tactic|(
repeat' (first |
exact differentiableAt_id' |
exact differentiableAt_const _ |
exact Real.differentiableAt_sin |
exact Real.differentiableAt_cos |
exact Real.differentiableAt_tan |
exact Real.differentiableAt_exp |
exact differentiableAt_pow _ |
apply DifferentiableAt.const_mul |
apply DifferentiableAt.add |
apply DifferentiableAt.sub |
apply DifferentiableAt.mul |
apply DifferentiableAt.div |
apply DifferentiableAt.pow
)))
30 changes: 7 additions & 23 deletions Game/Levels/Derivative/L11_DanielLow.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.Tactic
import Game.Metadata

import Game.Lemmas.Derivatives.DiffAt

World "Derivative"

Level 11

Title "Derivative of (x-1)^4/(x^2+2x)^5"


-- The derivative of frac{(x-1)^4}{(x^2 +2x)^5}



Statement (x : ℝ) (hx1 : (x^2 + 2*x)^5 ≠ 0) :
deriv (fun x : ℝ => (x-1)^4 / (x^2 + 2*x)^5) x
= (4*(x-1)^ 3 * (x^2 + 2*x)^5 - (x - 1)^4 * (5*(x^2 + 2*x)^4 * (2*x + 2))) / ((x^2 + 2*x)^5) ^ 2 := by
Expand Down Expand Up @@ -51,26 +47,12 @@ deriv (fun x : ℝ => (x-1)^4 / (x^2 + 2*x)^5) x
Hint "use simp to reduce to the final answer"
simp
Hint "Now to prove the differentiability conditions"
exact differentiableAt_id
exact differentiableAt_pow _
Hint "Use DifferentiableAt.const_mul for functions multiplied with a constant"
apply DifferentiableAt.const_mul; exact differentiableAt_id
Hint "Remember this is just the function u^5 but evaluated at a different value instead of just x"
apply differentiableAt_pow
Hint "Use the lemma we proved for differentiability of (x^2 + 2*x)"
exact diff_g₂
Hint "Same as before, this is just proving differentiability of function u^4 evaluated at some different point"
apply differentiableAt_pow
apply DifferentiableAt.sub_const; exact differentiableAt_id
Hint "For this, we need to use DifferentiableAt.comp, which requires us to rewrite into a function composition again"
rw [top]
Hint "Other than that, just have to prove that both functions in the composition are differentiable"
apply DifferentiableAt.comp; apply differentiableAt_pow; apply DifferentiableAt.sub_const; exact differentiableAt_id
rw [bottom]
apply DifferentiableAt.comp; apply differentiableAt_pow; exact diff_g₂
Hint "Finally, use our assumption that we do not divide by zero"
differentiability
exact hx1

/-- Reduce DifferentiableAt statements to easier assumptions -/
TacticDoc differentiability

/-- Chain Rule: $(f ∘ g)'(x)=f'(g(x))g'(x)$ -/
TheoremDoc deriv.comp as "deriv.comp" in "Derivative"

Expand All @@ -82,3 +64,5 @@ TheoremDoc DifferentiableAt.mul as "DifferentiableAt.mul" in "Differentiable"

/-- Product Rule: $(c * g)'(x) = c * g'(x))$ -/
TheoremDoc DifferentiableAt.const_mul as "DifferentiableAt.const_mul" in "Differentiable"

NewTactic differentiability