Variables evaluation

Variables evaluation - Symbolic to numerical substitution and evaluation - Poruke

#1 Objavljeno: 12. 4. 2022. 16:14:10
Mario Acevedo

Mario Acevedo

0 svidjanja u 11 postova.

Grupa: User

Dear all:

I am new to Smath Studio, great software!

Even I am new to its usage, I am trying quite complicated calculations I guess.

I am putting the following lines:

substitution.png

As you can see, I am using Maxima plugin and the Maxima function ev() to substitute values in the symbolic variable. I have some specific questions:
1.) Is there an alternative way to do this kind of calculations without using the Maxima plugin?
2.) v is a system of values, each value is an equality, is there an automatic way to generate a system of values?

Thank to all the people that could help.
#2 Objavljeno: 12. 4. 2022. 17:04:06
Martin Kraska

Martin Kraska

1.369 svidjanja u 2.283 postova.

Grupa: Moderator

I can't open your image. From what you describe, you might want to use the substitution function at() from Custom Functions plugin.

at.sm (22,23 KiB) preuzeto 1314 put(ova).
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
#3 Objavljeno: 12. 4. 2022. 18:16:56
Jean Giraud

Jean Giraud

983 svidjanja u 6.866 postova.

Grupa: User

Attach your Smath document.
#4 Objavljeno: 12. 4. 2022. 18:51:35
Jean Giraud

Jean Giraud

983 svidjanja u 6.866 postova.

Grupa: User

at(3) Demo.PNG
#5 Objavljeno: 12. 4. 2022. 19:41:47
Mario Acevedo

Mario Acevedo

0 svidjanja u 11 postova.

Grupa: User

Sorry about the image, now the image is visible.

What I want is to iterate over a set o values to substitute in a variable a store the results in a variable, something like this:

substitution.png

Is there a way to do this substitutions in an iterative way?.
I mean: using a set of programming lines?

In this worksheet I copied and pasted the lines to perform the iterations, but in a general problem solving it is desirable to iterate automatically.
#6 Objavljeno: 12. 4. 2022. 20:20:21
Mario Acevedo

Mario Acevedo

0 svidjanja u 11 postova.

Grupa: User

Here is the Worksheet:

Worksheet1.sm (10,95 KiB) preuzeto 1278 put(ova).
#7 Objavljeno: 12. 4. 2022. 20:45:20
Mario Acevedo

Mario Acevedo

0 svidjanja u 11 postova.

Grupa: User

Thank you Martin Kraska, at works fine and is what I needed.

It seems that to iterate I have to declare the sys vector by myself, isn't it?

Thanks a lot!
#8 Objavljeno: 12. 4. 2022. 21:29:50
Jean Giraud

Jean Giraud

983 svidjanja u 6.866 postova.

Grupa: User

Wrote

What I want is to iterate over a set o values to substitute in a variable a store the results in a variable, something like this:


An iterative process is a solving process.
As you say, you just want to plug something from command line.

Command Line UNK.PNG
#9 Objavljeno: 12. 4. 2022. 23:45:16
Mario Acevedo

Mario Acevedo

0 svidjanja u 11 postova.

Grupa: User

wow!, this is what I was looking for!!!, THANK YOU very much Jean Giraud!

#10 Objavljeno: 13. 4. 2022. 07:41:58
sergio

sergio

127 svidjanja u 342 postova.

Grupa: User

I take inspiration from Jean, but I use the Vectorize function and I forget the size of U

Prikaži spoiler


FunzioniVettori.sm (6,37 KiB) preuzeto 1275 put(ova).
sergio
#11 Objavljeno: 13. 4. 2022. 08:21:09
Martin_B

Martin_B

22 svidjanja u 84 postova.

Grupa: User

Pay attention! The definition of M(r) doesn't make much sense.

Screenshot 2022-04-13 131758.png
#12 Objavljeno: 13. 4. 2022. 08:41:51
Jean Giraud

Jean Giraud

983 svidjanja u 6.866 postova.

Grupa: User

Wrote

I take inspiration from Jean, but I use the Vectorize function and I forget the size of U


Superb Sergio ... added in the main document.
#13 Objavljeno: 13. 4. 2022. 09:48:44
overlord

overlord

601 svidjanja u 1.382 postova.

Grupa: Moderator

An algorithm can also be used.
It may be simpler by this way.

Regards

Worksheet1_algorithm.sm (4,69 KiB) preuzeto 1319 put(ova).

2022-04-13_15-46.png
#14 Objavljeno: 13. 4. 2022. 14:10:35
Mario Acevedo

Mario Acevedo

0 svidjanja u 11 postova.

Grupa: User

Nice implementation!!

Just a question, does the S variable had to be declared and dimensioned previous to its use?

I will try the code asap!

Thank you !
#15 Objavljeno: 13. 4. 2022. 14:48:08
Martin_B

Martin_B

22 svidjanja u 84 postova.

Grupa: User

You should always define variables used as arrays in function before assigning elements.

Worksheet1_algorithm.sm (8,04 KiB) preuzeto 1297 put(ova).

Screenshot 2022-04-13 194527.png
1 korisnika je svidelo ovu objavu
sergio 13. 4. 2022. 16:00:00
#16 Objavljeno: 13. 4. 2022. 16:04:10
Jean Giraud

Jean Giraud

983 svidjanja u 6.866 postova.

Grupa: User

Wrote

Just a question, does the S variable had to be declared and dimensioned previous to its use ?


No, it sets by itself within the for loop.
Wise to clear within the algo ... U:=0
That will avoid interaction with else U above document.
Algo style is an immense companion in Smath.
Personally, I use it as much as possible,
it enables the local command line.
Cheers ... Jean.

Maths algo style MATRIX in_extenso.sm (5,88 KiB) preuzeto 1320 put(ova).


#17 Objavljeno: 13. 4. 2022. 16:47:50
overlord

overlord

601 svidjanja u 1.382 postova.

Grupa: Moderator

Wrote

You should always define variables used as arrays in function before assigning elements.


MarB is dead right.
Array variables should be considered carefully if they will be redefined multiple times.
Or they can be undefined and named uniquely. I tend to name variables in functions this way.
You can find below how I would name your functions variables.
Pretends mess of misusage.

Regards

worksheet1.png
#18 Objavljeno: 13. 4. 2022. 17:55:24
Davide Carpi

Davide Carpi

1.444 svidjanja u 2.936 postova.

Grupa: Moderator

Wrote

Just a question, does the S variable had to be declared and dimensioned previous to its use?



It isn't required but it is good practice. If the variable name already exists you might fall in some unexpected cases when the dimensions are different. In addition to the above suggestions, you can use also a Clear(S) as initializer.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
  • Novi postovi
  • Nema novih postova