🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.forth
Article #175

Re: bug in mpfr-3.1.0

#175
From: marcel hendrix
Date: Sat, 24 Oct 2026 22:44
72 lines
4193 bytes
On 10/24/2026 8:29 PM, Krishna Myneni wrote:
> On 10/24/26 11:13 AM, marcel hendrix wrote:
>> On 10/19/2026 1:01 PM, Krishna Myneni wrote:

[..]

>> I assume the pow and pow_... functions in the mpfr and mpc have this 
>> particular problem fixed by now.
>>
> 
> If you post these new calculations which have problems in ver 3.1, I can 
> test them with ver 4.1.

It is unlikely that my code will work for you, but here is the straight 
library call to push the mpfr function results on the F#stack ( iForth's 
arbitrary float stack). For mpfr_pow it was

\ : F#**   ( -- ) F#NOS DUP F#TOS F#RND mpfr_pow DROP F#DROP ;	\ tos <= 
tos^n, does not work for n=powerof[2]

The fix is

: F#^N     ( n -- ) F#TOS DUP ROT F#RND mpfr_pow_si DROP ; \ tos <= 
tos^n ) this DOES work when n is 2
: F#**     ( -- )   F#->N F#^N ; \ tos <= tos^n, does work for n=powerof[2]

Here is a test showing original and fixed code:

FORTH> : bad_F#**   ( -- ) F#NOS DUP F#TOS F#RND mpfr_pow DROP F#DROP ;  ok
FORTH> F#2.0 F#3.0 bad_F#** F#.  @.Inf@e-0001 ok
FORTH> F#2.0 F#3.0     F#** F#. 
8.0000000000000000000000000000000000000000e+0000 ok

---( * )---

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 
1.0156565710181145098753786965411679027747e+0000
    5 1.0369277551433699263313654864570341680570e+0000 
1.0046696906572835577705744708320341680570e+0000
    6 1.0173430619844491397145179297909205279018e+0000 
1.0014700461116642494800475623592799029018e+0000
    7 1.0083492773819228268397975498497967595998e+0000 
1.0004752616338931211207065516770367498342e+0000
    8 1.0040773561979443393786852385086524652589e+0000 
1.0001557875704933729187388808635580705751e+0000
    9 1.0020083928260822144178527692324120604856e+0000 
1.0000514456636556000450761571605095693333e+0000
   10 1.0009945751278180853371459589003190170060e+0000

It is unlikely to be a problem with the interface as, e.g., the mpfr_erf 
function (~ same call interface) gives the expected results when 
compared to Mathematica.

It would help me to see the output of the mpfr and/or mpc for the above 
functions. However, it is starting to look like I'm wasting my time with 
decade old dll's.

-marcel
Technical Details
Message-ID: <11bjcc9$2o4df$1@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-mail
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>

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: marcel hendrix <mhx@iae.nl>
Newsgroups: comp.lang.forth
Subject: Re: bug in mpfr-3.1.0
Date: Sun, 25 Oct 2026 00:44:21 +0200
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <11bjcc9$2o4df$1@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>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 24 Oct 2026 22:44:26 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="2888111"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+q/huEOSQLgxDa15m7JAYGqSn2eBtD0qA="; posting-host="b9e8675988f6fd571599dd5e86e97eb8"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:em8HZo1PJ1NO9P/Hw1DRThbIGqU= sha256:Lxqot6FUKrNch/a5RAuasMOR+6khRrBQ8y0X8YPH5AE=
	sha1:uTOnsdKHALJDkE3y0HoOBfOmj94= sha256:HvX74KGIqdQ2dahnGdcd2A5Uvnemg4uEYnOuB7t00/8=
In-Reply-To: <11bitev$2v6pq$1@dont-email.me>
Content-Language: en-US