Object:Gradient descent

To find a local minimum of a function with Gradient descent algorythm:

1. If function has many variables, e.g., f(x_{1}, x_{2}, ..., x_{n}), just choose an arbitrary point M_{0}in n-dimensional argument plane with coordinates (x_{1}, x_{2}, ..., x_{n}) (i.e., just give some initial values for every x) 2. Define a scalar stepMfor descending the function 3.RepeatCalculate gradient of the function at the point A_{0}Calculate new point A_{0}(x_{1}, x_{2},.., x_{n}) by calculating new coordinate for every x. Every new x_{n}value will be equal to previous value x_{n}-M* partial differential of the function in respect with x_{n}Untilgradient of the function equals 0 or its absolute value is "small enough"

After the procedure, the coordinates (x_{1},x_{2},..,x_{n}) will be the coordinates of a local minimum F_{min}(x_{1},x_{2},..,x_{n}).

## Example 1Edit

**Given function:** f(x,y) = -(x^2-7)-(y^2+12)+12

**Problem:** Find a local maximum when argument **x** is between -25 and 25, and argument **y** is between -25 and 25;

1. Let's choose initial M_{0} to be (0; 0). So x=0; y=0.

2. Let's choose **M** step to be one tenth: **M**= 0.1;

3. Let's repeat the cycle, but because we are searching for a maximum, not minimum, we have to change the - to +

Repeat ... xn+M * partial differential.. Until (condition)

In various mathematics software there are functions that will calculate gradient, so, let's construct the cycle in some of them.

### In Maple 10Edit

1. Defining function: (Press Ctrl+M before editing math text)

restart; // recommended to write before new calculation in Maplez := (x,y) -> -(x^2-7)-(y^2+12)+12; // defining the function