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

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline Razonar  
#1 Posted : 02 March 2019 01:30:46(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi. It's seems to me that here a in the f body isn't local:

Clipboard01.gif

Are the yellow correct?

Best regards.
Alvaro.

Edited by user 02 March 2019 02:10:42(UTC)  | Reason: Not specified

thanks 1 user thanked Razonar for this useful post.
on 02/03/2019(UTC)

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline Jean Giraud  
#2 Posted : 02 March 2019 02:44:00(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: Razonar Go to Quoted Post
Are the yellow correct ?

Yes and NO ... a:=Clear(a)=1 ... =1 is logical Yes
Smath Clear(,) does not evaporate from the kernel like Mathcad 11 equivalent.
It may clear a function, why because if you want to redefine f(a,x):=a*x
it is only necessary to re-assign the RHS.
Past SS 6179 can't tell behaviour .

Clear(a).PNG
Offline Davide Carpi  
#3 Posted : 04 March 2019 17:45:17(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)
Yes it is correct... from the arguments you have x=a, then defining a=3 makes the return value: 3*x=3*(3*a)=3*(3*3)=27

if "a=value" is defined before calling the function the value is passed, hence "x=value" is what is known inside the function; then Clear(a) act to avoid the use of global "value" when you use "a" inside the function.

If "a" is not defined before calling the function, then "x=a" is what is known inside the function and Clear(a) clears nothing (a is not defined -> nothing to clear). This means even that if you add a:5 after a:3, then when x is calculated at the end of the function 5 will be the value used.

Note that Clear() is not always needed. You need it if inside the function you need an unknown named in that way for symbolic calculations or either that name is used to build a local matrix whereas already exists a global matrix.

Edited by user 04 March 2019 18:19:22(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 04/03/2019(UTC)
Offline Jean Giraud  
#4 Posted : 04 March 2019 21:47:10(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)
Not easy to explain more generally, in fact Clear(,) is not needed
as does nothing, i.e: it does not evaporate the demand.
The great advantage of Smath is the fact that results are stored in
vector. When opening a work sheet that takes long time to calculate
results are there for quick copying result. Also useful for versions
not backward compatible as it has stored and saved results that can
re-used as is from copy/paste.
Explain from attached demo:
In the attached, there are 4 examples of fitting data sets.
Observe carefully the lengths of the model vector functions
lengths: 2, 3, 4, 3 ... the 3, 4, 3 are compatible even if
the last 3 is shorter than 4 because 3 already exists and they
don't care length 2
Now, if we disable/delete the first example length [2] thus having
3, 4, 3 we can't recover 3 ,4 ,3 ,2 and there is no way to
recover the fit of model 2
Differently, Mathcad that is a scalar CAS, compared to Smath
a vector CAS ... Mathcad wouldn't care and would solve the
examples lengths 3, 4, 3, 2

GenfitLinfit.sm (65kb) downloaded 14 time(s).
Offline Razonar  
#5 Posted : 05 March 2019 00:23:23(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi Davide. So, there are not way to declare a variable as local in SMath, and we need to use some decoration for the variables inside the body of a function.

local.sm (4kb) downloaded 19 time(s).
local.gif
Best regards.
Alvaro.
Offline Jean Giraud  
#6 Posted : 05 March 2019 01:44:08(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: Razonar Go to Quoted Post
So, there are not way to declare a variable as local in SMath


That's right, only function can be declared local.
Range series summation is the most known example.
Jean

Offline Jean Giraud  
#7 Posted : 05 March 2019 06:55:27(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: Jean Giraud Go to Quoted Post
Range series summation is the most known example.

... like in this document.

Spline De Boor [Colibri].sm (36kb) downloaded 26 time(s).

Offline Davide Carpi  
#8 Posted : 05 March 2019 10:55:42(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: Razonar Go to Quoted Post
Hi Davide. So, there are not way to declare a variable as local in SMath, and we need to use some decoration for the variables inside the body of a function.


You can use a decoration for local variables to minimize conflicts. However it is actually possible to avoid them completely; the trick to expose a variable from the input to the output is to "create and destroy" the local variables without using the input argument, then once locals are cleared you can use the input.

33.png

or in another way:

16.png

Edited by user 05 March 2019 11:16:16(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 4 users thanked Davide Carpi for this useful post.
on 05/03/2019(UTC),  on 05/03/2019(UTC),  on 05/03/2019(UTC),  on 05/03/2019(UTC)
Offline Razonar  
#9 Posted : 05 March 2019 11:35:55(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,356
Uruguay

Was thanked: 815 time(s) in 516 post(s)
Hi Davide. Thanks very much for show how to isolate completely a procedure in SMath. Both techniques looks good.
Best regards.
Alvaro.

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