Problem with the array

Problem with the array - Messages

#1 Posted: 8/26/2021 5:32:35 AM
Vasia

Vasia

0 likes in 17 posts.

Group: User

Столкнулся с такой проблемой:
Есть зависимость переменной А от диапазона чисел λ = [0.3, 0.31,...1.3].
При λ = 0.7 должно выводиться в массиве А = 0, но вместо этого почему-то А = 5.40901*10^{-18}.
Попробовал уменьшить диапазон λ = [0,6, 0,61,...1.3], тогда А = 0.
Что не так у меня? File not found.File not found.File not found.File not found.
#2 Posted: 8/26/2021 11:30:40 AM
overlord

overlord

552 likes in 1332 posts.

Group: Moderator

Wrote

Столкнулся с такой проблемой:
Есть зависимость переменной А от диапазона чисел λ = [0.3, 0.31,...1.3].
При λ = 0.7 должно выводиться в массиве А = 0, но вместо этого почему-то А = 5.40901*10^{-18}.
Попробовал уменьшить диапазон λ = [0,6, 0,61,...1.3], тогда А = 0.
Что не так у меня?


This is because electronics, how computers store numbers.
SMath assign numbers to variables as an internal rational representation.
10^-18 is considered zero for SMath, even if it is not zero.
I have written about this issue sometime ago. This is not a bug however.
You can add an additional calculation check to your function in order to prevent this.

Regards

massiv_r1.sm (32 KiB) downloaded 24 time(s).
#3 Posted: 8/27/2021 2:32:56 AM
Vasia

Vasia

0 likes in 17 posts.

Group: User

Wrote

Wrote

Столкнулся с такой проблемой:
Есть зависимость переменной А от диапазона чисел λ = [0.3, 0.31,...1.3].
При λ = 0.7 должно выводиться в массиве А = 0, но вместо этого почему-то А = 5.40901*10^{-18}.
Попробовал уменьшить диапазон λ = [0,6, 0,61,...1.3], тогда А = 0.
Что не так у меня?


This is because electronics, how computers store numbers.
SMath assign numbers to variables as an internal rational representation.
10^-18 is considered zero for SMath, even if it is not zero.
I have written about this issue sometime ago. This is not a bug however.
You can add an additional calculation check to your function in order to prevent this.

Regards

massiv_r1.sm (32 KiB) downloaded 24 time(s).



Спасибо, а не составит труда кинуть ссылку на тему, где Вы об этом писали?
#4 Posted: 8/27/2021 7:32:25 AM
overlord

overlord

552 likes in 1332 posts.

Group: Moderator

Wrote

Спасибо, а не составит труда кинуть ссылку на тему, где Вы об этом писали?


Look for Razonar's answers in this topic.

Regards.

https://en.smath.com/forum/yaf_postst20177_Equality.aspx
  • New Posts New Posts
  • No New Posts No New Posts