Of course, my exp(100) example is incorrect:
relative precision is better than 10^-12 even on 32-bit
system.
Also, ways to determine h should be different for qualities 0,1, and 2
Quality 0 requires much lesser h: for x from (0,1) 
sqrt($macheps) even 10^-1*sqrt($macheps) works OK
And of course if x==0 should be changed to something like
abs(x)<10^-1*sqrt($macheps) for quality 0
Currently, I can't tell about quality 1
Oleh
I'll write my impression on the tests later

30 грудня 2015, 12:48:19, від "Riccardo (Jack) Lucchetti" <r.lucchetti@univpm.it>:

On Wed, 30 Dec 2015, oleg_komashko@ukr.net wrote:

> We have 2 (3) ways of proceed : make experiments, find good expert on 
> numerical methods (do both) The script attached shows, for small x the 
> best h is as big as 10^5*sqrt($macheps) Still I do not know what to to 
> with x: abs(x)>10^5 and what to do with say, exp(100) try x = {100} eval 
> fdjac (x,exp(x)) - exp(100) That's ERROR! Oleh

Of course ANY numerical approximation to a derivative is a ratio; 
therefore, what is crucial to its precision is the relative order of 
magnitude of numerator and denominator. It's easy to contruct pathological 
cases and there's no silver bullet that works in all cases.

That said, the following settings seem to work reasonably well in a 
decently-sized array of cases (diff against git HEAD --- not applied yet).

<diff>
diff --git a/minpack/fdjac2.c b/minpack/fdjac2.c
index 9e9676a..54e64ec 100644
--- a/minpack/fdjac2.c
+++ b/minpack/fdjac2.c
@@ -144,10 +144,10 @@ int fdjac2_(S_fp fcn, int m, int n, int quality,
         for (j = 0; j < n; j++) {
             temp = x[j];
             if (quality == 2) {
-               if (fabs(temp) > 1000) {
-                   h = 1000 * sqrt(fabs(temp/1000)) * eps;
+               if (fabs(temp) > 128) {
+                   h = 128* sqrt(fabs(temp/128)) * eps / sqrt(6);
                 } else {
-                   h = 1000 * eps;
+                   h = 128 * eps / sqrt(6);
                 }
             } else {
                 h = eps * fabs(temp);
</diff>

I'm attaching a battery of tests.

-------------------------------------------------------
   Riccardo (Jack) Lucchetti
   Dipartimento di Scienze Economiche e Sociali (DiSES)

   Università Politecnica delle Marche
   (formerly known as Università di Ancona)

   r.lucchetti@univpm.it
   http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------