Name

cathetus — Given the hypotenuse and one side of a right triangle, calculate the other side.

Synopsis

#include <cathetus.h>
double cathetus( double h,
  double a);
 

DESCRIPTION

The cathetus function takes a pair of doubles representing, respectively, the (lengths of) the hyponenuese and a side (a cathetus) of a right triangle and returns a double which is the length of the other side. Thus it is a companion to the standard library hypot function (and like it, care is taken to avoid floating point overflow and undeflow as would occur in a naïve implementation of this functionality).

Note that the input values may be negative, but the output values are always non-negative (or NAN).

RETURN VALUE

Returns the length of the unspecifed cathetus. If the input hyponeuse is NAN, then the same is returned; if the input hypotenuse is ±INFINITY and the input cathetus is finite or NAN, then INFINITY is returned; if the input hyponeuese is ±INFINITY and the input cathetus is ±INFINITY, then NAN is returned; if the input hypotenuse is finite and the input cathetus is ±INFINITY, NAN, or larger (in absolute value) than the hypotenuse, then NAN is returned.

It is possible to pass small normalised values to function such that the result is subnormal, but it is not possible for the result to underflow. Nor does the function overflow. There are no inputs for which the function sets errno, nor for which a floating point exception is raised.

AUTHORS

J.J. Green.