Prove convexity when restricted to a line

The second part of your proof is incorrect. Convexity is not a pointwise property, but a property of the function on a specific set (its domain in most cases). So, saying "it is also convex for $t=0$" is inaccurate.

I would simply use definition of convexity to prove this part:

($\Leftarrow$) Let us take $x_1,x_2\in\text{dom}f$. We need to show that for every $\alpha\in[0,1]$ \begin{equation} \alpha f(x_1)+(1-\alpha)f(x_2)\geq f(\alpha x_1+(1-\alpha)x_2). \end{equation} Now, since $g(t)=f(x+vt)$ is convex for all $x\in\text{dom}f$ and all $v$, for every $\alpha\in[0,1]$: \begin{align} \alpha g(t_1)+(1-\alpha)g(t_2)&\geq g(\alpha t_1+(1-\alpha)t_2) \\ \alpha f(x+vt_1)+(1-\alpha)f(x+vt_2)&\geq f(x+v(\alpha t_1+(1-\alpha)t_2)) \end{align} let us take $x=x_1$, $v=x_2-x_1$, $t_1=0$ and $t_2=1$, and assign them to the last inequality: \begin{equation} \alpha f(x_1)+(1-\alpha)f(x_2)\geq f(\alpha x_1+(1-\alpha)x_2) \end{equation} and therefore $f$ is convex.


I want to add the ($\implies$) part to Gilad's answer.

Consider multivariate, real-valued function $f$. For any $x \in \mathrm{dom} f$ and $v \in \mathbb{R}^{n}$,

The proof of $f$ convex $\implies$ $g$ convex, where

$g(t)=f( x+tv )$ and $G = \left\{ t \in \mathbb{R} : x+tv \in \mathrm{dom}f \right\} \subset \mathbb{R}$ is the domain of $g$,

can be done directly from definition: For any $a,b \in G$ and $\alpha \in [0,1]$, $$g(\underbrace{\alpha a + ( 1-\alpha ) b }_{t}) = f( x + (\underbrace{ \alpha a + ( 1-\alpha ) b }_{t})v ) = f( \underbrace{\alpha x + ( 1-\alpha ) x}_{x} + \alpha av + ( 1-\alpha ) bv)$$ $$=f( \alpha ( x + av ) + ( 1-\alpha ) ( x+bv ) ) \leq \alpha f( x+av ) + ( 1- \alpha ) f(x + bv) = \alpha g( a ) + ( 1-\alpha ) g( b )$$ (using convexity of $f$ with $x=( x+av ), y=( x+bv)$)

Alternatively, assume towards a contradiction that $g( t ) = f( x + tv )$ isn't convex: $\exists a,b, \in G$ and $\exists \alpha \in [0,1]$ such that (*) $$g( \alpha a + (1-\alpha ) b) > \alpha g( a ) + ( 1-\alpha ) g( b )$$ Yet, $g( \alpha a + ( 1 - \alpha ) b ) = f( x + ( \alpha a + ( 1-\alpha ) b)v ) = f( \alpha ( x + av ) + ( 1- \alpha ) (x+bv) ) \leq \alpha f( x + av ) + ( 1 - \alpha ) f( x + bv ) = \alpha g( a ) + ( 1 - \alpha ) g( b )$ which contradicts (*) hence $g$ is convex.

For reference, related two questions below have alternative proofs:

  • Poof- A function is convex iff it is convex when restricted to a any line that intersects its domain.
  • Convexity vs convexity on every line