program newtc c c -- square and cube root of 2 by newton-s method c logical error integer out real x external sqr2, cube common /inout/ out c out = 6 write(out,*) ' newton-s method' x = 2 call newton(x, sqr2, error) write(out, 102) x call newton(x, cube, error) write(out, 105) x 99 stop 102 format(/' the square root of 2 is ', f8.5) 105 format(//' the cube root of 2 is ', f8.5) end subroutine cube(x, fx, dfx) c c -- the cube root of 2 c real x, fx, dfx, x2 c x2 = x * x fx = x2 * x - 2 dfx = 3 * x2 return end