Tag Info

Hot answers tagged

19

Oleksandr is correct about the way evaluation works. a/b seems to be interpreted (parsed) directly as Times[a, Power[b,-1]], or more readably: $a\times b^{-1}$. Divide[a,b] is interpreted as is. Evaluation then proceeds from these forms, and the arithmetic is carried out differently for the two cases: either $a\times (1/b)$ or $a/b$. Here are some ...


4

As rasher and the documentation both say, Equal has a certain level of fuzziness. The same is true of SameQ, though it has a more stringent tolerance. The following computations are all done with machine precision numbers. Similar things should hold with arbitrary precision numbers but the analysis might be trickier. (* 12 zeros, difference = ...


3

See the documentation for Equal. There is a tolerance for inexact numbers. The order of operations combined with precision of targets can affect whether things fall "in" or "out" of tolerance. See specifically the "Possible Issues" section in the documents for Equal. As far as why results themselves differ in FP arithmetic, there is no better source than the ...


1

An extended comment. I'm not sure if this has been realized, please correct me if it has. The result of the Divide[a,b] operation is not the same as the first 3 which are identical. {a, b} = List @@ RandomReal[{-50, 50}, {2, 1*^7}]; x1 = a/b; x2 = a b^-1; x3 = a/b; x4 = Divide[a, b]; Now... Tally[x1 - x2] Tally[x2 - x3] Both give 10^7 zeros. ...


1

This provides a nice application for FindSequenceFunction, as suggested by Michael f = FindSequenceFunction[{5, 7, 9, 10, 13, 13, 17, 16}] 1/4 (14 + 2 (-1)^#1 + 7 #1 - (-1)^#1 #1) & You can check that this sequence f starts out as specified: f /@ Range[10] {5, 7, 9, 10, 13, 13, 17, 16, 21, 19} To calculate the sum of the first 40 terms: Total[f /@ ...



Only top voted, non community-wiki answers of a minimum length are eligible