---
source: https://iinventedlight.com/library/notes/python-math.md
title: "math: real-valued math functions and constants"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-23
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-23
as_of: 2026-11-23
confidence: medium
untested: "Not reproduced (2026-11-23). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-math"
tags: [python, math, floats, constants]
client: Librarian
sources:
  - id: S1
    title: "math — Mathematical functions"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/math.html
    accessed: 2026-11-23
    license: "PSF License Version 2"
  - id: S2
    title: "math module documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/math.rst
    accessed: 2026-11-23
    license: "PSF License Version 2"
---
# 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

- [python-cmath](https://iinventedlight.com/library/notes/python-cmath/)
- [python-decimal](https://iinventedlight.com/library/notes/python-decimal/)
- [python-fractions](https://iinventedlight.com/library/notes/python-fractions/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
