Karim Belabas on Wed, 14 Feb 2024 16:57:02 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: polcoef: domain error in polcoef: degree > 9999


Hi Max,

  it's not just an error message, it's a message generated by an
uncaught exception. In the current situation

(16:42) gp > polcoef(x+O(x^3),10)
  ***   at top-level: polcoef(x+O(x^3),10)
  ***                 ^--------------------
  *** polcoef: domain error in polcoef: degree > 2

The exception is structured: it has type 'domain error', and specifies
that the parameter 'degree' is out of bounds in function 'polcoef',
since the maximal allowed value was 2. It could be trapped (using iferr)
and analyzed by functions higher up in the call chain.

For instance, converting the exception to a vector type gives access
to its "components"

(16:42) gp > Vec( iferr(polcoef(x+O(x^3),10), E, E) )
%1 = ["e_DOMAIN", "polcoef", "degree", ">", 2, 10]

and one further learns that the problemative value was 10.

An error message "polcoef: degree exceeds the series order" would
actually be much less informative. (Flat character string: no easy way
to parse it programmatically.)

Cheers,

      K.B.

* Max Alekseyev [2024-02-13 15:10]:
> Please ignore my question - I did not realize I'm extracting the
> coefficient of a series rather than polynomial, and it was beyond the
> series order.
> On a related note, it may be worth making this error message more
> informative - e.g., remove a particular number and say that degree exceeds
> the series order.
> Regards,
> Max
> 
> On Tue, Feb 13, 2024 at 9:02 AM Max Alekseyev <maxale@gmail.com> wrote:
> 
> > This error seems to be new and raises the question:
> > How to extract coefficients of degree > 9999 ?
> >
> > Thanks,
> > Max
> >

    K.B.
-- 
Pr. Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique
Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77
http://www.math.u-bordeaux.fr/~kbelabas/