File Exchange

image thumbnail

Legendre-Gauss Quadrature Weights and Nodes

version 1.0 (1.69 KB) by

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

118 Downloads

Updated

View License

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).

Comments and Ratings (53)

Kay

Kay (view profile)

How did you choose the initial guess for y?

Erdem Yilmaz

Yanpei Tian

Prudhvi Sai

tnx

Prudhvi Sai

hkj

songzhen gui

DUDE I LOVE YOU.
It works perfectly for my computation. Thanks you.

gaurav

gaurav (view profile)

Dao XIANG

Zaid Sawlan

Pavel

Pavel (view profile)

Hi!

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.

https://github.com/Pazus/Legendre-Gauss-Quadrature

xian zhang

thanks

haoyi huang

thanks

tara Moradi

Thank you Greg

Thanks!!! Its really help me!

Thomas

Thomas (view profile)

excellent, thanks a lot

very good

Chris Kurra

Wenjun

Wenjun (view profile)

yijie liu

very good

Xiangyuan

a code with great accuracy and speed! Well done!

Xiangyuan

Juan

Juan (view profile)

Peter

Peter (view profile)

great!

Chao

Chao (view profile)

Excellent! Thanks!

erick

erick (view profile)

thanks

u

u (view profile)

very good, thanks

Andrea

Andrea (view profile)

very handy, thanks!!

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.

Very Good, thanks.

AVIGYAN SINHA

rahman

rahman (view profile)

excellent

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

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!

Tim

Tim (view profile)

very handy tool! thanks!

Christine A.

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

Mohan KV

Neat program. Well done!

Mohan KV

alex qren

Xinghui Zhong

Dawid Z

Works pretty well - thanx

a a

Phuong Huynh

I would like Tabulated Gauss points

s b

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

vish j

kumar gautam

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.

DEIVEEGAN M

Tim Warburton

Very nice quadrature routine!.

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

Updates

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

MATLAB Release
MATLAB 6.1 (R12.1)
Acknowledgements

Inspired: Sound Power Directivity Analysis

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

» Watch video