# Confusion regarding the convexity of a function

I want to know how come the function f(y)=1/y is convex?

-

## migrated from stats.stackexchange.comJan 9 '13 at 23:56

This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.

How do you understand the word 'convex'? Aka what is your definition of a convex function? – Calvin Lin Jan 9 '13 at 23:58
@CalvinLin The function is convex only if y > 0 if y < 0 it is concave. So how can we say it is convex – user34790 Jan 10 '13 at 0:01
@user34790 The function is not convex over the entire $\mathbb{R}$. However, probably in your setting, you are studying the function for $y>0$ only and hence it is convex. – user17762 Jan 10 '13 at 0:11
@user34790 Great! (I think you mean $y''>0$) I'm glad you pointed that out the 2 different regions. When people define functions, they also talk about the domain of the function. In this case, you will have to look at the domain, which as Marvis pointed out. – Calvin Lin Jan 10 '13 at 15:32

One way to check convexity is to check if the second derivative, if it exists, is positive. It is easy to check that the second derivative is positive for $y>0$ in your case.
We have $f(y) = \dfrac1y$. Hence, $f'(y) = -\dfrac1{y^2}$, $f''(y) = \dfrac2{y^3} > 0$, for $y>0$.
Hence, the function is convex for $y>0$ and concave for $y<0$.