Closed dkrenn closed 8 years ago
Branch: u/dkrenn/asy/factorial
Last 10 new commits:
6e5a098 | Merge branch 'u/dkrenn/symbolic-subring' of trac.sagemath.org:sage into coerce/inverse-action |
5638459 | #19521: use coercion_reversed in InverseAction |
421e377 | mutable poset map: remove elements ``None`` |
1d28240 | term monoid: write change_parameter |
2c37889 | correct a bug in change_parameter |
bdcb72b | write map_coefficients |
15865eb | Merge branches 'coerce/inverse-action' and 'asy/map_coefficients' into t/19306/asy/generators |
94f003a | factorial |
5cbabc1 | seealso and links |
8858983 | correct :meth: --> :func: |
In principle, this would be fine; however, the following example fails:
sage: A.<m> = AsymptoticRing('m^QQ', QQ)
sage: m.factorial()
Traceback (most recent call last):
...
TypeError: ...
>>>>>> *previous* ArithmeticError: Cannot build log(m)
since log(m) is not in Growth Group
m^QQ * (e^(n*log(n)))^QQ * (e^n)^QQ * n^QQ * log(n)^QQ.
The problem is that the method tries to build the correct growth group in n
(hard-coded) but has no influence on the given growth group.
And if we have something like log(m).factorial()
, then everything gets more involved.
This either needs to be fixed or documented.
Reviewer: Clemens Heuberger
Branch pushed to git repo; I updated commit sha1. New commits:
5977604 | Merge tag '7.1.beta3' into t/19540/asy/factorial |
8a43e7e | Trac #19540: allow growth groups strings in TermMonoid factory |
0384e25 | Trac #19540: use is_one() |
3f0f855 | Trac #19540: variable_names for growth elements |
eb49c65 | Trac #19540: variable_names for terms |
5a4adf0 | Trac #19540: variable_names for asymptotic expansions |
d9f2796 | Trac #19540: `_factorial_` for terms |
c801853 | Trac #19540: rewrite factorial |
139f7c8 | Trac #19540: note on log(s).factorial() |
Replying to @cheuberg:
In principle, this would be fine; however, the following example fails:
sage: A.<m> = AsymptoticRing('m^QQ', QQ) sage: m.factorial() Traceback (most recent call last): ... TypeError: ... >>>>>> *previous* ArithmeticError: Cannot build log(m) since log(m) is not in Growth Group m^QQ * (e^(n*log(n)))^QQ * (e^n)^QQ * n^QQ * log(n)^QQ.
The problem is that the method tries to build the correct growth group in
n
(hard-coded) but has no influence on the given growth group.
Corrected (needed more rewriting than thought, but now factorial
can do much better)
And if we have something like
log(m).factorial()
, then everything gets more involved. This either needs to be fixed or documented.
Documented.
Branch pushed to git repo; I updated commit sha1. Last 10 new commits:
456d8c3 | Trac #19969: correct whitespaces |
b540598 | Trac #19969: add an additional doctest |
984ca4d | Merge branch 'u/dkrenn/asy/SA-generator-log' of git://trac.sagemath.org/sage into t/19944/asy/singularity-analysis-method |
e1e2ef3 | Trac #19944: minor restructure of code |
97249e7 | Trac #19944: minor improvement of docstrings (whitespaces, punctation, ...) |
ad62c31 | Trac #19944: show element in NotImplementedError |
9ce7b35 | Trac #19944: exchange order of parameters var and zeta in _singularity_analysis_ |
c79a6f7 | Trac #19944: exchange zeta and var in docstrings |
452c43b | Trac #19944: `_singularity_analysis_` methods: more precise documentation |
23948e4 | Merge branch 'u/cheuberg/asy/singularity-analysis-method' of git://trac.sagemath.org/sage into t/19540/asy/factorial |
Merged #19944 due to conflicts.
Changed dependencies from #19306, #19521, #19528 to #19306, #19521, #19528, #19944
self.parent()._var_.variable_names()
. I am wondering why they do not simply call self.parent().variable_names()
.if self.is_one():
return tuple()
else:
return self.parent()._var_.variable_names()
which would probably end in a desaster if called on a generic growth element, but we are not supposed to instantiate generic growth elements anyway ...
The rest is fine for me.
Replying to @cheuberg:
- The growth elements call
self.parent()._var_.variable_names()
. I am wondering why they do not simply callself.parent().variable_names()
.- Why can't a generic growth element decide on its own? It could simply call
if self.is_one(): return tuple() else: return self.parent()._var_.variable_names()
which would probably end in a desaster if called on a generic growth element, but we are not supposed to instantiate generic growth elements anyway ...
1+2: In the way it is it allows to build n.factorial()
starting in AsymptoticRing('m^QQ * n^QQ', QQ)
; self.parent().variable_names()
would not allow this.
Branch pushed to git repo; I updated commit sha1. New commits:
3bd6573 | Trac #19540: collect and compactify various variable_names methods |
Replying to @cheuberg:
- This would not change functionality, but the parent has a method, why not calling it.
- The generic implementation proposed here would be usable for all growth groups except products, but those have to implement their own method anyway.
Now I understand. Code rewritten.
Changed branch from u/dkrenn/asy/factorial to u/cheuberg/asy/factorial
I added a doctest because I wanted to know what happens for a generic growth group. At first glance, it was surprising that I do get an AttributeError
instead of a NotImplementedError
. The method is_one
seems to be contributed by the category.
I noticed that the docstring of GenericGrowthGroup
(and the other growth groups) says "It has to be a subcategory of Join of Category of groups and Category of posets. This is also the default category if None is specified." which is a relict from the past.
Furthermore, we have
# set everything up to determine category
from sage.categories.sets_cat import Sets
from sage.categories.posets import Posets
from sage.categories.magmas import Magmas
from sage.categories.additive_magmas import AdditiveMagmas
in the class GenericGrowthGroup
which shows all these Categories in the documentation, similar as #20045.
Shall we fix those in a separate ticket or right here?
Please cross-review my commit and set to positive_review if you are satisfied.
New commits:
0e6a0c5 | Trac #19540: additional doctest |
Replying to @cheuberg:
I added a doctest because I wanted to know what happens for a generic growth group. At first glance, it was surprising that I do get an
AttributeError
instead of aNotImplementedError
. The methodis_one
seems to be contributed by the category.I noticed that the docstring of
GenericGrowthGroup
(and the other growth groups) says "It has to be a subcategory of Join of Category of groups and Category of posets. This is also the default category if None is specified." which is a relict from the past.Furthermore, we have
# set everything up to determine category from sage.categories.sets_cat import Sets from sage.categories.posets import Posets from sage.categories.magmas import Magmas from sage.categories.additive_magmas import AdditiveMagmas
in the class
GenericGrowthGroup
which shows all these Categories in the documentation, similar as #20045.Shall we fix those in a separate ticket or right here?
This is now #20077.
Please cross-review my commit and set to positive_review if you are satisfied.
Done.
Changed branch from u/cheuberg/asy/factorial to 0e6a0c5
Use existing Stirling approximation to calculate the factorial.
Depends on #19306 Depends on #19521 Depends on #19528 Depends on #19944
CC: @behackl @cheuberg
Component: asymptotic expansions
Author: Daniel Krenn
Branch/Commit:
0e6a0c5
Reviewer: Clemens Heuberger
Issue created by migration from https://trac.sagemath.org/ticket/19540