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.
So?
In UnivariateTaylorSeriesCategory it says...
coefficients: % -> Stream Coef
++ \spad{coefficients(a0 + a1 x + a2 x^2 + ...)} returns a stream
++ of coefficients: \spad{[a0,a1,a2,...]}. The entries of the stream
++ may be zero.
Which means, if I implement the "coefficients" function by just
returning the stream [a0], that would also match the above
specification. It doesn't say anything about finite/infinite. It doesn't
even say whether all or just 1 or 2 or 3 coefficients should be returned.
BTW have you tried.
(12) -> c := coefficients s
(12) [0,1,1,1]
Type: Stream(Expression(Integer))
(13) -> c.10
>> Error detected within library code:
elt: no such element
And this is OK, because in Stream(S), S can be any set, so what would be
the distinguished element?
You first have to change the specification if you want coefficients to
always return an infinite stream. (Such a patch wouldn't get my
approval, by the way.)
How streams stored internally is another business. For example, with
your s above, the implementation is best if the test s=s is really
algorithmically decidable.
I just looked, but I couldn't find an issue. But I remember there was
some place where I also had the impression that there is some misleading
function... Perhaps this...
(1) -> s := [2]::Stream(Integer)
(1) [2]
Type: Stream(Integer)
(2) -> finite? s
(2) true
Type: Boolean
Oh no that does more look like a bug, because
(8) -> finite? [n for n in 0..]
(8) true
It comes from ORDCOMP(STREAM(NNI)).
This looks not really OK.
(9) -> explicitlyFinite? s
(9) true
Type: Boolean
because the documentation says...
explicitlyFinite?: % -> Boolean
++ explicitlyFinite?(s) tests if the stream has a finite
++ number of elements, and false otherwise.
and at the same time Stream(S) says
++ A stream is an implementation of an infinite sequence using
++ a list of terms that have been computed and a function closure
++ to compute additional terms when needed.
Actually the documentation for Stream is wrong, because Stream inherits
from
++ A stream aggregate is a linear aggregate which possibly has an infinite
++ number of elements. A basic domain constructor which builds stream
++ aggregates is \spadtype{Stream}. From streams, a number of infinite
++ structures such power series can be built. A stream aggregate may
++ also be infinite since it may be cyclic.
++ For example, see \spadtype{DecimalExpansion}.
StreamAggregate(S:Type): Category ==
So a Stream is actually only "possibly infinite".
> 1) there is no bug, we should only specify in coefficients that a
> finite stream means that the remaining coefficients are zero
I think this is the case.
> 2) series: Stream Coef -> % should require that the given stream is
> infinite. (but cannot check that of course)
But why?
> 3) we make the stream infinite in series. I don't know how one could
> do that.
Why?
Then you could not check s=s as I said above, so you would lose
computational power.
Ralf
--
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.