Function as a program

Function as a program - Messages

#1 Posted: 9/30/2010 7:11:34 PM
Andrey Ivashov

Andrey Ivashov

2269 likes in 3729 posts.

Group: Super Administrator

Hey! I have really good news today!


Hint 1: Local variable and functions are really local now.
Hint 2: Line as a body of definition (right part of equation) is required.
Hint 3: Last element of line(..) function returns an answer to the left part.

Seems SMath Studio 0.90 will be really powerful tool! Thanks to all for helping me with a project!

Best regards, Andrey Ivashov.

Related topics:
  • Operators behavior?
  • User defined functions
  • and others...
  • #2 Posted: 9/30/2010 7:37:33 PM
    Andrey Ivashov

    Andrey Ivashov

    2269 likes in 3729 posts.

    Group: Super Administrator

    SMath Studio Live updated with the latest sources, so anyone can test new features:
    [LIVE width=303 height=177]http://smath.info/live/?file=1616[/LIVE]

    Regards.
    #3 Posted: 9/30/2010 7:51:33 PM
    Oscar Campo

    Oscar Campo

    124 likes in 298 posts.

    Group: Moderator

    Thanks a lot!! It's really a wonderful improvement.
    #4 Posted: 10/1/2010 1:54:06 AM
    Radovan Omorjan

    Radovan Omorjan

    325 likes in 2052 posts.

    Group: Moderator


    I will test it these days - of course

    Many thanks Andrey
    When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
    #5 Posted: 10/1/2010 3:13:05 AM
    Radovan Omorjan

    Radovan Omorjan

    325 likes in 2052 posts.

    Group: Moderator

    Hello Andrey,

    Test 1
    [LIVE width=571 height=445]http://smath.info/live/?file=1619[/LIVE]
    in the 0.89_6, variable "n" will have the same value and variable "y" will be undefined ("i" will be just i -imaginary unit).

    Am I missing something? I've thought that variables "n", "y" and "i" should not be known here. i.e. being local to the function g(x,f(x)).

    Hint 1: Local variable and functions are really local now.
    Please explain what does this mean. I might be misleading.

    Regards,
    Radovan
    When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
    #6 Posted: 10/1/2010 3:31:25 AM
    Radovan Omorjan

    Radovan Omorjan

    325 likes in 2052 posts.

    Group: Moderator

    Hello Andrey

    Test 2
    [LIVE width=457 height=553]http://smath.info/live/?file=1625[/LIVE]
    This is nice

    Regards,
    Radovan
    When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
    #7 Posted: 10/1/2010 6:05:49 AM
    Andrey Ivashov

    Andrey Ivashov

    2269 likes in 3729 posts.

    Group: Super Administrator

    Radovan, thank you for testing!

    Wrote

    Am I missing something? I've thought that variables "n", "y" and "i" should not be known here. i.e. being local to the function g(x,f(x)).

    Hint 1: Local variable and functions are really local now.
    Please explain what does this mean. I might be misleading.


    It is an error that I should fix. Variables defined in the right part of expression will not be visible outside of this expression.

    Regards.
    #8 Posted: 10/1/2010 6:47:23 AM
    Radovan Omorjan

    Radovan Omorjan

    325 likes in 2052 posts.

    Group: Moderator

    Wish you good luck Andrey,

    This is one of the greatest feature needed for SMath IMHO.

    Regards,
    Radovan
    When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
    #9 Posted: 10/3/2010 10:12:41 AM
    Radovan Omorjan

    Radovan Omorjan

    325 likes in 2052 posts.

    Group: Moderator

    This is also working now
    Assignment inside matrix! Matrix has the value and the variables inside as matrix elements.
    [LIVE width=256 height=192]http://smath.info/live/?file=1640[/LIVE]
    Regards,
    Radovan
    When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
    #10 Posted: 10/3/2010 6:02:42 PM
    Andrey Ivashov

    Andrey Ivashov

    2269 likes in 3729 posts.

    Group: Super Administrator

    Hello.

    Interesting thing - line(..) function on the right part of equation means now that SMath Studio will not even parse all stuff of the line before left part will be called by someone. And here is a side effect:


    This is not the error, but some interesting way to work with functions. In other words it is like one more option of Optimization. Numeric optimization means, that program will try to evaluate right part of equation numerically, symbolic optimization - evaluate symbolically, no optimization means, that program will substitute all previous definitions to the right part of equation and line(..) function at right means that program will not substitute previous definitions to the right part at all.

    Best regards.
    #11 Posted: 10/4/2010 8:37:13 AM
    Radovan Omorjan

    Radovan Omorjan

    325 likes in 2052 posts.

    Group: Moderator

    Wrote

    ... line(..) function at right means that program will not substitute previous definitions to the right part at all.


    This is also a nice one . The solution when you want to see how the function was actually defined - without replacing things.

    BTW., just tried 0.89_8. I am not sure but there might be a minor issue. If you have the file "somefile.sm" and in the same folder save as HTML, there would be "somefile.htm" file and "somefile" folder with pictures. Now, if you try to save the compressed SMath studio file with the name "somefile" as the compressed SMath type "*.smz", it will not be saved unless you explicitly type in the file name box "somefile.smz".

    Regards,
    Radovan
    When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
    #12 Posted: 10/1/2012 7:05:48 AM
    adiaz

    adiaz

    5 likes in 25 posts.

    Group: User

    Wrote

    This is not the error, but some interesting way to work with functions. In other words it is like one more option of Optimization. Numeric optimization means, that program will try to evaluate right part of equation numerically, symbolic optimization - evaluate symbolically, no optimization means, that program will substitute all previous definitions to the right part of equation and line(..) function at right means that program will not substitute previous definitions to the right part at all.
    Best regards.



    I'm not comftable with this. As shown in the picture, when write 'g', 'a' appears as 'a = 2'. Others programs have a warning message for the use of global variables locally. I think that you must to introduce a global command to catch the value of a in g(x).

    Regards.

    Alvaro.
    Clipboard02.gif
    #13 Posted: 10/1/2012 9:15:31 AM
    Radovan Omorjan

    Radovan Omorjan

    325 likes in 2052 posts.

    Group: Moderator

    Hello Alvaro,

    I could not get the same results as you did.
    See the picture please.

    Regards,
    Radovan
    symbnum.png
    When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
    #14 Posted: 10/1/2012 9:44:55 AM
    adiaz

    adiaz

    5 likes in 25 posts.

    Group: User

    Hi. In my example it is (|a*x)*1, but yours is (|a*x*1)

    Regards.
    #15 Posted: 10/1/2012 10:03:28 AM
    Radovan Omorjan

    Radovan Omorjan

    325 likes in 2052 posts.

    Group: Moderator

    Hello Alvaro,
    Wrote

    Hi. In my example it is (|a*x)*1, but yours is (|a*x*1)


    You are right. This might be sometimes quite frustrating. Everything looks the same but the result is different. SMath can not deal with braces correctly and satisfactory quite often

    This one is one of the examples of that problem I mentioned few times here on the Forum.

    [MATH=eng]range(1,6*2)=mat(1,2,3,4,5,6,7,8,9,10,11,12,12,1)[/MATH] [MATH=eng]range(1,6)*2=mat(2,4,6,8,10,12,6,1)[/MATH]

    Regards,
    Radovan
    When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
    1 users liked this post
    Davide Carpi 10/1/2012 12:41:00 PM
    #16 Posted: 10/1/2012 11:05:07 AM
    adiaz

    adiaz

    5 likes in 25 posts.

    Group: User

    Well, as I see, this the price for obtain clarity in others expression. Mathematica have a lot of this problems with TraditionalNotation, Maple too. But at the end, this give less mistakes that working with parenthesis and text notations.

    Defining a function as f(x) := 1*(| ... ) make all variables in line(...) as globals.

    Regards.
    • New Posts New Posts
    • No New Posts No New Posts