#include <iostream>
using namespace std;
void main()
{
float x0,result,e;
float u(float x);
float aitken(float (*f)(float),float x0,float e);
cout<<"输入初始值:";
cin>>x0;
cout<<"输入精度:";
cin>>e;
result=aitken(u,x0,e);
cout<<"运算结果是:"<<result<<endl;
}
float aitken(float (*u)(float),float x0,float e)
{
float x1,x2;
x1=u(x0),x2=u(x1);
x2=x2-(x2-x1)*(x2-x1)/(x2-2*x1+x0);
while(x2-x0>=e || x0-x2>=e)
{
x0=x2;
x1=u(x0);x2=u(x1);
x2=x2-(x2-x1)*(x2-x1)/(x2-2*x1+x0);
}
return x2;
}
float u(float x) [url=file://要/]file://要[/url]解的方程为x=u(x)
{
return x*x-12;
}