program cnewraph ! Program to solve the equation f(x)=0, where f is a complex ! analytic function, using the Newton-Raphson iteration scheme ! x = x - f(x)/f'(x) ! This program requires as input an initial approximation to the ! root of the equation f(x)=0 , where f(x) and its derivative f'(x) ! are specified in the accompanying function subprograms. The output ! is the required root accurate to tolerance TOL, if convergence is ! attained !Declare variables: implicit none integer :: i real :: tol complex :: x0, x, f, fdash character(len=1) :: check problem_loop: do ! Data prompt: write(*,*) 'Enter initial approximation to root and tolerance : ' ! Input and echo data: read *, x0, tol write(*,20) x0, tol 20 format(/2x,' x0 = ',('(',e14.7,',',e14.7,')'),5x,' tol = ',e8.2/) ! Header: write(*,*) 'Iteration Approximation' NRiteration_loop: do i = 1,100 x = x0 - f(x0)/fdash(x0) ! Newton-Raphson method. write(*,30) i,x 30 format(1x,i4,13x,('(',e14.7,',',e14.7,')')) if(abs(x-x0)