Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.3K Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

What type of command do I use to repeat a function until it stop?

Posted 11 years ago

Hello community.

As I remember for other types of software, I can do a loop to repeat the equation until it satisfy a current condition.

So now I have an equation that I need repeat the function until it satisfy the condition. I have check Mathematica tutorials and I can't seem to find a best method (maybe I still don't understand the functions completely). Here is what I want to do.

    Tinitial = (*any value*)
f[t_] = (*something*)
(*Obtain Tnew*)
Tnew=Tinitial -> False

Replace Tinitial with Tnew

Repeat Loop until Tnew=Tinitial -> True
Stop

Or Stop when Looping of function reached N-loops So any suggestions?

POSTED BY: Thai Kee Gan
3 Replies

As I remember for other types of software, I can do a loop to repeat the equation until it satisfy a current condition.

Why can't you use a While ?

tStop = 10;
t = 0;
keepLooping = True;

While[ keepLooping,
 t++;
 If[t >= tStop,
  keepLooping = False,
  Print["I am still looping !"]
  ]
 ]
POSTED BY: Nasser M. Abbasi
Posted 11 years ago

Thank you for your suggestions, I will try that. I have not thought of While, been occupied with For, Do, Nest and FixedPoint. How do While command replace Tnew into Twater?

POSTED BY: Thai Kee Gan
Posted 11 years ago
POSTED BY: Thai Kee Gan
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard