View License

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

» Watch video

Highlights from
Simpson's rule for numerical integration

5.0 | 4 ratings Rate this file 78 Downloads (last 30 days) File Size: 2.48 KB File ID: #25754 Version: 1.5
image thumbnail

Simpson's rule for numerical integration


Damien Garcia (view profile)


05 Nov 2009 (Updated )

The Simpson's rule uses parabolic arcs instead of the straight lines used in the trapezoidal rule

| Watch this File

File Information

Z = SIMPS(Y) computes an approximation of the integral of Y via the Simpson's method (with unit spacing). To compute the integral for spacing different from one, multiply Z by the spacing increment.
Z = SIMPS(X,Y) computes the integral of Y with respect to X using the Simpson's rule.

Z = SIMPS(X,Y,DIM) or SIMPS(Y,DIM) integrates across dimension DIM

SIMPS uses the same syntax as TRAPZ.

% The integral of sin(x) on [0,pi] is 2
% Let us compare TRAPZ and SIMPS
x = linspace(0,pi,6);
y = sin(x);
trapz(x,y) % returns 1.9338
simps(x,y) % returns 2.0071


This file inspired Generation Of Random Variates, Simpson Quadrature, and Vgrid: Utility To Help Vectorize Code.

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (6)
20 Dec 2015 David MERCIER

13 Oct 2015 Nicholas Tavares

I am confused on how to use this I'm having the same problem as fernando

Comment only
12 Sep 2013 fernando

its very simple,and now i understand the trapz code but then the simps seems to not work on me says
"Undefined function or method 'simps' for input arguments of
type 'double'." how can i fix this?

Comment only
19 May 2013 Matthew

18 May 2013 Angelos

That is a very good example for the for understand the Simpson's rule!! Excellent work!

30 Aug 2011 Danny Sale

This is a great extension of Simpson's rule. I find it most valuable that this file works correctly for both even and odd length vectors, and that it can correctly handle arbitrary spacing. Also, the method is fully vectorized so it is very fast. Thank you and excellent work!

20 Nov 2009 1.2

Minor modifications in the descriptions and help texts of the two functions.

17 May 2013 1.4

Modifications in the help text

22 May 2013 1.5

Modification in the description

Contact us