Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // calcular numericamente int_{0.1}^{1.0} (dx/x) = -ln(0.1)
- // ponto médio!! (mais precisão)
- #include <stdio.h>
- #include <math.h>
- #define n 100
- int main (void)
- {
- int i;
- double h,x,soma=0.0f;
- h=(1.0-0.1)/n;
- for (i=0;i<n;i++)
- {
- x=0.1+h*(i+1/2.); //i+1, não somente i
- // repara esse ponto!!
- soma+=h*(1/x);
- }
- printf("\nIntegral calculada: %f. Valor real: %f\n\n",soma, -log(0.1));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement