powered by
Calculate the (Pythagorean) hypotenuse of two numeric vectors using the obvious algorithm.
hypotenuse(x, y)
A numeric vector.
A numeric vector of the hyptenuse of the inputs.
Cleve Moler (MATLAB creator and discoverer of the Moler-Morrison algorithm for calculating hypotenuses) discusses the pro and cons of several algorithms here. http://blogs.mathworks.com/cleve/2012/07/30/pythagorean-addition
hypot
# NOT RUN { hypotenuse(5, 12) #okay hypotenuse(1e-300, 1e-300) #fails hypotenuse(1e300, 1e300) #fails # }
Run the code above in your browser using DataLab