# difference between convex and concave functions

what is the difference between convex, non-convex, concave and non-concave functions? how will we come to know that the given function is convex or non-convex? and if a function is non-convex then it will necessarily be concave one?
A convex function has one minimum – a nice property, as an optimization algorithm won’t get stuck in a local minimum that isn’t a global minimum. Take $x^2 - 1$, for example:
A non-convex function is wavy – has some ‘valleys’ (local minima) that aren’t as deep as the overall deepest ‘valley’ (global minimum). Optimization algorithms can get stuck in the local minimum, and it can be hard to tell when this happens. Take $x^4 + x^3 -2x^2 -2x$, for example:
A concave function is the negative of a convex function. Take $-x^2$, for example: