# Writing a program in c for integration of a mathematical function?

I want to wirte aprogram in c for integration of a mathematical function plz help

I want to wirte aprogram in c for integration of a mathematical function plz help

- Views 6855
- Followers 8
- Answers 4

## 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?