exp.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { factory } from '../../utils/factory.js';
  2. import { expNumber } from '../../plain/number/index.js';
  3. var name = 'exp';
  4. var dependencies = ['typed'];
  5. export var createExp = /* #__PURE__ */factory(name, dependencies, _ref => {
  6. var {
  7. typed
  8. } = _ref;
  9. /**
  10. * Calculate the exponential of a value.
  11. * For matrices, if you want the matrix exponential of square matrix, use
  12. * the `expm` function; if you want to take the exponential of each element,
  13. * see the examples.
  14. *
  15. * Syntax:
  16. *
  17. * math.exp(x)
  18. *
  19. * Examples:
  20. *
  21. * math.exp(2) // returns number 7.3890560989306495
  22. * math.pow(math.e, 2) // returns number 7.3890560989306495
  23. * math.log(math.exp(2)) // returns number 2
  24. *
  25. * math.map([1, 2, 3], math.exp)
  26. * // returns Array [
  27. * // 2.718281828459045,
  28. * // 7.3890560989306495,
  29. * // 20.085536923187668
  30. * // ]
  31. *
  32. * See also:
  33. *
  34. * expm1, expm, log, pow
  35. *
  36. * @param {number | BigNumber | Complex} x A number to exponentiate
  37. * @return {number | BigNumber | Complex} Exponential of `x`
  38. */
  39. return typed(name, {
  40. number: expNumber,
  41. Complex: function Complex(x) {
  42. return x.exp();
  43. },
  44. BigNumber: function BigNumber(x) {
  45. return x.exp();
  46. }
  47. });
  48. });