Hi All, I wanna solve Ax=b system using gauss iteration method. Bu I want the iteration stop when it reached stopping criteria. Instead of giving number of iteration before iteration start, iteration should stop when Norm(b-alast iteration)/Norm(b-afirst iteration)<10^(-10)
I guess we I can use NestWhileList instead of NestList but I could not figure it out.
Any suggestion? I have attached my code.
Thanks in advance..
Selahittin..
I used Length[] and I got 28 that is what I am looking for..
Thanks again..
Awesome!! Thanks. One more quick question. How can I find number of iteration? I used NestWhileList and count number of element in the list?
An alternative is to bake the length into the function.
X[{j_, k_}] := {j + 1, BGS.k + Inverse[DD - EE].b} NestWhile[X, {0, X0}, (Norm[b - A.#[[2]]]/Norm[b] > 10^(-10)) &] (* Out[137]= {27, {1.00000000003, 1.00000000025, 0.999999999371, 1.00000000038, 1.00000000019}} *)
Here is one way.
NestWhile[X, X0, (Norm[b - A.#]/Norm[b] > 10^(-10)) &] (* Out[22]= {1.00000000003, 1.00000000025, 0.999999999371, \ 1.00000000038, 1.00000000019} *)
Could instead use FiexdPoint.
FixedPoint[X, X0] (* Out[23]= {1., 1., 1., 1., 1.} *)