DADiSP Worksheet Functions > Function Categories > Statistics and Calculus > HYPOT

 

HYPOT

Purpose:

Computes the square root of the sum of squares.

Syntax:

HYPOT(x, y)

x

-

A scalar, series or table.

y

-

A scalar, series or table.

Returns:

A scalar or series, the right triangle hypotenuse formula sqrt(x*x + y*y) computed with underflow and overflow protection.

Example:

hypot(3, 4)

 

returns 5, the hypotenuse of a 3-4-5 triangle.

Example:

a = 1e200;

b = sqrt(a*a + a*a);

c = hypot(a, a);

 

b == inf

c == 1.414214e+200

 

Variable a contains a large real value. The straightforward computation overflows, but HYPOT returns the correct value without overflow.

Example:

a = 1e-200;

b = sqrt(a*a + a*a);

c = hypot(a, a);

 

b == 0.0

c == 1.414214e-200

 

Variable a contains a small real value. The straightforward computation underflows, but HYPOT returns the correct value without underflow.

Example:

W1: 1..5

W2: {3, 1, inf, 3, 5}

W3: hypot(w1, w2)

 

W3 == {3.162278, 2.236068, inf, 5.000000, 7.071068}

Remarks:

HYPOT(x, y) computes the right triangle hypotenuse formula:

 

 

with underflow and overflow protection using a routine compatible with the IEEE 754 hypot function.

 

 For complex x or y, HYPOT effectively computes:

 

See Also:

ABS

MAGNITUDE

MAKECARTESIAN

NORM