###############################################################
# Building 'newt2' and sample output on lnx1.
#
# Note how different roots are found depending on the initial
# guess and how, in each case, convergence of both dx and 
# the residual is quadratic as the solution is approached.
###############################################################
lnx1% pwd; ls
/home/phys410/nonlin/newt2
Makefile  newt2.f

lnx1% make
pgf77 -g -c newt2.f
pgf77 -g -L/usr/local/PGI/lib newt2.o  -lp410f -llapack -lblas \
      -o newt2

lnx1% newt2
 usage: newt2 <x0> <y0> [<tol>]

###############################################################
# Start with initial guess (1.0,1.0) and use default tolerance
###############################################################
lnx1% newt2 1.0 1.0
 Iter           x                     y           log10(dx) log10(res)

 1 -3.2999966453609808E-02  1.4010001006391706E+00   -0.11    0.70
 2  3.7660093320946681E-01  2.2207017966697333E+00   -0.19   -0.40
 3  2.6508349149835868E-01  1.9187667230922997E+00   -0.64   -0.30
 4  2.7416951525985471E-01  1.9092166705387069E+00   -2.03   -1.19
 5  2.7423631305849172E-01  1.9092977465351673E+00   -4.13   -3.95
 6  2.7423631371214592E-01  1.9092977458408303E+00   -9.17   -8.33

   0.2742363137121459        1.909297745840830

###############################################################
# Start with initial guess (10.0,10.0)
###############################################################
lnx1% newt2 10.0 10.0
 Iter           x                     y           log10(dx) log10(res)

 1  1.1551311217431483E+01  8.5653933652294452E+00    0.17    1.43
 2  5.2821340061726980E+00  6.2494950887340224E+00    0.67    0.26
 3  7.9156169058357619E+00  7.0845635560826592E+00    0.29    0.58
 4  8.0553488925966921E+00  7.0945184795080038E+00   -1.00   -0.08
 5  8.0478800969985382E+00  7.0913532277563132E+00   -2.24   -1.34
 6  8.0480621354266226E+00  7.0914295327798467E+00   -3.86   -2.93
 7  8.0480622340064549E+00  7.0914295740731097E+00   -7.12   -6.20

    8.048062234006455        7.091429574073110

###############################################################
# Start with initial guess (100.0,100.0)
###############################################################
lnx1% newt2 100.0 100.0
 Iter           x                     y           log10(dx) log10(res)

 1  1.4561314470371519E+02  5.4378394341111459E+01    1.66    3.82
 2  1.9021837653952545E+02  3.7701738714769562E+01    1.53    3.17
 3  2.0349983567820647E+02  3.5070267397907138E+01    0.98    2.29
 4  2.0392234856561166E+02  3.5007684984188501E+01   -0.52    0.70
 5  2.0390326095147370E+02  3.5005993323580434E+01   -1.87   -0.53
 6  2.0391023928640129E+02  3.5006591323292412E+01   -2.31   -0.59
 7  2.0391061250942664E+02  3.5006623302706338E+01   -3.58   -1.92
 8  2.0391061457091234E+02  3.5006623479357074E+01   -5.83   -4.18
 9  2.0391061457097669E+02  3.5006623479362588E+01  -10.34   -8.68

    203.9106145709767        35.00662347936259

###############################################################
# Start with initial guess (0.0,0.0), generates singular
# Jacobian
###############################################################
lnx1% newt2 0.0 0.0
 Iter           x                     y           log10(dx) log10(res)

 newt2: dgesv failed.

###############################################################
# Start with initial guess (1.0,1.0) but use more stringent
# tolerance
###############################################################
lnx1% newt2 1.0 1.0 1.0e-15
 Iter           x                     y           log10(dx) log10(res)

 1 -3.2999966453609808E-02  1.4010001006391706E+00   -0.11    0.70
 2  3.7660093320946681E-01  2.2207017966697333E+00   -0.19   -0.40
 3  2.6508349149835868E-01  1.9187667230922997E+00   -0.64   -0.30
 4  2.7416951525985471E-01  1.9092166705387069E+00   -2.03   -1.19
 5  2.7423631305849172E-01  1.9092977465351673E+00   -4.13   -3.95
 6  2.7423631371214592E-01  1.9092977458408303E+00   -9.17   -8.33
 7  2.7423631371214592E-01  1.9092977458408303E+00  -16.28  -16.07

   0.2742363137121459        1.909297745840830