Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ |
2 | #include |
||
3 | |||
4 | double tanh(double x) |
||
5 | { |
||
6 | if (x > 50) |
||
7 | return 1; |
||
8 | else if (x < -50) |
||
9 | return -1; |
||
10 | else |
||
11 | { |
||
12 | const double ebig = exp(x); |
||
13 | const double esmall = 1.0/ebig; |
||
14 | return (ebig - esmall) / (ebig + esmall); |
||
15 | } |
||
16 | }> |
||
17 |