sagemath / sage

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

implement derivatives of lazy series #34413

Closed mantepse closed 1 year ago

mantepse commented 2 years ago

We implement derivatives for LazyLaurentSeries, LazyTaylorSeries and LazySymmetricFunctions

Depends on #34383

CC: @tscrim

Component: combinatorics

Keywords: LazyPowerSeries

Author: Martin Rubey

Branch/Commit: cdea820

Reviewer: Travis Scrimshaw

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

mantepse commented 2 years ago

Branch: u/mantepse/implement_derivatives_of_lazy_series

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

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

55761b8better derivative for LazyLaurentSeries
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Commit: 55761b8

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

Changed commit from 55761b8 to 50ce450

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

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

50ce450derivative for LazyTaylorSeries
mantepse commented 2 years ago

Changed keywords from none to LazyPowerSeries

mantepse commented 2 years ago

Description changed:

--- 
+++ 
@@ -1 +1 @@
-
+We implement derivatives for LazyLaurentSeries, LazyTaylorSeries and LazySymmetricFunctions
mantepse commented 2 years ago

Author: Martin Rubey

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

Changed commit from 50ce450 to 10cfc11

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

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

10cfc11derivative for LazySymmetricFunctions
mantepse commented 2 years ago

Dependencies: #32324

mantepse commented 2 years ago

Changed dependencies from #32324 to #34383

tscrim commented 2 years ago
comment:9

I don't think there is anything we need to worry about with regards to analytic stuff (since there is an assumption the derivatives commute), but I want to confirm you also think so too.

Also you have empty INPUT: blocks. Either remove, add the inputs, or provide a link to something that explains how to parse the inputs.

tscrim commented 2 years ago

Reviewer: Travis Scrimshaw

mantepse commented 2 years ago
comment:10

Replying to @tscrim:

I don't think there is anything we need to worry about with regards to analytic stuff (since there is an assumption the derivatives commute), but I want to confirm you also think so too.

That's correct.

Also you have empty INPUT: blocks. Either remove, add the inputs, or provide a link to something that explains how to parse the inputs.

Done.

Besides, I now know of a way to make sense of

sage: L.<x,y> = LazySymmetricFunction(SymmetricFunctions(QQ).s())
sage: f = 1/(1-x*y)

The natural thing is to set x = tensor([s[1], s[0]]) and y = tensor([s[0], s[1]]). Doing so, also

sage: f.derivative(x, 2, y)

makes sense. In fact, this is what we do all the time in the doctests anyway.

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

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

07ca029add a consistency check
1d559ccimprove composing Taylor series, start making plethysm more general
c47b060Doing some changes to normal symmetric functions plethysm to support coefficients and lazy symmetric functions.
5776c61Adding the category of commutative rings to the category of tensor products of commutative algebras.
5f21f3dMerge branch 'public/categories/tensor_commutative_rings-34453' into public/rings/lazy_series_revert-34383
a2e9ed7Making the test for coercion of plethysms wrt tesnor products more robust.
94219d4fix plethysm with f having finite support
6745cf1Some last details and optimizations to Stream_plethysm.
3d6d39ffix typo in comment
ee35418Merge branch 'public/rings/lazy_series_revert-34383' of trac.sagemath.org:sage into t/34413/implement_derivatives_of_lazy_series
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 10cfc11 to ee35418

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

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

dafdcb4fix doctests
9124987Merge branch 'public/rings/lazy_series_revert-34383' of trac.sagemath.org:sage into t/34413/implement_derivatives_of_lazy_series
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from ee35418 to 9124987

tscrim commented 2 years ago
comment:13

Replying to @mantepse:

Replying to @tscrim: Besides, I now know of a way to make sense of

sage: L.<x,y> = LazySymmetricFunction(SymmetricFunctions(QQ).s())
sage: f = 1/(1-x*y)

The natural thing is to set x = tensor([s[1], s[0]]) and y = tensor([s[0], s[1]]). Doing so, also

