I'm creating a GUI interface for my Python computing class that is supposed to showcase a few types of numerical integration. One of the ones I want to put in as an option is Gauss–Legendre quadrature.

Part of the project is making a visualization of the method. The Newton–Cotes methods are easy to visualize. As well as is Monte Carlo integration. I'm stuck as to how I can visualize Gauss–Legendre quadrature though.

I was thinking about using a Lagrange polynomial fit with nodes at the roots of the Legendre polynomials. Is that the best way to do it?

Any ideas?

• That's the only way that comes to mind... select some function that shows noticeable differences to the Legendre polynomial, and show how the areas cancel out. Note that the polynomial you'd get by Lagrange interpolation is the Legendre polynomial linear combination. – vonbrand Apr 7 '13 at 23:30
• I guess I should have been more specific about the GUI. The user will be providing a function and the n value. So I can't pick a nice function. I guess I'll have to go with it. Thanks! – John K. Apr 7 '13 at 23:46
• You might want to see this. – J. M. is a poor mathematician Apr 7 '13 at 23:49
• I only have free access to SIAM review articles up till 2007 :( I looked up the Clenshaw Curtis algorithm though and it's pretty neat. I like it. My project is meant for freshman-sophomore level computational scientists, so the theory needed to understand that is a little much. Thanks anyway though. I'll definitely do some independent research on it. – John K. Apr 8 '13 at 0:20
• @John, search for Nick Trefethen's website; he should have a freely-accessible version of that paper. – J. M. is a poor mathematician Apr 12 '13 at 13:50

I don't this is possible, because from among the initial methods of numerical integration, this method and the Euler method are technical. However, you can show the geometry of legendre polynomials, which is the turning point of the Gauss-Legendre Quadrature. I recently did a job on my graduation about this, I'll be happy to clarify any doubts.

• What do you mean by Euler Method? The ODE solver? My project is sticking strictly to area under the curve type of numerical integration. I think your suggestion is more along the line of proving that Gauss-Legendre Quadrature works in a visual way. That's neat, but I was looking for a way for an amateur mathematician to see why it works without needing to go into detail. I think you're right though, it's too technical. – John K. Apr 7 '13 at 23:52
• Also, my GUI will require a user-defined function. – John K. Apr 7 '13 at 23:53
• Exacty, the suggestion is more along the line of prove. The proof consists in considering these polynomials so that their roots are the optimal choices to minimize the error between the approximation and integral. The method is concerned with choosing the points (nodes) great, then you could make some comparisons between functions and Legendre polynomials, trying to relate the roots of Legendre with the choices that must be made to calculate the function to minimize the error. – Irddo Apr 9 '13 at 22:30