math.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. :mod:`math` -- mathematical functions
  2. =====================================
  3. .. module:: math
  4. :synopsis: mathematical functions
  5. |see_cpython_module| :mod:`python:math`.
  6. The ``math`` module provides some basic mathematical functions for
  7. working with floating-point numbers.
  8. *Note:* On the pyboard, floating-point numbers have 32-bit precision.
  9. Availability: not available on WiPy. Floating point support required
  10. for this module.
  11. Functions
  12. ---------
  13. .. function:: acos(x)
  14. Return the inverse cosine of ``x``.
  15. .. function:: acosh(x)
  16. Return the inverse hyperbolic cosine of ``x``.
  17. .. function:: asin(x)
  18. Return the inverse sine of ``x``.
  19. .. function:: asinh(x)
  20. Return the inverse hyperbolic sine of ``x``.
  21. .. function:: atan(x)
  22. Return the inverse tangent of ``x``.
  23. .. function:: atan2(y, x)
  24. Return the principal value of the inverse tangent of ``y/x``.
  25. .. function:: atanh(x)
  26. Return the inverse hyperbolic tangent of ``x``.
  27. .. function:: ceil(x)
  28. Return an integer, being ``x`` rounded towards positive infinity.
  29. .. function:: copysign(x, y)
  30. Return ``x`` with the sign of ``y``.
  31. .. function:: cos(x)
  32. Return the cosine of ``x``.
  33. .. function:: cosh(x)
  34. Return the hyperbolic cosine of ``x``.
  35. .. function:: degrees(x)
  36. Return radians ``x`` converted to degrees.
  37. .. function:: erf(x)
  38. Return the error function of ``x``.
  39. .. function:: erfc(x)
  40. Return the complementary error function of ``x``.
  41. .. function:: exp(x)
  42. Return the exponential of ``x``.
  43. .. function:: expm1(x)
  44. Return ``exp(x) - 1``.
  45. .. function:: fabs(x)
  46. Return the absolute value of ``x``.
  47. .. function:: floor(x)
  48. Return an integer, being ``x`` rounded towards negative infinity.
  49. .. function:: fmod(x, y)
  50. Return the remainder of ``x/y``.
  51. .. function:: frexp(x)
  52. Decomposes a floating-point number into its mantissa and exponent.
  53. The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e``
  54. exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise
  55. the relation ``0.5 <= abs(m) < 1`` holds.
  56. .. function:: gamma(x)
  57. Return the gamma function of ``x``.
  58. .. function:: isfinite(x)
  59. Return ``True`` if ``x`` is finite.
  60. .. function:: isinf(x)
  61. Return ``True`` if ``x`` is infinite.
  62. .. function:: isnan(x)
  63. Return ``True`` if ``x`` is not-a-number
  64. .. function:: ldexp(x, exp)
  65. Return ``x * (2**exp)``.
  66. .. function:: lgamma(x)
  67. Return the natural logarithm of the gamma function of ``x``.
  68. .. function:: log(x)
  69. Return the natural logarithm of ``x``.
  70. .. function:: log10(x)
  71. Return the base-10 logarithm of ``x``.
  72. .. function:: log2(x)
  73. Return the base-2 logarithm of ``x``.
  74. .. function:: modf(x)
  75. Return a tuple of two floats, being the fractional and integral parts of
  76. ``x``. Both return values have the same sign as ``x``.
  77. .. function:: pow(x, y)
  78. Returns ``x`` to the power of ``y``.
  79. .. function:: radians(x)
  80. Return degrees ``x`` converted to radians.
  81. .. function:: sin(x)
  82. Return the sine of ``x``.
  83. .. function:: sinh(x)
  84. Return the hyperbolic sine of ``x``.
  85. .. function:: sqrt(x)
  86. Return the square root of ``x``.
  87. .. function:: tan(x)
  88. Return the tangent of ``x``.
  89. .. function:: tanh(x)
  90. Return the hyperbolic tangent of ``x``.
  91. .. function:: trunc(x)
  92. Return an integer, being ``x`` rounded towards 0.
  93. Constants
  94. ---------
  95. .. data:: e
  96. base of the natural logarithm
  97. .. data:: pi
  98. the ratio of a circle's circumference to its diameter