hypot

hypot(a, b, c, ...)

hypot([a, b, c, ...])

Try it yourself:

See also:

Find a Euclidean length with hypot

hypot(a, b, c, ...) returns the square root of the sum of squared inputs. For two values, it is the hypotenuse length sqrt(a^2 + b^2); for more values, it gives the Euclidean length in higher dimensions.

Examples

hypot(3, 4) is 5. This is useful for distance from coordinate differences: subtract coordinates with subtract, then pass the differences to hypot. For a vector already stored as a matrix, norm is often the more direct expression.

Numerical advantages

Hypot is generally preferable to manually squaring and summing because it can use a stable implementation that reduces overflow and underflow risk. Compare sqrt when you specifically need a square root of one value, and distance for a direct point-to-point operation.

Inputs

Inputs should be numeric and share meaningful units. A negative component is fine because it is squared; a nonnumeric value is not. Very large or very small values still deserve attention when interpreting precision.

Try Hypot in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions