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

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline Richard Gardiner  
#1 Posted : 24 September 2016 14:50:14(UTC)
Richard Gardiner

Rank: Newbie

Groups: Registered
Joined: 24/09/2016(UTC)
Posts: 4
United Kingdom

Hello,
First post, please be gentle.
I tried to attach a screen grab that illustrates my question, hope it works!
x, y and z are symbolic variables, I multiplied by unit 'm'
x,y and z evaluate symbolically is as expected.
v1 is as expected, i.e. a cube with unit m³
a is area of rectangle xy and unit is as expected 'm²'
for v2, symbolic evaluation is as expected x.y.z, but the unit is not as expected (m^5 instead of m³ )
v3 is a trial with b as a tester in 'm²' it works as expected

I arrived here from trying to do a much more complicated symbolic evaluation with other units and getting odd results. Maybe I am trying to do something that is not supported?
Any help greatly appreciated!

I suppose my question is "why isn't the v2 result the the same as v1 and v3? and is this supposed to work?"
smath studio version 0.98(build:6103)

Thanks, Richard
Untitled.png

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

Offline uni  
#2 Posted : 24 September 2016 15:09:34(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
It seems that you have found a bug.
Russia ☭ forever
Viacheslav N. Mezentsev
Offline Richard Gardiner  
#3 Posted : 24 September 2016 16:28:41(UTC)
Richard Gardiner

Rank: Newbie

Groups: Registered
Joined: 24/09/2016(UTC)
Posts: 4
United Kingdom

Jean,
Thanks for your suggestion.
Please see below, is this the expected behaviour? (all symbolic evaluation)
Thanks
Richard
Untitled3.png
Offline uni  
#4 Posted : 24 September 2016 16:37:30(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
Here how it happens

Snimok ehkrana ot 2016-09-24 18-36-53.png
Russia ☭ forever
Viacheslav N. Mezentsev
Offline Richard Gardiner  
#5 Posted : 24 September 2016 17:34:58(UTC)
Richard Gardiner

Rank: Newbie

Groups: Registered
Joined: 24/09/2016(UTC)
Posts: 4
United Kingdom

If I use auxilary variables a,b,c and add the unit in seperate step everything works fine.
It would be nice to be able to define a symbolic variable with a unit in a single step.

i.e x:=xm

Untitled4.png
Offline mkraska  
#6 Posted : 25 September 2016 01:26: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)
With pencil and paper math, it would be plain wrong to identify a quantity with the same quantity times a unit.

This is not better than saying i=i+1 and then complaining that the value of i changes whenever that expression is evaluated.

Correct would be to use separate variables for a quantity and it's numeric value, say x:x0*'m with x0 being a dimensionless number and x a physical quantity.

The behaviour observed is not a bug, just a consequence of inappropriately using recursive definitions.

BTW, be careful with bashing symbolic evaluation. There has been quite some progress recently. Both in bug fixing and in documentation, see Davide's handbook on user functions in the extension manager.

You can't always expect symbolic evaluation as you want. It's all about knowing the limitations and watching which expressions are actually stored in a variable or function. The dynamic assistant is your friend.


Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline Richard Gardiner  
#7 Posted : 25 September 2016 13:47:38(UTC)
Richard Gardiner

Rank: Newbie

Groups: Registered
Joined: 24/09/2016(UTC)
Posts: 4
United Kingdom

Hi Martin,
Thanks for taking the time to share your thoughts.
I already tried using an auxilary variable for symbolic definition and then defining a second one with the unit as you suggest (see post 6).
The problem with this workaround is that subsequent calculations are defined in terms of x,y,z and evaluated in terms of a,b,c which seems to me to be clumsy / non elegant and confusing for anyone that I might show the calculations to, so I suggest this is not 'correct', certainly not ideal. Maybe it is the case that the correct way doesn't exist yet but that's ok.
What I am looking for is a way to define a symbolic variable as having a unit without it relying on other auxilary variables, maybe this is not possible?

Further, consider the example below, multiple evaluations of a and b do not result in m², m³ etc, however, a second evaluation of c does but further repeated evaluations do not.

Also, who is 'complaining' and 'bashing'?
Regards,
Richard

Untitled5.png
Offline mkraska  
#8 Posted : 25 September 2016 19:03:57(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: Richard Gardiner Go to Quoted Post
Hi Martin,
I already tried using an auxilary variable for symbolic definition and then defining a second one with the unit as you suggest (see post 6).
The problem with this workaround is that subsequent calculations are defined in terms of x,y,z and evaluated in terms of a,b,c which seems to me to be clumsy / non elegant and confusing for anyone that I might show the calculations to, so I suggest this is not 'correct', certainly not ideal. Maybe it is the case that the correct way doesn't exist yet but that's ok.

Untitled5.png


I think a correct way exists, but not under the condition that the quantity is not the same as the quantity divided by a unit. Just as a vector should not be represented by the same name as it's co-ordinates. A unit is a base in the linear space of the quantities of a certain physical dimension. Quantity is a number times a unit. In that sense the number is the co-ordinate of a vector. Quantity and co-ordinate can be unknown but for a certain variable name you have to choose. According to DIN standard, any quantity can be written as a={a}[a], where [a] is the unit of a and {a} is the numerical value. If you use some modifier like the text index v instead of the curly braces, you can represent that in SMath Studio as well. [a] can be written as UnitsOf(a).

What is bad with the approach in the lower part of the attachment?

