Talk:Numerical integration: Difference between revisions

(→‎f(x) = x cases.: new section)
Line 18:
# I wanted to see if I could expose differences in floating-point/rational number implementations between languages using a simple case.
Roughly speaking, IEEE 754 floating-point numbers (what most programmers are probably accustomed to working with) allow for up to 24 bits of integer precision for a 32-bit floats. This means they will tend to precisely represent non-negative integers of up to 2^24, or 16,777,216. (I'm sure it's slightly more complicated than that, or I would have mentioned it along with the test cases. In any case, a simple test program I wrote for incrementing a float detected integer precision loss when it tried to go past 2^24 or thereabouts.) The final result of the [0,5000] case is an integer below 2^24, and so it can be accurately and precisely represented. The final result of the [0,6000] case is an integer above 2^24, and may not be. (I'm sure there's someone who will read this who can identify the the next greater positive integer above 2^24 that can be represented with an IEEE 32-bit float, and could speak to this directly.) Granted, in either case, the intermediate values during approximation are likely to lose precision by always falling on exact representations. Using a different number of approximating steps (such as 5,000 and 6,000 respectively) could cover that. --[[User:Short Circuit|Michael Mol]] 08:03, 12 September 2010 (UTC)
 
:I needed several hours of computation to complete the answers to the last two tests in Python (but that's what sleep is for, right). Unfortunately Python uses double-precision FP by default so had no problem with precision. I would have thought that a more 'squiggly' function would be the best to show differences in approximation methods as several are probably exact when approximating a straight line. Maybe 2**24*sin(x) for 1<=x<=1 using 1000 steps might do the trick (without taking the chill off my study early in the morning). --[[User:Paddy3118|Paddy3118]] 08:41, 12 September 2010 (UTC)
Anonymous user