Karim Belabas on Sat, 29 Oct 2022 14:29:31 +0200 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: arithmetic operations with t_INFINITY |
* Max Alekseyev [2022-10-29 13:40]: > Bill, I do not quite follow. The issue you describe will not appear if > comparison of oo with oo is forbidden (which should be the case). It a general "philosophical" issue. Right PARI is highly permissive and many operations are provided without being formally defined anywhere in the documentation ; "sensible" defaults being provided on a case by case basis and hardly ever tested. This is a really bad thing which took years to fix partially. Right now the only thorough tests we have for arithmetic operations generate randomly complex objects and test arithmetic properties that "should" hold. Then some exceptions are introduced in the system to cater for exceptions, etc. E.g. a SEGV is always bad, some errors are acceptable as are most cancellations, then some identities just don't hold to the expected generality. Right now, t_INFINITY is not an arihmetic type and all operations result in an error: clean and simple. If we start allowing addition and multiplication, then why not division (then \ and \/), then most arithmetic operations. And each operation on every pair of types should be properly defined, then implemented. For instance, 1 + I*oo can make a lot of sense (say, you're integrating on a line Re(z) = 1), and why not quadgen(5) + oo since quadgen(5) gets typecast to (1 + sqrt(5)) / 2, etc. And it's difficult to prevent an arithmetic type from becoming a polynomial coefficient. Even if we draw some arbitrary line somewhere as to what is supported and what is not, it will take some effort to document it properly, then really enforce it in code, then test it ! Lots of work, no motivation (except "it could be made to work, eventually"). Cheers, K.B. > On Sat, Oct 29, 2022, 5:12 AM Bill Allombert < > Bill.Allombert@math.u-bordeaux.fr> wrote: > > > Le Fri, Oct 28, 2022 at 04:13:49PM -0400, Max Alekseyev a écrit : > > > It seems reasonable to expect that "123 + oo" or "-567 * oo" should > > > evaluate in "+oo" and "-oo", respectively, but at the moment they both > > > result in the "forbidden" error. > > > Can support of basic arithmetic operations for t_INFINITY be added? > > > Of course, undefined operations such as "oo - oo" should still produce an > > > error. > > > > When we added oo, we decided that we would not allow arithmetic operations > > with > > infinity because they are not well defined and and not obey the usual > > equations: > > a+x == b+x => a==b > > etc. > > so this can only lead to strange bugs. > > > > Cheers, > > Bill. -- Karim Belabas, IMB (UMR 5251), Université de Bordeaux Vice-président en charge du Numérique T: (+33) 05 40 00 29 77; http://www.math.u-bordeaux.fr/~kbelabas/ `