X-Y Plot Region

X-Y Plot Region - Extends SMath Studio with a X-Y Plot Region. - Сообщения

#121 Опубликовано: 22.05.2013 06:07:20
Davide Carpi

Davide Carpi

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

Группа: Moderator

Wrote

For now my conclusion is a new survival rule:
"Do not use eval() in functions that you want to plot with xyplotregion."

I don't know if that is a bug or a feature of function definitions in general (dummy argument namespace concept), of eval() in particular or of the plugin. Of course, the fact that the internal plot function works with eval(), is sort of a hint...


In the same way you cannot use eval() with my Nonlinear Solvers, if eval() contains undefined variables (this behavior was noticed by omorr some month ago).

[edit] this is true also for the built-in solve() function.


best regards,

w3b5urf3r
eval.png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 пользователям понравился этот пост
Radovan Omorjan 22.05.2013 07:25:00
#122 Опубликовано: 22.05.2013 07:27:26
Mike Kaganski

Mike Kaganski

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

Группа: User

The same inability to use eval() may be seen in functions as arguments:

[MATH lang=eng]f.1(x):x[/MATH]

[MATH lang=eng]f.2(x):eval(x)[/MATH]

[MATH lang=eng]k(f(x),y):f(y)[/MATH]

[MATH lang=eng]k(f.1(x),5)=5[/MATH]

[MATH lang=eng]k(f.2(x),5)=#[/MATH] -- x - not defined
С уважением, Михаил Каганский
2 пользователям понравился этот пост
Davide Carpi 22.05.2013 08:02:00, Radovan Omorjan 22.05.2013 07:57:00
#123 Опубликовано: 22.05.2013 07:56:18
Radovan Omorjan

Radovan Omorjan

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

Группа: Moderator

Thank you for mentioned this once more

We discussed about this many times with lots of examples of this contradictory situation. To make long story short, I think we are in some kind of "Catch-22" situation with eval() here. There are many situations where:

a ) if you do not use eval() you can not get the result
b ) the obtained result can not be used if you used eval()

and of course vice versa, more or less...

The question is. Is there any chance to get out of this paradoxal situation ?

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
3 пользователям понравился этот пост
Peter 22.05.2013 08:02:00, ioan92 23.05.2013 06:19:00, Davide Carpi 22.05.2013 08:03:00
#124 Опубликовано: 22.05.2013 08:00:09
Davide Carpi

Davide Carpi

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

Группа: Moderator

Wrote

The same inability to use eval() may be seen in functions as arguments


Yes, I suppose because the arguments preprocessing of user functions works like as I've explained in the post #120 about plugins functions
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 пользователям понравился этот пост
ioan92 23.05.2013 06:22:00
#125 Опубликовано: 22.05.2013 17:14:37
Вячеслав Мезенцев

Вячеслав Мезенцев

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

Группа: Moderator

The source code for the function eval():

[albumimg]153[/albumimg]

Therefore, it makes no sense to use this function where needed purely symbolic (pre)processing. This function is a numeric (TNumber eq = SMath.Math.Numeric.Expression.Calculate(args[0], store); ). Accordingly, the standard plot region is also numeric. X-Y Plot Region is not numeric since it uses a symbolic (pre)processing.
Russia ☭ forever, Viacheslav N. Mezentsev
2 пользователям понравился этот пост
Davide Carpi 01.02.2016 13:26:00, Mike Kaganski 22.05.2013 19:09:00
#126 Опубликовано: 22.05.2013 19:49:08
Mike Kaganski

Mike Kaganski

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

Группа: User

Wrote

The source code for the function eval():



Thank you for this useful information.

The problem, however, remains unresolved. There are cases when one must use eval() in a function (like the case I posted here) because there's no other way to obtain result (in my case it was too large number in the middle of a calculation). In the same time one must use tools like solve() or w3b5urf3r's NonlinearSolvers (or may like to use your wonderful extension).

So, the question is not why this is impossible (we kind of already guessed it), but how to change it from current unacceptable state in a satisfactory way.

The problem must not be totally unsolvable. If you use my example above like this:

k(eval(x);5)

then if x is undefined before the call, you get the standard "x - not defined" error, but if you define x previously, then the error will say "Variables should be defined for argument-functions" (as a side note, I must say that Russian translation of this text makes more sense - "You cannot pass values inside argument-functions" ). This means that Andrey has means to differentiate cases when a function is passed as argument, and not its value. In this case, if unresolved (throwing "x - not defined" error) eval() inside such function is detected, its processing must be postponed until its invocation, in which place the usual rules should be applied to the eval() called with actual defined parameters. In other words, when preparing functions, the resulting pseudo-code must still have all unresolved eval()s inherited from its "parents" in the corresponding places, and not preprocessed results of such eval()s.

This would eliminate a lot of frustration and limitations, and allow for much higher usability and intuitivity. SMath will simply be useful, and not just a toy.

Edit:
1. I might guess that the preparation of a function creates a representation where all user-defined functions are expanded, all extension (dll) functions are represented as their entry points and all special functions are processed like in the source code that you provided above. If so, then it would make sense to define yet another dll function "eval" that would take simply SMath-syntax text and act like a "SMath inside SMath". It would be used when the conditions depicted above are met instead of usual processing.
2. The same technique could be used for other special functions that create problems inside argument-functions, like str2num().

