According to a calculus book I have been reading, we call a function $g(x)$ a convex function if
$$g(\lambda x +(1-\lambda)y) \leq \lambda g(x) +(1-\lambda)g(y)$$, for all $x,y$ and $0<\lambda<1$.
But if I have to check if a given function is convex or not,this definition seems hard and impractical to use. So,my question is, is there any easier way of checking convexity of a function and if there is,then why it is equivalent to this defiinition.
Thanks in advance!
What you gave is the standard definition of a convex function.
If $f$ is supposed to be continuous, it is enough to check that
$$f\left(\frac{x+y}{2}\right) \le \frac{f(x)+f(y)}{2}$$ for all $x,y$.
If $f$ is twice differentiable, it is enough to check that the second derivative is non negative.