#include<iostream> #include<cmath> 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); temp=xn; xn=xnplus1; if(abs(temp-xn)>=accu){ return newt(xn, accu); } return xn; }
Ph.D. 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 software from time to time. Can code in most of the popular languages. I like to share my knowledge in Physics and applications using this Blog and a YouTube channel.
[wpedon id="7041" align="center"]