Integration of a function is summation of the finite elements of the same function. In numerical analysis there are many ways to do it such as : Simpson's Rule, Trapezoidal Rule 1/3 and 3/8 etc etc. depending upon the function and error minimization

So all u need to do is to run a *for* loop from a to b and divide it into a good number of pieces to get good results else there would be large errors(smaller the increment, better the results , though it affects ur computational time) and define the finite element function of the mathematical function.

Step 1 Set h = (b - a)/n.
Step 2 Set XI 0 = f(a) + feb);
XI 1 = 0; (Summation of f(x2i-1).)
X I2 = O. (Summation of f (X2i)')
Step 3 For i = 1, ... ,n - 1 do Steps 4 and 5.
Step 4 Set X = a + ih.
Step 5 If i is even then set XI2 = X/2 + f(X)
else set XIl = XIl + f(X).
Step 6 Set XI = h(XIO + 2· XI2 + 4· XIl)/3.
Step 7 OUTPUT (Xl);
STOP.

Look for" Numerical recipes in c the art of scientific computing" its good book for all kind of mathematical computation ,I used only that its very good !!
Thanks

## All Answers (4)

Rahul Singh Kotesa· Indian Institute of ScienceSo all u need to do is to run a *for* loop from a to b and divide it into a good number of pieces to get good results else there would be large errors(smaller the increment, better the results , though it affects ur computational time) and define the finite element function of the mathematical function.

Your starting point ---> http://en.wikipedia.org/wiki/Numerical_integration

Rest all is a 10 min job

Cheers !!

Rozafat Radogoshi·To approximate the integral I = J: f(x) dx:

INPUT endpoints a, b; even positive integer n.

OUTPUT approximation X I to I.

Step 1 Set h = (b - a)/n.

Step 2 Set XI 0 = f(a) + feb);

XI 1 = 0; (Summation of f(x2i-1).)

X I2 = O. (Summation of f (X2i)')

Step 3 For i = 1, ... ,n - 1 do Steps 4 and 5.

Step 4 Set X = a + ih.

Step 5 If i is even then set XI2 = X/2 + f(X)

else set XIl = XIl + f(X).

Step 6 Set XI = h(XIO + 2· XI2 + 4· XIl)/3.

Step 7 OUTPUT (Xl);

STOP.

Tushar Gonjari· University of PuneThanks

Safa Ahmed· Université Ibn Khaldoun Tiaretit's an open scientific C library

Can you help by adding an answer?