sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.3k stars 449 forks source link

Implement Krawtchouk, Meixner, and Hahn polynomials #33393

Closed tscrim closed 2 years ago

tscrim commented 2 years ago

These are three classes of orthogonal polynomials in the Askey scheme. We should provide an implementation based on their definition as hypergeometric functions.

This ticket provides just a basic implementation with no particular reason for the normalization choices.

CC: @dimpase @sagetrac-tmonteil @ferihr @fchapoton @mezzarobba @slel

Component: symbolics

Keywords: orthogonal polynomials

Author: Travis Scrimshaw

Branch/Commit: 9b40ec4

Reviewer: Frédéric Chapoton

Issue created by migration from https://trac.sagemath.org/ticket/33393

tscrim commented 2 years ago
comment:1

An implementation of the Krawtchouk polynomials appear in coding/delsarte_bounds.py. I am cc-ing those people as they might be interested (at least for consistency such as normalization differences and/or possible cross-references). This code is likely slower as it is more general but I haven't checked.


New commits:

9b5f2e1Cleanup functions/orthogonal_polys.py.
6dca173Adding krawtchouk polynomials.
cb7a54cAdding Meixner polynomials; fixing some details with Krawtchouk.
9399347Implement Hahn polynomials.
tscrim commented 2 years ago

Branch: public/symbolics/more_orthogonal_polys-33393

tscrim commented 2 years ago

Description changed:

--- 
+++ 
@@ -1 +1,3 @@
 These are three classes of orthogonal polynomials in the Askey scheme. We should provide an implementation based on their definition as hypergeometric functions.
+
+This ticket provides just a basic implementation with no particular reason for the normalization choices.
tscrim commented 2 years ago

Commit: 9399347

fchapoton commented 2 years ago
comment:2

the "eval_recursive" should be cached (in parent ?), don't you think ?

tscrim commented 2 years ago
comment:3

There isn't really a parent per se. Since the input could be widely varied, it doesn't make so much sense to cache it (and could quick eat up memory). There might be some benefit to caching the resulting (generic) polynomial, but this would likely need a bit of refactoring.

slel commented 2 years ago

Description changed:

--- 
+++ 
@@ -1,3 +1,7 @@
-These are three classes of orthogonal polynomials in the Askey scheme. We should provide an implementation based on their definition as hypergeometric functions.
+These are three classes of orthogonal polynomials in
+the [Askey scheme](https://en.wikipedia.org/wiki/Askey_scheme).
+We should provide an implementation based on
+their definition as hypergeometric functions.

-This ticket provides just a basic implementation with no particular reason for the normalization choices.
+This ticket provides just a basic implementation with
+no particular reason for the normalization choices.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 9399347 to b9f1eef

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

b9f1eefeval_recursive() is a method, not a function.
tscrim commented 2 years ago
comment:6

This fixes the pyflakes issues reported by the otherwise green patchbot.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from b9f1eef to cc6feca

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

f3e2af0Merge branch 'public/symbolics/more_orthogonal_polys-33393' of https://github.com/sagemath/sagetrac-mirror into public/symbolics/more_orthogonal_polys-33393
cc6fecaSome little documentation tweaks and improvements.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

2c45db3Some additional document improvements, including some more history.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from cc6feca to 2c45db3

tscrim commented 2 years ago
comment:9

Patchbot is (morally) green.

fchapoton commented 2 years ago
comment:10

ok

maybe one could add cross-references from and to the Krawtchouk polynomials in coding ?

dimpase commented 2 years ago
comment:11

Replying to @fchapoton:

ok

maybe one could add cross-references from and to the Krawtchouk polynomials in coding ?

perhaps on a follow-up ticket?

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 2c45db3 to b0154c5

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

7a20625Merge branch 'develop' into public/symbolics/more_orthogonal_polys-33393
b0154c5Adding crossrefs and a bit more documentation.
tscrim commented 2 years ago
comment:13

I think that is a good idea to have crossrefs. I have added them along with an explicit test checking the relationship between the conventions.

fchapoton commented 2 years ago
comment:14

ok, thenl let's go

fchapoton commented 2 years ago

Reviewer: Frédéric Chapoton

tscrim commented 2 years ago
comment:15

Thank you.

vbraun commented 2 years ago
comment:16
[sagemath_doc_pdf-none] ? 
[sagemath_doc_pdf-none] ! Emergency stop.
[sagemath_doc_pdf-none]  ...                                              
[sagemath_doc_pdf-none]                                                   
[sagemath_doc_pdf-none] l.4558 They are named after Pafnuty Chebyshev (Ч
[sagemath_doc_pdf-none]                                                  ебышёв 1821\sphinxhyp...
[sagemath_doc_pdf-none] 
tscrim commented 2 years ago
comment:17

It looks like the pdf doc doesn’t like Cyrillic so much; I thought it would be fine with the Russian tutorial. Do you know how to get that to work? If not, then we can just remove it.

fchapoton commented 2 years ago
comment:18

just remove cyrillic

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

9b40ec4Remove Cyrillic from doc so pdf will compile.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from b0154c5 to 9b40ec4

tscrim commented 2 years ago
comment:20

Removed.

fchapoton commented 2 years ago
comment:22

did you check that pdf doc compiles ?

tscrim commented 2 years ago
comment:23

Yes, the pdf doc compiles for me.

fchapoton commented 2 years ago
comment:24

Thanks, then let's move on

vbraun commented 2 years ago

Changed branch from public/symbolics/more_orthogonal_polys-33393 to 9b40ec4