3. It is already possible for SMath to correctly process expressions which have some placeholders not filled (consider [MATH]time(#)[/MATH] call that in this partial form yields correct results). Thus, it could be useful to allow syntax like this: [MATH]k(f(#);5)[/MATH] to work without throwing errors. This would avoid cases when a formal parameter name happens to be previously defined.
С уважением, Михаил Каганский
2 пользователям понравился этот пост
Davide Carpi 23.05.2013 04:22:00, ioan92 23.05.2013 06:29:00
#127 Опубликовано: 22.05.2013 21:28:17
Вячеслав Мезенцев

Вячеслав Мезенцев

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

Группа: Moderator

In my opinion there is one solution. The function should only work with numerical optimization. In all other cases the argument must be returned as is.

[MATH]time(#)[/MATH] - this is a bug
Russia ☭ forever, Viacheslav N. Mezentsev
#128 Опубликовано: 22.05.2013 21:43:12
Mike Kaganski

Mike Kaganski

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

Группа: User

This is a bug that would be nice to turn into a feature This would make syntax of formal placeholders clean.

As to your solution - I seem to fail to follow you. Could you please show me what do I need to do to make XYPlot to show me a graph of the function ν(x*'MPa,300*'K) from this file?
С уважением, Михаил Каганский
#129 Опубликовано: 22.05.2013 22:03:54
Вячеслав Мезенцев

Вячеслав Мезенцев

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

Группа: Moderator

Wrote

As to your solution - I seem to fail to follow you. Could you please show me what do I need to do to make XYPlot to show me a graph of the function ν(x*'MPa,300*'K) from this file?


In earlier versions SMath Studio support the long integers. But the implementation is too slow, so Andrey lowered accuracy and range of integers. I think that this is the main problem. You bypass the big integers by using the eval(). Andrey promised to try to return long integers reworking their implementation.
My suggestion - it is an additional opportunity to skip this function without any exceptions.
Russia ☭ forever, Viacheslav N. Mezentsev
3 пользователям понравился этот пост
Davide Carpi 23.05.2013 04:27:00, ioan92 23.05.2013 04:26:00, Mike Kaganski 23.05.2013 05:45:00
#130 Опубликовано: 22.05.2013 22:38:07
Mike Kaganski

Mike Kaganski

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

Группа: User

To summarize, this solution will only be universally possible when the results of any thinkable expression that contains eval()s will be exactly same as of the same expression with eval()s removed (with only possibly different calculation time).

That would be a great time!
С уважением, Михаил Каганский
2 пользователям понравился этот пост
Davide Carpi 23.05.2013 04:27:00, ioan92 23.05.2013 04:26:00
#131 Опубликовано: 23.05.2013 04:44:38
Radovan Omorjan

Radovan Omorjan

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

Группа: Moderator

Wrote

To summarize, this solution will only be universally possible when the results of any thinkable expression that contains eval()s will be exactly same as of the same expression with eval()s removed (with only possibly different calculation time).

That would be a great time!


One more "hedeach-giving" example of this symptomatic behavior.

Regards
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#132 Опубликовано: 26.05.2013 06:30:02
Martin Kraska

Martin Kraska

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

Группа: Moderator

SMath crash on accessing context menu (try to switch on input display)

Error message details in attached text file
Konische Welle.sm (120 КиБ) скачан 66 раз(а).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#133 Опубликовано: 26.05.2013 06:45:55
sergio

sergio

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

Группа: User

Hello Martin,
I have no problems with Win7 and Smath 0.96 build 4884

Sergio
#134 Опубликовано: 26.05.2013 06:47:56
Radovan Omorjan

Radovan Omorjan

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

Группа: Moderator

I can confirm this - 0.96 build 4884, Win7(32). XY-plugin 0.1.4884.13578

I think Martin already mentioned this "Continue" thing. Context menu will produce this error, but we can choose "Continue".
BTW, plot should be selected first - just left click into it, then right click.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#135 Опубликовано: 26.05.2013 06:55:33
Martin Kraska

Martin Kraska

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

Группа: Moderator

Wrote


I think Martin already mentioned this "Continue" thing. Context menu will produce this error, but we can choose "Continue".



Right, but there is no way to access the context menu to switch on the input area and change the input expressions :-(
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#136 Опубликовано: 26.05.2013 06:57:56
Radovan Omorjan

Radovan Omorjan

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

Группа: Moderator

Wrote

Wrote


I think Martin already mentioned this "Continue" thing. Context menu will produce this error, but we can choose "Continue".



Right, but there is no way to access the context menu to switch on the input area and change the input expressions :-(



Yes, you are right. Trying to select, copy or whatever will be impossible. Quite annoying
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
#137 Опубликовано: 26.05.2013 07:00:48
Martin Kraska

Martin Kraska

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

Группа: Moderator

Wrote

Hello Martin,
I have no problems with Win7 and Smath 0.96 build 4884

Sergio



Sergio, can you please switch on the input area of both plots, save the file and post it (or send it to kraska@fh-brandenburg.de)?
Currently I almost rebuilt the plots from scratch, but would be interesting if that would be an option to recover a file.

Thanks, Martin
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#138 Опубликовано: 26.05.2013 07:10:57
Radovan Omorjan

Radovan Omorjan

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

Группа: Moderator

Hmm... a bit puzzling

I used Martin's previous version (SMath with plugins - 0.96.4875 and XY plugin 0.1.4883.2883) and it works. See the picture and the attached file

Konische Welle-debug.sm (141 КиБ) скачан 78 раз(а).
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
1 пользователям понравился этот пост
Martin Kraska 26.05.2013 07:41:00
#139 Опубликовано: 26.05.2013 07:13:24
sergio

sergio

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

Группа: User

Hello Martin,
I had mistakenly understood that the problem is on the plot ' geometries '
It was working fine
now trying on "spannungen" plot, I have the same problem
I apologize
Sergio
1 пользователям понравился этот пост
Martin Kraska 26.05.2013 07:42:00
#140 Опубликовано: 26.05.2013 07:21:57
sergio

sergio

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

Группа: User

the file posted by Radovan works correctly even with Win7(64) and Smath 0.96 build 4884
Sergio
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений