Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

math

import math

This module contains functions and constants to make trigonometric and non-trigonometric mathematics a breeze. The module also defines a couple of commonly used scientific and mathematical constants such as PI.

The math API

Every public name in math, wherever it is declared. Each links to the page that documents it.

NameKindSummary
math.Econstantrepresents Euler’s number, the base of natural logarithms
math.InfinityconstantMathematical infinity
math.LOG_10constantrepresents the natural logarithm of 10
math.LOG_10_Econstantrepresents the base 10 logarithm of e
math.LOG_2constantrepresents the natural logarithm of 2
math.LOG_2_Econstantrepresents the base 2 logarithm of e
math.NaNconstantMathematical NaN
math.PIconstantrepresents the ratio of the circumference of a circle to its diameter
math.ROOT_2constantrepresents the square root of 2
math.ROOT_3constantrepresents the square root of 3
math.ROOT_HALFconstantrepresents the square root of 1/2

Constants

PI

math.PI

represents the ratio of the circumference of a circle to its diameter

E

math.E

represents Euler’s number, the base of natural logarithms

LOG_10

math.LOG_10

represents the natural logarithm of 10

LOG_10_E

math.LOG_10_E

represents the base 10 logarithm of e

LOG_2

math.LOG_2

represents the natural logarithm of 2

LOG_2_E

math.LOG_2_E

represents the base 2 logarithm of e

ROOT_2

math.ROOT_2

represents the square root of 2

ROOT_3

math.ROOT_3

represents the square root of 3

ROOT_HALF

math.ROOT_HALF

represents the square root of 1/2

Infinity

math.Infinity

Mathematical infinity

NaN

math.NaN

Mathematical NaN


2021, Richard Ore and Zuri contributors