Article View: comp.lang.forth
Article #180Re: bug in mpfr-3.1.0
From: Krishna Myneni
Date: Mon, 26 Oct 2026 20:35
Date: Mon, 26 Oct 2026 20:35
100 lines
4841 bytes
4841 bytes
On 10/25/26 9:48 AM, Krishna Myneni wrote:
> On 10/24/26 17:44, marcel hendrix wrote:
>> On 10/24/2026 8:29 PM, Krishna Myneni wrote:
> ...
>>> If you post these new calculations which have problems in ver 3.1, I
>>> can test them with ver 4.1.
>>
> ...
>>
>> I've found additional issues with mpfr_zeta. Here the Borwein
>> algorithm #2 delivers results as good as Mathematica, while mpfr_zeta
>> is far from the expected 40 decimals.
>>
>> : F#ZETA ( -- ) F#TOS DUP F#RND mpfr_zeta DROP ; ( tos <= zeta[tos] )
>>
>> Here is the correct output of the Borwein algorithm ( IIRC you have
>> that ) in iForth vs. the mpfr result for a couple of integer inputs:
>>
>> FORTH> .zeta \ input -- Borwein -- mpfr
>> 2 1.6449340668482264364724151666460251892189e+0000
>> 1.3116821137232264364724151666460251892189e+0000
>> 3 1.2020569031595942853997381615114499907649e+0000
>> 1.0592003052592036603997381615114499907649e+0000
>> 4 1.0823232337111381915160036965411679027747e+0000
> I have a double precision version of the zeta function based on your
> code, with automated tests from your computed reference values in the
> kForth-x packages: forth-src/fsl/extras/zzeta.4th
>
> === snippet from zzeta.4th ===
> ...
> \ 60 digit reference values computed by Marcel Hendrix
> \ using MPFR/MPC version of zzeta.
>
> 1e 0e f/ fconstant +inf
> cr
> TESTING ZETA
> t{ 0e zeta -> -5.00000000000000e-01 r}t
> t{ 1e zeta -> +inf r}t
> t{ 2e zeta -> 1.6449340668482264364724151666460251892190e r}t
> t{ 3e zeta -> 1.2020569031595942853997381615114499907651e r}t
> t{ 4e zeta -> 1.0823232337111381915160036965411679027749e r}t
> ...
> === end snippet ===
>
MPFR has an instrinsic Riemann zeta function. I used it to compute and
print the values to 60 digits:
test
0 -0.50000000000000000000000000000000000000000000000000000000000E0
1 0.@Inf@000000000000000000000000000000000000000000000000000000E0
2 0.164493406684822643647241516664602518921894990120679843773556E1
3 0.120205690315959428539973816151144999076498629234049888179227E1
4 0.108232323371113819151600369654116790277475095191872690768298E1
5 0.103692775514336992633136548645703416805708091950191281197419E1
6 0.101734306198444913971451792979092052790181749003285356184241E1
7 0.100834927738192282683979754984979675959986356056523870641728E1
8 0.100407735619794433937868523850865246525896079064985002032911E1
9 0.100200839282608221441785276923241206048560585139488875654860E1
10 0.100099457512781808533714595890031901700601953156447751725779E1
Presently this only works in kForth-32. The 64-bit library interface
does not include the special functions yet. I will have to add these to
work under kForth-64. I am using MPFR 4.2.
--
KM
=== begin code ===
include ans-words
include modules
include syscalls
include mc
include asm
include strings
include lib-interface
include libs/gmp/libmpfr
include libs/gmp/mpfr-utils
\ Set precision before initializing mp vars
256 mpfr_set_default_prec
mpfr_t dst
mpfr_t num
dst mpfr_init
num mpfr_init
\ Compute the zeta function of n
: rzeta ( n -- a )
num swap GMP_RNDN mpfr_set_si drop
dst num GMP_RNDN mpfr_zeta drop
dst
;
: test 11 0 do i dup 2 .r 2 spaces rzeta dst 60 mpfr. cr loop cr ;
=== end code ===
Technical Details
Message-ID:
<11bodhq$trdt$2@dont-email.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<11b2su5$229je$1@dont-email.me> <11b4t9g$204qr$1@dont-email.me> <11biler$v49b$1@dont-email.me> <11bitev$2v6pq$1@dont-email.me> <11bjcc9$2o4df$1@dont-email.me> <11bl4rb$3mohg$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Krishna Myneni <krishna.myneni@ccreweb.org> Newsgroups: comp.lang.forth Subject: Re: bug in mpfr-3.1.0 Date: Mon, 26 Oct 2026 15:35:06 -0500 Organization: A noiseless patient Spider Lines: 100 Message-ID: <11bodhq$trdt$2@dont-email.me> References: <11b2su5$229je$1@dont-email.me> <11b4t9g$204qr$1@dont-email.me> <11biler$v49b$1@dont-email.me> <11bitev$2v6pq$1@dont-email.me> <11bjcc9$2o4df$1@dont-email.me> <11bl4rb$3mohg$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 26 Oct 2026 20:35:07 +0000 (UTC) Injection-Info: dont-email.me; logging-data="978365"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EP3zp4p+m7cCMpyiyKSDU"; posting-host="72ed8fc175f83233c1c4c668dd6df89e" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:YlGEd/NloKoRikGGVjje+ct16AU= sha256:eHahjfuhWr+RnofeAVbSb6E5v8KJYhFV3LlPkN3TZxk= sha1:bl/YxP1UOlKdY7yeXGdIPEKkvC8= sha256:Jwba8/csVQmixj6eAmXhUaocpYz6PFuFch3YSSBuZaw= Content-Language: en-US In-Reply-To: <11bl4rb$3mohg$1@dont-email.me>