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
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)←5C=mat(0;0;0;0;0;5;2;3)Just:
el(C;2;3)←5C=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