Max Alekseyev on Thu, 09 Mar 2023 12:09:51 +0100


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

Re: logint() bug?


I'd assume logint(x,b) is just an accurate implementation of floor( log(x) / log(b) ) and from this perspective I do not see why there is a need to restrict it to x >= 1. Let it have the same domain as log(x), that is x > 0, and make it work there.
Regards,
Max

On Thu, Mar 9, 2023 at 4:02 AM Karim Belabas <Karim.Belabas@math.u-bordeaux.fr> wrote:
* Bill Allombert [2023-03-09 09:52]:
> On Wed, Mar 08, 2023 at 10:19:12PM -0500, Max Alekseyev wrote:
> > I see the following inconsistent results, while in both cases I expect the
> > result to be -1. Bug?
> >
> > ? logint(.5,2)
> > %1 = 0
> >
> > ? logint(1/2,2)
> >   ***   at top-level: logint(1/2,2)
> >   ***                 ^-------------
> >   *** logint: domain error in logint: x <= 0
> >   ***   Break loop: type 'break' to go back to GP prompt
>
> This is why my original implementation of logint only allowed integers...

Yes, the documentation is faulty: logint(x, b) should require
x >= 1 real number (instead of x > 0).

It may work in other cases, but the implementation doesn't support it
(and there's no way to support it efficiently)

I'll fix the doc.

Cheers,

    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/
`