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 overlord  
#1 Posted : 11 March 2021 13:27:28(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,125
Turkey

Was thanked: 506 time(s) in 337 post(s)
I had encountered this issue last night and tried to simplify it here.
Some equalities are not resulted as "1" but they should be.
If I use eval() they are calculated correctly.
Should I have to use eval() everytime to be sure of boolean calculations?
Below you can find the issue as an example.

Regards

equality.sm (32kb) downloaded 8 time(s).

2021-03-11_13-29.png

Edited by user 11 March 2021 13:29:47(UTC)  | Reason: Not specified

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

Offline Jean Giraud  
#2 Posted : 11 March 2021 21:36:00(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Numeric.PNG
Offline Jean Giraud  
#3 Posted : 11 March 2021 22:58:29(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Numeric QED.PNG
Offline Razonar  
#4 Posted : 12 March 2021 19:26:15(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)
Originally Posted by: overlord Go to Quoted Post
I had encountered this issue last night and tried to simplify it here.
Some equalities are not resulted as "1" but they should be.
If I use eval() they are calculated correctly.
Should I have to use eval() everytime to be sure of boolean calculations?
Below you can find the issue as an example.

Regards



Hi overlord. Usually it's hard to check equalities in math programs. For example, check the issues in Wolfram Mathematica (this picture is from https://reference.wolfra.../language/ref/Equal.html ):

Clipboard01.jpg

For numeric testing I use

Clipboard01.jpg

Best regards.
Alvaro.
Offline Jean Giraud  
#5 Posted : 12 March 2021 20:30:27(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: Razonar Go to Quoted Post
Hi overlord. Usually it's hard to check equalities in math programs.

That was discussed few months ago ... ULP
ULP in short: Unit (floating numerical) in Last Place
Well explained in Mathematica 4.0 ... Floating maths are granular
Hola Alvaro !
Offline overlord  
#6 Posted : 13 March 2021 02:07:39(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,125
Turkey

Was thanked: 506 time(s) in 337 post(s)
Originally Posted by: Razonar Go to Quoted Post
Hi overlord. Usually it's hard to check equalities in math programs.
Best regards.
Alvaro.

You are right about arbitrary precision and how computers store numbers, my bad.
But I can't still understand the behavior of SMath in the example below.
As you can see, sqr(3) * sqr(12) = 6. Obviously sqr(36) = 6 too.
But if you subtract them inline, result is not zero unless they are attached to a variable.
When the subtract is assigned to variable c calculation is still not zero.
However if you assign them to a and b, subtraction is magically zero again.
All calculations are set to numerical optimization with SMath by the way.

What I am trying to say, there is an inconsistency between calculations and results.
What I would expect is all answers to be zero or -8.8818x10^-16.
Not to differentiate between expressions. maple() doesn't suffer from this issue.

calculation.png

I have also checked with Wolfram Mathematica 8.0, no matter how I enter result is always 0.

mathematica.png

WolframAlpha is showing -8.8818x10^-16 during expression entry but resulted as zero when you press enter.

wolframalpha.png

Regards

Offline Jean Giraud  
#7 Posted : 13 March 2021 03:18:27(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: overlord Go to Quoted Post
Not to differentiate between expressions.

Never mind systems that reply to please. Numerical maths are of no commerce.

Equality.PNG
Offline Jean Giraud  
#8 Posted : 13 March 2021 03:51:07(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
... in Smath, zero [0] is undefined.
I commented that in my early 2015 Smath, not acknowledged.
From recollection in 1990, IEEE was discussing what zero [0]
should be valued ... ± agreed 10^-12. Since, I lost track
and after all don't bloody care for a dime.
In there, insert 0 to turn Bolean 1.

Equality QED.PNG
Offline Jean Giraud  
#9 Posted : 13 March 2021 04:02:13(UTC)
Jean Giraud

Rank: Guest

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

Was thanked: 980 time(s) in 808 post(s)
... all that equality reflects in practical projects.
Take care Overlord ... Jean

Solve Difficult.sm (10kb) downloaded 5 time(s).
Offline Razonar  
#10 Posted : 13 March 2021 05:18:39(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 overlord.

Originally Posted by: overlord Go to Quoted Post

But I can't still understand the behavior of SMath in the example below.
As you can see, sqr(3) * sqr(12) = 6. Obviously sqr(36) = 6 too.
But if you subtract them inline, result is not zero unless they are attached to a variable.
When the subtract is assigned to variable c calculation is still not zero.
However if you assign them to a and b, subtraction is magically zero again.
All calculations are set to numerical optimization with SMath by the way.

What I am trying to say, there is an inconsistency between calculations and results.
What I would expect is all answers to be zero or -8.8818x10^-16.
Not to differentiate between expressions. ...


SMath convert all numbers to an internal rational representation. This is why, in my opinion, you get different answers doing the roots in one line than store partial results into variables.

smathx.jpg

Originally Posted by: overlord Go to Quoted Post

... maple() doesn't suffer from this issue.


Yes, it have the same issue, but you can't see it inside the maple plugin, because SMath parse values as exact rationals. In maple you can use a dot for indicate floating point numbers

maple.jpg

Originally Posted by: overlord Go to Quoted Post


I have also checked with Wolfram Mathematica 8.0, no matter how I enter result is always 0.



It's harder to show the same behavior in Mathematica, but you can see it with some other numbers and floating point operations

wm.jpg

Hope that this notes helps.
Best regards.
Alvaro.
Users browsing this topic
Similar Topics
Iteration of values to satisfy an inequality (Questions)
by Orlando 31/05/2023 18:21:54(UTC)
[SS-2300] booolean equality comparision issue (Bugs & Problems)
by Dik 08/04/2018 09:37:18(UTC)
Inequality with units says incompatibe units if the units are the same (Bugs & Problems)
by jmc 19/11/2012 17:32:41(UTC)
How does the equality operator work? (Questions)
by Stuart Bruff 18/06/2012 09:21:07(UTC)
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.