Can't calculate minus power

Can't calculate minus power - Messages

#1 Posted: 8/24/2016 12:21:14 PM
Berk Koç

Berk Koç

0 likes in 21 posts.

Group: User

Hello,

I want to create a file to calculate pressures in a cylindrical silo with respect to EN standards. I have entered the datas and formulas needed to calculate. Bu the programe can't calculate a formula.

I tried it on the mathematica and it worked. How can I solve this issue?




en 1991-4.sm (320 KiB) downloaded 48 time(s).
#2 Posted: 8/24/2016 12:47:41 PM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

Hello Berk,

To accomplish you task you have to loop through the values of the input vector; to do this you can use the function vectorize(...) or a loop (for(...), while(...));

vectorize:
2016-08-24 17_53_25-SMath Studio Desktop - [en%201991-4.sm_].png

loop:
2016-08-24 17_58_43-SMath Studio Desktop - [en%201991-4.sm_].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
Berk Koç 8/25/2016 2:39:00 AM
#3 Posted: 8/24/2016 1:03:55 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Two quick observed bobos: YR is not digestible and unit problem
Always plot before "I want this, I want that"


Jean

en 1991-4.sm (346 KiB) downloaded 39 time(s).
#4 Posted: 8/24/2016 4:40:21 PM
Berk Koç

Berk Koç

0 likes in 21 posts.

Group: User

Wrote

Hello Berk,

To accomplish you task you have to loop through the values of the input vector; to do this you can use the function vectorize(...) or a loop (for(...), while(...));

vectorize:
2016-08-24 17_53_25-SMath Studio Desktop - [en%201991-4.sm_].png

loop:
2016-08-24 17_58_43-SMath Studio Desktop - [en%201991-4.sm_].png




Dear Davide,

Thank you for your reply. It is working with the vectorize function but why it should be like that? I couldn't understand. For example variable "a" has values when you press equal without any vectorize function.

Wrote

Two quick observed bobos: YR is not digestible and unit problem
Always plot before "I want this, I want that"


Jean

en 1991-4.sm (346 KiB) downloaded 39 time(s).



Dear Jean,

Thank you for your answer too.

Do you mean that smath can not calculate it because of it is very long equation?
#5 Posted: 8/24/2016 9:04:34 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Hello Berk,

Just like this:

Forum Berk.gif
1 users liked this post
Berk Koç 8/25/2016 2:40:00 AM
#6 Posted: 8/25/2016 4:41:28 AM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

Wrote

It is working with the vectorize function but why it should be like that? I couldn't understand. For example variable "a" has values when you press equal without any vectorize function.



In SMath while you are working with matrices "raise to power" it is a shorthand for matrix multiplication/inverse multiplication -> it works just when the exponent is an integer;

