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

Notification

Icon
Error

Login


2 Pages<12
Options
Go to last post Go to first unread
Offline Davide Carpi  
#21 Posted : 02 May 2018 10:09:38(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)
Hello everyone Good

Originally Posted by: MarB Go to Quoted Post
Shouldn't the variable A be replaced by its value 1 when 'cases' is used instead of 'if/else'?

cases.png

This is by design and is related to functions and undefined arguments; however if I remember correctly was needed because the old way caes() was coded, I'll check if with current cases() and smath code can be removed. Also, applies ony when cases is on the RHS of functions.


Originally Posted by: Jean Giraud Go to Quoted Post
I notice one instance if/otherwise does not work vs if/else.
Reported, not acknowledged ... maybe more than one instance.

Silly.PNG

No way this can work, because a is defined after the plot; keeping this layout you have to move the vertical position of the plot down or the vertical position of a:0 up Good

Edited by user 02 May 2018 10:14:40(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 02/05/2018(UTC)
Offline Jean Giraud  
#22 Posted : 02 May 2018 14:23:22(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: MarB Go to Quoted Post
I really don't want to play silly games with you anymore.

I asked a simple question:
"Why is the value of the canvas variable A not stored in the function, when cases is involved ?"

Your answer has absolutely nothing to do with my question.


Convince yourself, try the right/wrong code in De Boor Colibri.
It may have to do with another next possible not silly visit/question.

adAbsurdum.PNG

Spline De Boor [Colibri].sm (40kb) downloaded 13 time(s).


Offline Jean Giraud  
#23 Posted : 02 May 2018 14:49:12(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)
A CAS like Smath and others do not know if
0.123 is exactly = 0.123000000000000
I'm not aware of such an option in Smath

Example from Mathematica 4.0

pitFall.PNG


Offline Jean Giraud  
#24 Posted : 02 May 2018 14:57:09(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
Example from Mathematica 4.0

Explained otherwise in Mathcad/Mathsoft

x^1/2 will output 250 floating point decimals [1/2 is exact]
x^0.5 will output 15 decimals [0.5 is unknown]



Offline Jean Giraud  
#25 Posted : 02 May 2018 15:37:40(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
Explained otherwise in Mathcad/Mathsoft


... I will leave it from there.
Please, don't hesitate to submit your project.
There was that futile discussion about 32/64/128 floating point
In PC's, 32 bits is enough. Common math functions as delivered
by Microsoft are 21 decimals, uncertain down to 18 decimals
agreed to true 15 decimals taking account of reasonable
numerical errors propagation.

A Mathsoft Collab wanted > 15 decimals. Answer was simple:
Mahcad 11 extended 64 floating point:
Install Chebyshev 25 decimals [Clenshaw, Luke ...]

Accuracy.sm (20kb) downloaded 16 time(s).

Offline CBG  
#26 Posted : 02 May 2018 23:45:55(UTC)
CBG


Rank: Advanced Member

Groups: Registered
Joined: 14/10/2015(UTC)
Posts: 308

Was thanked: 77 time(s) in 58 post(s)
Originally Posted by: Alyles

Quote:
The difference comes when the value of A changes after the definition of f(x) and g(x).

For g(x) the original definition of A:=1 remains. However, for f(x) the value of A changes.



I see that the problem is caused by the definition of the variable A, before the functions, changing the definition of this variable after the definitions of the functions, the problem is solved.

This indicates to us that we must be very careful when programming functions when some of the variables that integrate in them have already been defined previously, because we could arrive at erroneous results

Cases_ok_cbg.png

cases_ok_cbg.sm (8kb) downloaded 17 time(s).


Best Regards


Carlos
Offline PompelmoTell  
#27 Posted : 03 May 2018 10:54:00(UTC)
PompelmoTell


Rank: Advanced Member

Groups: Registered
Joined: 23/12/2011(UTC)
Posts: 319
Man
Italy
Location: italy

Was thanked: 109 time(s) in 93 post(s)
I think MarB is right. It is advisable to have homogeneous behavior of the functions. In this case, function "cases" is used as an alternative to function "if...else" to avoid using nesting; it is evident that one expects the same behavior.

sergio
thanks 1 user thanked PompelmoTell for this useful post.
on 03/05/2018(UTC)
Offline Jean Giraud  
#28 Posted : 03 May 2018 16:16:30(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: PompelmoTell Go to Quoted Post
it is evident that one expects the same behavior.

They do behave the same, except for the rare case that I reported.
In mainy instances < or <= won't matter
In other instance it matters to scrap the project [De Boor re-posted in this thread].
In less visible instance, if the form is not appropriate will freak the project.
Same things with Mathcad ... ad nauseum doctored.
No matter the arguments, Smath is correct, does not forgive user incorrect coding.


Offline MarB  
#29 Posted : 03 May 2018 17:10:40(UTC)
MarB


Rank: Advanced Member

Groups: Registered
Joined: 21/10/2016(UTC)
Posts: 84

Was thanked: 21 time(s) in 17 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Originally Posted by: PompelmoTell Go to Quoted Post
it is evident that one expects the same behavior.

They do behave the same, except for the rare case that I reported.

Take a look at post #1 or #3. That's about what we are talking here.

Another example:
cases_x.PNG

The first A is replaced by its value, the second is not.
Not really intuitive or obvious, in my opinion.
thanks 1 user thanked MarB for this useful post.
on 03/05/2018(UTC)
Offline Jean Giraud  
#30 Posted : 03 May 2018 18:06: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: MarB Go to Quoted Post
The first A is replaced by its value, the second is not.
Not really intuitive or obvious, in my opinion.

The best is to apply to a project and make it work.

ifOtherwiseExample.PNG

Offline Davide Carpi  
#31 Posted : 03 May 2018 19:02:11(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)
I'm too to not create confusion, however some features are tied to this feature; by removing it:

  • any argument will be preprocessed by smath; this means f.e. that if you place a definition, this will be evaluated despite the condition is met or not (like in if function)
    2018-05-03 17_58_00-SMath Studio - [Page1_].png2018-05-03 17_57_40-SMath Studio - [Page1_].png
  • the protection against assignments won't work anymore
  • won't be possible anymore to use functions like error()
    2018-05-03 17_58_22-SMath Studio - [Page1_].png


(you will be able do them using line, though)

Edited by user 03 May 2018 19:55:37(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
Users browsing this topic
Guest
2 Pages<12
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.