当输入在Mathematica中包含浮点时获得任意精度

Wei*_*Shi 2 wolfram-mathematica

我试图以任意精度计算Mathematica中的中心矩.但是使用不同的输入格式我得到了不同的结果

显然,第一时刻应该是0精确,但Mathematica并没有给我0的浮点输入.有没有办法强迫它使用任意精度?我的输入是一个CSV文件,浮点数如xxx.xx

CentralMoment[{3,0.7}, 1]=0.x10^-16 // very close to 0, but not exact
CentralMoment[{3,7/10}, 1]=0
//You could try the above with Wolfram alpha online
Run Code Online (Sandbox Code Playgroud)

acl*_*acl 5

在这里,它做到了这一点

CentralMoment[{3, 0.7`16}, 1]
(*
-> 0.\[Times]10^-16
*)
Run Code Online (Sandbox Code Playgroud)

CentralMoment[{3, 0.7}, 1]
(*
-> 0
*)
Run Code Online (Sandbox Code Playgroud)

所以可能它正在以一定的有限精度读取它们.现在,从那以后

CentralMoment[{3, SetPrecision[0.7`12, \[Infinity]]}, 1]
(*
-> 0
*)
Run Code Online (Sandbox Code Playgroud)

我猜你想要的是什么SetPrecision.