The optimization problem is best described as the search for a local maximum or minimum value of a scalar-valued function *f(x)*. This search can be performed for all possible input values in the domain of *f* (and in this case, we refer to this problem as an unconstrained optimization), or for a specific subset of it that is expressible by a finite set of identities and inequalities (and we refer to this other problem as a constrained optimization). In this section, we are going to explore both modalities in several settings.

### Unconstrained optimization for univariate functions

We focus on the search for the local minima of a function *f(x)* in an interval *[a, b]* (the search for local maxima can then be regarded as the search of the local minima of the function *–f(x)* in the same interval). For this task, we have the routine `minimize_scalar`

in the module `scipy.optimize`

. It accepts as obligatory input a univariate function *f(x)*, together with a search method.

Most search methods are based...