Newton Raphson Method C++ Program

using namespace std;
double newt(double, double);

int main(){
	double guess1=10, guess2=-10, accuracy=0.1;
	double result1=newt(guess1,accuracy);
	double result2=newt(guess2,accuracy);
	cout<<"The roots are"<<'\t'<<result1<<","<<'\t'<<result2<<endl;
	return 0;
double newt(double xn, double accu){
	double temp;
	double f=(6*xn*xn)-(17*xn)-14;
	double fdash=(12*xn)-17;
	double xnplus1=xn-(f/fdash);
		return newt(xn, accu);
	return xn;

PhD researcher at Friedrich-Schiller University Jena, Germany. I'm a physicist specializing in computational material science. I write efficient codes for simulating light-matter interactions at atomic scales. I like to develop Physics, DFT and Machine Learning related apps and softwares from time to time. Can code in most of the popular languages. Like to share my knowledge in Physics and applications using this Blog and a YouTube channel.
[wpedon id="7041" align="center"]

Leave a Reply

Your email address will not be published. Required fields are marked *