[Math] Show the level set of a convex function is convex but that the converse is not necessarily true

convex optimizationconvex-analysis

I have the following question:

A level set of a function $f(x)$ is a set of the form $\{x : f(x) ≤ c\}$ for different constants $c ∈ \mathbb{R}$. Show that any level set of a convex function is also convex. Also, give an example to show the converse is NOT true, i.e., give an example of a simple 1-dimensional function such that any of its level sets is convex, but the function is not convex.

For this I took two sets $C$ and $D$ such that:

$$D = \{x:f(x)\}\space x \in \Bbb R$$

and

$$C = \{x:f(x) \leq c\}\space x,c \in \Bbb R$$

so $C \subset D$ therefore if $\space x_1,x_2 \in C\space$ then $\space x_1,x_2 \in D$ and since $D$ is convex then $C$ must be convex.

I am stuck on proving the converse though, I get conceptually that I want a quasiconvex function such that any level set is convex. A few places I read that $\sqrt\mid x \mid$ fits the bill but I can't see how it does. Thanks in advance!

Best Answer

The implication

$ \quad\qquad$ convex function $\qquad \Rightarrow\qquad$ convex level sets

is straightforward. Let me provide a counter-example for the inverse implication. It can be $\ f:\mathbb R\rightarrow\mathbb R\ $ given by:

$$ f(x)\ :=\ x+sin(x) $$

You may have a look at the graph if you have any doubts; then you may follow by a proof.