[ create a new paste ] login | about

Link: http://codepad.org/uyJgFWuO    [ raw code | output | fork ]

C, pasted on Mar 21:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<stdio.h>
#include<math.h>
double problem()
{
		double x=1.0,x0,f,f1;
	do
	{
    x0=x;
	f=x0*x0*x0+2*x0*x0+3*x0+4;
	f1=3*x0*x0+4*x0+3;
	x=x0-f/f1;
	}while(fabs(x-x0)>=1e-5);
	printf("%f", x0);
}
void main()
{
	double m;
	m=problem();
}


Output:
1
-1.650638


Create a new paste based on this one


Comments: