Zulip Chat Archive

Stream: maths

Topic: polynomials from coefficient


Johan Commelin (Mar 07 2022 at 12:35):

Suppose I have a bunch of coefficients a 0, a 1, a 2, ..., a n, probably implemented as a : nat -> R for some ring R. What is the best way to turn this into the polynomial i<naiXi\sum_{i < n} a_i X^i?
One can simply write

(finset.range n).sum (λ i, (a i : R[X]) * X ^ i)

But this has the disadvantage that is ins't very structured. For example, showing that the i-th coefficient is a i is not a 1-lemma application. Should we have a dedicated constructor for this? Or does something already exist?

Yakov Pechersky (Mar 07 2022 at 12:47):

You turn "a" into a finsupp, and use polynomial.of_finsupp

Yakov Pechersky (Mar 07 2022 at 12:48):

Unfortunately I'm wrong and we don't have that constructor. Can you make an add_monoid_algebra from your "a"?

Johan Commelin (Mar 07 2022 at 12:58):

Afaik, we really don't have a good constructor + API for this type of examples.

Riccardo Brasca (Mar 07 2022 at 13:02):

If P : ℕ →₀ R then polynomial.of_finsupp P should give the polynomial, doesn't it?

Riccardo Brasca (Mar 07 2022 at 16:21):

I just realized that your question is probably related to #12447 :face_palm:

Junyan Xu (Mar 08 2022 at 03:48):

There is no polynomial.of_finsupp P because what you want is simply ⟨P⟩.

structure polynomial (R : Type u_1) [semiring R] : Type u_1
    (to_finsupp : add_monoid_algebra R )
add_monoid_algebra k G = (G →₀ k)

Kevin Buzzard (Mar 08 2022 at 07:08):

One should rename the constructor of_finsupp using the :: syntax

Eric Wieser (Mar 08 2022 at 07:39):

src#polynomial

Eric Wieser (Mar 08 2022 at 07:40):

Sebastien Gouezel went back in time and renamed it for you

Kevin Buzzard (Mar 08 2022 at 07:40):

Nice! I didn't know he could do that.

Eric Wieser (Mar 08 2022 at 07:41):

So more accurate would be "the docs do not list a polynomial.of_finsupp because it is a structure constructor like sigma.mk"

Yakov Pechersky (Mar 08 2022 at 13:10):

So I wasn't insane thinking we had one in the first place...

Kevin Buzzard (Mar 08 2022 at 15:47):

It depends if you thought it before Sebastien went back in time.


Last updated: Dec 20 2023 at 11:08 UTC