core/static/exp.js

  1. /**
  2. * Calculates the exponential function with base E.
  3. * @memberof Complex
  4. * @static
  5. * @param {Complex} num - Exponent
  6. * @returns {Complex} The value of E to the power of num
  7. */
  8. function exp(num) {
  9. if (!(num instanceof this)) {
  10. return this.NaN;
  11. }
  12. const re = num.getReal();
  13. const theta = num.getImaginary();
  14. const r = Math.exp(re);
  15. return new this(
  16. r * Math.cos(theta),
  17. r * Math.sin(theta),
  18. );
  19. }
  20. module.exports = exp;