Karim BELABAS on Tue, 7 Jan 2003 04:04:48 +0100 (MET)


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

Re: gp: gcd(0), tan(Pi/2) error messages unhelpful


On Mon, 6 Jan 2003, Michael Somos wrote:
> ? gcd(0)
>   ***   incorrect type in association.
> ? \p29
>    realprecision = 38 significant digits (29 digits displayed)
> ? tan(Pi/2)
>   ***   division by zero in R/R
>
> These error messages are unhelpful. In a program which calls these
> in lower-level functions, it is not easy to figure out where these
> error messages came from. While not bugs in 'gp' itself, they can
> make finding bugs in user function difficult. Shalom, Michael

The second one is easy to fix:

(03:57) gp > tan(Pi/2)
  ***   can't compute tan(Pi/2 + kPi).

For the first one, it's more awkward. The error occurs in the generic wrapper
for divide/conquer computation of (associative) operators. Currently the
wrapper does not know the name of the calling function. So a more cumbersome
interface would be needed [ either check a return value, or pass the routine
name as a further argument for the sole purpose of a potential exception, or
setup an exception trap ]. Not worth it, I think.

Would
 ? gcd(0)
   ***   incorrect type in associative operator

be clearer ? [ the wrapper can currently be called by chinese, gcd and
lcm ]

    Karim.
-- 
Karim Belabas                    Tel: (+33) (0)1 69 15 57 48
Dép. de Mathématiques, Bât. 425  Fax: (+33) (0)1 69 15 60 19
Université Paris-Sud             Email: Karim.Belabas@math.u-psud.fr
F-91405 Orsay (France)           http://www.math.u-psud.fr/~belabas/
--
PARI/GP Home Page: http://www.parigp-home.de/