As to the remarks: they referred to using the term "bug" further up in the topic history. However, sometimes it is indeed hard to tell a bug from wrong usage, because there is no official document specifying the SMath design intent. Thus all we have is our observations and some assumptions on what the design intent might be. Some years ago one of the SMath survival rules was "Don't use symbolic optimization". Currently, I am investigating if that rule still applies. My impression is that it might be possible to replace it by a set of rules for symbolic optimization. Yet, the challenge is to write clear and easy rules.

units5.sm (10kb) downloaded 15 time(s).
units5.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline uni  
#9 Posted : 25 September 2016 20:43:48(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
2016-09-25_22-35-59.png
Russia ☭ forever
Viacheslav N. Mezentsev
Offline Davide Carpi  
#10 Posted : 25 September 2016 20:57:55(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)
As pointed out by Martin, the general correct way should be to name the "object" differently from how it is named the dimensionless value (f.e. consider "a" the edge's length in meters of a rectangular prism and "x" his length divided by meters; "d" will be the area of a side in square meters, "v" the volume in cubic meters):

2016-09-25 19_33_52-SMath Studio Desktop - [symbolic.sm].png

However you can still use your syntax, if you want, just pay attention on the order of definitions.

When you define (:=) something:
  • If something was already defined (:=) the value is stored (see IfDefined(...) or the dynamic assistance to check if it was already defined)); the value is anything on the Right Hand Side (doesn't matter if has a numerical value or contains unknowns);
  • If something is not yet defined, the name is stored;


In your example "d" was defined after x and y -> the values are stored (x*'m for x and y*'m for y; hold the mouse over d); then you ask to display a result for d * z -> (x*'m*y*'m)*z -> according on what is defined on the canvas: x is x*'m, y is y*'m, z is z*'m -> x*y*z*'m^5

If you define d:x*y before defining x and y, d will contains just x*y, then further evaluations will replace these unknowns with their values, if available:

2016-09-25 19_52_01-SMath Studio Desktop - [symbolic.sm_].png

Another way is to use a procedure - line(...); since it is not evaluated at his definition, his content will be replaced only when will be evaluated (when it is used on the RHS to define a variable or you ask for a result):

2016-09-25 19_57_36-SMath Studio Desktop - [symbolic.sm_].png

Edited by user 28 September 2016 17:50:50(UTC)  | Reason: marked as solved

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 3 users thanked Davide Carpi for this useful post.
on 25/09/2016(UTC),  on 25/09/2016(UTC),  on 25/09/2016(UTC)
Offline uni  
#11 Posted : 25 September 2016 21:42:48(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

Was thanked: 1274 time(s) in 745 post(s)
Let's see how the old maple works. You can't do these things there.

2016-09-25_23-29-43.png
Russia ☭ forever
Viacheslav N. Mezentsev
Offline mikekaganski  
#12 Posted : 26 September 2016 10:26:30(UTC)
mikekaganski


Rank: Advanced Member

Groups: Registered
Joined: 17/01/2013(UTC)
Posts: 296
Man
Russian Federation
Location: Khabarovsk, Russia

Was thanked: 151 time(s) in 107 post(s)
For quite a some time, I'm witnessing a great example of a religious thinking here at the forum.
I'm talking about someone who obviously has substantial knowledge in applied math. Who had been an active collaborator at MathSoft forums. And who makes awesome gifts to SMath community.

Let's see: there is SMath software, that was created by Andrey. He tried to express his intention in real code, using existing hardware and software frameworks. There is some plan (unknown to others), and SMath is its real implementation (though incomplete and imperfect, as any software is).

As a user of a proprietary software, you may take it as is and just use it; you may get involved in a limited way: ask questions, report bugs, help newbies, write plugins, ask for new features, and even discuss the overall plot (and try to convince the author to change his mind on some topics).

But there is another, very creative way: you may take your (absolutely marginal) knowledge, and invent your own explanation of what's going on with the software. Then, you may present your inventions as "facts" to the audience, decorated by "good deeds" such as contributions, and visible "competence" such as usage of relevant terminology.

Have you ever watched a movie that mentions topics that you are competent with? Haven't you had an urge to tell the author to go to school to learn basic things? And haven't you seen others, who don't know the topic, who draw conclusions from that utter garbage from the movie? You may be that "other" yourself, as long as that same movie tells about other things you don't know about...

So let's use some cryptic (err, parable) language to encrypt strange ideas. E.g., let's declare your misunderstanding of time() return as something related to units "puzzled handling". Let's put some citations into the attached worksheet, that are relevant to "computer time handling" (UNIX epoch/POSIX time etc.); let's also touch the trial softwares and evil Microsoft... instead of doing 5-minutes research to discover that SMath counts time from January 1st 1601, and find out that that's what e.g. FILETIME structure is used for. Let's say that "Smath has two symbolic engines" with default Maxima (while it actually has its own, and others are not of SMath, but of external plugins, and there may be others as well). Let's avoid clear descriptions, but use colored phrases like "curiosity", "so what so", "Big Blue" style". And don't forget to do that without a shadow of doubt.

What will this do? As long as existing users concerned, everyone will just exercise their tolerance. But for a new user, who may come to forum, the multitude of posts in every topic will probably be at least as important as author's words... A "prophet" with an interpretation, that may well gains importance on its own.

Of course, I already knew how those "great" books from "experts" about everything are created, but now I see that in progress...

Just an observation. Feel free to mark as inappropriate.
Best regards,
Mike Kaganski
thanks 2 users thanked mikekaganski for this useful post.
on 26/09/2016(UTC),  on 26/09/2016(UTC)
Users browsing this topic
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.