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 stanley  
#1 Posted : 07 September 2009 03:41:25(UTC)
stanley

Rank: Newbie

Groups: Registered
Joined: 01/05/2009(UTC)
Posts: 8
Man
Location: Czech Republic


(download sm file)

Edited by user 08 September 2009 00:54:19(UTC)  | Reason: Not specified

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

Offline Andrey Ivashov  
#2 Posted : 07 September 2009 05:01:02(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)
Thank you very much!

Just for information:
1) Since SMath Studio 0.85 release there is not required to define Vector/Matrix dimensions before elements definitions;
2) eval(..) function can speed up this calculations (on my PC: from 3.3 sec to 0.57 sec).

For more information please, take a look to the screenshot:


Thanks again. Best regards, Andrey Ivashov.
Offline stanley  
#3 Posted : 08 September 2009 02:57:31(UTC)
stanley

Rank: Newbie

Groups: Registered
Joined: 01/05/2009(UTC)
Posts: 8
Man
Location: Czech Republic

Hallo Andrey,
thanks for tip with function "eval". After using "eval" function calculation took five time quickly. But I don't understand when shall I use "eval" functin. And what do you mean "define Vector/Matrix dimensions before elements definitions"?
Offline Andrey Ivashov  
#4 Posted : 08 September 2009 03:50:09(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)
You are welcome.

stanley wrote:
But I don't understand when shall I use "eval" functin

Here is description about eval(..) function from Insert Function Dialog: "Converts analytic expression to the numeric notation."
For example, please, try to define such variable:
A←mat(sqrt(3);sin(8);ln(5);e;2;2)^{-1}
If you will check then the numeric result, you'll see this:
A=mat(0,8724;-0,3175;-0,5165;0,5559;2;2)
But you should remember, that SMath Studio stores all intermediate calculations in symbols. To see it, just try to get symbolic result (or just hover the A definition by the mouse):
A—mat(e/{e*sqrt(3)-ln(5)*sin(8)};-sin(8)/{e*sqrt(3)-ln(5)*sin(8)};-ln(5)/{e*sqrt(3)-ln(5)*sin(8)};sqrt(3)/{e*sqrt(3)-ln(5)*sin(8)};2;2)

So, if you'll try now to calculate, f.e.:
B←A^3 (Fig. 1)
And to check symbolic result, you'll see this one:
B—mat({e*(e^2+sin(8)*ln(5))+(e+sqrt(3))*sin(8)*ln(5)}/{(e*sqrt(3)-ln(5)*sin(8))^3};-{(e^2+sin(8)*ln(5)+(e+sqrt(3))*sqrt(3))*sin(8)}/{(e*sqrt(3)-ln(5)*sin(8))^3};-{(3+ln(5)*sin(8)+e*(e+sqrt(3)))*ln(5)}/{(e*sqrt(3)-ln(5)*sin(8))^3};{(e+sqrt(3))*ln(5)*sin(8)+(3+ln(5)*sin(8))*sqrt(3)}/{(e*sqrt(3)-ln(5)*sin(8))^3};2;2) (Fig. 2)
Numerically it is:
B=mat(1,0413;-0,5458;-0,8879;0,4972;2;2) (Fig. 3)

As you can note, all next calculations are become more complex. Of course, to evaluate such big expressions SMath Studio needs a time. But you can ask the program for numerical simplification of the examples. Let's try:
B←eval(A^3) (Fig. 1*)
B—mat(52063850537761/50000000000000;-545822825158897/1000000000000000;-110989617673979/125000000000000;62147432086303/125000000000000;2;2) (Fig. 2*)
Or numerically:
B=mat(1,0413;-0,5458;-0,8879;0,4972;2;2) (Fig. 3*)

Now program don't need to work with log, sin, sqrt and constants - all these represented as numbers. That's how you can save CPU time! But you don't need to use eval(..) everywhere Good It is useful only when symbolic results are really big!
One more thing about eval - when you converts analytically given expression to numbers, you round it to 15 decimal places, so, in some cases you can get calculations errors. When you use symbols you just cannot get the error in calculations, but it takes more time.

If you still have questions about this, please, ask.

stanley wrote:
And what do you mean "define Vector/Matrix dimensions before elements definitions"?

You don't need to do these:
C←matrix(2;3)
el(C;2;3)←5
C=mat(0;0;0;0;0;5;2;3)
Just:
el(C;2;3)←5
C=mat(0;0;0;0;0;5;2;3)

This means, that Vectors and Matrices now works like dynamic arrays.

Best regards, Andrey Ivashov.

Edited by user 08 September 2009 03:58:38(UTC)  | Reason: Not specified

Offline stanley  
#5 Posted : 08 September 2009 21:39:55(UTC)
stanley

Rank: Newbie

Groups: Registered
Joined: 01/05/2009(UTC)
Posts: 8
Man
Location: Czech Republic

Thanks for explanation, using of "eval" is clear. Dynamic building of arrays is very interesting, but in my opinion is matrix definition in this case more transparent.
Best Regardes
Standa
Offline omorr  
#6 Posted : 08 September 2009 21:57:40(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 Standa,
stanley wrote:
Dynamic building of arrays is very interesting, but in my opinion is matrix definition in this case more transparent.
Could you be more specific, please. I do not understand your point.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline stanley  
#7 Posted : 08 September 2009 23:28:24(UTC)
stanley

Rank: Newbie

Groups: Registered
Joined: 01/05/2009(UTC)
Posts: 8
Man
Location: Czech Republic

omorr wrote:
Hello Standa,
stanley wrote:
Dynamic building of arrays is very interesting, but in my opinion is matrix definition in this case more transparent.
Could you be more specific, please. I do not understand your point.

Regards,
Radovan


Sorry,
I answered on wrong topic, my answer on this place is nonsense. I thought about Nyquist plot (first and second topic). For understanding there is better first define matrix. Of coarse is posible use dynamic array, as showed Andrey is 2nd topic.
Offline omorr  
#8 Posted : 09 September 2009 00:02:59(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)
No problem Good

You can use it in the way you find it more convenient.

Regards,
Radovan

Edited by user 09 September 2009 00:05:58(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.