View Single Post
Espy Espy is offline
Wanderer
Default Gaussian Quadrature + MATLAB   #327  
Coda suggested I put this here for easier viewing :P

This problem has to do with Gauss Quadrature, specifically one-point to five-point Gauss-Legendre formulas.

Here's the problem:


And here's my code so far.
I've split it into two parts: the first part of the if statement deals with cases where n is even, and the second where n is odd. (n is the number of points used in the quadrature, and corresponds to the row of both matrices.)

I've tried it against a test code and an example from the text, both where n = 3, and both passed. I tested the example with n = 4, and since Gauss quadrature is accurate to the third degree, and the solutions for n = 3 and n = 4 were the same, I'm reasonably certain that the first half is okay. However, using n = 5 for that example, the answer given didn't match the actual value of the integral, or the solutions for n = 3 and n = 4.

My code fails an assertion (test), but that test is hidden, so I'm not sure which part of my code is messing up. However, since the solution for n = 5 seems wrong, I'm assuming that might be it.
STONEWALL WAS A RIOT

Last edited by Espy; 04-26-2017 at 07:43 PM.
Old Posted 04-26-2017, 07:18 PM Reply With Quote