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)
- // regra do trapézio (mais precisão)
- #include <stdio.h>
- #include <math.h>
- #define n 100
- int main (void)
- {
- int i;
- double h,x1,x2,soma=0.0f,soma2=0.0f;
- h=(1.0-0.1)/n;
- for (i=0;i<n;i++)
- {
- x1=0.1+h*i;
- x2=0.1+h*(i+1);
- soma+=0.5*h*(1/x1 + 1/x2);
- }
- 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