Python:math module

From AIMSWiki

The functions on this page: acos, asin, atan, atan2, ceil, cos, cosh, degrees, exp, floor, hypot, log, log10, modf, radians, sin, sinh, sqrt, tan, tanh,

The constants on this page: e, pi

Table of contents


Constants

  • e: 2.7182818284590451
  • pi: 3.1415926535897931

Trigonometric functions

The trigonometric functions

  • sin(x)
  • cos(x)
  • tan(x)

and their inverses

  • asin(x)
  • acos(x)
  • atan(x)
  • atan2(y, x): This returns the arctan of y/x

all use radians (and not degrees). You can use

  • degrees(x) to convert from radians to degrees, and
  • radians(x) to convert from degrees to radians.

Hyperbolic

  • sinh(x)
  • cosh(x)
  • tanh(x)

Integer functions

  • ceil(x) (the ceiling of x)
  • floor(x) (the floor of x)
  • modf(x) (the fractional and integer parts of x), for example
>>> modf(10.5)
(0.5, 10.0)

Other functions

  • exp(x) (ex)
  • log(x) (the logarithm to base e)
  • log10(x) (the logarithm to base 10)
  • sqrt(x) (the square root of x)
  • hypot(x, y) (compute the length of the vector (x, y): sqrt(x*x + y*y))

Return to the Python index