Code covered by the BSD License  

Highlights from
gaussleg

4.42857

4.4 | 8 ratings Rate this file 19 Downloads (last 30 days) File Size: 1.98 KB File ID: #7499

gaussleg

by

 

20 Apr 2005 (Updated )

Calculates the integral of function f from a to b using ngp Gauss points.

| Watch this File

File Information
Description

gaussleg(f,a,b,ngp)

I have found that this is on average +20 times faster than 'Gauss-Legendre' file(4560), and easier to read because it is shorter.

Acknowledgements

Gauss Legendre inspired this file.

MATLAB release MATLAB 6.5.1 (R13SP1)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
05 Feb 2013 Giuseppe Cascarino

Sorry, my fault. I did a beginner's error, it works. My apologies.

05 Feb 2013 Matt Fig

Giuseppe, what are you talking about??

>> f=inline('sin(x)/x');
>> gaussleg(f,-1,1,8)

ans =

1.8922

>> f=@(x) sin(x)./x;
>> gaussleg(f,-1,1,8)

ans =

1.8922

>> version

ans =

7.14.0.739 (R2012a)

29 Jan 2013 Giuseppe Cascarino

doesn't work , at least on matlab 2012

05 Oct 2006 sotos ...  
28 Jan 2006 Rami Boul  
27 Jan 2006 Eric Alvarez

It's slow. The culprit is the use of EIG in the subfunction GAUSS. Moreover, it eats a lot of precious memory.

05 Nov 2005 Sreekanth M.S

This program ROCKS!!
I owe the grade of my project to you! :)
Was getting pissed of by 'quad' function which cannot deal with matrices

01 Sep 2005 Ashesh CB

Definelty a simple and excellent program...

10 Aug 2005 tim cowdry

fast and easy.

Updates
25 Apr 2005

Updated to be 4% faster.

24 Oct 2005

Now checks for NaNs.

19 Dec 2005

fixed a typo.

30 Jan 2006

Increased the speed as per a suggestion.

02 Feb 2006

Higher tolerance for finding Gauss points.

Contact us