math: real-valued math functions and constants
Answer: These functions cannot be used with complex numbers; cmath is the module for that. The math module provides common mathematical functions and constants, including those from the C standard. Most return values are floats. Constants include pi, e, tau, inf, and nan.
Real functions, not complex
math is the standard-library entry point for common mathematical functions and constants, including the ones defined by the C standard.
These functions cannot be used with complex numbers. If you need complex support, use the same names in the cmath module.
The docs explain the split: most users do not want to learn quite as much mathematics as complex numbers require.
Except when the docs say otherwise, all return values are floats.
Ceiling, floor, and constants
ceil(x) is the ceiling of x: the smallest integer greater than or equal to x.
floor(x) is the floor of x: the largest integer less than or equal to x.
fabs(x) returns the absolute value of x.
Listed constants include pi, e, tau (2π), inf for positive infinity, and nan for “Not a number”.
The source documentation
The library source documentation also says these functions cannot be used with complex numbers if you require support for complex numbers from the cmath module.
See also
Claims
- id: C1 claim: math provides common mathematical functions and constants from the C standard. source: S1 evidence: "access to common mathematical functions and constants"
- id: C2 claim: math functions cannot be used with complex numbers; use cmath instead. source: S1 evidence: "These functions cannot be used with complex numbers"
- id: C3 claim: Except where noted, return values are floats. source: S1 evidence: "all return values are floats"
- id: C4 claim: ceil(x) is the smallest integer greater than or equal to x. source: S1 evidence: "the smallest integer greater than or equal to x"
- id: C5 claim: The source docs also point complex work to cmath. source: S2 evidence: "require support for complex numbers"
Sources
- [S1] math — Mathematical functions. Python Software Foundation. https://docs.python.org/3/library/math.html . License: PSF License Version 2. Accessed 2026-11-23.
- [S2] math module documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/math.rst . License: PSF License Version 2. Accessed 2026-11-23.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, math — Mathematical functions; CPython, math module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, math — Mathematical functions; CPython, math module documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.
Cite this
iinventedlight. 2026. "math: real-valued math functions and constants." iinventedlight Library, iil:note:8krna8xc, version of 2026-11-23. https://iinventedlight.com/library/notes/python-math/. License: CC-BY-4.0.
@misc{iil_note_8krna8xc,
author = {{iinventedlight}},
title = {{math: real-valued math functions and constants}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-23},
url = {https://iinventedlight.com/library/notes/python-math/},
note = {Permanent ID iil:note:8krna8xc. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- python-math.schema.json (schema; CC-BY-4.0)
- python-math.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-math.md.