Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


2 Pages12>
Options
Go to last post Go to first unread
Offline Andrey Ivashov  
#1 Posted : 24 June 2010 14:28:29(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)
24.02.2010
omorr wrote:
just for the curiosity, tell me what are your plans concerning multiline functions and functions as function arguments, or some other kind of this ability. Very often I wish that was implemented in SMath (I commented these things on an "brainstorming" topic on the Forum Good ).I would just like to know what are your plans about it, nothing else.

smath wrote:
Regarding multiline functions. I also see, that this should be implemented to extend abilities to create functions and I plan to implement it near time.

Functions as function arguments not in my asap list, because I have no ideas of how to do this... I mean, that one of the important differences between Mathcad and SMath Studio is that functions and variables can be specified with the same names without covering:
Code:
f:=2;
f(f):=f^2;
f(f)=4;

According to this, I don't know how to enable this functionality... But I believe it possible, so if I'll understand how, I'll do.

omorr wrote:
Yes, you are quite right. I was thinking about that but did not mentioned. I did not have any idea yet how to distinguish the function arguments,actually - how to make the difference between the variable and function name. I thought that the inclusion of text variables might lead to the solution. Then the problem would be how to distinguish the text constant from the function. I do not know?
Is there any possibility to have something like:
Code:
x:=5
y:=6
g(a,b):=a+sin(b)
f(x,y,h(x,y)):=x+y+h(x,y)
result:=f(x,y,g(x,y))

or
Code:
x:=5
y:=6
g(a,b):=a+sin(b)
f(x,y,"fun h(2)"):=x+y+h(x,y)
result:=f(x,y,"fun g(2)")

Which means everything after "fun" (or something like that) must be a function name with number of arguments in parenthesis.
I do not think this could be implemented, but I believe you will find the best way.

Concerning functions, the SMath way gives improved functionality and greater flexibility comparing to Mathcad. I believe you will find the way to include functions as function arguments and multiline function.

smath wrote:
Great ideas! Not sure about using text to define functions in arguments, but the first variant is rather interesting! Also, I've combined both solutions you have mentioned and got this:
Code:
x:=5
y:=6
g(a,b):=a+sin(b)
f(x,y,h(2)):=x+y+h(x,y)
result:=f(x,y,g(x,y))

