Skip to main content

Math: How to Find the Minimum and Maximum of a Function

  • Author:
  • Updated date:

I hold both a bachelor's and a master's degree in applied mathematics.

How to find the max and min of a function

How to find the max and min of a function

Maximum and Minimum of a Function

Finding the minimum or maximum of a function can be very useful. It often comes up in optimization problems that do not have constraints, or in which the constraints do not prevent the function from reaching its minimum or maximum.

These types of problems occur a lot in practice. An example would be determining the price of a certain article. If you know the demand for a given price (or a good estimation of the demand), you can calculate the price for which you will make the most profit. This can be formulated as finding the maximum of the profit function.

The minimum and maximum of a function are also called extreme points or extreme values of the function. They can be local or global.

Local and Global Extrema

A local minimum/maximum is a point in which the function reaches its lowest/highest value in a certain region of the function. In formal words, this means that for every local minimum/maximum x, there is an epsilon such that f(x) is smaller/greater than all values f(y) for all y that have distance at most epsilon to x. That looks very complicated but it does mean as much as f(x) is the smallest/largest value for all points close to x. There might be values, however, that are smaller/larger than the local minimum/maximum, but they are further away.

The global minimum is the smallest value the function takes on in its entire domain. Equivalently, the local maximum is the largest value of the function. Therefore, every global extreme point is also a local extreme point, but the opposite is not true.

Do All Functions Have a Minimum and a Maximum?

A function does not necessarily have a minimum or maximum. For example, the function f(x) = x does not have a minimum, nor does it have a maximum. This can be seen easily as follows. Suppose the function has a minimum at x = y. Then fill in y-1 and the function has a smaller value. Therefore we have a contradiction and y was not the minimum, and hence the minimum does not exist. An equivalent proof can be given for the maximum.

The function f(x) = x2 does have a minimum, namely at x = 0. This is easily verified since f(x) can never become negative, since it is a square. At x = 0, the function has value 0, so this must be the minimum. It does not have a maximum, which can be proven using the exact same argument as we used before.

How to Find the Extreme Points of a Function

At a local minimum, the function changes direction. This is because it is the lowest point in its neighborhood. Therefore the slope of the function goes from negative to positive, since the function was decreasing until it reached the minimum, and then it started increasing again. This means that in the local minimum, the slope is equal to zero, and hence the derivative of the function must be equal to zero in the point that is the minimum. The same holds for the local maximum of a function, since there the function goes from increasing to decreasing.

Therefore, to find the location of the local maxima and local minima you have to solve the equation f'(x) = 0. Therefore you have to first find the derivative of the function. If you are not familiar with the derivative, or if you would like to know more about it I recommend reading my article about finding the derivative of a function. For this article, I assume the derivative is known.

After you have solved the equation f(x)= 0, you have found the locations at which the extrema are located. To find the value of the extrema you need to fill in the location in the function. From the solutions you can not directly see whether it is a local minimum or a local maximum, since both are solutions to the same equation. Therefore, you have to plot the function to determine this.

Also, you cannot say directly if you have found a global minimum or maximum, or if it is only local. Also, you can determine this with the help of the plot of the function.

An Example

As an example, we will use the function f(x) = 1/3 x3 - 4x. First we calculate the derivative of the function, which is:

f'(x) = x2 - 4

Then we solve f'(x) = 0:

x2 + 4 = 0

This gives x = 2 or x = -2. Therefore we know that the local extrema are located at 2 and -2. We fill both in to determine the value of the extrema:

1/3 23 - 4*2 = 8/3 - 8 = -16/3

1/3 (-2)3 - 4*-2 = -8/3 + 8 = 16/3

Then we plot the function.

Plot of 1/3*x^3 -4x

Plot of 1/3*x^3 -4x

As you can see in the plot, at x=-2 we have a local maximum with value 16/3. At x=2 we have a local minimum with value -16/3. We can also see however, that both local extrema are not global, since clearly there are points at which the function value is smaller than -16/3 and also there are points at which the function value is larger than 16/3. This means that the global minimum and global maximum do not exist, even though there do exist local extrema, which can happen.

Solving f'(x) = 0

Here, f'(x) was a quadratic function, which means we had to find the roots of a quadratic function to find the local extrema. Here I did not go deep into how I did solve this, but I did write an article about how to solve these kind of equations.

Another example is f(x) = sin(x). Then f'(x) = cos(x), which is zero at ±pi/2, ±2pi/2, ±3pi/2, ....

At these points, the function values are -1 and 1 alternating. This means that there are infinitely local minima with value -1 and infinitely many local maxima with value 1. Since the function is nowhere smaller than -1 and nowhere larger than 1 all these local extrema are global. So this is an example of a function where the global minimum and global maximum do exists and are not unique.

Plot of sin(x)

Plot of sin(x)


A minimum or a maximum is called an extreme point. A local extreme point is the smallest or largest value in its neighborhood. If it is also the smallest or largest at the entire domain of the function, it is called a global extreme point.

The local minima and maxima can be found by solving f'(x) = 0. Then using the plot of the function, you can determine whether the points you find were a local minimum or a local maximum. Also, you can determine which points are the global extrema.

Not all functions have a (local) minimum/maximum. And even if a function has a local minimum, it can happen that a global minimum does not exist. The same holds for the maximum. Also, the global minimum and maximum do not have to be unique. It might happen that at multiple points the function reaches its smallest or largest value.

This content is accurate and true to the best of the author’s knowledge and is not meant to substitute for formal and individualized advice from a qualified professional.


Umesh Chandra Bhatt from Kharghar, Navi Mumbai, India on December 06, 2020:

Well explained.