### Thread: I need to integration code in c language

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
4
Rep Power
0

#### I need to integration code in c language

Hi

i need to code in c language for the integration of 1/x from 1 to 10, i want it .

2. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
1
Rep Power
0
As I understand it you have to write a program which will display
the values of function 1/x from 1 to 10.
Code:
```#include <stdio.h>

int main()
{
float x;
for (x = 1.0; x <= 10; x++)
printf("f(%f) = %f\n", x, 1/x);

return 0;
}```
good luck! :)
3. Numeric methods for approximating integration are many and very well known; eg, Trapazoidal Rule, Simpson's Rule. Learn one and implement it.
4. #### Test value

5. Good point, b49P23TIvg. Does he need to use an approximation method or can he just apply his knowledge of what the integral of 1/x is?
6. Originally Posted by aybek
As I understand it you have to write a program which will display the values of function 1/x from 1 to 10.
I am pretty sure you don't understand it. That is not integration.
7. This is a C programming site, not a maths site. You might get a larger number of answers if you did the maths, so those that can code but are not necessarily mathematicians might help.

That said the definite integral of 1/x for the range a to b is equal to ln(|b|) - ln(|a|). In the standard C math library the log() function computes the natural logarithm (as opposed to log10() for base 10 logs). So:

Code:
`double i = log(10) - log(1) ;`
ln(1) is zero, so in fact just i = log(10) in this case.
8. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Apr 2013
Posts
4
Rep Power
0
thank you all for that