Serving the Quantitative Finance Community

 
User avatar
maximeb
Topic Author
Posts: 0
Joined: February 8th, 2005, 2:09 pm

Quadrature

March 11th, 2005, 3:03 pm

Hi , I need some advices about quadrature ! I need to compute many times an integration of f(x)w(x) on [0,1] ( f can change a little but w don't change). I use NaG library's integration tool each time but I wonder whether it would be more efficient to compute quadrature points for weights w(x) (w is quite complicated) and after to use the same quadrature for each integration. The first step could be long but I do only one time ! I suppose Nag library's integration tool compute or have recorded legendre quadrature points which could be not efficient in my problem. Thus the special computed quadrature could more efficient and quicker. What do you mean about this idea? I'm sorry but I don't have any experience in numerical analysis ... and maybe somebody have aldeady met this kind of problem.Many thanksMax
 
User avatar
irada
Posts: 0
Joined: June 20th, 2003, 12:36 pm

Quadrature

March 11th, 2005, 8:52 pm

Maxi,I am not sure I understand your question, but I'll give you some advice anyway:The huge power of the quadrature is that the abscissas (x_i) and weights (w_i) are "independent" of the function you integrate (I used quotation because in fact they are dependent: Gauss-Legendre works for functions defined of a finite interval [a,b], Gauss-Hermite on (-infinity, +infinity) so on; but once you have established the class of functions to be integrated, the "independence" appears).SO, you produce abscissas and weights for the interval [a,b] ONCE, and compute the integral of ANY function (if it is in the right class, which we assume anyway) f as follows: sum_i^N f(x_i)*w_i. You see: x_i's and w_i's are frozen, while f can be changed. The number N of points is up to you (it does not have to be too big, but too small is not good either; about 100 will do it).Find "Numerical Recipes in C/C++" and find "gauleg" function in index. You can rewrite it yourself, you do not need pre-packaged things, and is good exercise and reading anyway.Take care
 
User avatar
maximeb
Topic Author
Posts: 0
Joined: February 8th, 2005, 2:09 pm

Quadrature

March 14th, 2005, 8:14 am

Hi , ok I was not clear (sorry for my english ...) My question is : Is numerically efficient to compute myself orthogonal polynoms for a special weight w(x) ? is it more efficient than NaG quadrature algorithm ? It isn't a theorical question but a numerical. For instance the theory of hermite polynoms is perfect but it is very difficult to implemente because hermite coefficients are too big !! A special point is that I compute orthogonal polynoms only one time and I use many times for computing similar integration (of f(x)w(x)). First step could be long but anyway I do it only one time. I hope I was clear this time Many thanksMax
 
User avatar
irada
Posts: 0
Joined: June 20th, 2003, 12:36 pm

Quadrature

March 14th, 2005, 12:28 pm

"Reading in" pre-determined stuff is always quicker than complicated function calls.There is no debate there, I think.
 
User avatar
spursfan
Posts: 2
Joined: October 7th, 2001, 3:43 pm

Quadrature

March 14th, 2005, 12:32 pm

you'll find lots of this stuff in abramowitz and stegun - and some (all?) of their text can be found on the web - and then you can type in the quadrature points and weights (type in half of them and use symmetry for the other half)