I did some testing with C++ hypot() and Java Math.hypot. They both seem to be significantly slower than sqrt(a*a + b*b). Is that because of a better precision? What method to calculate a hypotenuse hypot function uses? Surprisingly I couldn’t find any indication of poor performance in the documentation.
I did some testing with C++ hypot() and Java Math.hypot . They both seem
Share
It’s not a simple sqrt function. You should check this link for the implementation of the algorithm: http://www.koders.com/c/fid7D3C8841ADC384A5F8DE0D081C88331E3909BF3A.aspx
It has while loop to check for convergence
EDIT (Update from J.M):
Here is the original Moler-Morrison paper, and here is a nice follow-up due to Dubrulle.