]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libc/port/tanh.c
libregexp: improve the transition to next available thread, instruction, and generation
[plan9front.git] / sys / src / libc / port / tanh.c
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 }