Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - feat(ring_theory/polynomial): show gaussian form of hermite n #18896

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c18d6fc
feat(ring_theory/polynomial): show gaussian form of `hermite n`
lukemantle Apr 28, 2023
0139513
modify docstring, rename lemmas
lukemantle Apr 28, 2023
3eb686b
remove inv_gaussian, modify docstring
lukemantle Apr 28, 2023
e3c4d85
add docstrings to definitions
lukemantle Apr 28, 2023
44763e4
split oversized line
lukemantle Apr 28, 2023
9d6e6ec
move cont_diff.iterate_deriv to cont_diff.lean, correct proof of inv_…
jakelev Apr 29, 2023
930aead
fix proof using aeval rw lemma
jakelev Apr 29, 2023
1ae19cf
remove separate equality of lambdas
jakelev Apr 29, 2023
22a9add
remove gaussian definition, simplify all proofs
jakelev Apr 30, 2023
9fb7f4c
add finite-level version of cont_diff.iterate_deriv
jakelev Apr 30, 2023
257a8f0
correct docstring
jakelev Apr 30, 2023
ed92185
golf and format
eric-wieser Apr 30, 2023
0248c18
inline proof of recurrence
jakelev Apr 30, 2023
04fafe5
modified proof to use division
jakelev May 2, 2023
ac5025a
correct typo
jakelev May 2, 2023
5ab5fb9
modify docstring
jakelev May 4, 2023
086953e
add polynomial.deriv_aeval
jakelev May 5, 2023
07044aa
move PR to ring_theory/polynomial/hermite/
jakelev May 5, 2023
e198737
modify docstring
jakelev May 5, 2023
c2e742f
added variant lemma statements
jakelev May 5, 2023
3a28d9a
Update src/ring_theory/polynomial/hermite/gaussian.lean
jcommelin May 5, 2023
549d5d2
Update src/ring_theory/polynomial/hermite/gaussian.lean
eric-wieser May 5, 2023
150bf46
fix style, squeeze a slow simp
eric-wieser May 5, 2023
a7b25eb
Update src/analysis/calculus/deriv.lean
eric-wieser May 5, 2023
f3a41d2
avoid side goal
jakelev May 5, 2023
98c4b9a
Merge branch 'hermite_gauss' of https://github.com/leanprover-communi…
jakelev May 5, 2023
bdde511
Apply suggestions from code review
jakelev May 5, 2023
e174f58
Merge branch 'master' into hermite_gauss
eric-wieser May 11, 2023
b6c1adc
Delete duplicate import from bad merge
eric-wieser May 11, 2023
a39abab
use the new lemma in the proof
eric-wieser May 11, 2023
8c65b73
correct failing proof
jakelev May 12, 2023
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
10 changes: 10 additions & 0 deletions src/analysis/calculus/cont_diff.lean
Original file line number Diff line number Diff line change
Expand Up @@ -2296,6 +2296,16 @@ lemma cont_diff.continuous_deriv (h : cont_diff 𝕜 n f₂) (hn : 1 ≤ n) :
continuous (deriv f₂) :=
(cont_diff_succ_iff_deriv.mp (h.of_le hn)).2.continuous

lemma cont_diff.iterate_deriv :
∀ (n : ℕ) {f₂ : 𝕜 → F} (hf : cont_diff 𝕜 ∞ f₂), cont_diff 𝕜 ∞ (deriv^[n] f₂)
jakelev marked this conversation as resolved.
Show resolved Hide resolved
| 0 f₂ hf := hf
| (n + 1) f₂ hf := cont_diff.iterate_deriv n (cont_diff_top_iff_deriv.mp hf).2

lemma cont_diff.iterate_deriv' (n : ℕ) :
∀ (k : ℕ) {f₂ : 𝕜 → F} (hf : cont_diff 𝕜 (n + k : ℕ) f₂), cont_diff 𝕜 n (deriv^[k] f₂)
jakelev marked this conversation as resolved.
Show resolved Hide resolved
| 0 f₂ hf := hf
| (n + 1) f₂ hf := cont_diff.iterate_deriv' n (cont_diff_succ_iff_deriv.mp hf).2

end deriv

section restrict_scalars
Expand Down
5 changes: 5 additions & 0 deletions src/analysis/calculus/deriv.lean
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Authors: Gabriel Ebner, Sébastien Gouëzel
-/
import analysis.calculus.fderiv
import data.polynomial.derivative
import data.polynomial.algebra_map
import linear_algebra.affine_space.slope

/-!
Expand Down Expand Up @@ -1880,6 +1881,10 @@ p.differentiable.differentiable_on
@[simp] protected lemma deriv : deriv (λx, p.eval x) x = p.derivative.eval x :=
(p.has_deriv_at x).deriv

@[simp] protected lemma deriv_aeval {R : Type*} [comm_semiring R] [algebra R 𝕜] (p : polynomial R) :
deriv (λ (x : 𝕜), aeval x p) x = aeval x (derivative p) :=
by simp [aeval_def, eval₂_eq_eval_map]

protected lemma deriv_within (hxs : unique_diff_within_at 𝕜 s x) :
deriv_within (λx, p.eval x) s x = p.derivative.eval x :=
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This file defines `polynomial.hermite n`, the nth probabilist's Hermite polynomi

## Results

