Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
 
4
/*
5
	tanh(arg) computes the hyperbolic tangent of its floating
6
	point argument.
7
 
8
	sinh and cosh are called except for large arguments, which
9
	would cause overflow improperly.
10
 */
11
 
12
double
13
tanh(double arg)
14
{
15
 
16
	if(arg < 0) {
17
		arg = -arg;
18
		if(arg > 21)
19
			return -1;
20
		return -sinh(arg)/cosh(arg);
21
	}
22
	if(arg > 21)
23
		return 1;
24
	return sinh(arg)/cosh(arg);
25
}