Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


2 Pages12>
Options
Go to last post Go to first unread
Offline mkraska  
#1 Posted : 29 May 2013 15:36:49(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,980
Germany

Was thanked: 1120 time(s) in 718 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):
units.sm (176kb) downloaded 36 time(s).
mkraska attached the following image(s):
units.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 3 users thanked mkraska for this useful post.
on 29/05/2013(UTC),  on 29/05/2013(UTC),  on 07/08/2013(UTC)

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Davide Carpi  
#2 Posted : 29 May 2013 16:32:11(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,639
Man
Italy
Location: Italy

Was thanked: 1323 time(s) in 873 post(s)
Confirmed Good
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline omorr  
#3 Posted : 29 May 2013 16:47:29(UTC)
omorr


Rank: Administration

Groups: Registered, Advanced Member
Joined: 23/06/2009(UTC)
Posts: 1,740
Man
Serbia

Was thanked: 318 time(s) in 268 post(s)
me too
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline mkraska  
#4 Posted : 19 June 2013 22:58:14(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,980
Germany

Was thanked: 1120 time(s) in 718 post(s)
Maybe, this problem is related. SMath fails to correctly simplify exponents of units.
File Attachment(s):
norme.sm (12kb) downloaded 32 time(s).
mkraska attached the following image(s):
norme.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 2 users thanked mkraska for this useful post.
on 07/08/2013(UTC),  on 07/08/2013(UTC)
Offline mkraska  
#5 Posted : 07 August 2013 10:45:05(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,980
Germany

Was thanked: 1120 time(s) in 718 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):
units2.sm (15kb) downloaded 35 time(s).
mkraska attached the following image(s):
units2.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 2 users thanked mkraska for this useful post.
on 07/08/2013(UTC),  on 07/08/2013(UTC)
Offline Ber7  
#6 Posted : 07 August 2013 12:59:28(UTC)
Ber7


Rank: Advanced Member

Groups: Registered
Joined: 15/07/2010(UTC)
Posts: 437
Man
Israel
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
thanks 1 user thanked Ber7 for this useful post.
on 07/08/2013(UTC)
Offline kilele  
#7 Posted : 07 August 2013 13:29:18(UTC)
kilele


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

thanks 1 user thanked kilele for this useful post.
on 07/08/2013(UTC)
Offline mkraska  
#8 Posted : 07 August 2013 13:57:47(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,980
Germany

Was thanked: 1120 time(s) in 718 post(s)
Originally Posted by: kilele Go to Quoted Post
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):
units2a.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 1 user thanked mkraska for this useful post.
on 07/08/2013(UTC)
Offline kilele  
#9 Posted : 07 August 2013 14:03:53(UTC)
kilele


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.
thanks 3 users thanked kilele for this useful post.
on 07/08/2013(UTC),  on 07/08/2013(UTC),  on 07/08/2013(UTC)
Offline kilele  
#10 Posted : 07 August 2013 16:46:36(UTC)
kilele


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 Go to Quoted Post
Originally Posted by: kilele Go to Quoted Post
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. Oh my it could be an issue related with saving the current session settings.
Offline kilele  
#11 Posted : 07 August 2013 17:20:04(UTC)
kilele


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):
periodDecimal.png
commaDecimal.png
Offline mkraska  
#12 Posted : 07 August 2013 21:11:55(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,980
Germany

Was thanked: 1120 time(s) in 718 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):
units3.PNG
units2a.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline kilele  
#13 Posted : 07 August 2013 22:03:58(UTC)
kilele


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

Offline Davide Carpi  
#14 Posted : 08 August 2013 22:05:03(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,639
Man
Italy
Location: Italy

Was thanked: 1323 time(s) in 873 post(s)
Originally Posted by: ioan92 Go to Quoted Post
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 Biggrin


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
thanks 1 user thanked Davide Carpi for this useful post.
on 08/08/2013(UTC)
Offline Davide Carpi  
#15 Posted : 08 August 2013 22:28:18(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,639
Man
Italy
Location: Italy

Was thanked: 1323 time(s) in 873 post(s)
Originally Posted by: ioan92 Go to Quoted Post
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 Go to Quoted Post
Of course, as always, it's essential to know the rules

I agree... two rules, not so hard Happy

Originally Posted by: ioan92 Go to Quoted Post
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
thanks 1 user thanked Davide Carpi for this useful post.
on 08/08/2013(UTC)
Offline kilele  
#16 Posted : 08 August 2013 22:41:32(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
this sample by omorr is quite explanatory
http://en.smath.info/for...tly-in-0-9.aspx#post5932
if you use a variable name when calling a function this variable defined with the same name before on the canvas will be overwritten.

Edited by user 08 August 2013 22:51:11(UTC)  | Reason: Not specified

thanks 1 user thanked kilele for this useful post.
on 08/08/2013(UTC)
Offline Davide Carpi  
#17 Posted : 08 August 2013 22:55:11(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,639
Man
Italy
Location: Italy

Was thanked: 1323 time(s) in 873 post(s)
Originally Posted by: ioan92 Go to Quoted Post
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 Good
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 08/08/2013(UTC)
Offline Davide Carpi  
#18 Posted : 08 August 2013 23:10:49(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,639
Man
Italy
Location: Italy

Was thanked: 1323 time(s) in 873 post(s)
Originally Posted by: kilele Go to Quoted Post
this sample by omorr is quite explanatory
http://en.smath.info/for...tly-in-0-9.aspx#post5932
if you use a variable name when calling a function this variable defined with the same name before on the canvas will be overwritten.

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 Go to Quoted Post
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 Yes ; actually what I mean is that there is a logic and is not so complicated as appears if you don't know these rules. Vuala

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
thanks 1 user thanked Davide Carpi for this useful post.
on 09/08/2013(UTC)
Offline kilele  
#19 Posted : 08 August 2013 23:25:45(UTC)
kilele


Rank: Advanced Member

Groups: Registered
Joined: 30/03/2011(UTC)
Posts: 393

Was thanked: 132 time(s) in 113 post(s)
I should have posted this link from the same thread
http://en.smath.info/for...tly-in-0-9.aspx#post5930
so replace "name" by "reference" on my previous post, though in most of the cases names coincide with references.
thanks 1 user thanked kilele for this useful post.
on 08/08/2013(UTC)
Offline kilele  
#20 Posted : 08 August 2013 23:50:28(UTC)
kilele


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 Go to Quoted Post
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#Conclusion
Maybe 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

thanks 1 user thanked kilele for this useful post.
on 08/08/2013(UTC)
Users browsing this topic
2 Pages12>
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.