proving convexity of a function over a convex set Question: Suppose $X\subset \mathbb{R}^n$ is convex and $f: X \to \mathbb{R}$ is continuous, where $\mathbb{R}^n$ and $\mathbb{R}$ are given Euclidean metrics. Show that, if $f(\frac{x}{2} + \frac{y}{2}) \le \frac{f(x)}{2} + \frac{f(y)}{2}$ for all $x,y \in X$, then $f$ is a convex function.
I am not able to generalize $f(\frac{x}{2} + \frac{y}{2}) \le \frac{f(x)}{2} + \frac{f(y)}{2}$ to $f(tx +(1-t)y) \le tf(x) + (1-t)f(y)$ where $x,y \in X$ and $t \in (0,1)$.
 A: Ok, we have to work with $t\in [0,1]$ which we can always represent using the binary expansion
$$
  t = \sum_{k=1}^\infty a_k 2^{-k} \tag{1}
$$
where $a_k\in \{0,1\}$. Some preparation first. Let us focus on number with a finite binary expansions, that is those $t$ for which $a_k = 0$ in $(1)$ for $k$ big enough, namely
$$
  t = \sum_{k=1}^n a_k 2^{-k}. \tag{2}
$$
Note that for any $t$ in the form $(2)$, it holds that $1-t$ can be represented as
$$
  1-t =  \sum_{k=1}^n b_k 2^{-k}. \tag{3}
$$
where $b_k\in \{0,1\}$ and whose representation so far is not very important for us.

Lemma: For any $n\in \Bbb N$ and any $t_n$ as per $(2,3)$ it holds that
  $$
  f\left(t_n x + (1-t_n)y\right)\leq t_nf(x) + (1-t_n)f(y). \tag{4}
$$
  Proof: for $n=1$ we simply get the definition that you have. Now, suppose that $(4)$ holds for $n$ and consider $t_{n+1} = \sum_{k=1}^{n+1} a_k 2^{-k}$ such that $1-t_{n+1} = \sum_{k=1}^{n+1} b_k 2^{-k}$. Clearly, if $a_1 = b_1 = 1$ then we are in the situation of $n=1$, so w.l.o.g. we can assume that $a_1 = 1$ and $b_1 = 0$. Hence,
  $$
  f\left(t_{n+1} x + (1-t_{n+1})y\right) = f\left(\frac12x + \sum_{k=2}^{n+1} a_k 2^{-k} x + \sum_{k=2}^{n+1} b_k 2^{-k}y\right)
$$
  $$
  = f\left(\frac12 x + \frac12\left(t_nx + (1-t_n)y\right)\right)
$$
  where $t_n = 2(t_{n+1}-\frac12) = \sum_{k=1}^n a_{k+1} 2^{-k}$. We can now apply $(4)$ for $n=1$:
  $$
  \leq\frac12f(x) + \frac12 f\left(t_n x + (1-t_n)y\right)
$$
  and now apply $(4)$ for $n$
  $$
  \leq \frac12f(x) + \frac12t_nf(x) + \frac12(1-t_n)f(y) = t_{n+1}f(x) + (1-t_{n+1})f(y)
$$
  as desired.

Now, for any $t\in [0,1]$ we can construct a sequence $t_n\to t$ such that any $t_n$ has some representation as in $(2)$. As a result, by continuity we obtain that
$$
  f(tx+(1-t)y) = \lim_n f(t_nx + (1-t_n)y) \leq \lim_nt_nf(x) + (1-t_n)f(y) = tf(x) + (1-t)f(y).
$$
A: Hint: Proof by contradiction: suppose that there exists $x,y,t$ such that $f(tx + (1-t)y) > tf(x) + (1-t)f(y)$. Let $\epsilon > 0$ be such that for every $s \in (t - \epsilon, t + \epsilon), f(sx + (1-s)y) > sf(x) + (1-s)f(y)$ (Why can you find such an $\epsilon$?).
Next take an $s$ of the form $N / 2^k$ in the above interval (Can you see why one exists?).
Now you can prove by induction on $k$ by using the fact that 
$$ \frac{N}{2^k } = \frac12\left( \frac{\lfloor N / 2 \rfloor}{2^{k-1}} + \frac{\lceil N / 2 \rceil}{2^{k-1}}\right)$$ 
that every $s$ of the above form satisfies $f(sx + (1-s)y) \leq sf(x) + (1-s)f(y),$ which is a contradiction.
Hope this helps.
EDIT: Some more details on the inductive step:
Assume that for a given $k$ and $\tilde{N} = 1,2,\ldots, 2^k - 1$, the following holds: if $s = \tilde{N} / 2^k$, $f(sx + (1-s)y) \leq sf(x) + (1-s)f(y)$ (this is obvious for $\tilde{N} = 0 \text{ or }2^k)$. Let us now consider $k+1$.
Take $1 \leq N \leq 2^{k+1} - 1, s = N/2^{k+1}$. Now if 
$$\tilde{s} = \frac{\lfloor N/2 \rfloor}{2^k}, \tilde{t} = \frac{\lceil N/2 \rceil}{2^k} $$ 
then $0 \leq \lfloor N/2 \rfloor , \lceil N/2 \rceil \leq 2^k$ and $$sx + (1-s)y = \frac12 ([\tilde{s}x + (1-\tilde{s})y] + [\tilde{t}x + (1-\tilde{t})y]).$$
Can you take it from here?
