Hi Florent, On Tue, 22 Nov 2011 09:04:13 +0100 Florent Hivert <florent.hiv...@lri.fr> wrote:
> Follow up from thread "indexed symbolic variables". > > > > > Do we have to call Maxima to compute the numerator of a rational > > > > fraction ? Is seems to me that Pynac/Ginac should be able to do > > > > it by themselves. > > > > > > > Unfortunately, we still call maxima for a lot of trivial > > > operations. > > > > This is now #12068 > > To speedup some computation I'm trying to wrap Ginac numer and denom > method. Thanks to Cython, this is very easy. However, Maxima and > Ginac have a different semantic for those two functions: > > - Maxima: Does not change the expression; if the expression is not a > quotient, then this will return the expression itself. > - Ginac: try to normalize the expression to put it in the form N/D > and then return N; > > For example, with an expression such as "x + y/(x + 2)", > > - Maxima: numer = x + y/(x + 2), denom = 1 > - Ginac: numer = (x^2 + 2x + y), denom = x + 2 > > I can more or less emulate Maxima's behavior with Ginac, but I'm not > sure what's best to do. I see several options: > > 1 - Forget about Maxima and follows Ginac semantic; > 2 - Follows Maxima semantic as close as possible using Ginac; > 3 - Have a parameter 'algorithm' to select the needed one. Depending > one the algorithm the semantic differ; > 4 - Have a parameter 'normal' to select if we normalize or nor the > result before computing the numerator, always use Ginac however. > 5 - 3 and 4, have two parameters, one for selecting Maxima or Ginac, > one for performing a normalization before. > 6 - other options ??? > > In case 3, 4, 5, we also should decide what is the default. > > What do you think ? I like 4 best, though I suggest calling the parameter 'normalize.' How do you plan to handle normalize=False? I suggest if the expression is not a mul: return self else: separate the positive and negative exponents Thank you. Cheers, Burcin -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org