|
Hmmm... how can I get .net on my Itanium (OpenVMS) system?
|
|
|
|
|
I work on whatever Tim Cook decides should be in my Macbook.
cheers
Chris Maunder
|
|
|
|
|
I have a guess. When dealing with stuff in mathematics that involves a degree of error, you want to treat all input consistently. Having some input that generates a value with error baked in and other input that generates a hard-coded exact value is a bad idea.
With Complex.Sqrt , they use polar coordinates to calculate the complex number. This is going to have some error baked in. If a developer using Complex is adjusting for error, and the operations on Complex treat some input differently (like -1), then this adjustment would remove the error from some cases and introduce error in others. If you want an error-less representation of Complex.Sqrt(-1) you can use Complex.ImaginaryOne .
That would be my reasoning at least.
|
|
|
|
|
I hope you know you just induced me to have a flashback to the graduate linear systems course I took in 1988, the last time I cared that i = √-1 was a thing.
I'm now going to have to spend the evening drinking hard apple cider, binge-watching Eureka[^], and talking to my sleeping greyhound in order to purge the memory from my neural cache.
Software Zen: delete this;
|
|
|
|
|
That looks like an implementation error. Does the 32-bit system have a 80x87 math coprocessor?
|
|
|
|
|
Well, I had to try it in C++...
#include <complex>
#include <iomanip>
#include <iostream>
int main() {
const auto a = std::complex<long double>{-1, 0};
const auto b = std::sqrt(a);
std::cout << std::setprecision(20) << "sqrt" << a << " -> " << b << "\n";
}
and that output
sqrt(-1,0) -> (0,1)
in gcc and clang.
And, as you have been a physicist, I figured maybe Fortran might be an alternative...
program test
implicit none
COMPLEX*8 a,b
a = (-1,0)
b = sqrt(a)
write (*,*) a,b
endprogram test
Guess what - sqrt(-1) == i there too:
(-1.00000000,0.00000000) (0.00000000,1.00000000)
And all the other non .NET languages I tried also gave the same answer... So I guess .NET is the outlier here!
With all that, though, they're still missing the negative root
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Are we sure that we are comparing like-with-like?
The original answers were (6.12303176911189E-17, 1) or (6.12323399573677E-17,1)
Your answers were (0.00000000,1.00000000)
If you display 6.12303176911189E-17 in a non-exponent form, it will come out as 0.00000000 because it is a rounded version of 0.000000000000000006123... (I may have miscounted the zeros)
So both answers may be representations of the same number. This is easy to test e.g. in FORTRAN which has an E format type for exponential and F for floating point.
|
|
|
|
|
Ugh. Excellent point.
cheers
Chris Maunder
|
|
|
|
|
Good point!
For C++, I would say so, as I turned precision up to 20, which should show 20 sig figs (I turned it up to 100 before posting, but went back down to 20 - wouldn't want to overdo it!).
Fortran... I changed my sample to use this format:
write (*,fmt='(E18.10/)') a,b
and it wrote
0.0000000000E+00
0.0000000000E+00
0.1000000000E+01
so - looks like fortran is good too. Just need to work out how to format exponentials in Haskell, Go and Ada to verify those ones!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
That is awesome. Thank you.
cheers
Chris Maunder
|
|
|
|
|
I had a message-passing algorithm written in MATLAB, but our SW Dev department wanted it written in C#. After I wrote it in C#, I found a numerical instability in the C# version. Later I wanted to run the same algorithm on a Spark Cluster, so I rewrote it again in Python. The MATLAB version running on my Windows 10 machine yields the same answers as the Python version (whether I run on my local machine or a Spark Cluster in Azure). The only fix I could find for C# was to round the output of one method to 11 or 12 decimal digits so that the numbers that ought to remain identical would remain identical. I think something funky is happening to double precision (maybe all floating point) calculations in .NET.
Thanks for introducing me to GodBolt.org. I think it's going to be very useful.
|
|
|
|
|
To be precise Sqrt(-1) corresponds to (0,1) and (0,-1) complex values (+/-i). From the implementation point of view I believe simple cases to detect like this should be considered at the code level for avoid introducing calculations and corresponding errors for free. If the software can easily do better then it should.
|
|
|
|
|
We're experiencing a high level of traffic. You're in a virtual queue, thank you for waiting.
Your estimated wait time is:33 minutes
(BC's government site - new vaccine cards today. Thanks EDS/IBM/whoever scaled this puppy)
TTFN - Kent
|
|
|
|
|
A virtual queue?...what, one that doesn't really exist? a faux queue?
Sorry Kent, I couldn't resist! Hope it doesn't get me banned...nothing personal.
"Go forth into the source" - Neal Morse
"Hope is contagious"
|
|
|
|
|
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Yeah - they had that on the Ontario vaccine booking site. A long bar showing how far off the front of the queue you were, an animated man walking (not reading the news, taking toilet breaks, making breakfast, yelling at the kids next door and occasionally coding, as was the case here).
This was for the day my age group (over 21's) were allowed to get their shot. Virtual doors opened at 8am. At 7:50 I was over 60,000 behind the head of the queue.
And what was really weird: Once you were in, you could take all the time in the world. Which you had to, because their system was so, deeply, terribly, useless at actually trying to find you an open slot.
Totally artificial throttle.
cheers
Chris Maunder
|
|
|
|
|
I would expect the usual NaN minutes .
|
|
|
|
|
I've seen that before with an online sale. It was to prevent the site / servers from being overwhelmed.
|
|
|
|
|
Can you not count to ten in French if you have a huit allergy?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
I am une-decided.
If you can't laugh at yourself - ask me and I will do it for you.
|
|
|
|
|
Could you explain for us mere mortals
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
modified 7-Sep-21 13:39pm.
|
|
|
|
|
The French number 8 (huit) is pronounced the same as "wheat".
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Ah ok thanks
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
|
|
|
|
|
Don't you hate it when you have to explain a joke?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|