sage: f.derivative(x, 2, y)

makes sense. In fact, this is what we do all the time in the doctests anyway.

I agree that it makes a little bit of sense to think of the variable as a the unique degree one element (up to scalar). However, this would be a hack IMO because the degree one elements do not generate the ring of symmetric functions (as it is a freely generated by ei). So the result of gens() would be wrong if it was the degree one elements. Now a way to explain yourself out of this is that the R.<x,y> type syntax returns the first (in some ordering) n generators.

I still do not think this extra little agreement with a completely different class (where I expect no such compatibility) and implementation is worth all of this extra complexity and effort. Although I won’t oppose it because you are not going to create some extra class for the variables (at least, judging by what you’re saying). However, to me it adds to maintenance costs without a clear benefit.

Actually, isn’t what is happening just a renaming of “skew_by“? Will that be implemented here too?

mantepse commented 2 years ago
comment:14

you never sleep, do you?

Yes, this is skey_by(p[1]).

Indeed, it is a bit unclear to me whether it makes sense to implement all the methods on SymmetricFunctions also on LazySymmetricFunctions. It would be nicer to have an automatism for those which are graded maps.

However, that's almost certainly for a different project.

tscrim commented 2 years ago
comment:15

Replying to @mantepse:

you never sleep, do you?

I wanted to convey my thoughts while you were still awake in case you wanted to respond.

Yes, this is skey_by(p[1]).

It seems like that is your mathematical model is disguise. It just happens to have all of the other usual derivative properties when doing p[1].

Indeed, it is a bit unclear to me whether it makes sense to implement all the methods on SymmetricFunctions also on LazySymmetricFunctions. It would be nicer to have an automatism for those which are graded maps.

However, that's almost certainly for a different project.

I think we can port them over as we find them to be useful.

Anyways, for follow-up tickets.

Can you add the following tests:

(For exact series with nonzero constant)

sage: L.<z> = LazyLaurentSeriesRing(ZZ)
sage: f = L([1,2], valuation=-2, constant=1)
sage: f
z^-2 + 2*z^-1 + 1 + z + z^2 + O(z^3)
sage: f.derivative()
-2*z^-3 - 2*z^-2 + 1 + 2*z + 3*z^2 + 4*z^3 + O(z^4)

Calculus rules (up to an implicit sign choice):

sage: L.<z> = LazyLaurentSeriesRing(QQ)
sage: log(1-z).derivative()
-1 - z - z^2 - z^3 - z^4 - z^5 - z^6 + O(z^7)

Side note: This doesn't work over ZZ because we are too greedy about converting things to the ring. Indeed, the failure for ZZ stems from

sage: L.<z> = LazyLaurentSeriesRing(ZZ)
sage: log(1-z)
<repr(<sage.rings.lazy_series_ring.LazyLaurentSeriesRing_with_category.element_class at 0x7f2c90572c80>) failed: TypeError: no conversion of this rational to integer>

This is the only stream that is forcing the output to be in a particular ring and an explicit example about why we shouldn't do that in Streams. We should change this on a separate ticket (or here if you want).

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

Changed commit from 9124987 to 610078f

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

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

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

Changed commit from 610078f to 5666eae

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

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

731072aremove unnecessary code leftover from merge, and remove unneccesary import detected by pyflakes
5666eaeMerge branch 'public/rings/lazy_series_revert-34383' of trac.sagemath.org:sage into t/34413/implement_derivatives_of_lazy_series
tscrim commented 2 years ago
comment:18

Thank you.

vbraun commented 2 years ago
comment:20
sage -t --long --warn-long 46.9 --random-seed=123 src/sage/combinat/sf/sfa.py
**********************************************************************
File "src/sage/combinat/sf/sfa.py", line 3139, in sage.combinat.sf.sfa.SymmetricFunctionAlgebra_generic_Element.plethysm
Failed example:
    s(2*T.one())
Expected:
    (2*B[word:]#B[word:])*s[]
Got:
    (2*B[]#B[])*s[]
^CKilling test src/sage/combinat/sf/sfa.py
----------------------------------------------------------------------
Doctests interrupted: 0/1 files tested
----------------------------------------------------------------------
tscrim commented 2 years ago

Changed branch from u/mantepse/implement_derivatives_of_lazy_series to u/tscrim/derivatives_lazy_series-34413

tscrim commented 2 years ago

Changed commit from 5666eae to none

tscrim commented 2 years ago

Changed dependencies from #34383 to #34383, #34494

tscrim commented 2 years ago
comment:21

The doctest fails due to changes in #34494. Trivial doctest update.

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

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. Last 10 new commits:

ee35418Merge branch 'public/rings/lazy_series_revert-34383' of trac.sagemath.org:sage into t/34413/implement_derivatives_of_lazy_series
dafdcb4fix doctests
9124987Merge branch 'public/rings/lazy_series_revert-34383' of trac.sagemath.org:sage into t/34413/implement_derivatives_of_lazy_series
610078fadd doctests
731072aremove unnecessary code leftover from merge, and remove unneccesary import detected by pyflakes
5666eaeMerge branch 'public/rings/lazy_series_revert-34383' of trac.sagemath.org:sage into t/34413/implement_derivatives_of_lazy_series
1729827Merge branch 'u/mantepse/implement_derivatives_of_lazy_series' of https://github.com/sagemath/sagetrac-mirror into u/tscrim/derivatives_lazy_series-34413
ab98f2eless verbose monomials in shuffle algebras
5d76825Merge branch 'u/chapoton/34494' of https://github.com/sagemath/sagetrac-mirror into u/tscrim/derivatives_lazy_series-34413
97df300Updating sf/sfa.py doctest due to #34494.
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Commit: 97df300

tscrim commented 2 years ago
comment:23

Slightly too fast with updating the ticket.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 1 year ago

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. Last 10 new commits:

fbccb39normalize degree in Stream_exact for correct equality
b930f58Merge branch 'u/mantepse/categories_of_lazy_series' of https://github.com/sagemath/sagetrac-mirror into u/tscrim/categories_lazy_series-34470
b47407bImplementing `_floordiv_`, Stream._true_order to boolean, first fraction field, more tests, marking long tests.
e077b66Using dynamic classes for FPS gcd.
ddc04a1Fixing last pyflakes things.
9260d14Merge branch 'u/tscrim/categories_lazy_series-34470' of https://github.com/sagemath/sagetrac-mirror into u/tscrim/derivatives_lazy_series-34413
1388b8aMerge branch 'u/chapoton/34494' of https://github.com/sagemath/sagetrac-mirror into public/rings/lazy_series_revert-34383
7bfe5f7Merge branch 'public/rings/lazy_series_revert-34383' of https://github.com/sagemath/sagetrac-mirror into public/rings/lazy_series_revert-34383
2039990Updating doctest due to changes from #34494.
1b9897dMerge branch 'public/rings/lazy_series_revert-34383' into u/tscrim/derivatives_lazy_series-34413
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 1 year ago

Changed commit from 97df300 to 1b9897d

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 1 year ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

cdea820Merge branch 'public/rings/lazy_series_revert-34383' of https://github.com/sagemath/sagetrac-mirror into u/tscrim/derivatives_lazy_series-34413
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 1 year ago

Changed commit from 1b9897d to cdea820

tscrim commented 1 year ago

Changed dependencies from #34383, #34494 to #34383

tscrim commented 1 year ago
comment:26

Trivial update of #34383, which should have had the #34494 change instead.

mantepse commented 1 year ago

Changed branch from u/tscrim/derivatives_lazy_series-34413 to u/mantepse/derivatives_lazy_series-34413

vbraun commented 1 year ago

Changed branch from u/mantepse/derivatives_lazy_series-34413 to cdea820