Talk:Numerical integration/Gauss-Legendre Quadrature: Difference between revisions

Content deleted Content added
Avi (talk | contribs)
mNo edit summary
Line 4: Line 4:
::<math>\int_{-3}^{3} e^x \, dx = e^3 - e^{-3} \approx 20.035749854819805</math>
::<math>\int_{-3}^{3} e^x \, dx = e^3 - e^{-3} \approx 20.035749854819805</math>
: That last value is what I get when I compute it directly (using my platform's libc's implementation of the exponential function for double-precision IEEE arithmetic). A correct implementation ''should'' tend toward that value in this case as the order of the Legendre polynomial being used is increased, up to a limit where it no longer helps. I observe that with the Tcl code, where I've tested up to 13 it indeed improves, but beyond that it ceases to help, becoming slow but getting no more accurate. I guess that this is running into the limits of the accuracy of the method for this type of equation (and note that it is delivering about 9 decimal digits of accuracy at that point; pretty good…) –[[User:Dkf|Donal Fellows]] 09:31, 2 June 2011 (UTC)
: That last value is what I get when I compute it directly (using my platform's libc's implementation of the exponential function for double-precision IEEE arithmetic). A correct implementation ''should'' tend toward that value in this case as the order of the Legendre polynomial being used is increased, up to a limit where it no longer helps. I observe that with the Tcl code, where I've tested up to 13 it indeed improves, but beyond that it ceases to help, becoming slow but getting no more accurate. I guess that this is running into the limits of the accuracy of the method for this type of equation (and note that it is delivering about 9 decimal digits of accuracy at that point; pretty good…) –[[User:Dkf|Donal Fellows]] 09:31, 2 June 2011 (UTC)

::My OCaml implementation converges to the correct value for n > 14 (see the example), but that may just be luck. [[User:TobyK|TobyK]] 19:04, 13 July 2011 (UTC)


How did you decide on the number of Newton-Raphson iterations to use when computing the node values? Wouldn't that also affect the accuracy? (I passed the required precision as a parameter and iterated until two consecutive estimates agreed up to that precision.) Exact floating point representations of the coefficients are also possible with sufficient precision. Increasing the precision always seems to give more accurate results, but having too many nodes can strangely make it worse. --[[User:Sluggo|Sluggo]]
How did you decide on the number of Newton-Raphson iterations to use when computing the node values? Wouldn't that also affect the accuracy? (I passed the required precision as a parameter and iterated until two consecutive estimates agreed up to that precision.) Exact floating point representations of the coefficients are also possible with sufficient precision. Increasing the precision always seems to give more accurate results, but having too many nodes can strangely make it worse. --[[User:Sluggo|Sluggo]]