April 22nd, 2013, 01:33 AM
I need to integration code in c language
i need to code in c language for the integration of 1/x from 1 to 10, i want it .
please help me
April 22nd, 2013, 05:40 AM
As I understand it you have to write a program which will display
the values of function 1/x from 1 to 10.
good luck! :)
for (x = 1.0; x <= 10; x++)
printf("f(%f) = %f\n", x, 1/x);
April 22nd, 2013, 09:08 AM
Numeric methods for approximating integration are many and very well known; eg, Trapazoidal Rule, Simpson's Rule. Learn one and implement it.
April 22nd, 2013, 11:35 AM
Your answer, if I remember my calculus correctly, should be about 2.3.
[/code] are essential for python code and Makefiles!
April 22nd, 2013, 11:57 AM
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?
April 22nd, 2013, 02:15 PM
I am pretty sure you don't understand it. That is not integration.
Originally Posted by aybek
April 22nd, 2013, 02:38 PM
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:
ln(1) is zero, so in fact just i = log(10) in this case.
double i = log(10) - log(1) ;
April 23rd, 2013, 12:58 AM
thank you all for that
but the answer of
clifford maybe its right
Comments on this post