Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void newton_rapshon(vector<double>& results, vector<int>& iterations, double a, double b)
- {
- double beg_point = (a + b) / 2;
- double x1 = beg_point - 1, f0 = function(beg_point), x0 = beg_point, f1;
- int iteration_count = 0;
- while ((fabs(x1 - x0) > EPSILON) && (fabs(f0) > EPSILON))
- {
- f1 = derivative_of_function(x0);
- x1 = x0;
- x0 = x0 - f0 / f1;
- f0 = function(x0);
- iteration_count++;
- if (iteration_count > NMAX)
- break;
- }
- if (x0>a && x0<b)
- {
- results.push_back(x0);
- iterations.push_back(iteration_count);
- }
- }
- a = A_POINT, b = A_POINT + 0.5;
- while (b != B_POINT)
- {
- newton_rapshon(results, iterations, a, b);
- a += 0.5;
- b += 0.5;
- }
- Metoda Stycznych
- Wyniki:
- x1 = -9.424777960769379300 Iteracje: 3
- x2 = -6.283185307179576500 Iteracje: 2
- x3 = -3.141592653589793100 Iteracje: 3
- x4 = -0.000000000000000000 Iteracje: 3
- x5 = 0.000000000000000000 Iteracje: 3
- x6 = 3.141592653589793100 Iteracje: 3
- x7 = 6.283185307179576500 Iteracje: 2
- x8 = 9.424777960769379300 Iteracje: 3
- Suma iteracji = 22
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement