newtons methods implementation
问题 i have posted a few hours ago question about newtons method,i got answers and want to thanks everybody,now i have tried to implement code itself #include <iostream> #include <math.h> using namespace std; #define h powf(10,-7) #define PI 180 float funct(float x){ return cos(x)-x; } float derivative (float x){ return (( funct(x+h)-funct(x-h))/(2*h)); } int main(){ float tol=.001; int N=3; float p0=PI/4; float p=0; int i=1; while(i<N){ p=p0-(float)funct(p0)/derivative(p0); if ((p-p0)<tol){ cout<