Problem with a "while loop"

Problem with a "while loop" - 消息

#1 已发布: 2011/3/4 08:39:06
zureks

zureks

0个赞,共9个帖子。

组: 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 已发布: 2011/3/4 09:57:45
Radovan Omorjan

Radovan Omorjan

325个赞和1个踩,共2,052个帖子。

组: 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 已发布: 2011/3/5 16:17:33
zureks

zureks

0个赞,共9个帖子。

组: 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
  • 有新帖
  • 无新帖