Message Boards Message Boards


Gauss iteration method-nestlist-stopping criteria

Posted 9 years ago
4 Replies
2 Total Likes

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..


POSTED BY: selahittin cinar
4 Replies

I used Length[] and I got 28 that is what I am looking for..

Thanks again..

POSTED BY: selahittin cinar

Awesome!! Thanks. One more quick question. How can I find number of iteration? I used NestWhileList and count number of element in the list?

POSTED BY: selahittin cinar

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}} *)
POSTED BY: Daniel Lichtblau

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.} *)
POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract