expsin.cpp 660 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Do the exponential sine function.
  2. #include "stdafx.h"
  3. #include "defs.h"
  4. void
  5. eval_expsin(void)
  6. {
  7. push(cadr(p1));
  8. eval();
  9. expsin();
  10. }
  11. void
  12. expsin(void)
  13. {
  14. save();
  15. p1 = pop();
  16. push(imaginaryunit);
  17. push(p1);
  18. multiply();
  19. exponential();
  20. push(imaginaryunit);
  21. divide();
  22. push_rational(1, 2);
  23. multiply();
  24. push(imaginaryunit);
  25. negate();
  26. push(p1);
  27. multiply();
  28. exponential();
  29. push(imaginaryunit);
  30. divide();
  31. push_rational(1, 2);
  32. multiply();
  33. subtract();
  34. restore();
  35. }
  36. #if SELFTEST
  37. static char *s[] = {
  38. "expsin(x)",
  39. "1/2*i*exp(-i*x)-1/2*i*exp(i*x)",
  40. };
  41. void
  42. test_expsin(void)
  43. {
  44. test(__FILE__, s, sizeof s / sizeof (char *));
  45. }
  46. #endif