Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main(void) {
- double x, x1 = 0.0, x2 = 1.0, e = 0.000001, xvstep, sum = 0.0, hop;
- while (x2 - x1 > e)
- {
- x = x1 + (x2 - x1) / 2;
- if ((atan(x1) - 5.0 / 7) * (atan(x) - 5.0 / 7) < 0)
- x2 = x;
- else x1 = x;
- }
- printf("%.7f\n%.8f\n", x, x2 - x1);
- int n = 1;
- xvstep = x;
- sum += x;
- e = 0.00001;
- //hop = sum - 0.4;
- /*while (hop > e)*/
- //while (sum % -> e)
- while ((int)(sum * 10000.0) % 10 > 0)
- {
- xvstep = (xvstep * x * x) / (2 * n + 1);
- sum = sum + n % 2 == 0 ? +xvstep : -xvstep;
- n++;
- //hop = sum - 0.4;
- //if (hop < 0)
- // hop = hop * (-1);
- }
- printf("%.6f\n%d\n", sum, n - 1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement