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 fanda  
#1 Posted : 09 March 2013 14:07:54(UTC)
fanda

Rank: Newbie

Groups: Registered
Joined: 09/03/2013(UTC)
Posts: 4
Czech Republic
Location: Prague

Hello,
I downloaded SMath Studio 2 days ago and I am really having fun using it. Thank you for making it available for everybody.

Currently, I am using it for calculations with vectors. It looks that there is an error, when vector or vector of vectors is assigned to a variable. You can see different results than expected in variables M and N:

vectors_to_variable

I have the latest version of SMath - 0.95 (build: 4594), running on Windows XP.

Thank you for reviewing this behavior, Fanda

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

Offline mkraska  
#2 Posted : 09 March 2013 14:46:52(UTC)
mkraska


Rank: Advanced Member

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

Was thanked: 1124 time(s) in 721 post(s)
Hello,

the problem is in the default optimization setting of the definition of M. By default, optimization is set to "symbolic" in definitions (assignments with :=) and to "numeric" in evaluations by "=". As such, this should not create any problems if the symbolic engine was reliable. Unfortunately it is not. In particular, the engine is unaware of the different meaning of the multiplication dots depending on operator type. You can see that by removing the defintions of the vectors and hovering with the mouse over the definition of M. As you see, the braces are gone.
If you switch to numeric in the context menu, you get the correct result.

This is not yet the whole story. If you set a defintion to symbolic and evaluate it later in the sheet, the value depends on the variables as defined at the place, where the evaluation is made. That means, if you change the vectors a, b or c later, M has different ddisplayed values beyond that changes.

Now, if your definition is set to numeric, then two things may happen:
a ) all variables in the definition have a value, then M is evaluated immediately and the result is stored as value of M.
Later modifications of the variables do not have any effect.
b ) at least one variable is undefined. Then the definition is stored as given (without spoiling it by wrong simplifications) and you get the expected behaviour.

Again, all this can be seen in the dynamic assistant or in the definition preview (mouse hovering)

Edited by user 09 March 2013 14:57:59(UTC)  | Reason: Not specified

mkraska attached the following image(s):
matrix.PNG
matrix1.PNG
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline fanda  
#3 Posted : 09 March 2013 16:09:58(UTC)
fanda

Rank: Newbie

Groups: Registered
Joined: 09/03/2013(UTC)
Posts: 4
Czech Republic
Location: Prague

Thank you for answering, I understand the problem now.

As a workaround, I tried:
M2:mat((a*Cool*c,c*(a*b+0),2,1)

Without a,b,c defined, hovering over shows the same simplification, but the numerical result is correct.

Also, when I set the Optimization on M to None, brackets stay and the result is also correct.

Greetings, Fanda
Offline fanda  
#4 Posted : 11 March 2013 23:06:20(UTC)
fanda

Rank: Newbie

Groups: Registered
Joined: 09/03/2013(UTC)
Posts: 4
Czech Republic
Location: Prague

If there was a dot product operator just for vectors, we could write
a * (b dot c)
and symbolic engine would not simplify it to
a * b * c
which means
(a dot b ) * c

Another workaround therefore is to define a dot product on our own:

dot(u,v):sum(el(u,k)*el(v,k),k,1,rows(u))

And we get what we were looking for:

M3:mat(dot(a,Cool*c,c*dot(a,Cool,2,1)

M3=mat(mat(-30,30,30,3,1),mat(-30,30,30,3,1),2,1)


PS: Simpler version dot(u,v):u*v didn't work - it is also substituted and we get a wrong result.
Users browsing this topic
Guest
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.