s_ctanhl.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* $OpenBSD: s_ctanhl.c,v 1.2 2011/07/20 19:28:33 martynas Exp $ */
  2. /*
  3. * Copyright (c) 2008 Stephen L. Moshier <steve@moshier.net>
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. /* ctanhl
  18. *
  19. * Complex hyperbolic tangent
  20. *
  21. *
  22. *
  23. * SYNOPSIS:
  24. *
  25. * long double complex ctanhl();
  26. * long double complex z, w;
  27. *
  28. * w = ctanhl (z);
  29. *
  30. *
  31. *
  32. * DESCRIPTION:
  33. *
  34. * tanh z = (sinh 2x + i sin 2y) / (cosh 2x + cos 2y) .
  35. *
  36. * ACCURACY:
  37. *
  38. * Relative error:
  39. * arithmetic domain # trials peak rms
  40. * IEEE -10,+10 30000 1.7e-14 2.4e-16
  41. *
  42. */
  43. #include <openlibm_complex.h>
  44. #include <openlibm_math.h>
  45. long double complex
  46. ctanhl(long double complex z)
  47. {
  48. long double complex w;
  49. long double x, y, d;
  50. x = creall(z);
  51. y = cimagl(z);
  52. d = coshl(2.0L * x) + cosl(2.0L * y);
  53. w = sinhl(2.0L * x) / d + (sinl(2.0L * y) / d) * I;
  54. return (w);
  55. }