alternative definition of Affine map 
Let $f:X\longrightarrow Y$ be a function on real vector spaces (note that $X,Y$ have arbitrary dimensions). If $T(x)=f(x)-f(0)$ is linear, $f$ is called an affine map.

Prove that $f$ is affine if and only if $f\left(\displaystyle\sum_{k=1}^na_kx_k\right)=\displaystyle\sum_{k=1}^n a_k f(x_k),\ \forall n\in\mathbb N,\ \forall x_1,x_2,\dots,x_n\in X,\ \forall a_k\in\mathbb R\text{ such that }\displaystyle\sum_{k=1}^na_k=1 \ .$ 
 A: Suppose $f$ is affine. Then the $T$ above is linear. Then $f(x) = Tx + f(0)$.
Now suppose $\sum_k a_k =1$. Then $f(\sum_k a_k x_k ) = \sum_k a_k T x_k + f(0)$, by linearity, and since $\sum_k a_k =1$, we have 
$\sum_k a_k T x_k + f(0) = \sum_k a_k (T x_k + f(0)) = \sum_k a_k f(x_k)$, as required.
For the other direction, suppose $f(\sum_k a_k x_k ) = \sum_k a_k f(x_k)$ whenever $\sum_k a_k =1$. Define $T(x) = f(x)-f(0)$. We want to show that $T$ is linear. Let $\lambda \in \mathbb{R}$, then
\begin{eqnarray}
T(\lambda x) &=& f(\lambda x)-f(0) \\
&=&  f(\lambda x + (1-\lambda)0) + f(0) \\
&=&  \lambda f(x) + (1-\lambda)f(0)-f(0) \\
&=&  \lambda(f(x)-f(0)) \\
&=&  \lambda T(x)
\end{eqnarray}
Now consider
\begin{eqnarray}
T\left(\frac{x+y}{2}\right) &=& f\left(\frac{x+y}{2}\right) -f(0) \\
&=&  \frac{1}{2}(f(x)+f(y)) -f(0) \\
&=&  \frac{1}{2}(f(x)-f(0)+f(y) -f(0) ) \\
&=&  \frac{1}{2}(T(x) + T(y))
\end{eqnarray}
Combining this with the previous result, we have $T(x+y) = T(x)+T(y)$, hence $T$ is linear.
