Karim Belabas on Fri, 09 Feb 2024 19:31:30 +0100
|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: floor(tanh(91)) depends on the precision
|
- To: pari-dev@pari.math.u-bordeaux.fr
- Subject: Re: floor(tanh(91)) depends on the precision
- From: Karim Belabas <Karim.Belabas@math.u-bordeaux.fr>
- Date: Fri, 9 Feb 2024 19:31:06 +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=1707503468; c=relaxed/relaxed; bh=2Io2XG+B+gTOn4lh9Epd2637jW/XMjCar79b5NucFTE=; 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=rTFByJabg0frSWu7xrY82yTJ3kkECNP3dlyHYFmdqzQzHwwxRkTESNPGIs3rzqksIFZWQjh7h1CtzGeRvCFWNoDbGv3X2jHIvgF0p7WN6sKQsU3HsPYWMyghGsVIgrJysLQZkYO95hoaiB1UdgKWV2cBcPt7sb3RXKI8t16PSBXdi2NjzajM8Zr0pcgDLH9qM1C7DsLtdRbG11IQAca6PdoOaNfpSfpqUBlidTQDfxxDR1RM8+dwxTfUHTa0XA0Dowb9gqSUqK2ZCcHa4C3Oi6A59I7UQy3npXOiXrpPZ2+zX+owBNkuaTIy0aa/105awMubEl0uFahmjEROOHeCJrfwt/t/AbjaYB8XaqDOGOSWpnx4OajISREjnkY9uBLyry0Psnj+mopjt8vtgVI14L8YtcpiphcuB+rc9P2hWdVHC9DRrUSyDx/yD8ybAhSRrUgsgjXViw7ayaTO6KfN24jNX3lVKW0IRu2u9NPMiWJ1DTAsNxZQOMkWKou9mUBMQlCJnGIzHmbR0fFUzIjmXhrrwVwIVGugxIFufcxPkIm3j1WUqgr0KzwHTSa3omo+6uuLBoU2VBT+9A4A6oyvl8BcTJjT1dK3FTQZL0HNIrwqFVdzIIazheAa4Fg5P8TiUiTwIN7tZCEIPb02RV5bRJH8z+7HUGU0oTIpYPNaDSo=
- Arc-seal: i=1; a=rsa-sha256; d=math.u-bordeaux.fr; s=openarc; t=1707503468; cv=none; b=ddr/JnfB7JdO2SF9eP+lQKJR71lrvzVXe2do81+p5bIOuxzDy5tivfhRb+JfRUWi+GMqBhq6/vqlVylRPsfa2Zs+R4RlmbcKVq88Q8/blY9uY/vnWl+P2DWxvJ/c/rRY4QJUC9C+bTzxGNgon40Z9fIAxDxIF00vbgLCRnfjgk8QCpsJHfhRESxOfuD3d2FzTDBxGwLLBUyCSzoxKucV9w+zVdJDg2mGsM8xKq7XrOALHkyEB200NzCT9pLrnPrKYHs4tr5cgpwrZCAZrLcoptmc4AYYb5QqwCdjV40Kx+jnY2c/2vPqsuhn4wqm4gti/3A79I9YOiBkr4md2sgfqqnBCf33s09y3E/2zYkx07CrFW1laNbTy503T0hLma0IFjYsCaUJGRqHSFk96+d5bRvdGY5UQWswhtnOoKqikUpWi9LZJ0NtN+GH28nQpkOCezzF+jqtEyBvNmIsAzqFe0g6Jhq7seeASzCX7znLEwQoqRlN5zIcrQQdwB4JoTZiQltmgc2wp6OSkMeuC6sg8R5E1DWArM5UVBPXjSsHvTlKf3hsLCBjIWhdNaMziDtEsYd9Tch4a755cyH/3CGTlT3JdYxuxlIK6WOirM0LQYNphSdPGAyDfidu5SOyXE+OPAQGgHIIWZN10lzoqP8xPJXWUkqEIE2nE+2LyvE2Nts=
- Authentication-results: smail; dmarc=none header.from=math.u-bordeaux.fr
- Authentication-results: smail; arc=none
- Delivery-date: Fri, 09 Feb 2024 19:31:30 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=math.u-bordeaux.fr; s=2022; t=1707503468; bh=2Io2XG+B+gTOn4lh9Epd2637jW/XMjCar79b5NucFTE=; h=Date:From:To:Subject:References:In-Reply-To:From; b=dhVZoUTbPf+kPTsFAdQr2HACXyB5aLkcE3HY6ShgKLMxzmUdwetMCnWge5lbdpWnf gN6UUHFHXUGVOtm7pCiTlLVo+OuFiv+056yKIxraUQmSiJrDCrDeBFzkfModkeBWry b7Qujx4M8jzLuh6gjtbeI6fzTl3kKGESgz+grqHBD5jidykqJ7kM0fLreuNKawO3QF 7FIeJBgFFxemBGXBjabCXAfip44FvoM6dlZI9jLOjAKzcdjmVh9tvbLHR3AZGU99QD /jgmpUNpqNJP1kOXCcVsl8wOl+RwlBgNNJD/VF7zs5GLqhUyZx9JDYTna8l6BQOsDe GwA+Itb9vCRA0MN2SKEj53HDqVMaLIOuWiTz6WPit3n/7/H+empvibM2NJPTmecmQp gBYWRwIdApMaeutYgwzyMMI7FAvU59Fi1PVC2JtKh3ypnsec5XwPRa4o7D7r8AyR4M Q5T3AONAwOfLKKi3SgI+TPUjkAZJG78ard8ubiZSQBkvTvxot4kO8Mr880WvEAPPq7 kei46ZRmqBdHmqRWT0Yfrgp/7h8wMRHR49ka9qobLnx8B6lot63tLjq6c55C90G6Dd irDlscJ9//dtwnn0Sqw4l71uM6sbEQu/OnSlBpm4JI2ddemIhFLrFp3sBLhIOZAmgm LX7n/3lcrvLFmO0OVNKvp7Jg=
- In-reply-to: <d949ec01-1782-407f-b41a-590c8b13c31a@isolution.nl>
- Mail-followup-to: pari-dev@pari.math.u-bordeaux.fr
- References: <CAGUWgD_FC94LOK9HoPqcv+NgKmdZG9GCAMR4xUbyzCN+3548ug@mail.gmail.com> <d949ec01-1782-407f-b41a-590c8b13c31a@isolution.nl>
* Ruud H.G. van Tol [2024-02-09 18:48]:
>
> On 2024-02-09 18:25, Georgi Guninski wrote:
> > There was discussion about this on sage-devel mailing list.
> > I don't claim it is a bug, just FYI:
> >
> > ? floor(tanh(91))
> > %1 = 1
> > ? default(realprecision,10^4)
> > ? floor(tanh(91))
> > %3 = 0
>
> ? default(realprecision, 79)
> ? tanh(91)
> %2 = 0.999...
>
> ? default(realprecision, 78)
> ? tanh(91) < 1
> %3 = 1
>
> See also https://www.wolframalpha.com/input?i=tanh%2891%29
> and click on [More digits].
Not a bug, rather an intrinsic limitation: 'tanh(91)' means
"converting 91 to floating point at the current default accuracy then
return the floating point number tanh(91.0)".
.
The tanh function is computed as (t-1) / (t+1) for some huge t = exp(2*91.0);
but at low accuracy, we have t - 1.0 = t + 1.0 = t (if t is large enough),
using standard floating point computation rules.
In fact, the tanh function returns a floating point number which is exactly
equal to 1. Hence it's floor is computed correctly as 1.
The return value is actually close enough to the actual result: we do
have |tanh(91) - 1| < 10^(-78) in exact arithmetic (using mathematical
definitions, not floating point arithmetic), so PARI's result conforms
to the specification.
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/