arctanh.cpp 567 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "stdafx.h"
  2. #include "defs.h"
  3. void
  4. eval_arctanh(void)
  5. {
  6. push(cadr(p1));
  7. eval();
  8. arctanh();
  9. }
  10. void
  11. arctanh(void)
  12. {
  13. double d;
  14. save();
  15. p1 = pop();
  16. if (car(p1) == symbol(TANH)) {
  17. push(cadr(p1));
  18. restore();
  19. return;
  20. }
  21. if (isdouble(p1)) {
  22. d = p1->u.d;
  23. if (d < -1.0 || d > 1.0)
  24. stop("arctanh function argument is not in the interval [-1,1]");
  25. d = log((1.0 + d) / (1.0 - d)) / 2.0;
  26. push_double(d);
  27. restore();
  28. return;
  29. }
  30. if (iszero(p1)) {
  31. push(zero);
  32. restore();
  33. return;
  34. }
  35. push_symbol(ARCTANH);
  36. push(p1);
  37. list(2);
  38. restore();
  39. }