Message Boards Message Boards

Different error in Linux Cloud vs on Windows 11 in 1/(-1.)^1.2?

Posted 1 year ago

Indeed, Linux in Wolfram cloud prints for 1/(-1.)^1.2 (after copy paste of the answer)

-0.8090169943749475+0.587785252292473 I

while windows prints

-0.8090169943749475 + 0.5877852522924731 I

Yep. Both of them have an error, as N[1/(-1)^(12/10), 50]

-0.80901699437494742410229341718281905886015458990288 + 0.58778525229247312916870595463907276859765243764315 I

So it should be 74 not 75 and 731 must be in both cases. I suppose you use Intel C++ compiler math library, since it is the only one that has complex numbers apart from glibc?

Found an error in much more complex https://mathematica.stackexchange.com/q/282358/82985

POSTED BY: ZAQU zaqu
9 Replies

The relative error is already smaller than 1/2 $MachineEpsilon. Honestly, what do you expect from floating point arithmetic?

x8664 Linux and x8664 windows are the same, apart that windows uses LLP64 model (so long is 32 bit only, not 64 as on linux).

How is this relevant for floating point arithmetic?

That may be just a bug in compiler gcc or clang vs msvc on windows.

You admit yourself that the relative errors here are below what agents on the market agreed on to be sufficient. So none of the compiler vendors would consider this a bug.

That is not what is the problem here, the problem is reproducability.

What I am trying to tell you: You simply cannot expect this degree of reproducability between different systems.

To my knowledge, exp and pow are not considered as "elementary arithmetic operations" in IEEE 754. So strictly speaking, they are not required to be exact to 1/2 ulp. In practice, most implementation are exact up to roughly 1 ulp.

This was fixed in gcc (maybe in 2020? I do not quite remember): https://stackoverflow.com/questions/13774912/gcc-c-pow-accuracy

I would not call the integer-rounding of int(std::pow(100,2)) to 99 a bug. I would rather call fixing this "adding a feature". From a floating point of view, 100 - 0.5 * ulp(100) would be a perfectly correct result for std::pow(100,2). The issue is solely that the integer cast operator rounds always towards zero. This comes quite unexpected for most of us. So probably the gcc developers decided that it might be nice (and lead to less confusion) if every result that can be expressed exactly by floating point numbers would also be represented correctly. But your example 1/(-1.)^1.2 cannot be represented exacly by a floating point number. So one has no choice to rescue to some approximation. And I doubt that there is any standard that mandates, how 1/(-1.)^1.2 has to be evaluated. The only reasonable thing is to expect is that the relative error is in the order of 1 ulp or half an ulp. So I even wonder why you think the Windows version would be the ground truth. Maybe it was only by chance that it returned a "better" result?

Anyways, if you simply want to file a bug report, then why don't you do it where these are supposed to go? Neither Wolfram Community nor Mathematica.StackExchange.com are the right places for that.

Posted 1 year ago

The relative error must be smaller or equal than 1/2 $MachineEpsilon in all 5 rounding modes of IEEE 754 with all inputs anyway, but in practice no one has that, glibc and Intel do not. That is not what is the problem here, the problem is reproducability.

x8664 Linux and x8664 windows are the same, apart that windows uses LLP64 model (so long is 32 bit only, not 64 as on linux). That may be just a bug in compiler gcc or clang vs msvc on windows. In fact clang ARM has no such bugs and prints the same as in Windows 11, as you confirmed.

So it is bad.

POSTED BY: ZAQU zaqu
Posted 1 year ago

Strictly speaking we are in 2023, so new algorithms were invented to make libm to ideal 0.5 ulp (which exp(), expm1(), exp(), pow() are a part of, as part of language C math.h) and more or less as fast. This: https://gitlab.inria.fr/core-math/core-math/

You simply cannot expect this degree of reproducability between different systems.

Linux and Microsoft are almost the same OS, except for the LLP64 in Windows and modular kernel vs Hybrid kernel and a different default inside default floating point control register (i.e. FPCSR\NPXCW) between Linux and NT: glibc assumes 0x37f but NT uses 0x27f (not a problem outside WSL1, see my comment https://github.com/microsoft/WSL/issues/830#issuecomment-507988489 ). That is all I know of. All other differences come from bugs inside MSVC and wrong use of flags inside gcc.

So none of the compiler vendors would consider this a bug.

You assume a bug like that was not opened and not already fixed in gcc 13. This was fixed in gcc (maybe in 2020? I do not quite remember): https://stackoverflow.com/questions/13774912/gcc-c-pow-accuracy

POSTED BY: ZAQU zaqu
Posted 1 year ago

wonder why you think the Windows version would be the ground truth.

So you do not know how to calculate ground truth in floating arithmetic? Well, I just used infinite precision: N[1/(-1)^(12/10), 50] and saw that using school rounding the result in Windows is the same as linux in real part but different in complex, Windows being more accurate.

Neither Wolfram Community nor Mathematica.StackExchange.com are not the right places for that.

What? Why?? There is even header for bugs and tag bugs, bug in stackexchange. I am all for open bug tracker, so I am not going to do closed Wolfram one.

POSTED BY: ZAQU zaqu

Well, I just used infinite precision: [...]

So does Windows always find the "right" solution? Or did it find it here just by chance?

What? Why??

Mathematica.StackExchange.com is purely community-driven. It is not an official channel by Wolfram Research. And, although being an outlet by Wolfram Research, Wolfram Community is also not meant as bug tracker. You should better contact Wolfram Support and issue a bug report there. But I am pretty sure that they will tell you the same as I do.

Posted 1 year ago

If you are using glibc, then that is to be expected. :( I just thought you did your own complex numbers libraries, not used glibc complex.h.

POSTED BY: ZAQU zaqu
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract