In mathematics, a constant function is a function whose output value is the same for every input value.[1][2][3] For example, the function y ( x ) = 4 {\displaystyle y(x)=4} is a constant function because the value of y ( x ) {\displaystyle y(x)} is 4 regardless of the input value x {\displaystyle x} (see image).
Formally, a constant function f(x):R→R has the form f ( x ) = c {\displaystyle f(x)=c} . Usually we write y ( x ) = c {\displaystyle y(x)=c} or just y = c {\displaystyle y=c} .
Example: The function y ( x ) = 4 {\displaystyle y(x)=4} or just y = 4 {\displaystyle y=4} is the specific constant function where the output value is c = 4 {\displaystyle c=4} . The domain is all real numbers ℝ. The codomain is just {4}. Namely, y(0)=4, y(−2.7)=4, y(π)=4,.... No matter what value of x is input, the output is "4".
In the context where it is defined, the derivative of a function measures the rate of change of function (output) values with respect to change in input values. A constant function does not change, so its derivative is 0.[6] This is often written: ( c ) ′ = 0 {\displaystyle (c)'=0} .
Example: y ( x ) = − 2 {\displaystyle y(x)=-{\sqrt {2}}} is a constant function. The derivative of y is the identically zero function y ′ ( x ) = ( − 2 ) ′ = 0 {\displaystyle y'(x)=(-{\sqrt {2}})'=0} .
The converse (opposite) is also true. That is, if the derivative of a function is zero everywhere, then the function is a constant function.[7]
Mathematically we write these two statements:
A function f : A → B is a constant function if f(a) = f(b) for every a and b in A.[8]
Real-world example: A store where every item is sold for 1 euro. The domain of this function is items in the store. The codomain is 1 euro.
Example: Let f : A → B where A={X,Y,Z,W} and B={1,2,3} and f(a)=3 for every a∈A. Then f is a constant function.
Example: z(x,y)=2 is the constant function from A=ℝ² to B=ℝ where every point (x,y)∈ℝ² is mapped to the value z=2. The graph of this constant function is the horizontal plane (parallel to the x0y plane) in 3-dimensional space that passes through the point (0,0,2).
Example: The polar function ρ(φ)=2.5 is the constant function that maps every angle φ to the radius ρ=2.5. The graph of this function is the circle of radius 2.5 in the plane.
There are other properties of constant functions.[source?]