Problem with a "while loop"

Problem with a "while loop" - Messages

#1 Posted: 3/4/2011 8:39:06 AM
zureks

zureks

0 likes in 9 posts.

Group: User

I have the following peculiar problem which seems to be linked to the "while loop". I calculate a value and iterate it a few times in a while loop (please see the link below). The result of the calculation changes very little between 3 or 4 iterations. However, when I try to use this result in an equation later I get an error message "Result is above max. allowed positive number."

This happens when the while loop is executed 4 times and more (bottom part of the screenshot), but does not when the loop is executed 3 times or less (top part). The numerical value changes less than 5%, so it cannot be that?

https://docs.google.com/leaf?id=0B6nP6MmgoMhdNjc3NmUyMDEtZTdiOC00NmYyLTk3MTItNjBhYmQ0ZWZiYjY2&hl=en_GB&authkey=CObT0e8O

I would appreciate any comments.

Regards

Stan
#2 Posted: 3/4/2011 9:57:45 AM
Radovan Omorjan

Radovan Omorjan

325 likes in 2052 posts.

Group: Moderator

Hello Stan,

In those or similar problems with the same error message, you can try disabling Symbolic optimization (Right click and choose Optimization|None or Numeric). On the other hand, when you have an iterative procedure as in your case, "gap=f(gap)", the symbolic answer might be quite complicated including the mentioned error message "Result is above max. allowed positive number.". Moreover, you are interested only in the numerical value and therefore you might consider using eval() function in those cases i.e. "gap=eval(f(gap)".

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#3 Posted: 3/5/2011 4:17:33 PM
zureks

zureks

0 likes in 9 posts.

Group: User

Thank you Radovan.

I know I can find a workaround, but it was just interesting to see that even though there is no problem with calculating the number (the while loop always executes fine) the value does not work when used later.

Regards

Stan
  • New Posts New Posts
  • No New Posts No New Posts