Minimizing a non-linear function
In the previous recipe, we saw how to minimize a very simple linear function. Unfortunately, most functions are not linear and usually don’t have nice properties that we would like. For these non-linear functions, we cannot use the fast algorithms that have been developed for linear problems, so we need to devise new methods that can be used in these more general cases. The algorithm that we will use here is called the Nelder-Mead algorithm, which is a robust and general-purpose method that’s used to find the minimum value of a function and does not rely on its gradient.
In this recipe, we’ll learn how to use the Nelder-Mead simplex method to minimize a non-linear function containing two variables.
Getting ready
In this recipe, we will use the NumPy package imported as np
, the Matplotlib pyplot
module imported as plt
, the Axes3D
class imported from mpl_toolkits.mplot3d
to enable 3D plotting, and the SciPy optimize
module...