Gradient Descent

This function finds the local minima of a function.
2.2K Downloads
Updated 3 Dec 2012

View License

Finds local minima according to http://en.wikipedia.org/wiki/Gradient_descent

Run test_grad_descent for example.

>>The first output of the function should be the function value whereas the
>>second should be the gradient

% Inputs:
% func : the function in which to be optimised over, must
% return value as first argument and gradient as second
% x : starting point to begin optimisation
% gamma (optional) : minimising parameter, small values will get to the
% local maxima, slowly whereas bigger parameters will
% be faster but might overshoot (default 0.2)
% iter (optional) : Number of iterations over which it is optimised
% (default 100)
% thresh (optional): stopping criteria for which the function is not
% minimised any more. (default 1e-6)
% display (optional): Whether or not to display ouput of iteration,
% function value, and change (default 1)
%
% Outputs:
% x: locally optimised location
% val: f(x) i.e. the function value

Thanks,
Sachin

Cite As

Sachinthaka (2024). Gradient Descent (https://www.mathworks.com/matlabcentral/fileexchange/38588-gradient-descent), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.0.0

>> Changed the output order to x val such that you get the optimised value first.
>> Showed more options in the demo file

1.0.0.0