Skip to contents

Calculates the length of a vector using the Pythagorean theorem.

Usage

pythagoras(x, y)

Arguments

x

A numeric vector with the same length as y. It should represent the lengths of the first leg (cathetus) of right triangles.

y

A numeric vector with the same length as x. It should represent the lengths of the second leg (cathetus) of right triangles.

Value

Returns a numeric vector with the same length as x and y, reflecting the lengths of the hypotenuse of the right triangles.

Author

Pepijn de Vries

Examples

pythagoras(x = c(1, 2), y = c(1, 2))
#> [1] 1.414214 2.828427