hypot
hypot(x, y)
Compute the $\sqrt{x^2+y^2}$ avoiding overflow and underflow
Examples
julia> hypot(3, 4)
5.0
julia> hypot(0.5, 0.5)
0.7071067811865476
julia> x = 1e100;
julia> y = 1e-100;
julia> hypot(x, y)
1.0000000000000002e100
Common mistake example:
julia> hypot("3", 4)
MethodError: no method matching hypot(::String, ::Int64)
In this example, the hypot
function expects numerical arguments, but a string was provided instead. Make sure to pass the correct argument types to the hypot
function.
See Also
User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.