#include #include #include using namespace std; #include "matrix.h" Trow g (Trow xx) { Trow out; double x = xx[0]; double y = xx[1]; x = pow(2/y,.5); out.push_back (x); out.push_back (pow(1/x,.25)); return out; } main () { Trow p,pold; const double tol = pow(10,-6.0); p.push_back (8); // initial guess p.push_back (8); cout << 0 << "\t" << p ; for (int i = 0; i < 50; i++) { pold = p; p = g (p); cout << i << "\t" << p ; if (norm (p+(-1)*pold) < tol) break; } }