This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
OM/Claudio_Maggioni_3/backtracking.m

8 lines
227 B
Mathematica
Raw Normal View History

2021-04-20 13:04:00 +00:00
function alpha = backtracking(f, gf, p, x, alpha, rho, c)
xn = x + alpha * p;
while f(xn(1), xn(2)) > f(x(1), x(2)) + c * alpha * gf(x(1), x(2))' * p
alpha = rho * alpha;
xn = x + alpha * p;
end
end