PROGRAM nr IMPLICIT NONE REAL::f,g,ea=6,es=1,x1,x0 INTEGER::c=0 PRINT *, "============================================" PRINT *, "PROGRAM TO FIND ROOTS USING - NEWTON RAPHSON METHOD [BY - www.BottomScience.com]" PRINT *, "============================================" PRINT *,'INITIAL APPROXIMATION?' READ(*,*)x0 DO WHILE(ea>es) x1=x0-((f(x0))/(g(x0))) ea=abs(((x1-x0)/x1)*100) x0=x1 c=c+1 IF(c>50) EXIT PRINT *,'CURRENT ROOT IS',X1 END DO PRINT *,'FINAL ROOT IS',X1 END PROGRAM REAL function f(x1) REAL::x1 f=(x1**2)-3 RETURN END FUNCTION REAL function g(x2) REAL::x2 g=2*x2 RETURN END FUNCTION
OUTPUT
============================================ PROGRAM TO FIND ROOTS USING - NEWTON RAPHSON METHOD [BY - www.BottomScience.com] ============================================ INITIAL APPROXIMATION? 1 CURRENT ROOT IS 2.00000000 CURRENT ROOT IS 1.75000000 CURRENT ROOT IS 1.73214281 CURRENT ROOT IS 1.73205078 FINAL ROOT IS 1.73205078 ------------------ (program exited with code: 0) Press any key to continue . . .
We are one of the best sources to provide deep knowledge of science concepts and we dedicated to empower you with the very best information and news of every field of science.