Affine Function — Definition, Formula & Example
An affine function is a linear function shifted by a constant: it scales and combines its inputs, then adds a fixed offset. Its graph is a line, a plane, or a higher-dimensional flat surface. That surface does not have to pass through the origin.
A function is affine if there exist an matrix and a vector such that for all . An equivalent condition is that for all and all real . The map is the linear part, and is the translation.
Key Formula
Where:
- = Input vector in
- = An matrix that gives the linear part of the function
- = Constant vector in , equal to
Worked Example
Problem: Let . Find the linear part and the translation of , then show that is affine but not linear.
Step 1: Find the translation by evaluating at the origin.
Step 2: Subtract to get the linear part. It is multiplication by the matrix , so has the affine form. Its graph is a plane that crosses the -axis at .
Step 3: Test additivity with and . The two sides disagree, so is not linear. The constant gets counted twice on the left side but only once on the right.
Answer: The linear part is and the translation is . So is affine. Since and additivity fails, is not linear.
Why It Matters
Each fully connected layer of a neural network applies an affine function before its nonlinearity. In multivariable calculus, the tangent-plane approximation is an affine function. Linear programming optimizes affine objectives subject to affine constraints.
Common Mistakes
Mistake: Calling with a linear map because its graph is a straight line.
Correction: In linear algebra, a map is linear only if and for all vectors and scalars. These conditions force . When , the function is affine, not linear. Algebra courses often say "linear function" loosely for , so check which meaning your course uses.
