Can you please tell me how to cast to the form x = f (x) in the method of simple iterations, if the function has the form x ^ 3 - 2 * x ^ 2 - 15 * x + 36?
1 answer
Okay, I wanted to bring you to thinking and understanding yourself, but alas - there is no time.
For such functions, you can build a new function as
Well, the easiest choice of a suitable function.
so that the condition of convergence is fulfilled -
Here, see for yourself:
#include <iostream> #include <iomanip> using namespace std; double it(double x) { return ((2*x-2)*x*x-36)/((3*x-4)*x-15); } double f(double x) { return ((x-2)*x-15)*x+36; } int main(int argc, const char * argv[]) { double x = 10, y = 0; while(abs(xy) > 1e-7) { y = x; x = it(x); } cout << "x = " << x << endl; cout << "f(x) = " << f(x) << endl; } - Thank you very much for your help :) - Nico_99
- If you are satisfied - do not leave a pending question, accept the answer ... - Harry
|

