xref: /csrg-svn/usr.bin/f77/libF77/CCI/tanh.c (revision 47942)
1*47942Sbostic /*-
2*47942Sbostic  * Copyright (c) 1991 The Regents of the University of California.
3*47942Sbostic  * All rights reserved.
4*47942Sbostic  *
5*47942Sbostic  * This code is derived from software contributed to Berkeley by
6*47942Sbostic  * Computer Consoles Inc.
7*47942Sbostic  *
8*47942Sbostic  * %sccs.include.proprietary.c%
929957Smckusick  */
1029957Smckusick 
11*47942Sbostic #ifndef lint
12*47942Sbostic static char sccsid[] = "@(#)tanh.c	5.2 (Berkeley) 04/12/91";
13*47942Sbostic #endif /* not lint */
14*47942Sbostic 
1529957Smckusick /*
1629957Smckusick 	tanh(arg) computes the hyperbolic tangent of its floating
1729957Smckusick 	point argument.
1829957Smckusick 
1929957Smckusick 	sinh and cosh are called except for large arguments, which
2029957Smckusick 	would cause overflow improperly.
2129957Smckusick */
2229957Smckusick 
2329957Smckusick double sinh(), cosh();
2429957Smckusick 
2529957Smckusick double
tanh(arg)2629957Smckusick tanh(arg)
2729957Smckusick double arg;
2829957Smckusick {
2929957Smckusick 	double sign;
3029957Smckusick 
3129957Smckusick 	sign = 1.;
3229957Smckusick 	if(arg < 0.){
3329957Smckusick 		arg = -arg;
3429957Smckusick 		sign = -1.;
3529957Smckusick 	}
3629957Smckusick 
3729957Smckusick 	if(arg > 21.)
3829957Smckusick 		return(sign);
3929957Smckusick 
4029957Smckusick 	return(sign*sinh(arg)/cosh(arg));
4129957Smckusick }
42