Tag Info

New answers tagged

3

The answer to the second part of your question is that you need to abandon machine precision arithmetic. Perhaps the best way to proceed is use Mathematica's exact arithmetic. a = Rationalize @ {15., 15.01, 3., 3.01} Round[Abs[a - Mean[a]], 1/100] {6, 6, 6, 6} You could also use Mathematica's slower but more accurate arbitrary precision arithmetic. ...


3

FullForm seems to be working fine here. Here is what belisarius alluded to in his comment, using your definitions and either InputForm, or FullForm as he suggested: InputForm@Abs[a - Mean[a]] FullForm@Abs[a - Mean[a]] (* Out from InputForm: {5.995000000000001, 6.005000000000001, 6.004999999999999, 5.994999999999999} Out from FullForm: ...


3

As it turns out, one can exploit the behavior of Interval[] when applied to a machine-precision number to obtain the previous and next representable machine-precision numbers (thanks to Szabolcs for the fix): SetAttributes[nextafter, Listable]; nextafter[x_?MachineNumberQ, s_?NumericQ] /; s != 0 := First[Interval[x]][[ -Sign[s - x] ]] To obtain a ...



Top 50 recent answers are included