Custom Search

PYTHON 3: Math Functions

To call upon maths functions in Python3 we need to call on a library of maths functions.

We must therefore head the program with:

import math

Once this is done you can then have access to mathematical functions defined by the C standard. See this page.

These functions cannot be used with complex numbers; use the functions of the same name from the cmath module if you require support for complex numbers.

- The distinction between functions which support complex numbers and those which don't is made since most users do not want to learn quite as much mathematics as required to understand complex numbers.

- Receiving an exception instead of a complex result allows earlier detection of the unexpected complex number used as a parameter, so that the programmer can determine how and why it was generated in the first place.

Except when explicitly noted otherwise, all math functions return values are floats.

 

The math library contains constants (such as 'e' and 'π'), trigonometric values, hyperbolic functions, power and logarithmic functions, and lots of other number-theoretic and representation functions.

Do check it out! Most of them are way beyond the scope of my maths ability.