Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // calcular numericamente int_{0.1}^{1.0} (1/x)dx = -ln(0.1)
- // calcular pela regra retangular
- #include <stdio.h>
- #include <math.h>
- #define n 1000
- int main(void)
- {
- int i;
- double h,x,sum=0.0,val,e;
- h=(1.0-0.1)/n;
- for (i=1;i<=n;i++)
- {
- x=0.1+h*i;
- sum+=h*(1/x);
- }
- val=-log(0.1);
- e=((val-sum)/val)*100;
- printf("Valor calculado: %lf\n",sum);
- printf("Valor real: %lf\n",val);
- printf(
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement