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

Notification

Icon
Error

Login


3 Pages<123>
Options
Go to last post Go to first unread
Offline ElSid  
#21 Posted : 23 March 2016 05:21:29(UTC)
ElSid


Rank: Advanced Member

Groups: Registered
Joined: 05/03/2009(UTC)
Posts: 433
Man
United States
Location: USA

Was thanked: 17 time(s) in 15 post(s)
Originally Posted by: ioan92 Go to Quoted Post
Originally Posted by: ElSid Go to Quoted Post
Update ... In SMath --> Help --> Examples --> Handbooks? If so, the PDF file in post #1 did not appear as a download
Try this way:
SMath Menu --> Tools --> Plugins --> Extensions Manager --> Handbooks

Turns out it's the same location. Thank you
thanks 1 user thanked ElSid for this useful post.
on 23/03/2016(UTC)
Offline Jean Giraud  
#22 Posted : 23 March 2016 15:25:24(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: RFreund Go to Quoted Post
When you say
"when a canvas variable is defined at function's definition, the value is stored..."
This really means:
"when a canvas variable is defined before the function's definition, the value is stored..."
before = above or left of the function (on the canvas)
Right?


You would install parameters up above the function definition in the case
parameters result from other specifics of the project, i.e: if parameters
result from some type of calculations. Otherwise, if the parameters are
"solid", put them below the definition at the point of usage, like near the
plot so you can play with the graph.
Words speak and may be confusing, image don't speak but verdict.

Jean

Forum Define Parametric.gif

thanks 1 user thanked Jean Giraud for this useful post.
on 23/03/2016(UTC)
Offline Davide Carpi  
#23 Posted : 23 March 2016 21:56:28(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Originally Posted by: RFreund Go to Quoted Post
Davide,

When you say
"when a canvas variable is defined at function's definition, the value is stored..."
This really means:
"when a canvas variable is defined before the function's definition, the value is stored..."
before = above or left of the function (on the canvas)
Right?

Thanks

You're right, I'll use your formulation in next revision Good

Edited by user 24 March 2016 00:33:19(UTC)  | Reason: Not specified

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline RFreund  
#24 Posted : 24 March 2016 04:28:13(UTC)
RFreund


Rank: Advanced Member

Groups: Registered
Joined: 25/09/2013(UTC)
Posts: 325
United States
Location: IL

Was thanked: 19 time(s) in 17 post(s)
Sorry I should have shown with an example.

Another way to say it would be:

"when a canvas variable is already defined at the function's definition, the value is stored..."

I suppose any of those works. It's just that when you read the word "at" you think that it is being somehow defined in the function itself.

Anyway, Thanks for confirming.
Offline Jean Giraud  
#25 Posted : 24 March 2016 06:09:31(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
No "value is stored" ... the algo is stored,
implicit of the associated argument. In this
example, the argument is β indexed, stored
in the algo stack.

Jean

Forum Define Scalar Function.gif


Integrate Scalar Express.sm (12kb) downloaded 32 time(s).
Offline mkraska  
#26 Posted : 19 September 2016 21:54:10(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
0.98.6103

It seems that certain changes happened in what is allowed as formal arguments in function definitions. I compare the pdf and the .sm file of the user function guide.

- dummy argument: empty string no more allowed, empty placeholder (type #) is accepted instead.
- unit names are now protected, they stick to their meaning no matter what value is used in the function call.

2016-09-19 20_49_06-SMath Studio Desktop - [Userfunctions.sm_].png
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline Davide Carpi  
#27 Posted : 19 September 2016 23:53:59(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Thank you Martin,

yes these behaviors were unintentionally introduced by Andrey in 0.98, patched recently; I'll update this document ASAP (here and in the EM too) Good

Edited by user 19 September 2016 23:57:06(UTC)  | Reason: Not specified

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
Offline mkraska  
#28 Posted : 19 September 2016 23:59:56(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post
Thank you Martin,

yes these behaviors were unintentionally introduced by Andrey in 0.98, patched recently; I'll update this document ASAP Good


I don't mind these changes to remain. I think the empty placeholder is much better visual clue to something that does not matter than the empty string (and requires less typing).

I also would suggest to allow leaving the placeholder empty if no input to the function is required. Just as with DocumentDirectory()
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline Jean Giraud  
#29 Posted : 20 September 2016 04:39:07(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: mkraska Go to Quoted Post
I think the empty placeholder is much better visual clue


Agreed 100% Martin ... 'x' makes "conventional sense" also.
Anything else => for the birds .
Offline mkraska  
#30 Posted : 21 September 2016 18:18:56(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
Hello Davide, I refer to your tips in the guide to user-defined functions:

Code:
- if you are running NUMERICAL calculations inside the function:
     - if you don't want/need values from outside, you have to check that everything is defined
         inside the function  ("pure" function -> copy the function in an empty worksheet, run it 
         directly ->  shouldn't run if something is missing in the function)
     - if you use unknowns to get values from outside the function:
         1) document somewhere the dependancies (f.e. in the description)
         2) test it in an empty worksheet, define the dependacies and check the consequences of
               the loss of any single dependancy (A,B,C -> keep A and B, remove C, then keep A and C
               and remove B, etc..)

- if you are running SYMBOLICAL calculations inside the function, you may need to choose
    hardly predictable unknowns' names (such as x#, _x, _x_, #x, §x, ...) to avoid
    unintentional replacements from the canvas;



I know that using strange variable names within functions is common practice in SMath programming. However, somehow I have forgotten why we do this or at least fail to explain it.

Could you please give an example for an unintended replacement which has to be avoided by strange names?
Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
Offline Davide Carpi  
#31 Posted : 21 September 2016 19:32:27(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Currently I'm reworking the document, I think that this section will be changed to be more clear.

Leaving aside [SS-111]/[SS-2327] (this is a bug, Andrey will work on it), issues are related to an existing variable on the parent level (commonly the canvas, but you can extend the logic to nested functions), and a variable with the same name in the function; cases in my knowledge:
  1. unintentional pass-by-reference: this is not really a problem if you pay attention to it; if you don't want to pay attention, you can use the "strange variables' names" approach (not really a best practice, but it is a way); this is the only case in which you can modify unintentionally external variables from inside the function.
    2016-09-21 18_28_16-SMath Studio Desktop - [name_intef_issue_symb.sm_].png

  2. Matrices/systems: if are not initialized within the procedure and you write only some elements or you change the sizes; this may affects the expected result.
    2016-09-21 18_28_39-SMath Studio Desktop - [name_intef_issue_symb.sm_].png

  3. Symbolic calculations: you assign a local unknown to a variable, then you do stuff like differentiation thinking that the variable contains an unknown; this may affects the expected result. If the worksheet is sharable or with complex logic, hardly predictable unknown names here are almost mandatory IMO (plus it might help to identify that is a generic unknown).
    2016-09-21 18_28_05-SMath Studio Desktop - [name_intef_issue_symb.sm_].png

    In the example above, this is the logic when you evaluate f(3):
    1. v1 stores 13 (3+2*5), because b=5 exists on the top level;
    2. v2 stores 3+2*c, because c doesn't exists anywhere;
    3. o1 stores 2 (expected value), because the order of computation: differentiation is made, then the assignments looks to replace unknowns from RHS to store it in the variable on the LHS;
    4. o2 stores 2 (expected value), because v2 contains the unknown c;
    5. o3 stores 0, because you are differentiating 13;


P.S. please note that the canvas' variables here are placed after functions' definitions, to remark that the logic applies when you evaluate the function.

