{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"initial-bracket.ipynb","provenance":[],"collapsed_sections":[],"authorship_tag":"ABX9TyNWD5imoNBHASQJyK+3khf3"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"markdown","metadata":{"id":"2nkHIR9BNmae"},"source":["# Finding an Initial bracket \n","When optimizing a function, we often start by first bracketing an interval containing a local minimum. We then successively reduce the interval to converge to the local minimum."]},{"cell_type":"code","metadata":{"id":"8fhVinjdOsKZ"},"source":["import numpy as np"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"LoibsOYtHTlE"},"source":["# function definition - single dimension\n","def f(x):\n"," #return x**4 - 14*x**3 + 60*x**2 - 70*x\n"," return x**2 + 4 * np.cos(x)"],"execution_count":null,"outputs":[]},{"cell_type":"code","metadata":{"id":"gASFIEO5Wdkb"},"source":[" '''Function to find the range in the function which contains the minimum value of the function\n"," Satisfying the condition f(x1)>f(x0) f_x2): #''' Check for f(x2) > f(x1)'''\n"," \n"," while (f_x1 > f_x2): #''' Finding the point in the function which is greater than f(x2) such that f(x1)>f(x2)f(x0) f_x2): #Check for f(x2) > f(x1)\n"," \n"," while (f_x1 > f_x2): Finding the point in the function which is greater than f(x2) such that f(x1)>f(x2)