I know this question has been asked several times but the answers don't really make sense to me (I'll explain misunderstandings:)
Question: Suppose that a function $f: \mathbb R^n \rightarrow \mathbb{R}$ is both concave and convex. Prove that $f$ is an affine function. My solution uses: How to prove convex+concave=affine? as inspiration. However, I'm not sure if I did it correctly especially for the negative cases and I'm not exactly sure if I have showed that $g$ is linear in all cases.
et $g(x)=f(x)-a$, where $a=f(0)$. Thus $g(0)=0$. Also since $f$ is convex and concave, $g$ is convex and concave as well. Thus for $x,y \in \mathbb R^n $, $0 \leq \lambda \leq 1$, by inequalities resulting from convexity and concavity we have: $g(\lambda x +(1-\lambda) y)$=$\lambda g(x) +(1-\lambda)g(y)$. Does this mean $g$ is linear (why?, I don't get this from looking at the other stack-exchange posts) and hence $f$ is affine.
Case 2: $\lambda >1$. Note $x = (1/\lambda ) (\lambda x) + (1 - 1/\lambda) (0)$. Note then $1/ \lambda \in [0,1]$. Thus $g(x)=g((1/\lambda) (\lambda x) + (1 - 1/\lambda) (0))$=$1/\lambda \cdot g(\lambda x)+$$(1- 1/\lambda) \cdot g(0) $. This means $g(x)=1/\lambda * g(\lambda x)$. Hence $g(\lambda x)=\lambda g(x)$.
Case 3: $\lambda <0$. Not sure what to do now....
Perhaps I could do :
Case : $\lambda \leq -1$.
$$x=(-1/\lambda)(-\lambda x)+(1+1/\lambda)(0)$$ Note that $-1/\lambda \in [0,1]$
$g(x)=g((-1/\lambda)(-\lambda x) + (1 + 1/\lambda) (0))$=$-1/\lambda \cdot g(-\lambda x)+$$(1+1/\lambda) \cdot g(0) $. This means $g(x)=-1/\lambda * g(-\lambda x)$. Hence $g(-\lambda x)=-\lambda g(x)$.
Case: $-1< \lambda <0$ Note $-\lambda \in [0,1]$. Thus $x=(-\lambda)(-1/\lambda \cdot x)+(1+\lambda)(0)$
$g(x)=g((-\lambda) (-1/\lambda \cdot x) + (1 + \lambda) (0))$=$-\lambda \cdot g(-1/\lambda \cdot x)+$$(1+\lambda) \cdot g(0) $. This means $g(x)=-\lambda * g(-1/\lambda \cdot x)$. Hence $g(-1/\lambda \cdot x)=-1/ \lambda \cdot g(x)$.
Any help would much appreciated. Thanks.
Thus, linear in all cases...not exactly sure if this is correct at all.