Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
SMath refuses to correctly handle the given example: error "Units don't match" Edited by user 23 March 2014 14:36:41(UTC)
| Reason: Not specified File Attachment(s): mkraska attached the following image(s): |
|
3 users thanked mkraska for this useful post.
|
on 29/05/2013(UTC), on 29/05/2013(UTC), on 07/08/2013(UTC)
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1332 time(s) in 876 post(s)
|
Confirmed |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Administration Groups: Registered, Advanced Member Joined: 23/06/2009(UTC) Posts: 1,740 Was thanked: 318 time(s) in 268 post(s)
|
|
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!" |
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
Maybe, this problem is related. SMath fails to correctly simplify exponents of units. File Attachment(s): mkraska attached the following image(s): |
|
2 users thanked mkraska for this useful post.
|
on 07/08/2013(UTC), on 07/08/2013(UTC)
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
I found a bloody workaround, which essentially spoils the visual appearance of the formula and is by no ways explicable to students. Normally, I say that non-matching units are an indication for physically wrong equations. But it turns out, that prior to draw this conclusion, you have to try hard spreading eval() over the components of the equation. You never know if you tried all possible combinations... I easily can be blamed for confusing the students by recommending inappropriate and unreliable math software, if even arithmetics do not work. Thus, this issue has rather high priority for me. I just hope that this can be fixed without complete rewrite of the units engine. If the fix requires to always simplify to base units (Pa is a derived unit, as it can be expressed by N, m, s), then be it, as long as I can still change the result unit to Pa or MPa. File Attachment(s): mkraska attached the following image(s): |
|
2 users thanked mkraska for this useful post.
|
on 07/08/2013(UTC), on 07/08/2013(UTC)
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/07/2010(UTC) Posts: 437 Location: Beer-Sheva Was thanked: 520 time(s) in 288 post(s)
|
I noticed that the operator Eval is only required for the square root
|
1 user thanked Ber7 for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 30/03/2011(UTC) Posts: 393
Was thanked: 132 time(s) in 113 post(s)
|
It seems to work without eval if one raises the expression to 0.5 instead of using the square root symbol. Edited by user 07 August 2013 14:01:43(UTC)
| Reason: Not specified
|
1 user thanked kilele for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
Originally Posted by: kilele It seems to work without eval if one raises the expression to 0.5 instead of using the square root symbol Can't confirm that. mkraska attached the following image(s): |
|
1 user thanked mkraska for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 30/03/2011(UTC) Posts: 393
Was thanked: 132 time(s) in 113 post(s)
|
I know that it may sound harsh but I think Andrey should fix symbolic engine issues like this one before developing any other features. This may scare off some users despite being SMath a great tool.
|
3 users thanked kilele for this useful post.
|
on 07/08/2013(UTC), on 07/08/2013(UTC), on 07/08/2013(UTC)
|
|
Rank: Advanced Member Groups: Registered
Joined: 30/03/2011(UTC) Posts: 393
Was thanked: 132 time(s) in 113 post(s)
|
Originally Posted by: mkraska Originally Posted by: kilele It seems to work without eval if one raises the expression to 0.5 instead of using the square root symbol Can't confirm that. It's strange, it happened to me the same as you but then changed the decimal delimiter and saved the file, closed it and opened it again, this time the calculation was right. it could be an issue related with saving the current session settings.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 30/03/2011(UTC) Posts: 393
Was thanked: 132 time(s) in 113 post(s)
|
Can you confirm this ? the first one is opened with period decimal enabled on tools->options, the other one with comma. Edited by user 07 August 2013 17:25:29(UTC)
| Reason: Not specified kilele attached the following image(s):
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1126 time(s) in 723 post(s)
|
Kilele, I confirm a dependence on the decimal separator setting, however, quite different from what you show. mkraska attached the following image(s): |
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 30/03/2011(UTC) Posts: 393
Was thanked: 132 time(s) in 113 post(s)
|
Yes we are experiencing different results! For your information I'm using the unofficial portable version 0.96.4909 which I think it is the 32bit patched one, my os is Vista32. I wonder if this is related to the way variables are dealt with on 32-bit and 64-bit systems. I think that not only the decimal symbol has influence but also the different combinations with the argument separator, some of them make the eval expression fail or even 0.5 is reported as "input string does not correct format", apart from the already mentioned error "units don't match". At least I hope this thread gives some new insights to Andrew. Edited by user 07 August 2013 22:06:31(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1332 time(s) in 876 post(s)
|
Originally Posted by: ioan92 and if possible give us some minimum survival rules About your functions the rules are: - Inside functions "global variables" are all the variables not defined inside the function but defined on the canvas; if you define a variable already defined on the canvas, SMath assumes that you are defining a local variable. If you want to write a global variable use the rule below. - if you assign a value to an input variable inside a function, the input variable will change globally (the value will propagate outside your function) (passing by reference feature - look this thread). IMHO is a good way to handle local/global variables, obviously if you know these rules best regards, Davide Edited by user 08 August 2013 23:06:22(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
1 user thanked Davide Carpi for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1332 time(s) in 876 post(s)
|
Originally Posted by: ioan92 What do you think about the troubling case of the function f11 from my file. There all the precautions are taken - all variables are exclusively locals but there seems appearing an impact on the global variables a..c ? Inside your function f11 you redefine the input variables, so you are using the 2nd rule, that is the way to (over)write the global variables. Originally Posted by: ioan92 Of course, as always, it's essential to know the rules I agree... two rules, not so hard Originally Posted by: ioan92 Are they those of C# programming? Nope, and I think that is better... P.S. I've update my previous post Edited by user 08 August 2013 22:38:57(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
1 user thanked Davide Carpi for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 30/03/2011(UTC) Posts: 393
Was thanked: 132 time(s) in 113 post(s)
|
|
1 user thanked kilele for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1332 time(s) in 876 post(s)
|
Originally Posted by: ioan92 If I'm not wrong, the main difference between a function and a subroutine (as in BASIC) is that a function use only the input variables, without modifying them. Are SMath functions behaving as subroutines ? If it's so, the name function is a false one? better is to call them subroutines ? I don't know if your description is correct, but you can see the SMath functions in this way |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
1 user thanked Davide Carpi for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,648 Location: Italy Was thanked: 1332 time(s) in 876 post(s)
|
Originally Posted by: kilele Thank you for showing us this thread... as you can see the point is not the name, only the fact that you have changed the input argument ( passing by reference feature description by Andrey - same thread) As written by Andrey, there are several SMath features arising from this property... Originally Posted by: w3b5urf3r_reloaded the rules are: - Inside functions "global variables" are all the variables not defined inside the function but defined on the canvas; if you define a variable already defined on the canvas, SMath assumes that you are defining a local variable. If you want to write a global variable use the rule below. - if you assign a value to an input variable inside a function, the input variable will change globally (the value will propagate outside your function) (passing by reference feature - look this thread) [edit] Probably a better way can be found, and I hope that this will be ; actually what I mean is that there is a logic and is not so complicated as appears if you don't know these rules. Edited by user 08 August 2013 23:27:49(UTC)
| Reason: Not specified |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
1 user thanked Davide Carpi for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 30/03/2011(UTC) Posts: 393
Was thanked: 132 time(s) in 113 post(s)
|
|
1 user thanked kilele for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 30/03/2011(UTC) Posts: 393
Was thanked: 132 time(s) in 113 post(s)
|
Originally Posted by: ioan92 If I'm not wrong, the main difference between a function and a subroutine (as in BASIC) is that a function use only the input variables, without modifying them. Are SMath functions behaving as subroutines ? If it's so, the name function is a false one? better is to call them subroutines ? According to the conclusion of this article you are right, though this definition depends on the language. http://en.wikibooks.org/...and_Functions#ConclusionMaybe this feature could have been implemented to differentiate functions from subroutines or procedures, for example if there is return of variables then it'd be a function and everything would remain local, otherwise, without return it'd be a procedure and these variables would be overwritten globally, provide different type of lines for subroutines and functions, use the keyword "ref" before each paramenter called by reference as in C#, etc. Edited by user 09 August 2013 03:26:23(UTC)
| Reason: Not specified
|
1 user thanked kilele for this useful post.
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.