|
|
/* @(#)w_sinh.c 5.1 93/09/24 */
|
/* @(#)w_sinh.c 5.1 93/09/24 */
|
/*
|
/*
|
* ====================================================
|
* ====================================================
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
*
|
*
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
* Permission to use, copy, modify, and distribute this
|
* Permission to use, copy, modify, and distribute this
|
* software is freely granted, provided that this notice
|
* software is freely granted, provided that this notice
|
* is preserved.
|
* is preserved.
|
* ====================================================
|
* ====================================================
|
*/
|
*/
|
|
|
|
|
/*
|
/*
|
FUNCTION
|
FUNCTION
|
<<sinh>>, <<sinhf>>---hyperbolic sine
|
<<sinh>>, <<sinhf>>---hyperbolic sine
|
|
|
INDEX
|
INDEX
|
sinh
|
sinh
|
INDEX
|
INDEX
|
sinhf
|
sinhf
|
|
|
ANSI_SYNOPSIS
|
ANSI_SYNOPSIS
|
#include <math.h>
|
#include <math.h>
|
double sinh(double <[x]>);
|
double sinh(double <[x]>);
|
float sinhf(float <[x]>);
|
float sinhf(float <[x]>);
|
|
|
TRAD_SYNOPSIS
|
TRAD_SYNOPSIS
|
#include <math.h>
|
#include <math.h>
|
double sinh(<[x]>)
|
double sinh(<[x]>)
|
double <[x]>;
|
double <[x]>;
|
|
|
float sinhf(<[x]>)
|
float sinhf(<[x]>)
|
float <[x]>;
|
float <[x]>;
|
|
|
DESCRIPTION
|
DESCRIPTION
|
<<sinh>> computes the hyperbolic sine of the argument <[x]>.
|
<<sinh>> computes the hyperbolic sine of the argument <[x]>.
|
Angles are specified in radians. <<sinh>>(<[x]>) is defined as
|
Angles are specified in radians. <<sinh>>(<[x]>) is defined as
|
@ifinfo
|
@ifinfo
|
. (exp(<[x]>) - exp(-<[x]>))/2
|
. (exp(<[x]>) - exp(-<[x]>))/2
|
@end ifinfo
|
@end ifinfo
|
@tex
|
@tex
|
$${e^x - e^{-x}}\over 2$$
|
$${e^x - e^{-x}}\over 2$$
|
@end tex
|
@end tex
|
|
|
<<sinhf>> is identical, save that it takes and returns <<float>> values.
|
<<sinhf>> is identical, save that it takes and returns <<float>> values.
|
|
|
RETURNS
|
RETURNS
|
The hyperbolic sine of <[x]> is returned.
|
The hyperbolic sine of <[x]> is returned.
|
|
|
When the correct result is too large to be representable (an
|
When the correct result is too large to be representable (an
|
overflow), <<sinh>> returns <<HUGE_VAL>> with the
|
overflow), <<sinh>> returns <<HUGE_VAL>> with the
|
appropriate sign, and sets the global value <<errno>> to
|
appropriate sign, and sets the global value <<errno>> to
|
<<ERANGE>>.
|
<<ERANGE>>.
|
|
|
You can modify error handling for these functions with <<matherr>>.
|
You can modify error handling for these functions with <<matherr>>.
|
|
|
PORTABILITY
|
PORTABILITY
|
<<sinh>> is ANSI C.
|
<<sinh>> is ANSI C.
|
<<sinhf>> is an extension.
|
<<sinhf>> is an extension.
|
|
|
QUICKREF
|
QUICKREF
|
sinh ansi pure
|
sinh ansi pure
|
sinhf - pure
|
sinhf - pure
|
*/
|
*/
|
|
|
/*
|
/*
|
* wrapper sinh(x)
|
* wrapper sinh(x)
|
*/
|
*/
|
|
|
#include "fdlibm.h"
|
#include "fdlibm.h"
|
#include <errno.h>
|
#include <errno.h>
|
|
|
#ifndef _DOUBLE_IS_32BITS
|
#ifndef _DOUBLE_IS_32BITS
|
|
|
#ifdef __STDC__
|
#ifdef __STDC__
|
double sinh(double x) /* wrapper sinh */
|
double sinh(double x) /* wrapper sinh */
|
#else
|
#else
|
double sinh(x) /* wrapper sinh */
|
double sinh(x) /* wrapper sinh */
|
double x;
|
double x;
|
#endif
|
#endif
|
{
|
{
|
#ifdef _IEEE_LIBM
|
#ifdef _IEEE_LIBM
|
return __ieee754_sinh(x);
|
return __ieee754_sinh(x);
|
#else
|
#else
|
double z;
|
double z;
|
struct exception exc;
|
struct exception exc;
|
z = __ieee754_sinh(x);
|
z = __ieee754_sinh(x);
|
if(_LIB_VERSION == _IEEE_) return z;
|
if(_LIB_VERSION == _IEEE_) return z;
|
if(!finite(z)&&finite(x)) {
|
if(!finite(z)&&finite(x)) {
|
/* sinh(finite) overflow */
|
/* sinh(finite) overflow */
|
#ifndef HUGE_VAL
|
#ifndef HUGE_VAL
|
#define HUGE_VAL inf
|
#define HUGE_VAL inf
|
double inf = 0.0;
|
double inf = 0.0;
|
|
|
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
|
SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
|
#endif
|
#endif
|
exc.type = OVERFLOW;
|
exc.type = OVERFLOW;
|
exc.name = "sinh";
|
exc.name = "sinh";
|
exc.err = 0;
|
exc.err = 0;
|
exc.arg1 = exc.arg2 = x;
|
exc.arg1 = exc.arg2 = x;
|
if (_LIB_VERSION == _SVID_)
|
if (_LIB_VERSION == _SVID_)
|
exc.retval = ( (x>0.0) ? HUGE : -HUGE);
|
exc.retval = ( (x>0.0) ? HUGE : -HUGE);
|
else
|
else
|
exc.retval = ( (x>0.0) ? HUGE_VAL : -HUGE_VAL);
|
exc.retval = ( (x>0.0) ? HUGE_VAL : -HUGE_VAL);
|
if (_LIB_VERSION == _POSIX_)
|
if (_LIB_VERSION == _POSIX_)
|
errno = ERANGE;
|
errno = ERANGE;
|
else if (!matherr(&exc)) {
|
else if (!matherr(&exc)) {
|
errno = ERANGE;
|
errno = ERANGE;
|
}
|
}
|
if (exc.err != 0)
|
if (exc.err != 0)
|
errno = exc.err;
|
errno = exc.err;
|
return exc.retval;
|
return exc.retval;
|
} else
|
} else
|
return z;
|
return z;
|
#endif
|
#endif
|
}
|
}
|
|
|
#endif /* defined(_DOUBLE_IS_32BITS) */
|
#endif /* defined(_DOUBLE_IS_32BITS) */
|
|
|