Let $f\colon \Bbb R^n\to \Bbb R$ be a function. Then, $f$ is convex if and only if the function $g\colon\mathbb{R} \to \mathbb{R}$ defined as $g(t) \triangleq f(x+tv)$, with domain $$ \operatorname{dom}(g)=\{t\mid x+tv \in \operatorname{dom}(f), x\in \operatorname{dom}(f), v\in \mathbb{R}^n\}, $$ is convex in $t$.
It says that: a function is convex if and only if it is convex when restricted to any line that intersects its domain. My question was how to prove it?
Reference: Steven Boyd, Convex Optimization, Cambridge University Press, Page 67.
Here's a simple solution. A function $f:\mathbb{R}^n\to\mathbb{R}$ is convex iff the set $\Gamma_f=\{(x_1,\cdots,x_n,y)| f(x_1,\cdots,x_n)\leq y \}\subseteq\mathbb{R}^{n+1}$ is convex.
Now consider the region above the graph of $g(t)$: $\Gamma_G=\{(t,y)| g(t)\leq y\}$. But this set is just the intersection of $\Gamma_f$ with the plane centered at $x$ generated by the vectors $(v,0)$ and $(0,1)$. Since linear subspaces are convex, $\Gamma_f$ is convex, and the intersection of two convex bodies is still convex, $\Gamma_g$ is convex and so $g$ is convex.
The reverse direction is similar. Suppose $f$ is not convex. Then $\Gamma_f$ is not convex, and there exist points $a,b\in\Gamma_f$ such that the line between $a,b$ is not entirely contained in $\Gamma_f$. Since by definition such a line cannot be vertical, it means that the projection of such a line on to the first $n$ coordinates is again a line, and so we may choose that as the line that $g$ picks out. But then $g$ is not convex for the same reason- the line between $a$ and $b$ is not wholly contained in $\Gamma_g$.