Sufficient condition for a function to be affine If for a function $f:\mathbb{R}\to\mathbb{R}$, I can prove for any real $x,y$, that $f(\frac{x+y}{2})=\frac{f(x)}{2}+\frac{f(y)}{2}$, can I say for sure that it is affine, as in of the form $f(x)=ax+b$?
I am referring to the case of equality in Jensen's inequality here, but I'm thinking that maybe it is necessary to prove that $f(tx+(1-t)y)=tf(x)+(1-t)f(y)$ for any $t\in (0,1)$, and that the particular case of $t=1/2$, which I have, isn't sufficient.
 A: Having just $t = 1/2$ case is not sufficient. The following is the standard example for "midpoint convex does not imply convex" (assuming axiom of choice):

Let $f:\mathbb{R} \to \mathbb{R}$ be defined as follows. Since $\mathbb{R}$ as a $\mathbb{Q}$ vector space, it admits a Hamel basis. Let $\beta$ be an irrational basis element. Define $f$ to be the "projection to $\beta$", as in for any given $x$, $f(x)$ is the coefficient (a rational number) in front of $\beta$ in the basis expansion of $x$. This function is $\mathbb{Q}$-linear, and hence mid-point linear and mid-point convex. But it is not $\mathbb{R}$-linear or $\mathbb{R}$-convex. 

Assuming continuity then your assertion is true. If I remember correctly you can also weaken to assuming $f$ is Lebesgue measurable, but I don't remember the proof off the top of my head. 
A: Apparently you have $f(x)$ monotonic over some interval. That is sufficient. Rewrite as $f(x)+f(y)=2f(\frac{x+y}{2})$. Setting $y=0$ gives $2f(\frac{x}{2})=f(x)+f(0)$. Thus $f(x)+f(y)=2f(\frac{x+y}{2})=f(x+y)+f(0)$, so that $g(x)=f(x)-f(0)$ satisfies the Cauchy equation $g(x+y)=g(x)+g(y)$. Thus $g(x)=xg(1) \, \forall x \in \mathbb{Q}$. (I assume you know how to show this?) WLOG take $g(1) \geq 0$, otherwise just use $g'(x)=-g(x)$ in place of $g(x)$ in the following proof.
Since $f(x)$ is monotonic over some interval $I$, $g(x)$ is also monotonic over some interval $I$. Since $g(1) \geq 0$ and $g(x)=xg(1) \, \forall x \in \mathbb{Q}$, $g(x)$ cannot be decreasing, and so must be non-decreasing. Consider $x \in I \subseteq \mathbb{R}$, where $x$ is not an endpoint of $I$. Since the rationals are dense in $\mathbb{R}$, $\forall \epsilon>0, \exists p, q \in \mathbb{Q}$ s.t. $x-\epsilon<p<x<q<x+\epsilon$, then considering $\epsilon$ small enough so that $(x-\epsilon), (x+\epsilon) \in I$ (possible since $x$ is not an end point). Thus $g(1)(x-\epsilon) \leq pg(1)=g(p)\leq g(x) \leq g(q)=qg(1) \leq g(1)(x+\epsilon)$, so $g(x)=xg(1) \, \forall x \in I$, except maybe the end points.
Now for any $x \in \mathbb{R}$, we can write $x=x'+k$, where $k \in \mathbb{Q}$ and $x' \in I$, $x'$ not an endpoint of $I$. Then $g(x)=g(x')+g(k)=x'g(1)+kg(1)=xg(1)$, so $g(x)=xg(1) \, \forall x \in \mathbb{R}$, so $f(x)=g(x)+f(0)=x(f(1)-f(0))+f(0) \, \forall x \in \mathbb{R}$.
A: Hint: If we suppose $f$ is continuous then we can prove that $f$ is affine by following these steps:


*

*we prove, for all $b\in\mathbb{R}$,  if $f$ satisfies the given relation, then also for the function $g:x\mapsto f(x)+b$;

*we suppose $f(0)=0$  so we prove that $f$ is odd. We denote $f(1)=a$;

*we prove:
$$f(x)=ax,\quad \forall x\in \{\frac{m}{2^n}|m\in\mathbb{N}\};$$

*by density and continuity of $f$ we have $f(x)=ax,\quad \forall x\in\mathbb{R}_+$.
Now, we can conclude.

A: Let $g(x)=f(x)-f(0)$
1) $g(0)=0$
2)$g(-x)=-g(x)$
As $g(\frac{x-x}{2})=\frac{1}2(g(x)+g(-x))=0$
3)$g(x+y)=g(x)+g(y)$
As $g(\frac{x}{2})=\frac12g(x)$, So
$g(\dfrac{x+y}{2})=g(\frac {x}{2})+g(\frac {y}{2})$
4) $g(nx)=ng(x) \; n\in\mathbb{N}$
(Prove it by using 3)
5)$g(\frac pqx)=\frac{p}{q} g(x)$
(Using 4)
Then $g(x)=g(1)x \; $ if $x\in \mathbb{Q}$
If f is continuous, we can extend this to real numbers.
