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 omorr  
#1 Posted : 17 January 2012 09:43:58(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)
Hello,

There were recently introduced few SMath functions which require a symbolic vectors as arguments. Just take a look at this simple example of calculating Jacobi matrix.


In this example, there were used symbolic vectors x and y using the elements with the same name - x(1),x(2) and y(1),y(2). I used two ways to define them - the direct assignment and by using for loop. Do not know any other way. I was just wondering if there might be another more elegant way to define symbolic vectors, matrices like the ones presented.

It crossed my mind something like this - to use a 3 arguments matrix function:
Code:
x:=matrix(2,1,x)

to give:
x—mat(el(x,1),el(x,2),2,1)
or:
Code:
Z:=matrix(2,1,x)

to give:
Z—mat(el(x,1),el(x,2),2,1)

This will work, of course, provided the third argument to be symbolic (undefined) variable or function.

Any other suggestions or ideas? Good

Regards,
Radovan

Edited by user 17 January 2012 09:47:08(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"

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

Offline Andrey Ivashov  
#2 Posted : 17 January 2012 11:41:43(UTC)
Andrey Ivashov


Rank: Administration

Groups: Developers, Registered, Knovel Developers, Administrators, Advanced Member
Joined: 11/07/2008(UTC)
Posts: 1,616
Man
Russian Federation

Was thanked: 1978 time(s) in 666 post(s)
Hello Radovan!

Do you mean some built-in function like this?


(download example)

Regards.
Offline omorr  
#3 Posted : 17 January 2012 12:06:52(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)
Yes Andrey, that's it - very clever and interesting realization Good

It would be nice to have a built-in function like you described. It crossed my mind just to extend the matrix() function to matrix(3) in order to have such and similar functionality in filling a matrix, but did not come to my mind your solution. It seems that this function might be quite useful in matrix calculations.

On the other hand, I will definitely put this function as a "snippet". Thank you.

BTW, in order to make vectors we could make correction in above matrix(3) function or make a vector(2).

vector(n,f(1))←line(for(j←1,j≤n,j←j+1,el(result,j)←f(j)),result,2,1)
f(j)←el(x,j)
vector(3,f(j))—mat(el(x,1),el(x,2),el(x,3),3,1)

Rather useful for matrix elementwise operation (like vectorization in Mathcad)
f(j,k)←el(x,j,k)*e^el(y,j,k)
matrix(2,2,f(j,k))—mat(e^el(y,1,1)*el(x,1,1),e^el(y,1,2)*el(x,1,2),e^el(y,2,1)*el(x,2,1),e^el(y,2,2)*el(x,2,2),2,2)
f(j)←el(x,j)/el(y,j)
vector(3,f(j))—mat(el(x,1)/el(y,1),el(x,2)/el(y,2),el(x,3)/el(y,3),3,1)
x←mat(1,-1,6,3,1) y←mat(3,5,4,3,1)
vector(length(x),f(j))—mat(1/3,-1/5,3/2,3,1)

Actually, we have to pay attention on the function and varible names (f(2) and f(1) are functions with row, column indexes - x and y are global variables) but it is good enough Good

Regards,
Radovan

Edited by user 18 January 2012 01:30:37(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
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.