Demo entry 6627607

fixedpoint

   

Submitted by anonymous on Jun 29, 2017 at 12:08
Language: C++. Code size: 395 Bytes.

double fixed_point(double x,double error,int flag)
{
	//flag 标记求解的第几个方程根
	double p=0;
	if(flag==1)  
		//g(x)=(230 * x ^ 4 + 18 * x ^ 3 + 9 * x ^ 2  - 9)/221
		p = f4(x);
	else
		//g(x)=((221 * x + 9) / (230 * x*x + 18 * x + 9)) ^ 0.5
		p = f6(x);
	steps++; 
	cout << "x(" << steps << ") = " << p << endl;
	if (abs(p - x) < error)
		return p;
	return fixed_point(p, error,flag);
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).