File Exchange

image thumbnail

gaussleg

version 1.0 (1.98 KB) by

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

4.42857
8 Ratings

2 Downloads

Updated

View License

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.

Comments and Ratings (9)

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

Loginatorist

Loginatorist (view profile)

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)

doesn't work , at least on matlab 2012

sotos ...

Rami Boul

Eric Alvarez

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

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

Ashesh CB

Definelty a simple and excellent program...

tim cowdry

fast and easy.

Updates

Higher tolerance for finding Gauss points.

Increased the speed as per a suggestion.

fixed a typo.

Now checks for NaNs.

Updated to be 4% faster.

MATLAB Release
MATLAB 6.5.1 (R13SP1)
Acknowledgements

Inspired by: Gauss-Legendre

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

» Watch video