View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Legendre-Gauss Quadrature Weights and Nodes

4.5 | 39 ratings Rate this file 165 Downloads (last 30 days) File Size: 1.69 KB File ID: #4540 Version: 1.0

Legendre-Gauss Quadrature Weights and Nodes



26 Feb 2004 (Updated )

Computes the Legendre-Gauss weights and nodes for solving definite integrals.

| Watch this File

File Information

This is a simple script which produces the Legendre-Gauss weights and nodes for computing the definite integral of a continuous function on some interval [a,b]. Users are encouraged to improve and redistribute this script. See also the script Chebyshev-Gauss-Lobatto quadrature (File ID 4461).


This file inspired Sound Power Directivity Analysis.

MATLAB release MATLAB 6.1 (R12.1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (48)
15 Feb 2017 songzhen gui

It works perfectly for my computation. Thanks you.

29 Dec 2016 gaurav

gaurav (view profile)

24 Dec 2016 Dao XIANG

07 Dec 2016 Zaid Sawlan

26 Oct 2016 Pavel

Pavel (view profile)


I've implemented similar function, but it's twice as fast. I've compared the results with yours and the relative error was less then 1e-12%, numerical error basically.

Fill free to submit Pull request if you have something to add.

16 Jul 2016 xian zhang


Comment only
14 Jul 2016 Dimitrios Piretzidis

22 Jun 2016 haoyi huang


Comment only
14 May 2016 tara Moradi

Thank you Greg

21 Apr 2016 Marcelo Trindade

Thanks!!! Its really help me!

Comment only
16 Oct 2015 Thomas

Thomas (view profile)

excellent, thanks a lot


very good

Comment only
09 Apr 2015 Chris Kurra

20 Feb 2015 Wenjun

Wenjun (view profile)

30 Jan 2015 yijie liu

very good

03 Jan 2015 Nguyen Le Van

22 Sep 2014 Xiangyuan

a code with great accuracy and speed! Well done!

22 Sep 2014 Xiangyuan

07 Aug 2014 Juan

Juan (view profile)

13 May 2014 Peter

Peter (view profile)


07 May 2014 Siriratchanee Thammasuwan

13 Mar 2014 Chao

Chao (view profile)

Excellent! Thanks!

20 Dec 2013 erick

erick (view profile)


11 May 2012 u

u (view profile)

very good, thanks

04 Apr 2012 Andrea

Andrea (view profile)

very handy, thanks!!

27 Mar 2012 David Bergman

This is a very useful script. Thanks for sharing. I noticed that you are storing a lot of memory for items you don't need. As an example you never use the full Lp, set to zeros(N1,N2). Only the highest order is needed. If I comment out all but the last occurrence of Lp the script generates the same results. You could do the same for L(N1,N2) since you only need 3 values of k at any step in the calculation. Just a thought.

20 Mar 2012 Felipe Pinochet

06 Nov 2011 Javier Vazquez

Very Good, thanks.

Comment only

29 Mar 2011 rahman

rahman (view profile)


01 Nov 2010 David E. Horsley

Brilliant piece of code! I have been using this quite a lot without trouble. I'm always amazed that how quickly Gaussian quadrature converges.

29 Oct 2010 Orkan Umurhan

Thank you very much. The results are good and there are no problems with the accuracy of the approach nor are there any issues with normalization as some people above suggested. I have checked the integration for a wide range of reasonable functions and the numbers check out just right. Thanks!

28 Apr 2010 Tim

Tim (view profile)

very handy tool! thanks!

Comment only
22 Mar 2009 Christine A.

Excellent! Thanks for sharing. Do you have a reference for your algorithm?

05 Feb 2009 Mohan KV

Neat program. Well done!

Comment only
05 Feb 2009 Mohan KV

11 Sep 2008 alex qren

22 Apr 2008 Xinghui Zhong

02 Mar 2008 Dawid Z

Works pretty well - thanx

29 Nov 2007 a a

04 Aug 2007 Phuong Huynh

I would like Tabulated Gauss points

Comment only
09 Jan 2007 s b

works well in emag apps for tough integrands, fast and simple function

07 Oct 2006 vish j

26 Jun 2005 kumar gautam

05 Apr 2005 Nabeel Azar

My QUADG function in the quadrature category contains a subfunction called "gausslegendre" that does an equivalent computation using EIG; it can be used as a separate function if desired.

I don't know about the accuracy of your approach, but if I remember correctly the algorithm I had used is considered quite accurate. It's also very fast.

Comment only
29 Mar 2005 DEIVEEGAN M

24 Mar 2005 Tim Warburton

Very nice quadrature routine!.

24 Jan 2005 Dave Farrell

Very handy tool, which for some reason is missing in matlab, like the zeros of the bessel functions.

I did notice the weights are not normalized to 1 however, which seemed to result in an over estimation of the integral.

Good work and thank you

10 May 2004

Found a bug in scaling of weights. Also slight improvement to speed.

Contact us