* `polynomial.hermite_succ`: the recursion `hermite (n+1) = (x - d/dx) (hermite n)`
* `polynomial.coeff_hermite_of_odd_add`: for `n`,`k` where `n+k` is odd, `(hermite n).coeff k` is
zero.
* `polynomial.monic_hermite`: for all `n`, `hermite n` is monic.
Expand All @@ -39,6 +40,7 @@ noncomputable def hermite : ℕ → polynomial ℤ
| 0 := 1
| (n+1) := X * (hermite n) - (hermite n).derivative

/-- The recursion `hermite (n+1) = (x - d/dx) (hermite n)` -/
@[simp] lemma hermite_succ (n : ℕ) : hermite (n+1) = X * (hermite n) - (hermite n).derivative :=
by rw hermite

Expand Down
74 changes: 74 additions & 0 deletions src/ring_theory/polynomial/hermite/gaussian.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/-
Copyright (c) 2023 Luke Mantle. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Luke Mantle, Jake Levinson
-/

import ring_theory.polynomial.hermite.basic
import analysis.special_functions.exp
import analysis.special_functions.exp_deriv

/-!
# Hermite polynomials and Gaussians

This file shows that the Hermite polynomial `hermite n` is (up to sign) the
polynomial factor occurring in the `n`th derivative of a gaussian.

## Results

* `polynomial.deriv_gaussian_eq_hermite_mul_gaussian`:
The Hermite polynomial is (up to sign) the polynomial factor occurring in the
`n`th derivative of a gaussian.

## References

* [Hermite Polynomials](https://en.wikipedia.org/wiki/Hermite_polynomials)

-/

noncomputable theory
open polynomial

namespace polynomial

/-- `hermite n` is (up to sign) the factor appearing in `deriv^[n]` of a gaussian -/
lemma deriv_gaussian_eq_hermite_mul_gaussian (n : ℕ) (x : ℝ) :
deriv^[n] (λ y, real.exp (-(y^2 / 2))) x =
(-1 : ℝ)^n * aeval x (hermite n) * real.exp (-(x^2 / 2)) :=
begin
induction n with n ih generalizing x,
{ rw [function.iterate_zero_apply, pow_zero, one_mul, hermite_zero, C_1, map_one, one_mul] },
{ replace ih : (deriv^[n] _) = _ := _root_.funext ih,
have deriv_gaussian : deriv (λ y, real.exp (-(y^2 / 2))) x = (-x) * real.exp (-(x^2 / 2)),
{ simp [mul_comm, ← neg_mul] },
rw [function.iterate_succ_apply', ih, deriv_mul, deriv_const_mul, pow_succ (-1 : ℝ),
deriv_gaussian, hermite_succ, map_sub, map_mul, aeval_X, polynomial.deriv_aeval],
ring,
{ simp_rw [aeval_def, eval₂_eq_eval_map],
apply polynomial.differentiable },
{ simp_rw [aeval_def, eval₂_eq_eval_map],
apply differentiable.const_mul,
apply polynomial.differentiable },
{ simp } }
Copy link
Member

@eric-wieser eric-wieser May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These side goals go away if you work with has_deriv_at instead of deriv:

  induction n with n ih generalizing x,
  { rw [function.iterate_zero_apply, pow_zero, one_mul, hermite_zero, C_1, map_one, one_mul] },
  { replace ih : (deriv^[n] _) = _ := _root_.funext ih,
    have has_deriv_at_gaussian : ∀ x,
      has_deriv_at (λ y, real.exp (-(y^2 / 2))) ((-x) * real.exp (-(x^2 / 2))) x,
    { intro x,
      simpa [mul_div_cancel_left x (two_ne_zero), neg_mul, mul_comm]
        using (((has_deriv_at_id' x).pow 2).div_const 2).neg.exp },
    rw [function.iterate_succ_apply', ih],
    have := ((polynomial.has_deriv_at_aeval _ _).const_mul ((-1 : ℝ) ^ n)).mul (has_deriv_at_gaussian x),
    refine this.deriv.trans _,
    sorry },

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually also deriv_const_mul_field doesn't generate a side goal, I didn't notice it before (versus deriv_const_mul).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new version is pretty close to this, let's just go with it.

end

lemma hermite_eq_deriv_gaussian (n : ℕ) (x : ℝ) :
aeval x (hermite n) =
(-1 : ℝ)^n * (deriv^[n] (λ y, real.exp (-(y^2 / 2))) x) / real.exp (-(x^2 / 2)) :=
jakelev marked this conversation as resolved.
Show resolved Hide resolved
begin
rw deriv_gaussian_eq_hermite_mul_gaussian,
field_simp [real.exp_ne_zero],
rw [← @smul_eq_mul ℝ _ ((-1)^n), ← inv_smul_eq_iff₀, mul_assoc, smul_eq_mul,
← inv_pow, ← neg_inv, inv_one],
exact pow_ne_zero _ (by norm_num),
end

lemma hermite_eq_deriv_gaussian' (n : ℕ) (x : ℝ) :
aeval x (hermite n) =
(-1 : ℝ)^n * (deriv^[n] (λ y, real.exp (-(y^2 / 2))) x) * real.exp (x^2 / 2) :=
begin
rw [hermite_eq_deriv_gaussian, real.exp_neg],
field_simp [real.exp_ne_zero],
end

jcommelin marked this conversation as resolved.
Show resolved Hide resolved
end polynomial
Loading