A convex function is a continuous function whose value at the midpoint of every interval in its domain does not exceed the arithmetic mean of its values at the ends of the interval. More generally, a function f(x) is convex on an interval [a, b] if for any two points x_1 and x_2 in [a, b] and any λ where 0<λ<1, f[λ x_1 + (1 - λ) x_2]<=λ f(x_1) + (1 - λ) f(x_2) (Rudin 1976, p. 101; cf. Gradshteyn and Ryzhik 2000, p. 1132). If f(x) has a second derivative in [a, b], then a necessary and sufficient condition for it to be convex on that interval is that the second derivative f''(x)>=0 for all x in [a, b].