brute force methods note that if roots evaluates to true if roots is non-empty this is general test in pythonif evaluates to true if is non-empty or has nonzero value brute force optimization numerical algorithm we realize that xi corresponds to maximum point if yi yi similarlyxi corresponds to minimum if yi yi yi we can do this test for all "innerpoints to find all local minima and maxima in additionwe need to add an end pointi or nif the corresponding yi is global maximum or minimum implementation the algorithm above can be translated to the following python function (file brute_force_optimizer py)def brute_force_optimizer(fabn)from numpy import linspace linspace(abny (xlet maxima and minima hold the indices corresponding to (localmaxima and minima points minima [maxima [for in range( - )if [ - [ + ]maxima append(iif [ - [iy[ + ]minima append(iwhat about the end pointsy_max_inner max([ [ifor in maxima]y_min_inner min([ [ifor in minima]if [ y_max_innermaxima append( if [len( )- y_max_innermaxima append(len( )- if [ y_min_innerminima append( if [len( )- y_min_innerminima append(len( )- return and values return [( [ ] [ ]for in minima][( [ ] [ ]for in maximathe max and min functions are standard python functions for finding the maximum and minimum element of list or an object that one can iterate over with for loop