A function is a broad concept used to describe what something does, how it transforms inputs into outputs, or the role it plays within a system. Across disciplines the term unites ideas of mapping, operation, role and purpose, but its precise meaning and formalization differ with context.

Mathematics

In mathematics a function is a relation that assigns to each element of one set (the domain) a single element of another set (the codomain). Fundamental properties include injectivity (distinct inputs yield distinct outputs), surjectivity (every element of the codomain is an output of some input) and bijectivity (both). In analysis functions may be studied for continuity, differentiability and integrability. Other families include arithmetic, trigonometric, exponential and more abstract mappings between algebraic structures.

Computing and programming

In computer science a function is a named block of code that performs a task, often accepting parameters and returning a value. Functions promote modularity, reuse and abstraction. Variants and related terms include procedures, methods and subroutines. Key distinctions are pure functions, which have no side effects and always produce the same output for the same inputs, and impure functions, which may modify state or interact with external systems. Higher-order functions accept or return other functions, and recursion expresses repetition by self-reference.

Biology and physiology

In biology the term denotes the normal activity or role of a component within an organism or ecosystem, such as the function of the kidney in filtering blood. Functional descriptions may be mechanistic (how a process occurs) or evolutionary (why it evolved). Scientists distinguish between selected effects, system-level contributions, and emergent roles arising from interactions.

Engineering, design and social sciences

Engineers use function to mean required capabilities of a system or component; functional decomposition breaks a system into smaller tasks. In social sciences, functionalism describes how institutions or practices contribute to the stability or change of a society, distinguishing manifest (intended) from latent (unintended) functions.

Distinctions and usage

  • Relation vs function: a mathematical relation may associate one input with many outputs; a function associates each input with a single output.
  • Mapping vs process: some contexts emphasize static mapping (mathematics), others dynamic processes or roles (biology, engineering).
  • Specification vs implementation: in design, a function can be a requirement that various implementations realize.

Understanding which sense of "function" applies in a discussion clarifies questions about precision, causation, role and measurement. The concept remains central across science, technology and the humanities because it links causes or tasks to their observable effects or purposes.