Advertisement
luizaspan

Cálculo de pi pela Série de Sharp //PROBLEMA

May 21st, 2015
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #define pi M_PI
  5.  
  6. int main(void)
  7. {
  8. int k;
  9. double soma,e;
  10.  
  11. for(k=0;k<9;k++)
  12. {
  13. soma+=2*pow(-1.0,k)*pow(3.0,1/2-k)/(2.0*k+1);
  14. printf("%f \n",soma);
  15. }
  16. e=fabs((pi-soma)/pi);
  17.  
  18. printf("\nValor real: %lf \n",pi);
  19. printf("Valor calculado pela série: %lf \n",soma);
  20. printf("Erro relativo: %lf \n",e);
  21.  
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement