Bug? LaurentSeries as LaurentPolynomial

14 views
Skip to first unread message

Ralf Hemmecke

unread,
Oct 21, 2020, 3:51:40 PM10/21/20
to fricas-devel
It is clear that in general there is no decidable zero test for power
series, however, we have the function truncate: (%, INT) -> % that
basically creates a finite series. I hoped that it were possible to use
UnivariateLaurentSeries together with this truncate function to
essentially work with Laurent polynomials. I ran into a problem that I
did not expect.

With the attached file I get.

(9) -> zero? l0

(9) false

(13) -> zero? t0

(13) false

In fact, I consider this a bug. It is clearly possible to decide that l0
and t0 are 0 since their corresponding stream should be finite and at
most contain zeros.

Waldek, I can look into it if you also want the above return true.

Ralf

laurentzero.input

Ralf Hemmecke

unread,
Oct 21, 2020, 5:30:43 PM10/21/20
to fricas...@googlegroups.com
Oh, a solution is simple.

I got

(35) -> coefficients l0

(35) [0, 0, 0, 0]

So

(36) -> zero? removeZeroes l0

(36) true

Unfortunately, UnivariateTaylorSeries has no "removeZeroes". Maybe it
should be added?

(54) -> tx := x :: T

(54) x

Type: UnivariateTaylorSeries(Fraction(Integer),x,0)
(55) -> t := truncate(sin tx, 7)

1 3 1 5 1 7
(55) x - - x + --- x - ---- x
6 120 5040

Type: UnivariateTaylorSeries(Fraction(Integer),x,0)
(56) -> tt := t-t

(56) 0

Type: UnivariateTaylorSeries(Fraction(Integer),x,0)
(57) -> coefficients tt

(57) [0, 0, 0, 0, 0, 0, 0, 0]
Type: Stream(Fraction(Integer))
(58) -> zero?(tt)

(58) false
Type: Boolean

The following can, of course, be explained, but it looks strange to me.

(63) -> (tt =0)@Boolean

(63) true

And if I truncate at 20, then (tt =0)@Boolean also returns false.
Nevertheless, I don't think that it is a good idea that zero? and x=0
behave differently.

Ralf

Waldek Hebisch

unread,
Oct 21, 2020, 6:24:18 PM10/21/20
to fricas...@googlegroups.com
On Wed, Oct 21, 2020 at 09:51:35PM +0200, Ralf Hemmecke wrote:
> It is clear that in general there is no decidable zero test for power
> series, however, we have the function truncate: (%, INT) -> % that
> basically creates a finite series. I hoped that it were possible to use
> UnivariateLaurentSeries together with this truncate function to
> essentially work with Laurent polynomials.

I do not know what you really want. We have LaurentPolynomial.
The whole point of our series is that they are lazy. In
particular 'truncate' is lazy and other stream operations
can not see that stream is finite.

> I ran into a problem that I
> did not expect.
>
> With the attached file I get.
>
> (9) -> zero? l0
>
> (9) false
>
> (13) -> zero? t0
>
> (13) false
>
> In fact, I consider this a bug. It is clearly possible to decide that l0
> and t0 are 0 since their corresponding stream should be finite and at
> most contain zeros.
>
> Waldek, I can look into it if you also want the above return true.

I would prefer to remove 'zero?' and equality for series...

ATM equality gives different result than 'zero?', that is not
nice. OTOH this is something that original developers apparently
wanted, the offending 'zero?' is implemented as categry
default in UnivariateTaylorSeriesCategory, while otherwise we
would use 'zero?' from AbelianMonoid. The only reason I see
for adding such 'zero?' is that 'zero?' may be called
without need.

It would make some sense to remove definition from
UnivariateTaylorSeriesCategory, but in general, if
you want reliable equality then use finite domain...

--
Waldek Hebisch

Waldek Hebisch

unread,
Oct 21, 2020, 6:34:00 PM10/21/20
to fricas...@googlegroups.com
On Wed, Oct 21, 2020 at 11:30:41PM +0200, Ralf Hemmecke wrote:
> Unfortunately, UnivariateTaylorSeries has no "removeZeroes". Maybe it
> should be added?

By definition for Taylor series all coefficient must be present,
so no way to implement "removeZeroes".

--
Waldek Hebisch

Ralf Hemmecke

unread,
Oct 22, 2020, 12:57:42 AM10/22/20
to fricas...@googlegroups.com
> We have LaurentPolynomial. The whole point of our series is that they
> are lazy.

Lazyness is not totally important, but might be, because my series might
grow rather fast and with complicated coefficient formulas.

Actually, I thought I could stay in UnivariateLaurentSeries for two
reasons. (1) There is no simple conversion from series to polynomial
without much much conversion and (2) when I failed with easily just
calling an existing function for (1) I realized that truncated series
could do the job and would avoid the computation of coefficients that
are not important for the result. In fact the truncation will happen in
a place with a bound that maybe much to high. So yes, I would prefer
lazyness.

I will try to program a new domain that inherits from
UnivariateLaurentSeries, but overrides the zero? function.
No idea whether this TruncatedUnivariateLaurentSeries could be
interesting for inclusion in FriCAS.

Ralf
Reply all
Reply to author
Forward
0 new messages