home *** CD-ROM | disk | FTP | other *** search
/ Total Destruction / Total_Destruction.iso / addons / Lccwin32.exe / Lccwin32 / lccpub / lib / src / atanh.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-14  |  775 b   |  41 lines

  1. #include <math.h>
  2. #include <stdio.h>
  3. #include <errno.h>
  4. double atanh(double farg)
  5. {
  6.     if (farg < 0.0)
  7.         farg = -farg;
  8.     if (farg == 0.0 || farg > 1.0) {
  9.         errno = ERANGE;
  10.         return 0.0;
  11.     }
  12.     return 0.5 * log( (1.0 + farg) / (1.0 - farg) );
  13. }
  14.  
  15. #ifdef STANDALONE
  16. /*
  17. Correct output:
  18. J:\lcc\lib\src>atanh
  19. [0.1] 0.100335347731076
  20. [0.2] 0.202732554054082
  21. [0.3] 0.309519604203112
  22. [0.4] 0.423648930193602
  23. [0.5] 0.549306144334055
  24. [0.6] 0.693147180559945
  25. [0.7] 0.867300527694053
  26. [0.8] 1.098612288668110
  27. [0.9] 1.472219489583220
  28. */
  29. int main()
  30. {
  31.         int i=1;
  32.         double r;
  33.  
  34.         while (i < 10) {
  35.                 r= atanh((double)i/10.0);
  36.                 printf("[%3.1f] %10.15f\n",(double)i/10.0,r);
  37.                 i++;
  38.         }
  39. #endif
  40.