I think it is better, because f(x,y,h(x,y)) will cause misunderstandings about arguments (can we use the same arguments within main function's arguments and within the sub-function? If yes, then programs logic should be more complex, because in that case same names don't mean the same variables (?), otherwise constraints should be added (actually, I don't like constraints Good )). As I see, f(x,y,h(2)) also has some negative sides (mostly because f(2) looks like we try to evaluate function f using argument 2).

Will think about this...

omorr wrote:
I am glad that I could be of any help. Your solution is very interesting. I am also not sure about it but I think that when you define a function like:
f(x,y,h(2)):=
you might use something else to note that this particular function has two arguments. Something not to be confused with calling the function with a constant, say
f(x,y,h(2args)):=
f(x,y,h(_2_)):=
f(x,y,h(%2)):=

whatever you find it suitable, do not know.

After that, the possibility of calling the function with:

result:=f(x,y,g(x,y)) is great Good

24.02.2010
omorr wrote:
On my second thoughts, this might be the best solution Good . Fictive arguments in the function definition are declared fine and understandable:
f(x,y,h(2)):=
Because this is a function definition, hardly we can be confused. Fictive argument which contains (n) after its name, where n is an integer, could be a function with n fictive arguments. Anything else is a variable (numerical or symbolical). I might be wrong of course not seeing any other nagative sides, but the function arguments are not evaluated i.e. there could not be an expression as a function argument.

23.10.2010
smath wrote:
I remember about functions as function arguments and couple of days ago I started to implement it but have a problem - I still can't find a best way how to represent this feature for user. It's good enough for me, if definition for such functions will be:
f(g(2);c)←g(1;2)+c
but I not really like the ways I see how this definitions can be used:
  1. g(a,Cool←a*sqrt(Cool
    f(g(a;Cool;3)=#
  2. f(el(x;1)*sqrt(el(x;2));3)=#
  3. f(function(a*sqrt(Cool;a;Cool;3)=#

I think that all this variants is not user-friendly enough. The most acceptable way, of course, is the first one, but it requires separate definition of the function before using it in argument... Maybe I don't see anything simplest?
...
If we will understand how make it possible for user, I promise, I will implement it as soon as I can. This days I have a time and possibilities to do this work.

Edited by user 24 June 2010 14:30:53(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 : 26 June 2010 03:29:08(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)
Work started! Here are my first results:


Regards.
thanks 1 user thanked Andrey Ivashov for this useful post.
on 26/06/2010(UTC)
Offline omorr  
#3 Posted : 26 June 2010 09:13:12(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 Biggrinancing:

Very good start Andrey!

Looking forward to seeing some test SMath version with these features.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Andrey Ivashov  
#4 Posted : 28 June 2010 01:37:05(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)
Strange behavior of Mathcad found:


Same situation in SMath Studio:


Any idea why Mathcad can't evaluate this properly?

P.S.: This is a test file I've made to check SMath Studio.
Offline omorr  
#5 Posted : 28 June 2010 12:59:08(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 Andrey,

As far as I know, Mathcad does not use something like f(a,y):=b(a(x),x)+x in generall. Function arguments are only names (variale or function names). Function argument in the user defined function could not be "a(x)" - it must be just "a". Although, there are few exceptions. I do not use Mcad 14 but here is the image from an older Mcad version. However, It should be noted that there are different symbolic engines applied. Mcad 14 uses MuPad and older versions use Maple.
Please look at this image. It seems Ok.

But, if you change "v" into "v(x)" the results here is quite strange and sometimes unpredictible. I suppose this is because the Maple engine is involved here, and the problematic Mathcad use of Maple.

On the other hand, it seems that Mcad 14 can cope with it and I suppose that the problem is in y which is a constant not an undefined (symbolic) variable.

On the other hand SMath must work with the expression like v() pointing that this is a function with arguments (I hope I am right).
Regarding that those are just starting efforts, SMath example seems to me more understandable.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Andrey Ivashov  
#6 Posted : 28 June 2010 13:44:19(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.

Ah, yes. You're right, it is because I call m(v(x),x)... it should be m(v,x). Thank you!

Regards.
Offline omorr  
#7 Posted : 28 June 2010 14:12:34(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)
You are welcome Good

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Andrey Ivashov  
#8 Posted : 29 June 2010 04:26:04(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)
Live binaries updated, so current realization of functional programming can be tested using SMath Studio Live.

Open in SMath Cloud

Regards.
Offline omorr  
#9 Posted : 29 June 2010 10:06:13(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,

Just testing and tried to accept the logic behind this
Open in SMath Cloud

Should it be this way?

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline omorr  
#10 Posted : 29 June 2010 13:44:44(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)
Some more testing (very nice Good )
Open in SMath Cloud
But if I try:
G(5,f(x))—>
There will not be any result. It seems Live version does not like it, at the moment.
Andrey, If you can not reproduce this - it must be my computer fault.

Regards,
Radovan

Edited by user 29 June 2010 13:46:33(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Andrey Ivashov  
#11 Posted : 29 June 2010 14:30:55(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, Radovan! I see now at least two errors. Will fix them.

Regarding "This might be error 3-arguments function on the LHS?". Sorry, not sure I understand what you mean.

P.S.: Live really doesn't like G(5,f(x))—> Biggrin It captures 100% of one of server's CPUs and doesn't allow any other request till 30 seconds... interesting...
Offline omorr  
#12 Posted : 29 June 2010 17:21:20(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)
You are welcome Andrey, of course Good
smath wrote:

Regarding "This might be error 3-arguments function on the LHS?". Sorry, not sure I understand what you mean.

I'll try to be more specific. If I understood well, there are two ways to work with fun as fun arguments.
1. If we use dummy arguments like this
F(a,b,c,f(x,y,z)):=f(a,b )+f(c,d)
2. This should be the same
F(a,b,c,f(3)):=f(a,b )+f(c,d)

"a,b,c" should be used from the argument list ond the LHS of the function definition, and "d" is from the worksheet (might be defined previously or not).
I think that the LHS of the function definition tell us that on the RHS should be a function named "f" with 3 (three) arguments "x,y,z" dummy arguments or "3" in number. But, as we could see, on the RHS there is function "f" but not with three but two fictive (dummy) arguments f(a,b ) and f(c,d). If I understood it well, this must be regarded as an error in defining the function "F". Actually, if I try to use "F" this way, it will report that f(#,#,#) does not exist. I hope I am right.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Andrey Ivashov  
#13 Posted : 29 June 2010 17:54:14(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)
If I understood you well, then it is because of the important difference between SMath Studio and Mathcad - SMath Studio allows to create any number of the variables and functions with the same name if only these items has different signature (signature for every primitive in SMath Studio is its pair of name and number of arguments).

See these examples to understand how it works with functions in arguments:

Open in SMath Cloud

Open in SMath Cloud

Best regards, Andrey Ivashov.
Offline omorr  
#14 Posted : 29 June 2010 18:50: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)
Yes, I understand that. I thought something like this
Open in SMath Cloud
It does not matter what the second argument of function "F" is - it is simply redundant in the definition. We can put whatever we like (I think). My doubt is - could this be regarded as an error in the definition -f(x,y,z) is not used - or simply ignored?

Hmm...I might have the same doubts some time ago about it, but might have forgotten - sorry. Anyway, no harm done - just a user have been mistaken.

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Andrey Ivashov  
#15 Posted : 29 June 2010 19:10:28(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)
Ok, its clear now. This is a rather common thing - I think it is not regarding functions in arguments.
F.e.: f(a):5. Should we raise an error or not?

I believe that this should be possible for user to make such redundant arguments. Because some persons may want to define all arguments of the function before creating of the main function's logic or some similar case.

Regards.
Offline omorr  
#16 Posted : 29 June 2010 19:45:47(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, you are right. I agree with you Good . This might be quite useful.

I am now quite sure that you already mentioned this, but I forgot - sorry.

Regards,
Radovan

Edited by user 29 June 2010 19:56:04(UTC)  | Reason: Not specified

When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Andrey Ivashov  
#17 Posted : 30 June 2010 03:55:42(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)
Errors fixed, SMath Studio Live updated. Hint: click on the expression with error to read a message.

Open in SMath Cloud

Regards.
Offline omorr  
#18 Posted : 30 June 2010 11:37:15(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 Andrey,

Some more testing.
Open in SMath Cloud
Did I overlook something, or this was not implemented yet?

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Offline Andrey Ivashov  
#19 Posted : 30 June 2010 13:10:44(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)
Привет, Radovan.

When you call g(x,f(x)) SMath Studio substitute x wherever it appears in expression (it is a vector in your example, defined above), so to get the result you need just change it to something like g(x,f(someName)). But it is an error nevertheless - program should show a message about this issue like it does on g(x,f(3)).

Regards.
Offline omorr  
#20 Posted : 30 June 2010 15:21:11(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)
Zdravo, Andrey Good

Yes, you are right. It did not came to my mind. I checked that out.
I just need to put say g(x,f(a)) and it will work. The variable "a" must not be previously defined - The result would be zero then - if it was a scalar, and vector or matrix of zeros - if it was a vector or matrix. As you said, this should be issued as error.

On the other hand if you use f(x):=sin(x) -the intrinsic function-the error will be reported when using g(x,f(x))= as
"Argument must be scalar"

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
Users browsing this topic
2 Pages12>
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.