Question: Method of Steepest Descent Algorithm

I need to create an iterative code to find the minimum of the function


where x and b are vectors in R^2 and A is a 2X2 symmetric positive definite matrix. The implications of this is that the gradient of the function is


and that we are indeed searching for a minimum.

This is the code I have so far, using the while command to create a loop.

SteepestDescent := proc (A, b) local x, r, k, a;

x[0] := Vector(2, {(1) = -2, (2) = -2});

r[0] := b-A*x[0];

k := 0;

while r[k] <> 0

do k := k+1;

a[k] := Transpose(r[k-1])*r[k-1]/(Transpose(r[k-1])*A*r[k-1]);

x[k] := x[k-1]+a[k]*r[k-1];

r[k] := b-A*x[k]

end do; x := x[k]; print(x) end proc


So I use a matrix A and a vector B to test with the initial guess of x(0) as (-2,-2) and it just continues evaluating for 5-10 min and eventually the computer stalls and ends maple.


Any ideas about what I'm doing wrong?

Please Wait...