Bill Allombert on Mon, 22 Jan 2024 13:22:46 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
- To: pari-users@pari.math.u-bordeaux.fr
- Subject: Re: log_int_rat
- From: Bill Allombert <Bill.Allombert@math.u-bordeaux.fr>
- Date: Mon, 22 Jan 2024 13:22:26 +0100
- Arc-authentication-results: i=1; smail; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1705926150; c=relaxed/relaxed; bh=i+i0RGyhqLH7+H/14TV0mj9YxI3oRMfVWTcybGxZrYc=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:Mail-Followup-To: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; b=wRmkfKiZMM5Wgb6tsZy4GuSwAkhiIZs7kkDX8TerThuyrwggxbjx5OSVeW6QAEqe2ChTw7OceR2+8APp2HXW+axHd95Zk7XzSZdx1jper2O232rJbzwR5+w+VZgzQmAIGwFUFo5QPvfU3270IiJRwOMUA/MsZmCX5EFjKMH9hnVELo4UdywHPmYhq3FFZb3dDvILt+L7uVDwWWDEK1Zwpz12OcsaeCX7+96Q4jmrq0pZNvlt/l5TqE8mSS+fWcej83XE7A2A/ehWgH4HQH2f92Y8HhmC/lHxAdP4M2xF2l7Pwf1z9dZZW9fkrTvlJih4gXkM4xCUjNEQn4xz2uWkTcPuFCFWArfhafS6afALEK5AEhFW4CZE4zSwMaZC2BSryaKcf9uh3iMClb590A71ZitJcq4+xErDvTaRne6kxwe/i7855sXQf8KICKJikF73WQwspDrCP30gRwxMzDeK0MXlfJBD6N3TOEC9L1FCMepIj51dD2hBeXx75Z5hIGH9jBHKwYYcFMspJZZJLmQQP+YoXRy820P1l/K5tz1JCyKKKtAtpTS1YxwUWGpVBBUdY6IXPViQinV+pqZxR/eIuxXcC9FYnBPlLcepMdx2OybCHDorEvorIbgEwd2KSf7TQq2ul73H+deuWbRintZsDnc47STWrN+kj4UpGjy8zbI=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1705926150; cv=none; b=JLYcsLkFTo+Eq1ZBfSzB09oLyp73Uh+jlAzqPEzEjoFs8+F4zW/DucMY3HxC+QcaKTi+vJr+NokooFkeguGByAzRN2IF9c0fCuTtAqM/j/SnlfEgbLlC0OCbBarrvDgQCGGd9Nlo8GldbksQ6OTjUXDKlu+tKsQLQ2zMs22uy9u9XiYWvQcysNo7StsWv5xa1oTi3IrhGOz/B/vYWLh2g6zZ6usl1ifCJzqFDOhPAx3S3wNDAs1S3aPB7e6WxpAXacfBvgBR9Xdmng0iyH2kIdStPQiOOOlC4yad0MY1NKAIVpgBH8N1b6JlOjCGlFdudqhoJY8BvE3PImMurQmD++fNCTDXPRulgescGPH6oqCouMfUUSa6cgR1UcFk6soIJZpv8QIu3ME/P5/thz//vyRDBDppvhYG4F9H7a66ldrRo6B1Fn1jRofdnmzxoRvYNiv/Zgqyx/rSnZN6S6oQOErhtwAVX6aCO8ogUN0IOBXC+TjZFYr6SKW7VrYuedH4VthmIo2Y08hmpJ04pRGrU5niDUdSN1NMb4A9at2OSuFror5X+1cmiiTAW9k5XGwI4AzGPgzyGCtlRl0Bh++tJIPmXN6omDaRFjAB9nEKLcFrHMuccS/wI8CCiQvI8jPRu7F9inifKwdxIjZLwhSkjI+cu42plHq4VN9Ya0zrhZA=
- Authentication-results: smail; arc=none
- Delivery-date: Mon, 22 Jan 2024 13:22:46 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1705926150; bh=i+i0RGyhqLH7+H/14TV0mj9YxI3oRMfVWTcybGxZrYc=; h=Date:From:To:Subject:References:In-Reply-To:From; b=uk3eb5NuX8Y0t4OVIla/uV/MOPtKv8Ky33yBJq1rsAjOnvYU1Rt559VE7DmFEvUqB bxMALwK0GrnkKxJNxWjSc2mMQ4M4jPykDcGrSpIBiejcArAQ22ENpQJFkXt6pm12cs jUZQhrZlfDF8HazpoYQkiIqcm8w5mI0TaO4uqJED9GfVAqUcmH6Kpm1x0LN3h+gOsf SkGUnpLI77eL3rEOBhTUPTNZVTJX1LJmC2hiomk4nyCfdMzb+C7zP1SEJrH41gxR+M +9kGKvAl0NlZO7OM+PMPhS3szaDOuj1UNyETtEOu87Hm1pZ428v0PhumJAl+TTZMVA oZVLw8Uc7PuKL8+U6eMoM9hEaBFpjtUFmSwaUPitvkF0H4Eks6qjW1799LwSth6UUM /+C6kWjrTS9PJdLTqVzbARu5MIoMdzdQtoHMB+vvEP8xFlxI1f5xUCTYN7IhcKaXvs g60hX4H0iROItC42immgtwHv1XBmWVltGLlIMf+Yr3iyDye6go2yEzxxesaaSGHMz2 +ah5ytDP+gvj7SK70MOEeMfJfdERgzxRVw+kEQjIh+7w/MNopGmK4foaCAqUxHP+n2 h3T4gXYyosiLmGf6oe0HJLNoHuWL34ZQ95e/l+N0Zo5RXVrK2KbtPtFsf5/zEhgfnQ 4y8+C2Ea/G5S7tvposkWXGD8=
- In-reply-to: <168b6d04-075b-49c6-b89d-ab3b376fd8b5@isolution.nl>
- Mail-followup-to: pari-users@pari.math.u-bordeaux.fr
- References: <b7806246-4381-4aee-8cd6-8fcf0a16e40c@isolution.nl> <ZWeccfBdhkWy3DpL@seventeen> <7137957c-e6e5-48aa-b81d-6d21f49c53f3@isolution.nl> <0bd27b4e-5754-4ce4-943b-607e588990f2@isolution.nl> <001a5277-817e-4c70-8e14-b0bcaffc22e7@isolution.nl> <168b6d04-075b-49c6-b89d-ab3b376fd8b5@isolution.nl>
On Mon, Jan 22, 2024 at 11:56:29AM +0100, Ruud H.G. van Tol wrote:
>
> On 2024-01-22 11:25, Ruud H.G. van Tol wrote:
> > [...]
> > On the non-discrete code branch:
> >
> > a(n) = localbitprec(logint(n+2,2)); 1 + n + floor(n*log(2)/log(3/2));
> >
> > with test:
> >
> > {default(parisizemax,2^30); my(v=alist(2^20)); for(n=1,#v,
> > (v[n]!=a(n-1)) && print(n);break);}
> >
> > I received this report:
> >
> > > that code wrong result a(83690) = 226760 (in a 32-bit pari)
> > > with no hint that it didn't know right from wrong.
> >
> >
> > ? my(v=alist(83700)); v[83691]
> > cpu time = 485 ms, real time = 490 ms.
> > % 226759
>
> My current guess is that it needs something more like
> localbitprec(2*n+1); ...
No, the issue run deeper than that.
? 83690*log(2)/log(3/2)
%19 = 143068.9999732032502851373630
To get the correct floor() you need to 'skip' the four 9 digits.
Now consider this other example
? \p200
realprecision = 202 significant digits (200 digits displayed)
? 282896829528374*log(2)/log(3/2)
%22 = 483615324366282.99999999999999972480016707721405476228331340155888020025561304044368677831069845019580206096595446347432023644929708447688723054552955187462035282662255837003805169825570885964555199
Here you have to skip fifteen 9 digits.
So unless you have a formula for the maximal number of 9 or zeros that can
appear, you cannot get a sufficient precision.
Instead I offer this (written while waiting for the water to boil, so be careful)
safedigits(f)=
{
my(z=f(),e=exponent(z),k=3,r);
while(1,
my(K=10^k,y=round(K*z,&r));
if (r<0 && (y+1)%K>1, return(y\K));
k*=2;
localbitprec(e+4*k);z=f());
}
a(n) = localbitprec(logint(n+2,2)); 1+n+safedigits(()->(n*log(2)/log(3/2)));
Cheers,
Bill