Hi, working with powerseries has quite some traps.
Suppose, p is an infinite powerseries and p' is it's inverse. Then c=p*p' is a series that only has zero coefficients after the constant term. Then creating the stream of (coefficient, exponent)-pairs, i.e. calling terms(c) leads to a stream that cannot compute its second entry. http://fricas.github.io/api/UnivariatePowerSeriesCategory.html#l-univariate-power-series-category-terms Z ==> Integer Q ==> Fraction Z L ==> UnivariateLaurentSeries(Q, 't, 0) t := monomial(1$Q,1)$L p := 1/(1-t) pp := 1/p c := p*pp s := terms c; s.1 s.2 Yes, it's clear that it cannot return anything, because it is just looking for the next non-zero coefficient (which doesn't exist). Nevertheless, wouldn't it be advantageous to add a remark to the specification of the terms function that one should be careful with series that are not (constructively) known to be finite. For example series terms c does not give a laurent series that one can ask for the second coefficient. Proposed patch is attached. Opinions? 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 fricas-devel+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
From fb5bd8b27e4067c9adaa692d853298f4e5e84688 Mon Sep 17 00:00:00 2001 From: Ralf Hemmecke <r...@hemmecke.org> Date: Wed, 28 Nov 2018 19:07:04 +0100 Subject: add warning to "terms" function documentation --- src/algebra/pscat.spad | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/algebra/pscat.spad b/src/algebra/pscat.spad index 7cdd62e6..6a7dfbe4 100644 --- a/src/algebra/pscat.spad +++ b/src/algebra/pscat.spad @@ -85,6 +85,9 @@ UnivariatePowerSeriesCategory(Coef, Expon) : Category == Definition where ++ \spad{terms(f(x))} returns a stream of non-zero terms, where a ++ a term is an exponent-coefficient pair. The terms in the stream ++ are ordered by increasing order of exponents. + ++ Warning: If the series f has only finitely many non-zero terms, + ++ then accessing the resulting stream might lead to an infinite + ++ search for the next non-zero coefficient. --series: Stream Term -> % --++ \spad{series(st)} creates a series from a stream of non-zero terms, --++ where a term is an exponent-coefficient pair. The terms in the -- 2.17.1