Convexity and Affineness In reading about convex optimization, the author states that all convex sets are affine.  Are affinity and convexity equivalent?  If I understand, both definitions incorporate the notion that a set is affine/convex iff for every two points in the set, the line connecting them is also in the set.  It seems as if they are as their respective definitions are almost identical.  I would appreciate a delineation of the differences between affine sets and convex sets.  

A set $S$ is convex iff for every pair of points $x,y\in S$, the line segment $\overline{xy}$ joining $x$ to $y$ is a subset of $S$. $S$ is affine iff for every pair of points $x,y\in S$, the whole infinite line containing $x$ and $y$ is a subset of $A$. In the xy-plane, for instance, $S=\{(x,0):0\le x\le 1\}$ is a convex set but not an affine set: the smallest affine set containing $S$ is the whole $x$-axis.
Mathematically, $S$ is affine iff it contains every affine combination of its points, where an affine combination of the points $x_1,\dots,x_n\in S$ is any point of the form $$a_1x_1+a_2x_2+\cdots+a_nx_n$$ such that $$a_1+a_2+\cdots+a_n=1\;.$$
$S$ is convex iff it contains every convex combination of its points. Convex combinations are the special case of affine combinations in which all of the coefficients are non-negative. That is, a convex combination of the points $x_1,\dots,x_n\in S$ is any point of the form
$$a_1x_1+a_2x_2+\cdots+a_nx_n$$ such that $$a_1+a_2+\cdots+a_n=1$$ and $$a_1,a_2,\dots,a_n\ge 0\;.$$
You can think of a convex combination of points as a kind of weighted average of those points; an affine combination is then a weighted ‘average’ in which some of the weights are allowed to be negative. In particular, $$\{ax+by:a+b=1\text{ and }a,b\ge 0\}$$ is simply the set of points on the line segment from $x$ to $y$; the point $ax+yb$ is $b$ fraction of the way from $x$ to $y$. The set
$$\{ax+by:a+b=1\}\;,$$
on the other hand, includes the whole line through $x$ and $y$. The point $-x+2y$, for instance, does not lie between $x$ and $y$: instead, $y$ is between $x$ and $-x+2y$.
