How can I know the function $$f(x,y)=\frac{y^2}{xy+1}$$ with $x>0$,$y>0$ is convex or not?
-
7$\begingroup$ Have you looked at the Hessian matrix? If it is positive semidefinite, $f$ is convex. $\endgroup$– Michael GreineckerCommented Mar 12, 2012 at 20:37
-
$\begingroup$ I checked the Hessian matrix, but unfortunately it is indefinite. $\endgroup$– Xiangyu MengCommented Mar 12, 2012 at 20:51
-
8$\begingroup$ So the two eigenvalues of the Hessian have opposite signs, meaning one eigenvalue is negative. The function will be concave in the direction of the corresponding eigenspace. $\endgroup$– Harald Hanche-OlsenCommented Mar 12, 2012 at 21:18
-
$\begingroup$ Thanks for your answer. I think it is a good suggestion. $\endgroup$– Xiangyu MengCommented Mar 12, 2012 at 22:13
3 Answers
Consider $y=x$ then we have $\displaystyle g(x)=\frac{x^2}{x^2+1}=1-\frac 1{x^2+1}$
The second derivative of this is $g''(x)=\frac{2-6x^2}{(1+x^2)^3}$ and will change sign around $x=\frac 1{\sqrt{3}}$ so that $g$ is convex in $(0,\frac 1{\sqrt{3}})$ and concave in $(\frac 1{\sqrt{3}},\infty)$.
Your function is clearly not convex nor concave on $(\mathbb{R^{+*}})^2$ but you could search more restricted sets if needed...
Here is a picture (from below) of your function (convex near $y=0$ and concave when $y$ becomes larger at least in the x=y direction, in the x=-y direction it looks convex...) :
-
$\begingroup$ What is the motivation for setting $y = x$ ? $\endgroup$ Commented Aug 2, 2020 at 13:32
-
$\begingroup$ Simplify the problem to disprove convexity (it is a trick and proving complexity may require something like a Hessian for derivable functions). $\endgroup$ Commented Aug 3, 2020 at 14:17
-
$\begingroup$ yeah but you already know the answer about the convexity in advance right. Is there anyway to do this in an objective manner ? $\endgroup$ Commented Aug 5, 2020 at 3:56
-
$\begingroup$ In fact I didn't know it was convex or not and set $y=x$ to get some intuition. The Hessian way proposed in the comments and by robjohn is the way to go for two variables or more for a differentiable real function. $\endgroup$ Commented Aug 5, 2020 at 8:22
The Hessian of $\frac{y^2}{1+xy}$ is $$ H = \frac1{(1+xy)^3}\begin{bmatrix} 2y^4&-y^2(3+xy)\\[12pt] -y^2(3+xy)&2 \end{bmatrix} $$ and $$ \begin{bmatrix} u&v \end{bmatrix} H \begin{bmatrix} u\\v \end{bmatrix} =\frac2{(1+xy)^3}(v-uy^2)^2-\frac1{(1+xy)^2}uvy^2 $$ Setting $\begin{bmatrix}u&v\end{bmatrix}=\begin{bmatrix}1&y^2\end{bmatrix}$ gives $$ \begin{bmatrix} 1&y^2 \end{bmatrix} H \begin{bmatrix} 1\\y^2 \end{bmatrix} =-\frac{y^4}{(1+xy)^2} $$ so $\frac{y^2}{1+xy}$ is not convex as long as $y\ne0$.
-
$\begingroup$ What is the motivation for setting [$u$ $v$] = [$1$ $y^2$] ? $\endgroup$ Commented Aug 2, 2020 at 13:31
-
$\begingroup$ We want to find a point which gives a negative value. $\frac2{(1+xy)^3}(v-uy^2)^2-\frac1{(1+xy)^2}uvy^2=-\frac{y^4}{(1+xy)^2}$ at $\begin{bmatrix}u&v\end{bmatrix}=\begin{bmatrix}1&y^2\end{bmatrix}$ $\endgroup$– robjohn ♦Commented Aug 2, 2020 at 14:18
The book "Convex Optimization" by Boyd, available free online here, describes methods to check.
The standard definition is if f(θx + (1 − θ)y) ≤ θf(x) + (1 − θ)f(y) for 0≤θ≤1 and the domain of x,y is also convex.
So if you could prove that for your function, you would know it's convex.
The Hessian being positive semi-definite, as mentioned in comments, would also show that the function is convex.
See page 67 of the book for more.
-
$\begingroup$ Your answer is not useful. I think checking the eigenvalue of the Hessian matrix maybe a good approach. $\endgroup$ Commented Mar 12, 2012 at 22:13
-
4$\begingroup$ It is a very good book on the subject if you wish to go deeper than simple calculus. $\endgroup$ Commented Mar 12, 2012 at 22:26
-
1$\begingroup$ Using the standard definition is almost always completely useless. The only time it is useful is if you have a function which is not continuous in its second derivative (or it doesn't exist) then you can rule out it is convex if you can numerically find a counter-example simply by randomly evaluating SEVERAL points. But this isn't generally practical or fun, nor can it ever prove a function IS convex, only that it isn't if you happen to find a counter-example. $\endgroup$– SquirtleCommented Jul 29, 2013 at 23:47
-
2$\begingroup$ @Squirtle, it can absolutely prove a function is convex: if you show a function satisfies that condition, it is convex. As a basic example, let f(x)=5x and you will see that that condition is always an equality. Therefore f(x)=5x is convex everywhere. $\endgroup$– RasputinCommented Jul 17, 2017 at 19:53