Edited by user 21 September 2016 20:09:34(UTC)  | Reason: Not specified

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 1 user thanked Davide Carpi for this useful post.
on 21/09/2016(UTC)
Offline mkraska  
#32 Posted : 21 September 2016 23:21:44(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
Originally Posted by: Davide Carpi Go to Quoted Post

  • Symbolic calculations: you assign a local unknown to a variable, then you do stuff like differentiation thinking that the variable contains an unknown; this may affects the expected result. If the worksheet is sharable or with complex logic, hardly predictable unknown names here are almost mandatory IMO (plus it might help to identify that is a generic unknown).
    2016-09-21 18_28_05-SMath Studio Desktop - [name_intef_issue_symb.sm_].png



  • Thank you Davide,

    this is exactly what I was looking for. Using Clear(), you can close the canvas-bypass for variables used inside the functions. This is just the symbolic version of initialization.
    As long as you don't use the internal names as arguments in the function call, you are safe.
    Thus, I have to admit that still the names of the internal variables matter.

    clear.sm (9kb) downloaded 25 time(s).

    Clear.png

    Edited by user 21 September 2016 23:24:17(UTC)  | Reason: Not specified

    Martin Kraska

    Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
    Offline Jean Giraud  
    #33 Posted : 22 September 2016 00:46:35(UTC)
    Jean Giraud

    Rank: Guest

    Groups: Registered
    Joined: 04/07/2015(UTC)
    Posts: 6,866
    Canada

    Was thanked: 981 time(s) in 809 post(s)
    I didn't put much effort trying to understand what f(x)
    should do. For sure it's not going to cut the mustard for
    Engineers. If I would have to QA such a mess, I would return
    red crossed. On the other hand, "Clear" does nor clear,
    it does not empty the variable/constant. It will clear pi for 1
    and it does not clear predefined items before maple symbolic evaluation.
    Smath clear is nothing compared to Mathcad that creates "inexistance".

    Forum Unknown Stuff.gif
    Offline Jean Giraud  
    #34 Posted : 22 September 2016 00:58:49(UTC)
    Jean Giraud

    Rank: Guest

    Groups: Registered
    Joined: 04/07/2015(UTC)
    Posts: 6,866
    Canada

    Was thanked: 981 time(s) in 809 post(s)
    The compactum is very useful, but not always compatible.
    There are more instances of "not compatible".

    Compactum.gif
    Offline Jean Giraud  
    #35 Posted : 22 September 2016 06:42:19(UTC)
    Jean Giraud

    Rank: Guest

    Groups: Registered
    Joined: 04/07/2015(UTC)
    Posts: 6,866
    Canada

    Was thanked: 981 time(s) in 809 post(s)
    ... those things you want to compact in some way must be tested
    on real applications. Bits and pieces are no proof. This document
    shows two cases of failure [1: the compactum, 2: Algo]

    Jean

    Spline Quadratic [Model].sm (90kb) downloaded 30 time(s).

    Offline Davide Carpi  
    #36 Posted : 22 September 2016 11:47:40(UTC)
    Davide Carpi


    Rank: Advanced Member

    Groups: Registered, Advanced Member
    Joined: 13/01/2012(UTC)
    Posts: 2,647
    Man
    Italy
    Location: Italy

    Was thanked: 1329 time(s) in 875 post(s)
    Originally Posted by: mkraska Go to Quoted Post
    Using Clear(), you can close the canvas-bypass for variables used inside the functions. This is just the symbolic version of initialization.

    Yes, I guess it might be the best approach (probably the most clean even for occasional readers).

    Originally Posted by: Jean Giraud Go to Quoted Post
    On the other hand, "Clear" does nor clear,
    it does not empty the variable/constant. It will clear pi for 1
    and it does not clear predefined items before maple symbolic evaluation.
    Smath clear is nothing compared to Mathcad that creates "inexistance".

    You are right; this is because Clear() is not a built-in function, just rides a feature of line() wrt anything but functions.

    Two points to have a built-in clear() Good

    Edited by user 22 September 2016 12:39:07(UTC)  | Reason: Not specified

    If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
    Offline Jean Giraud  
    #37 Posted : 22 September 2016 17:21:49(UTC)
    Jean Giraud

    Rank: Guest

    Groups: Registered
    Joined: 04/07/2015(UTC)
    Posts: 6,866
    Canada

    Was thanked: 981 time(s) in 809 post(s)
    Originally Posted by: Davide Carpi Go to Quoted Post
    Two points to have a built-in clear()


    Yes Davide, but simpler than a "clear function", just like Mathcad:
    assign undefined ... a:= ... f(x):=

    In Mathcad, undefined would evaporate 'a'. If more paramaters were previously used,
    undefining all individually would render the symbolic "virgin" for expansion.
    That was Mathcad 11 and earlier versions, at least back to Mathcad 8 Pro.
    Alike evaporating parameters, Mathcad evaporates a function, f(x):=
    past undefining f(x):= 'f' can be re-used.

    In fact, we have it all naturally in Smath.

    1. Assume f(a,b,c,x) was a user function, now just define f(x):=ln(x)
    2. To clear parameters a,b,c ... just define a:=Shift+" [the blanking tool].

    Not completely proofed.

    Jean

    Maple coeffs NumDen [Companion].sm (19kb) downloaded 29 time(s).

    Visit the end of the work sheet.

    Offline mkraska  
    #38 Posted : 22 September 2016 17:58:25(UTC)
    mkraska


    Rank: Advanced Member

    Groups: Registered
    Joined: 15/04/2012(UTC)
    Posts: 1,986
    Germany

    Was thanked: 1124 time(s) in 721 post(s)
    Originally Posted by: Jean Giraud Go to Quoted Post


    Yes Davide, but simpler than a "clear function", just like Mathcad:
    assign undefined ... a:= ... f(x):=



    I agree with the proposal to have a:# or f(1):# or f(#):x being understood as deleting a definition. That could even be understood by non-SMath people, although an explicit "undefined" would be less subject to interpretation.

    Edited by moderator 23 September 2016 01:30:41(UTC)  | Reason: fixed BBCODE

    Martin Kraska

    Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
    Offline Andrey Ivashov  
    #39 Posted : 22 September 2016 19:44:36(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)
    Originally Posted by: Davide Carpi Go to Quoted Post
    Leaving aside [SS-111]/[SS-2327] (this is a bug, Andrey will work on it)

    Fixed. Thank you!
    thanks 1 user thanked Andrey Ivashov for this useful post.
    on 23/09/2016(UTC)
    Offline Jean Giraud  
    #40 Posted : 23 September 2016 07:58:36(UTC)
    Jean Giraud

    Rank: Guest

    Groups: Registered
    Joined: 04/07/2015(UTC)
    Posts: 6,866
    Canada

    Was thanked: 981 time(s) in 809 post(s)
    Originally Posted by: mkraska Go to Quoted Post
    I agree with the proposal to have a:# or f(1):# or f(#):x being understood as deleting a definition. That could even be understood by non-SMath people, although an explicit "undefined" would be less subject to interpretation.


    Good suggestion except that the gyzma # is not accessible in Smath.
    Not directly accessible via the Shift 3 keyboard, neither via the
    extended Alt 035. Smath 5346, XP Home SP3.

    My western keyboard is OK, but ignored by Smath 5346.
    gyzma from keyboard # ... gyzma Alt 035 #

    Users browsing this topic
    Guest
    3 Pages<123>
    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.