关于#c++#的问题:迭代法求方程

用简单迭代法编程,求方程的根,输出求根数列和相应的估计误差
x-2^-x=0

软国的兄弟?后面几个题有答案吗求一份,我这道这么写的,上面那个牛顿写的,和作业要求不一致

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <cmath>


using namespace std;

int main()
{
    double xn = 0.0, xn1 = 0.0;
    for(int i = 0; i < 20; i++){
        xn1 = pow(2,xn*(-1));
        cout << i+1 << " : " << xn1 << endl;
        xn = xn1;
    }
     return 0;
}


x-2^-x=0 这方程没写错吧?

牛顿迭代法:

x_{n+1} = x_n - f(x_n) / f'(x_n)

https://en.wikipedia.org/wiki/Newton%27s_method