Problem with a "while loop"

Problem with a "while loop" - Сообщения

#1 Опубликовано: 04.03.2011 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 Опубликовано: 04.03.2011 09:57:45
Radovan Omorjan

Radovan Omorjan

325 сообщений из 2052 понравились пользователям.

Группа: 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 Опубликовано: 05.03.2011 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
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений