You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
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.
Example:
-------
% 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
Cite As
Damien Garcia (2026). Simpson's rule for numerical integration (https://www.mathworks.com/matlabcentral/fileexchange/25754-simpson-s-rule-for-numerical-integration), MATLAB Central File Exchange. Retrieved .
Acknowledgements
Inspired: simpsonQuadrature, VGRID: utility to help vectorize code, Generation of Random Variates
Categories
Find more on Numerical Integration and Differential Equations in Help Center and MATLAB Answers
General Information
- Version 1.5.0.0 (2.48 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
