-
-
Notifications
You must be signed in to change notification settings - Fork 512
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
analytic combinatorics: new code for computing asymptotics for multivariate generating functions #10519
Comments
Attachment: mgf.sage.gz |
comment:2
Hi Alex, I can't address the mathematics on this one, but can give some hints about getting this reviewed.
Double-colons start verbatim blocks and sometimes print as colons. Sage code samples needs indentation.
All your functions won't be available in teh global namespace (where they could conflict with other). You should find an object (like maybe some kind of polynomial, especially if it is already int eh combinatorial library?) and make your functions be methods on that object. Thanks for your contribution - I hope the above is helpful for you. Rob |
comment:3
Question for you experienced Sage developers: how can i better package my code? I think it makes sense to move the major functions such as 'asymptotics' to methods in the class /Applications/sage/devel/sage/sage/rings/polynomial/multi_polynomial.pyx, but what about the subsidiary functions that don't concern polynomials in particular such as 'diff_prod' which calculates derivatives of products and solves equations? |
comment:4
Hi, I am currently at Sage Days 28. Right now, there is a discussion about How to structure a bunch of functions into classes? How to find which objects You are the best person to answer to these questions. You might have 30 The sage file you uploaded starts with :
Reading only these lines, I imagine the following structure: class HolomorphicMultivariateMeromorphicFunction(object):
# Constructor of the object
def __init__(self, F, G):
#stores important information on the object as attributes of self
self._F = F
self._G = G
def maclaurin_coefficients(self, n, alpha):
r"""
Return the maclaurin coefficients of self.
INPUT:
- ``alpha`` - tuple of positive integers
OUTPUT:
a python list of the first terms
OR
maybe an object of a class you implement if there exists pertinent
questions to ask to it.
"""
#Do some computations based (I guess) on self._F and self._G
intermediate_result1 = self.some_intermediate_computations_1()
#Do more computations
return something
def asymptotics(self, N, alpha):
r"""
Returns the asymptotics of Maclaurin coefficients.
"""
#Do some computations based (I guess) on self._F and self._G
intermediate_result2 = self.some_intermediate_computations_2()
intermediate_result3 = self.some_intermediate_computations_3()
return something
#put here all the others functions needed to compute the asymptotics
def some_intermediate_computations_1(self):
pass
def some_intermediate_computations_2(self):
pass
def some_intermediate_computations_3(self):
pass
... It also looks like you need some robustness somehow. But I need to know more
to decide whether this is checked at the creation of the object or before Hope this helps. Cheers, Sébastien Labbé, Montréal, (but currently at Sage Days 28, Orsay, France) |
comment:6
Hi Sebastien: Thanks very much for your helpful comments. I've been working on rewriting my code in an object-oriented way and will incorporate your suggestions. Some functions in mgf.sage, such as deciding whether a list of polynomials is algebraically dependent, are general purpose, and so i'm trying to put them into existing Sage classes. The others are more specific to asymptotics and deserve their own class similar to the one you outlined above. Robustness is also something i need to improve upon. I'll post my modifications here after i write and test them more. Thanks again. Alex |
Attachment: amgf_alpha_0_5.sage.gz New object oriented version |
Attachment: amgf.sage.gz Fixed a bug in cohomologous_integrand() |
comment:7
Hi Sebastien et al: I rewrote my code in object-oriented style. Please have a look if you have the time. Do i need to make the file into a patch, or is it useable as is? Thanks for your help. |
comment:9
Cool. I now see that a lot of the functions are now inside a class, which looks better. So, as I said earlier, this is not really my field of study, so I don't know how far I can go on that review. But, I can suggest at least two things:
To add your file to the documentation, you might want to look here. This winter, I gave a presentation on How to Contribute to Sage. This may helps you to start with Mercurial for instance. Also, right now, I am working on #11379 where I am adding a new file to Sage. You might find it helpfull to see how I proceed.
|
comment:10
To add a file to a patch, you must do:
I was not able to find this information anywhere which is strange... Tell me if you have questions. Sébastien |
comment:11
Thanks for your help, Se'bastien. I'm trying to put my Sage file into a patch by following your presentation slides, but am running into difficulties. I cloned Sage and copied my Sage file as 'amgf.sage' into /Applications/sage/devel/sage-araichev/sage/combinat/ I rebuilt Sage etc. and made it to step 10 "Test the changes" of your slides. But when i run Sage and test a few commands, Sage doesn't seem to see the QuasiRationalExpression class i created in /Applications/sage/devel/sage-araichev/sage/combinat/amgf.sage. I thought this might be because amgf.sage is a Sage file and not a Python file. So i renamed it amgf.py instead and got syntax errors. What's up with that? Do i have to rewrite all my code in Python instead of Sage? Thanks for your attention. |
comment:12
Hi Alex,
The basic answer is yes, but Rewriting is a big word for what is really Handling of integer
Importing stuffThe second big change is the necessity to import all what you need. More
You can ask Sage where to find PolynomialRing using:
This also correspond to the path starting after
I hope this helps, Florent |
comment:13
Just answering as a complement to Florent's answer.
To test your code in a Sage session, you will first need to import the good class (or function). For instance :
If you would like Sébastien |
comment:14
Thanks for the tips, Florent and Se'bastien. I'll get to work on converting amgf.sage to amgf.py. Alex |
comment:15
Hang on, can i somehow use the Sage pre-parser to automatically convert amgf.sage to amgf.py? Alex |
comment:16
Aha! The command 'sage amgf.sage' pre-parses amgf.sage and saves it as amgf.py. Thank you ask.sagemath.org! Alex |
Pythonified amgf.sage |
comment:132
I've now fixed all (at least I hope I got all) platform-dependent. Can someone please check with other platform than Linux, x86_64 on Intel i5-4690? |
comment:133
Replying to @vbraun:
Oh, I see (I thought, that display hooks sort by |
comment:134
Replying to @dkrenn:
I didn't see a difference from the original doctests on my laptop, so I can't give an explicit check. However, from looking over the doctestvs and Volker's failures, this seems to do the trick. Although I don't like the changes on 85c1f37. Instead, I think you should just explicitly check that the dictionary of solutions is the correct one:
|
comment:136
Replying to @tscrim:
Reverted and changed; indeed much nicer. |
comment:138
Thanks! |
Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:
|
Changed branch from public/combinat/10519 to |
This code is a collection of functions designed
to compute asymptotics of Maclaurin coefficients of certain classes of
multivariate generating functions.
The main function asymptotics() returns the first
N
terms ofthe asymptotic expansion of the Maclaurin coefficients
F_{n\alpha}
of the multivariate meromorphic function
F=G/H
asn\to\infty
.It assumes that
F
is holomorphic in a neighborhood of the origin,that
H
is a polynomial, and that asymptotics in the direction of\alpha
(a tuple of positive integers) are controlled by smoothor multiple points.
CC: @sagetrac-cyril-banderier @zafeirakopoulos @sagetrac-tmonteil @dkrenn @behackl
Component: combinatorics
Keywords: analytic combinatorics, multivariate generating functions
Author: Daniel Krenn, Alex Raichev
Branch/Commit:
a951f08
Reviewer: Daniel Krenn, David Loeffler, Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/10519
The text was updated successfully, but these errors were encountered: