Home

function

A function is a relation between two sets that assigns to every element of a domain exactly one element of a codomain. In mathematics, a function f from X to Y maps each x in X to a y in Y, written f(x) = y. The domain is the set of permissible inputs; the codomain is the target set, and the range is the set of actual outputs.

Functions can be classified by how they map inputs to outputs. An injective (one-to-one) function assigns distinct

Examples include polynomial, exponential, logarithmic, and trigonometric functions, as well as constant and piecewise-defined functions. Piecewise

In computer science, a function (or method) is a named block of code that accepts inputs and

outputs
to
distinct
inputs;
a
surjective
(onto)
function
covers
every
element
of
the
codomain;
a
bijective
function
is
both
injective
and
surjective
and
thus
has
an
inverse
function
f⁻¹
that
undoes
the
mapping.
Functions
can
be
composed:
if
g
maps
some
domain
to
an
intermediate
set,
then
f
∘
g
maps
the
original
domain
to
the
final
codomain.
The
graph,
formula,
table,
or
rule
may
describe
a
function.
functions
use
different
formulas
on
different
input
ranges
and
can
model
a
variety
of
real-world
behaviors.
returns
a
value.
Functions
may
have
side
effects
or
be
pure,
depending
on
whether
they
modify
state
outside
their
scope.
They
can
be
first-class,
meaning
they
can
be
passed
as
arguments,
returned
from
other
functions,
or
stored
in
data
structures.
Higher-order
functions,
closures,
and
recursion
enable
modular,
abstract
programming
and
expressive
control
structures.