Maths and AI | Concave, Convex Function and Minima and Maxima of a function

Adarsh Pathak
Mathematics and AI
Published in
4 min readApr 18, 2020

--

One of the most important term you will see while implementing Machine Learning models is concave , convex functions and maxima and minima of a function. Lets see what it is.

Plot graph of function f(x) and see its graph. If the function is concave, its graph will be inverted bowl shape and if it convex it shape will be of bowl shape. So next question is how will you plot the graph of a very complex function. example:- g(x) = x² + x*sin(x) + exp(-x), can you plot this function on paper? Probably No without computers help you can not plot them. So how will you find whether g(x) is concave or convex?

Convex and Convex functions

Lets plot g(x) first can find wether it is concave or convex.

g(x) graph

This graph helps us to find that g(x) is a convex function. Can you solve this problem without plotting a graph? Let’s solve it mathematically and later we will verify our answer with the help of this graph.

Steps to find whether a function is concave or convex:

  1. Differentiate function twice.
  2. if the second derivation of the function is positive then we can say it is convex otherwise the function is convex.

Solve g(x) using derivative method.

g(x) = x² + x*sin(x) + exp(-x)

differentiate g(x) with respect to x.

g’(x) = 2x + sin(x) + x*cos(x)- exp(-x)

again differentiate g’(x) with respect to x.

g’’(x) = 2 + cos(x) + cos(x)- x*sin(x) +e(-x)

g’’(x) = 2 + 2cos(x)-x*sin(x) + exp(-x)

Can you explain whether g’’(x) is positive or negative?

g’’(x) = 2+2cos(x) + exp(-x)- x*sin(x)

if we choose a range of x from -infinity to 2 that is (-infinity <x≤2). In this range we can say g’’(x) will always be positive .It means this function is convex function which is True. But what if we increase the range of x. If x < 0 then exp(-x) will increase exponentially so g’’(x) will always be greater than 0. What if x > 0?

In that case g’’(x) only depends on x*sin(x) value . since we know that sin(x) will oscillate from [-1 , 1] . g’’(x) will some times increase some time decrease. But overall if we observe the graph it is increase linearly. Check graph of g’’(x) in range[0,100] .

g’’(x) graph in range [1,100]

So in that graph x is varying from [-100 , 100]. In some interval g(x) is concave and in some interval it is convex. In this type of problem we can calculate convexity or concavity behaviour in a interval. We can also conclude from the function that global maximum and global minimum value of the function is at infinity and -infinity. That this function have local minimum and local maximum value in fixed interval. But there is no global minimum and global maximum value.

How to calculate minimum and maximum value of a function:

Before we discuss about global minimum and global maximum values, let’s discuss first how to calculate minimum and maximum value?

Steps to calculate maxima and minima of a function:

  1. Differentiate function f(x) and find value of x=a such that f’(a) = 0

2. Again differentiate f’(x) and check if f’’(a) ≥ 0 then the f(a) will be minimum value of f(x).

3. If f’’(a)< 0 then f(a) is maximum value of f(x).

This calculation helps us to find local minimum and local maximum value of f(x). Local minimum and local maximum value is least and maximum value of a function f(x) in that interval.

A function f(x) can have more that one local minimum and local maximum value.

Global Maximum and Global Minimum value

Global or absolute minimum is the lowest value of the function

Global or absolute maximum is the greatest value of the function.

A function f(x) can have only one absolute maximum and absolute minimum value.

courtesy mathisfun.com

Hope you like this article and understand the most important concept of maxima and minima and concave, convex functions. If you like this article give a clap. Share it with your friends or in your connections. Follow me and AI and Maths for more future articles on AI algorithms.Here i have point out topics which i will explain in this series. https://medium.com/@adarshp199877/ai-and-mathematics-121e4e200680

--

--