title: Is there a higher-order version of cumtrapz()?
body: <h1>Introduction</h1>
  
  <p>Suppose I have <code>N</code> points <code>x(1:N)</code> at which I have function values <code>f(1:N)</code>, for example: </p>
  
  <pre><code>x = [ 0.0795, 0.1327, 0.1395, 0.5133, 0.6470, 0.7358, 0.7640 ];
  f = [ 0.0388, 0.4774, 0.4547, 0.0784, 0.3241, 0.2818, 0.9667 ];
  </code></pre>
  
  <p>I want to calculate the cumulative integral of <code>f</code> with respect to <code>x</code> using these data. </p>
  
  <h1>Low-Order Solution</h1>
  
  <p>In MATLAB, I can do this easily using <a href="https://www.mathworks.com/help/matlab/ref/cumtrapz.html" rel="nofollow noreferrer"><code>cumtrapz()</code></a>:</p>
  
  <pre><code>&gt;&gt; result = cumtrapz( x, f )
  
  result =
  
       0    0.0137    0.0169    0.1165    0.1434    0.1703    0.1879
  </code></pre>
  
  <h1>Problem</h1>
  
  <p>Unfortunately, <code>cumtrapz()</code> uses the trapezoidal method for numerical integration, which is insufficient for my purposes. </p>
  
  <p><a href="http://www.damtp.cam.ac.uk/lab/people/sd/lectures/nummeth98/integration.htm" rel="nofollow noreferrer">Higher-order methods exist</a>, like Simpson's Rule, but to my knowledge there isn't a function that performs the cumulative version of Simpson's Rule for nonuniform grids at the MATLAB File Exchange, or anywhere else. </p>
  
  <p><strong>Does a higher-order version of cumtrapz() already exist? If not, what would I have to do to implement it myself?</strong> </p>