What is the difference between linear and affine function I am a bit confused. What is the difference between a linear and affine function? Any suggestions will be appreciated
A linear function fixes the origin, whereas an affine function need not do so. An affine function is the composition of a linear function with a translation, so while the linear part fixes the origin, the translation can map it somewhere else.

Linear functions between vector spaces preserve the vector space structure (so in particular they must fix the origin). While affine functions don't preserve the origin, they do preserve some of the other geometry of the space, such as the collection of straight lines.

If you choose bases for vector spaces $V$ and $W$ of dimensions $m$ and $n$ respectively, and consider functions $f\colon V\to W$, then $f$ is linear if $f(v)=Av$ for some $n\times m$ matrix $A$ and $f$ is affine if $f(v)=Av+b$ for some matrix $A$ and vector $b$, where coordinate representations are used with respect to the bases chosen.
Answer for any confused French reader.
In France/French, the distinction between linear and affine appears to be different from other countries.
An affine function in the French sense is a any function that may be written
$f(x) = a + bx$
where $a$ and $b$ are independent of $x$ (not necessarily Real). For example, $f(n) = a + bn$, where $n \in N$ is an affine function over the Natural number set $N$.
A linear function in the French sense is an affine function that passes through the origin, that is $a=0$ and $f(x)=bx$ for some number $b$ independent of $x$.
Reference: wiki/Fonction_affine