3

I'm comparing ILMath.Vec() with MatLab's and I'm seeing significant rounding errors.

For example, if I create a vector (using Start:0, Step:1.2635048525911006, End:20700) for each system:

MatLab: [Start:Step:End]

ILNumerics: Vec<double>(Start, Step, End)

And then take the average abs difference, I get an average error of 1.56019608343883E-09. However, I if create the vector by hand (using multiplication), I get an average error of only 3.10973469197506E-13, 4 magnitudes smaller error.

After looking at ILNumerics' vec function (using Reflector), I think I know why the average error value is so large. The ILMath.vec() function is using addition vs. multiplication. Summing the step value 16,384 times is not the same thing as multiplying the step value x N (where N is the current loop count) 16,384 times! The addition's rounding errors add up very quickly!

Please consider fixing this issue.

Kabua
  • 889
  • 8
  • 19
  • Good point! I've added an issue in the ilnumerics bugtracker: http://ilnumerics.net/mantis/view.php?id=197 – Haymo Kutschbach May 06 '14 at 09:05
  • Or do some kind of compromise, since addition is much faster than multiplication. Use addition for about 100 or 1000 steps, then rebase using multiplication. – Lutz Lehmann May 08 '14 at 11:54

0 Answers0