moreover when matrices are vectors (column matrices), instead of giving an error because dimensions of matrices are wrong, a special feature allows to the product to be the "dot product" (thus vector^power is the sum of its elements each one raised to power's value);

To apply scalar math to matrices/vectors you have to use vectorize(), programming (loops) or also you can use systems - sys(..) function.
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 users liked this post
Berk Koç 8/25/2016 4:48:00 AM
#7 Posted: 8/25/2016 10:31:55 AM
Berk Koç

Berk Koç

0 likes in 21 posts.

Group: User

Wrote

Wrote

It is working with the vectorize function but why it should be like that? I couldn't understand. For example variable "a" has values when you press equal without any vectorize function.



In SMath while you are working with matrices "raise to power" it is a shorthand for matrix multiplication/inverse multiplication -> it works just when the exponent is an integer;

moreover when matrices are vectors (column matrices), instead of giving an error because dimensions of matrices are wrong, a special feature allows to the product to be the "dot product" (thus vector^power is the sum of its elements each one raised to power's value);

To apply scalar math to matrices/vectors you have to use vectorize(), programming (loops) or also you can use systems - sys(..) function.



I have done this calculations by vectorize function. I need random value in this equation. For example I need YR at z 1,5 m. How can I get that value to be used in a different equation?
#8 Posted: 8/25/2016 11:08:04 AM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

There are several ways:

  • define again a or z, define again Y.R
  • define Y.R as a function: Y.R(a) or Y.R(z)
  • define Y.R before defining z or a -> each time you call Y.R, the last value you define for these parameters will be used
    2016-08-25 16_07_23-SMath Studio Desktop (ver. 0.98.6060) - [en%201991-4(1).sm_].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#9 Posted: 8/25/2016 11:34:39 AM
Berk Koç

Berk Koç

0 likes in 21 posts.

Group: User

Wrote

There are several ways:

  • define again a or z, define again Y.R
  • define Y.R as a function: Y.R(a) or Y.R(z)
  • define Y.R before defining z or a -> each time you call Y.R, the last value you define for these parameters will be used
    2016-08-25 16_07_23-SMath Studio Desktop (ver. 0.98.6060) - [en%201991-4(1).sm_].png



Thank you for your fast replies.

I couldn't define it as a function,
it didn't work for me to give a value to "z", it still give Y.R as matrix. I am really confused, sorry for misunderstanding.

PS: I have not defined variable "a" just written whole parameter in one line.en 1991-4.sm (594 KiB) downloaded 37 time(s).

#10 Posted: 8/25/2016 12:15:06 PM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

This should works:

en%201991-4(3).sm (596 KiB) downloaded 42 time(s).
2016-08-25 17_11_01-SMath Studio Desktop - [en%201991-4(3).sm_].png

BTW, it is even possible to move the vectorize() function from the definition to the point where you need to use it

Show Spoiler

If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#11 Posted: 8/29/2016 9:53:01 AM
Berk Koç

Berk Koç

0 likes in 21 posts.

Group: User

Wrote

This should works:

en%201991-4(3).sm (596 KiB) downloaded 42 time(s).
2016-08-25 17_11_01-SMath Studio Desktop - [en%201991-4(3).sm_].png

BTW, it is even possible to move the vectorize() function from the definition to the point where you need to use it

Show Spoiler



Thank you again for your fast reply.

It is not working for me. It calculated the value for Y.R for a single z for once, then I tried it for the later formulas at the end of sheet but it is not working. It gives a matrix solution again.en 1991-4.sm (607 KiB) downloaded 39 time(s).

#12 Posted: 8/29/2016 10:47:14 AM
Mike Kaganski

Mike Kaganski

184 likes in 434 posts.

Group: User

Berk,
that's because of the order of declarations in your file. Please notice that Davide defined formulas first, and later defined the variables that constitute the formulas. This way, when the formulas were defined, the meaning of its constituents was undefined, so it stayed as is: names. When later below, after all variables were set, you tried to get the Y.R value, SMath took the formula for Y.R, substituted all variables in it with their already-known values, and gave you the result for this set of values. After that, you re-defined some of variables, tried to get answer, and SMath repeated substitution in the formula, giving you the new answer.

But in your file, you define variables first, then define formula for Y.R. This way, at the Y.R definition, SMath already knows all variable values, so it stores them in the Y.R definition instead of their names. All later modifications of those variables won't have impact on what is inside the Y.R, so you won't see new results.

But you may use functional syntax instead, something like
Y.R(z):vectorize(1-(({z-h.o}/{z.o-h.o})+1)^n)
, to be independent on the declarations order.
С уважением, Михаил Каганский
#13 Posted: 8/29/2016 11:43:46 AM
Berk Koç

Berk Koç

0 likes in 21 posts.

Group: User

Wrote

Berk,
that's because of the order of declarations in your file. Please notice that Davide defined formulas first, and later defined the variables that constitute the formulas. This way, when the formulas were defined, the meaning of its constituents was undefined, so it stayed as is: names. When later below, after all variables were set, you tried to get the Y.R value, SMath took the formula for Y.R, substituted all variables in it with their already-known values, and gave you the result for this set of values. After that, you re-defined some of variables, tried to get answer, and SMath repeated substitution in the formula, giving you the new answer.

But in your file, you define variables first, then define formula for Y.R. This way, at the Y.R definition, SMath already knows all variable values, so it stores them in the Y.R definition instead of their names. All later modifications of those variables won't have impact on what is inside the Y.R, so you won't see new results.

But you may use functional syntax instead, something like

Y.R(z):vectorize(1-(({z-h.o}/{z.o-h.o})+1)^n)
, to be independent on the declarations order.



Thank you mikekaganski,

I am really confused because same things on the mathcad program works without any problem.

I have tried what you said in the attached file. I have put z range below the formulas. And I have created function of z with same variable ( both formulas are on the sheet now). But it couldn't calculate the results now with range.en 1991-4 (z).sm (602 KiB) downloaded 35 time(s).

#14 Posted: 8/29/2016 11:53:17 AM
Mike Kaganski

Mike Kaganski

184 likes in 434 posts.

Group: User

minusPower1.png
С уважением, Михаил Каганский
#15 Posted: 8/29/2016 1:01:48 PM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

Wrote

But it couldn't calculate the results now with range.en 1991-4 (z).sm (602 KiB) downloaded 35 time(s).



About your latest attachment:
  1. Set n optimization to numeric on his definition (possible issue on exponentation of unit to check from smath side)
  2. You have renamed Y.R to Y.r (lowercase) - restore it (there's no name's conflict between functions and variables) or update the name inside the definition of p.hf
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#16 Posted: 8/29/2016 5:50:20 PM
Berk Koç

Berk Koç

0 likes in 21 posts.

Group: User

Wrote

minusPower1.png



Maybe it is about the version of the program. I understand that you have done nothing about the file that I attached. But it was not like this on my work notebook. Now I opened it on my own notebook and it works. The version is same as yourds. But I can't remember the work notebook. I will check it on wednesday but if it is not the latest one then it is the previous one.

Thank you.
#17 Posted: 8/29/2016 5:54:11 PM
Berk Koç

Berk Koç

0 likes in 21 posts.

Group: User

Wrote

Wrote

But it couldn't calculate the results now with range.en 1991-4 (z).sm (602 KiB) downloaded 35 time(s).



About your latest attachment:
  1. Set n optimization to numeric on his definition (possible issue on exponentation of unit to check from smath side)
  2. You have renamed Y.R to Y.r (lowercase) - restore it (there's no name's conflict between functions and variables) or update the name inside the definition of p.hf



Davide,

Thank you again, I just wanted to clarify that Y.r was just for demo. To try two methods simultenously. I have written that it is now working on my home notebook but I behave to early.
I have put two files tiled and screenshoted. As you can see all the things are same for both files (left is yours). But mine is not computing. I have just written the explanations of the variables only.

minuspow.PNG
#18 Posted: 8/29/2016 8:43:54 PM
Mike Kaganski

Mike Kaganski

184 likes in 434 posts.

Group: User

Wrote

I have put two files tiled and screenshoted. As you can see all the things are same for both files (left is yours). But mine is not computing. I have just written the explanations of the variables only.



Wrote

  1. Set n optimization to numeric on his definition (possible issue on exponentation of unit to check from smath side)

С уважением, Михаил Каганский
#19 Posted: 8/30/2016 1:51:16 PM
Berk Koç

Berk Koç

0 likes in 21 posts.

Group: User

Wrote

Wrote

I have put two files tiled and screenshoted. As you can see all the things are same for both files (left is yours). But mine is not computing. I have just written the explanations of the variables only.



Wrote

  1. Set n optimization to numeric on his definition (possible issue on exponentation of unit to check from smath side)



Thank you mikekaganski,

But I am really exhausted. I can't figure it. When I say "ok" now finally, then other issue appears on other place. I thank the author for this program as it is free and capable, I think I am not able to use it efficiently. I started to copy all the text and formulas to mathcad again which is a time consuming process but I can't find any other better way unfortunately.

Please see the attached 1 and 2.png sequentially and 3 and 4.png sequentially. As I understand from numeric, I entered "n" manually after knew the result, then it worked. All the calculations were done and there were no error. The expression at the bottom were ok. Then I deleted "z" value at top of the sheet which was entered to do a trial to see results. Then at the bottom, latests equations gave error.

I tried in another sheet with Y.R(z), it was good at beginning but then it gave an error again when the equations arise.

File not found.File not found. File not found.File not found.

Best regards
#20 Posted: 8/30/2016 8:57:07 PM
Davide Carpi

Davide Carpi

1416 likes in 2873 posts.

Group: Moderator

Without this version of the file my best guess is you are feeding the tension with a vector, probably because p.he is involved and is defined after the first assignment of z -> you must move that definition before the first definition of z (another way could be to use Clear(z) from CustomFunction before p.he definition)


Please note, this is an important feature of SMath Studio:

if the dependancy from a variable is hidden (not a function or the variable is not an argument of the function)

  • if this variable is already defined, his value will be replaced and stored in the definition

  • if the variable is not yet defined, the variable name will be stored


See the attachment for simple examples: name value.sm (9 KiB) downloaded 42 time(s).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
  • New Posts New Posts
  • No New Posts No New Posts