Numerical Integration Methods - NumIntegral.nb

Finding  Numerical Approximations to Definite Integrals

Input the function you want to integrate, the left and right endpoints "a" and "b", and the number "n" of sub-divisions, and execute the command below:

f[x_] = x^7 - 4  x^2 + 3  x - 5a = 0b = 2\(n = 1700
; 
listend = Table[f[x], {x, a, b, \((b - a)\)/n}]; 

    listmid = Table[f[x], {x, a + \((b - a)\)/\((2  n)\), b, \((b - a)\)/n}]; 
    
TableForm[
	
      Table[{{StringForm["[`` Subdivisions]", n], 
            "Integral Approximation"}, {"", ""}, {
            "Left Riemann Sum:", 
            leftriemann = 
              N[Apply[Plus, Drop[listend, \(-1\)]]\ \((b - a)\)/n]}, 
          
{"Right Riemann Sum:", 
            rightriemann = N[Apply[Plus, Drop[listend, 1]]\ \((b - a)\)/n]}, 
          
{"Midpoint Rule:", 
            midpoint = N[Apply[Plus, listmid] \((b - a)\)/n]}, 
          
{"Trapezoidal Rule:", 
            trapez = 1/2\ \((rightriemann + leftriemann)\)}, 
          
{"Simpson's Rule:", 
            simpson = 2/3\ midpoint\  + 1/3\ trapez}}]]\)

Etc.

Author: H. Knaust (helmut@math.utep.edu)
Created: August 2000
Last Edits: August 21, 2000