On 02/21/2016 10:25 PM, Waldek Hebisch wrote: >> Since I have anyway a wrapper for Laurent series in my program, I >> changed the zero?(x) function there to destructively change x to >> (removeZeroes(x)). That works for my special case since I work >> with special Laurent series that allow algorithmic zero detection. > > Hmm. I consider calling 'zero?' on series as an error.
Sure. But as I said, I only work with a special subset of Laurent series where the zero test is decidable. > In fact I tried to modify 'zero?' for series to just raise error. > This discovered several places in algebra that depend on 'zero?' for > series. Yes. I would also consider that as a bug. > ATM I am keeping algebra as is to avoid loss of functionality. > However, the uses of 'zero?' I found are bugs: we are using > algorithms which were not desined to work with series and they may > produce wrong results or be very inefficient. Unfurtunately, proper > fix requires significant effort... Maybe you should publish a list of all your collected problems. >> But now the question is how and whether the current implementation >> of UnivariateLaurentSeries should be changed without too much >> impact on existing code that uses that domain. >> >> A good place to (destructively) change x when computing some >> function would be order: % -> Integer and order: (%, Integer) -> >> Integer. According to the documentation the order function looks >> for the first non-zero coefficient, so it needs to compute till the >> true order (or run into an infinite loop). I have no idea whether >> this place would be sufficient (probably not), but at least the >> series would behave a bit better. > > Maybe. But destructive modification is potentially troblesome, so I > would like to keep it confined to small number of places. Agreed. In fact, I didn't say that mathematically anything is incorrect. And I know that doing destructive changes might lead to problems in places that one would never expect. I could even live without changing the code, if there were a big warning in the docstring of UnivariateLaurentSeries about the trouble that one can hit (just like the one that I ran into). The domain already exports "removeZeroes", but unfortunately the domain description doesn't clearly say that one should call this function so that multiplication does not become to costly. Anyway, I think "order" would be the right place. >> One could additionally think of checking whether after addition >> (or multiplication in a ring with zero divisors) the leading >> coefficient is zero and thus increasing the order by at least 1. In >> fact, I think it would be a good idea to try checking the >> coeffients as long as the order is negative and stop at order=1 if >> all coefficients are 0. Furthermore, for a series x that yields >> n:=getExpon(x)>0 one would test (at most) n coefficients to get >> closer to the true order of the series. > Oh, no. Testing for zero is potentially troblesome, so we want to > have as little zero tests as possible. And you propose new tests... Yes. I somehow agree with this view. But if (before multiplication) I don't call removeZeroes on the arguments, I might end up in the problem that let me to all this investigation. Another solution could be to rename the current UnivariateLaurentSeries into LazyUnivariateLaurentSeries and create a new domain UnivariateLaurentSeries that more eagerly removes leading zeroes. > Loss of lazyness is a no go: it would break most computations with > series. I was thinking about this, but couldn't find an example that would convince me of not doing zero tests on the coefficients. BTW, UnivariateLaurentSeries is lying. It claims "Ring", but has no computable zero test. So I can use UnivariateLaurentSeries as a coefficient domain. That this must lead to trouble is clear. Eventually, we should remove all this lying in Algebra. > Take into account that standard series domains are dense (they keep > zero terms). Zero terms in the middle are not that bad if my series have only a few nonzero terms. What bothers me are the needless leading zeros. And you probably agree that seeing degree(x)=-4000 where order(x)=4 is quite bad. > We also have "sparse" series domains, you can try them. Yes, I'll try. But it's anyway not bad to think about needless leading zeroes in dense laurent series. I've already started with a patch, but I couldn't finish it today. Ralf -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
