Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // para cosx=0, com a=0 e b=3 e epsilon
- #include <stdio.h>
- #include <math.h>
- #define pi M_PI
- #define eps 1e-5
- int main(void)
- {
- double a=0, b=3, c, y;
- while ((b-a)>eps)
- {
- c=(a+b)/2;
- y=cos(c);
- if (y>0)
- a=c;
- else if (y<0)
- b=c;
- else if (y==0)
- break;
- }
- printf("Raiz calculada: %e \nRaiz teórica: %e \n",c,pi/2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement