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