gradient_descent2 ( f(), fp(), x, r, dxtol, fptol, itmax ) # gradient descent for a function of multiple parameters it = 0 Loop1: if ||fp(x)|| < fptol ) return xold = x beta = 1.0 Loop2: it = it + 1 if ( itmax < it ) return dx = - beta * r * fp(xold) if ( ||dx|| < dxtol ) return x = xold + dx if f(x) < f(xold) break Loop2 beta = beta / 2 Loop2 end Loop1 end Return x gradient_descent2 end