gpt4 book ai didi

wolfram-mathematica - Mathematica 中是否有 "normal"EqualQ 函数?

转载 作者:行者123 更新时间:2023-12-04 02:31:30 25 4
gpt4 key购买 nike

Equal 的文档页面上我们读到

Approximate numbers with machine precision or higher are considered equal if they differ in at most their last seven binary digits (roughly their last two decimal digits).



以下是示例(32 位系统;对于 64 位系统,在中间添加更多零):
In[1]:= 1.0000000000000021 == 1.0000000000000022
1.0000000000000021 === 1.0000000000000022

Out[1]= True

Out[2]= True

我想知道是否有 Equal 的“正常”类似物Mathematica 中的函数不会删除最后 7 个二进制数字?

最佳答案

In[12]:= MyEqual[x_, y_] := Order[x, y] == 0

In[13]:= MyEqual[1.0000000000000021, 1.0000000000000022]

Out[13]= False

In[14]:= MyEqual[1.0000000000000021, 1.0000000000000021]

Out[14]= True

这将测试两个对象是否相同,因为 1.0000000000000021 和 1.000000000000002100 的精度不同,因此它们不会被视为相同。

关于wolfram-mathematica - Mathematica 中是否有 "normal"EqualQ 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4983885/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com