CompensatedSummation in Total
- To: mathgroup at smc.vnet.net
- Subject: [mg81075] CompensatedSummation in Total
- From: "David Park" <djmpark at comcast.net>
- Date: Mon, 10 Sep 2007 18:57:54 -0400 (EDT)
In the 'More Information' section of the help for Total it mentions that
Method -> "CompensatedSummation" can be used as an option to reduce
numerical error. But in the Options, Method section they use the option
without quotation marks: Method -> CompensatedSummation. They actually
both seem to work.
I thought that the following example might be one that CompensatedSummation
might help on since the sum tends to be much smaller than a sum of the
absolute values. But I obtain exactly the same answer with or without
CompensatedSummation - every time. So I wonder exactly what
CompensatedSummation does for us?
testlist = Table[RandomReal[{-1, 1}], {10000000}];
NumberForm[Total[testlist], 16] // Timing
NumberForm[Total[testlist, Method -> "CompensatedSummation"],
16] // Timing
testlist = Table[RandomReal[{-1, 1}], {10000000}];
NumberForm[Total[testlist], 16] // Timing
NumberForm[Total[testlist, Method -> CompensatedSummation],
16] // Timing
--
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/