I just noticed the following behaviour, which I find surprising:
(2) -> s := taylor(x+x^2+x^3,x=0)$ExpressionToUnivariatePowerSeries(INT, EXPR
INT)
2 3
(2) x + x + x
Type: UnivariateTaylorSeries(Expression(Integer),x,0)
(3) -> s.10
(3) 0
Type: Expression(Integer)
(4) -> coefficients s
(4) [0,1,1,1]
Type: Stream(Expression(Integer))
In words: the stream of coefficients is finite, but getting the n'th
coefficient works.
I think that the stream of coefficients should always be infinite, but
I'm not sure. There is possibly a penalty: currently we have in
InnerTaylorSeries(Coef): Exports == Implementation where
Exports ==> Ring with
coefficients: % -> Stream Coef
++\spad{coefficients(x)} returns a stream of ring elements.
++ When x is a univariate series, this is a stream of Taylor
++ coefficients. When x is a multivariate series, the
++ \spad{n}th element of the stream is a form of
++ degree n in the power series variables.
series: Stream Coef -> %
++\spad{series(s)} creates a power series from a stream of
++ ring elements.
++ For univariate series types, the stream s should be a stream
++ of Taylor coefficients. For multivariate series types, the
++ stream s should be a stream of forms the \spad{n}th element
++ of which is a
++ form of degree n in the power series variables.
stream : % -> Stream Coef
stream x == x pretend Stream(Coef)
series st == st pretend %
coefficients x == stream x
and
UnivariateTaylorSeries(Coef,var,cen): Exports == Implementation where
coefficient(x,n) ==
-- Cannot use elt! Should return 0 if stream doesn't have it.
u := stream x
while not empty? u and n > 0 repeat
u := rst u
n := (n - 1) :: NNI
empty? u or n ~= 0 => 0
frst u
elt(x:%,n:NNI) == coefficient(x,n)
thus, UTS works explicitely around the possibility that the stream is
finite. I see the following possibilities:
1) there is no bug, we should only specify in coefficients that a finite
stream means that the remaining coefficients are zero
2) series: Stream Coef -> % should require that the given stream is
infinite. (but cannot check that of course)
3) we make the stream infinite in series. I don't know how one could do
that.
I think I like 2) best, but I'm not sure.
Martin
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.