construct a function that is not convex I came across this question as a bonus question and would like some help disecting it.
construct a function $ f:\mathbb{R}\times\mathbb{R}\rightarrow\mathbb{R}$ such that $\forall\;y\in\mathbb{R} \;x\mapsto f(x,y)$ is convex and $\forall\;x\in\mathbb{R} \;y\mapsto f(x,y)$ is convex, but f is not convex, but $f$ itself is not convex.
I know what it means for $f$ to not be convex, however it is $\forall\;y\in\mathbb{R} \;x\mapsto f(x,y)$ that is giving me problems.
I did have a thought of $f=(\sqrt{|x|}+\sqrt{|y|})^2\leq1.$ I know that $f$ is convex, but I am having trouble determining the other two qualifiers.
Any suggestion, hints and help will be greatly appreciated. 
 A: Idea
If you consider $C^2$-functions, you can use that:


*

*$f(\cdot,y):\mathbb{R}\to\mathbb{R} \text{ convex }\Longleftrightarrow f''(\cdot,y)\geq 0 \text{ for arbitrary }y\in\mathbb{R}\Longleftrightarrow \partial_x^2 f\geq 0$

*$f(x,\cdot):\mathbb{R}\to\mathbb{R} \text{ convex }\Longleftrightarrow f''(x,\cdot)\geq 0 \text{ for arbitrary }x\in\mathbb{R}\Longleftrightarrow \partial_y^2 f\geq 0$

*$\begin{align*}f:\mathbb{R}^2\to\mathbb{R}^2 \text{ convex } &\Longleftrightarrow \text{The Hessian }D^2f=\begin{pmatrix}\partial_x^2 f & \partial_x\partial_y f\\ \partial_x\partial_y f & \partial_y^2 f\end{pmatrix}\text{ is positive semi-definite}\\ &\Longleftrightarrow \text{ all principal minors of }D^2f \text{ are non-negative}\end{align*}$
You want 1. & 2., but not 3. to hold, so since the principal minors $(D^2f)_{11}$ and $(D^2f)_{22}$ are non-negative because of 1. & 2., you need for the remaining principal minor $\det D^2f$: $$\det D^2f = \partial_x^2f\partial_y^2f-(\partial_x\partial_yf)^2<0$$ which means
$$\partial_x^2f\partial_y^2f<(\partial_x\partial_yf)^2.$$
(Note that the left side should be non-negative because of 1. and 2.)
Example
While this should yield many examples, the easiest by far is $$f(x,y)=xy$$ (with $0<1$ in the inequality above) which is neither convex (which we just proved) nor concave (easy to check).
A: Take $f(x,y)=x^2+y^2-100xy$. For fixed $y_0$, the function $x\to f(x,y_0)$ is convex because it's second derivative is $2$. Similarly for fixed $x_0$, the function $y\to f(x_0,y)$ is convex. However, $f$ is not convex in $\mathbb{R}^2$, because $f(0,0)=0$, $f(1,1)=-98$, but $f({1\over 2},{1\over 2})$ is ${1\over 2}-25$, which is not smaller than ${f(1,1)+f(0,0)\over 2}=-{98\over 2}$. In fact $f(x,x)=-98x^2$, so $f$ is concave along the line $y=x$.
