Equality

Equality - Is this a bug? - Сообщения

#1 Опубликовано: 11.03.2021 07:27:28
overlord

overlord

547 сообщений из 1330 понравились пользователям.

Группа: 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 КиБ) скачан 30 раз(а).

2021-03-11_13-29.png
#2 Опубликовано: 11.03.2021 15:36:00
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Numeric.PNG
#3 Опубликовано: 11.03.2021 16:58:29
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Numeric QED.PNG
#4 Опубликовано: 12.03.2021 13:26:15
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: 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 Опубликовано: 12.03.2021 14:30:27
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 Опубликовано: 12.03.2021 20:07:39
overlord

overlord

547 сообщений из 1330 понравились пользователям.

Группа: 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 Опубликовано: 12.03.2021 21:18:27
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

Not to differentiate between expressions.


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

Equality.PNG
#8 Опубликовано: 12.03.2021 21:51:07
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 Опубликовано: 12.03.2021 22:02:13
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

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

Solve Difficult.sm (9 КиБ) скачан 22 раз(а).
#10 Опубликовано: 12.03.2021 23:18:39
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1674 понравились пользователям.

Группа: 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.
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений