# A function with convex level sets but is not a convex function

I have the function $$f(x)=\sqrt{|x|},$$ with $x\in\mathbb{R}$. I understand that for some values $x,y\in$ dom$f$ and $t\in[0,1]$ that the function is not convex. However, I am having trouble proving that this function has convex level sets. We can define the level set as, $$L_{c}(f):=\{x\in\mathbb{R}\mid f(x)\leq c\}.$$

I understand that for the level sets to be convex means that $\forall x,y\in$ dom$f$, and $\forall t\in[0,1]$, $f(tx+(1-t)y)\leq c$. But I do not know how to use the fact that $f(x)$ is not convex.

Based on the level sets for $f(x)$, we know that $-c^2\leq x\leq c^2$. And so if we find that $-c^2\leq tx+(1-t)y\leq c^2$, then the level sets are convex?

The level sets are the intervals $[-c^2,c^2]$, which are obviously convex sets. However, $f$ is not a convex function.

You have probably learned that if $f$ is convex, then its level sets are convex. his is an example that shows that the converse is not true in general.

You can attain your goal by proving that $\sqrt{|X|}$ is a quasi-convex function; that is, $f(tx+(1-t)y) \le \max \{f(x),f(y)\}$.

Assume wlog $x \le y$.

For $x \ge 0$, $f(x)$ is increasing; so, if $0<x<y$, $f(tx+(1-t)y) \le f(y)$.

Similarly, for $x \le 0$, $f(x)$ is decreasing; so, if $y \le 0$, $f(tx+(1-t)y) \le f(x)$.

Finally, suppose $x < 0 < y$. If $|y| \ge |x|$, then $f(tx+(1-t)y) \le f(y)$. And if $|y| \le |x|$, then $f(tx+(1-t)y) \le f(x)$.