Equality

Equality - Is this a bug? - Mensajes

#1 Publicado: 11/3/2021 7:27:28
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: Moderator

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 (31,06 KiB) descargado 1582 vez(es).

2021-03-11_13-29.png
#2 Publicado: 11/3/2021 15:36:00
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Numeric.PNG
#3 Publicado: 11/3/2021 16:58:29
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Numeric QED.PNG
#4 Publicado: 12/3/2021 13:26:15
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Wrote

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.wolfram.com/language/ref/Equal.html ):

Clipboard01.jpg

For numeric testing I use

Clipboard01.jpg

Best regards.
Alvaro.
#5 Publicado: 12/3/2021 14:30:27
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Wrote

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 !
#6 Publicado: 12/3/2021 20:07:39
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: Moderator

Wrote

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

#7 Publicado: 12/3/2021 21:18:27
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Wrote

Not to differentiate between expressions.


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

Equality.PNG
#8 Publicado: 12/3/2021 21:51:07
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

... 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
#9 Publicado: 12/3/2021 22:02:13
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

... all that equality reflects in practical projects.
Take care Overlord ... Jean

Solve Difficult.sm (9,21 KiB) descargado 1552 vez(es).
#10 Publicado: 12/3/2021 23:18:39
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Hi overlord.

Wrote


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

Wrote


... 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

Wrote



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.
  • Nuevos mensajes
  • Sin mensajes nuevos