Welcome to Pade Test Data – generated as described in gleg\Welcome.doc Figure 1 Test data 3073 points between -6 and 0 The points shown in figure 1 have relative errors less than 10-15. 1 Ln AiGau x Ln x exp t dt 2 (1) Probability integral.docx exp( Ln ALiGau x 2 exp t dt 1 exp( Ln ALiGau x 1 x Pade Approximate Npade cx Poly ( x, c ) 1 i 1 Npade 1 i 1 i 1 i (1) ci Npade x The total number of c’s is Ncon 2 Npade 1 (2) This is coded into PolyDA.for(3) i x 0 x0 (2) Pade approximates are notorious for zeroes in the denominator that can cause the approximating function to have spikes between data points. One solution is to use the absolute values of ci+Npade. This rather severely limits the denominator. A second problem is a tendency for the numerator and the denominator to become very large. Penalty A penalty form is coded into PolyDA.for which at least prevents the very large coefficients and is relatively successful in eliminating zeroes when data is plentiful. f x , c dati c A i erri i 1 Ndat 2 2 Npow Nv ci2 Npen i 3 At the beginning of the minimization should be large enough that the penalty accounts for on the order of 10% of the total chi. The difference is available after the last step when nlfit calculates chit which does not include the penalty. Npow gleg\Welcome.doc describes the generation of the test data. Below -3, the data was generated by integrating from -∞ to z using Gauss Laguerre quadrature. This made each point an independent. (4) Above -3, the points were integrated by adding the difference from the previous point making the entire set share the error. pade.dir , OUTPUT FILE NAME Laigau.out, DATA SET NAME 1,8 dimension of X in FA(X), NPOW in ((f-fA)/err)**(2*NPOW) C,1E-34,0,1E-15 'R' read data point,err, 'C' err=(a+bf)^.5 +c 19 total number of constants (ones with vary 0 are not being f 2000, maximum number of minimization steps 0.9999,Pen,2 2e0,abs, initial fr, Penalty-if all caps-,Npen Ala 1 VARY O FIX FITTED CONS ERROR IN CONS 1 -6.9314718055994506E-01 +- 1.243E-13 1 2.4248558638803122E+00 +- 15.8 1 -3.8596778751581624E+00 +- 46.9 1 3.6689470530103137E+00 +- 62.4 1 -2.2927494647421449E+00 +- 48.8 1 9.7372893169815855E-01 +- 24.4 1 -2.7912983009006404E-01 +- 7.91 1 5.1295970022983153E-02 +- 1.59 1 -5.2810630653471174E-03 +- 0.170 1 2.0483089058487465E-04 +- 5.820E-03 1 -1.8704205010795294E+00 +- 22.9 1 1.6050192612265761E+00 +- 30.4 1 -8.1419573615274221E-01 +- 19.6 1 2.5844644415456330E-01 +- 7.24 1 -5.0213969382383122E-02 +- 1.55 1 5.2757905896337618E-03 +- 0.170 1 -2.0491315246831215E-04 +- 5.820E-03 1 -1.3797084627869877E-09 +- 3.158E-08 1 -1.4116380869588198E-11 +- 5.803E-10 ended because abs(chb-chl)/chl<1e-9 CHI,CHIPEN= 1.5105E-03 0.000 FOR 3073 DATA POINTS CHI USED IN CALCULATING ERRORS IS 3054. SUM ((FA-F)/EP)**2 = 88.5263721791144094876991883243923 NDAT = 3073 It was necessary to start with Npow = 2 to get the last two parameters away from 0. The minimization was with nlfitqmp. Range The data in figure 1 has 3073 data points from x=-6 to x=0. The code PlotRes.wpj allowsextrapolation to any value. Watfor This FORTRAN interpreter checks for uninitialized variables. It is the most complete debugger that I have ever found. It also stores things in a nonstandard format and has slightly less accurate double precision than most FORTRAN compilers. I tested both a double precision code and a double/multiple precision code. More details are in ..\W4\Welcome.docx. Watcom – nlfit/nlfitmp Intel - nlfitq The double precision code is nlfit.wpj. Quadruple precision, nlfitq.vfproj, differs by the presence of real*16, including the first derivatives, and the use of the Intel compiler. Nlfitmp uses multiple precision to invert the matrices (250 digits) , but uses double precision for the derivatives. Nlfitqmp uses quadruple precision where appropriate and multiple precision to invert the matrices. Nlfitmpmp uses multiple precision for both the derivatives and the matrix inversion. The codes are listed in order of the time required for them to run. The most successful in this example is Nlfitqmp. Figure 2 Residuals as in (4) Npow = 6. pade.dir , OUTPUT FILE NAME Laigau.out, DATA SET NAME 1,5 dimension of X in FA(X), NPOW in ((f-fA)/err)**(2*NPOW) C,1E-4,0,1E-20 'R' read data point,err, 'C' err=(a+bf)^.5 +cf 5 total number of constants (ones with vary 0 are not being f 2000, maximum number of minimization steps 0.9999,PEN,2 1e1,abs, initial fr, Penalty-if all caps-,Npen Ala 1 VARY O FIX FITTED CONS ERROR IN CONS 1 -7.0296649242537557E-01 +- 5.440E-04 1 1.0179908657537597E+00 +- 1.311E-03 1 -7.2084655816792254E-01 +- 1.711E-03 1 4.1276799623572773E-02 +- 5.050E-04 1 2.3987903246443639E-03 +- 3.829E-05 ended because abs(chb-chl)/chl<1e-9 CHI,CHIPEN= 38.44 13.44 FOR 3073 DATA POINTS CHI USED IN CALCULATING ERRORS IS 3068. SUM ((FA-F)/EP)**2 = 728.3170098400192956 NDAT = 3073 Nlfitmp lowered the 38.44 to 38.42 after a few hundred steps when I stopped it. Nlfitq lowered this to 38.41 in relatively few steps. Bob*** 8/6/2015 The double precision code eventually fails. The inverted array does not correct with large values of . The code returns the values to this point. The intel quadruple precision code caries it further. Then nlfitmp.wpj with multiple precision carries it further yet, though the improvement is very small. Figure 3 The difference between the data and the fit is less than 0.003. pade2.dir , OUTPUT FILE NAME Laigau.out, DATA SET NAME 1,6 dimension of X in FA(X), NPOW in ((f-fA)/err)**(2*NPOW) C,1e-8,0,1E-20 'R' read data point,err, 'C' err=(a+bf)^.5 +cf 15 total number of constants (ones with vary 0 are not being f 2000, maximum number of minimization steps 0.9999,Pen,1e5,abs, initial fr, Penalty-if all caps-,lambda, ab 1 VARY O FIX FITTED CONS ERROR IN CONS 1 -6.932790915727651E-01 +- 1.830E-06 1 1.082256637822175E+00 +- 9.20 1 -5.789703219287241E-01 +- 17.7 1 6.557079075029873E-02 +- 13.4 1 1.762611667084673E-02 +- 4.42 1 3.260599094603882E-03 +- 0.372 1 3.780360755424656E-04 +- 5.556E-02 1 1.808451488260390E-05 +- 1.797E-03 1 6.320201829048598E-02 +- 13.3 1 9.520415409816399E-03 +- 6.18 1 2.430484480365099E-04 +- 0.116 1 -1.703774166936710E-04 +- 5.785E-02 1 -2.316481624453219E-05 +- 2.393E-02 1 -1.263327602876655E-06 +- 3.202E-03 1 -3.901269297096165E-08 +- 1.591E-04 ended because abs(chb-chl)/chl<1e-9 CHI= 594.5 FOR 3073 DATA POINTS CHI USED IN CALCULATING ERRORS IS 3058. SUM ((FA-F)/EP)**2 = 1283.3741324289612749 NDAT = 3073 Minimize numerator and denominator separately The above file with 15 constants is the first for which the numerator and denominator can be minimized separately. Below 15, such minimizations followed by a complete minimization always lead to noticeably lower minima. This one stays the same for both nlfitq and nlfitmp minimizations. Separate numerator and denominator minimizationsare much faster than the combined minimization. pade2.dir , OUTPUT FILE NAME Laigau.out, DATA SET NAME 1,6 dimension of X in FA(X), NPOW in ((f-fA)/err)**(2*NPOW) C,1e-12,0,1E-6 'R' read data point,err, 'C' err=(a+bf)^.5 +cf 21 total number of constants (ones with vary 1 are not being f 2000, maximum number of minimization steps 0.9999,Pen,1e5,abs, initial fr, Penalty-if all caps-,lambda, ab 1 VARY O FIX FITTED CONS ERROR IN CONS 1 -6.931462809758711E-01 +- 4.186E-06 1 1.084620407832966E+00 +- 1.929E+07 1 -5.714716776144769E-01 +- 2.802E+07 1 7.464461953405718E-02 +- 1.292E+07 1 2.273120438423467E-02 +- 8.675E+05 1 4.527216313088876E-03 +- 6.203E+05 1 3.827639996659974E-04 +- 2.035E+05 1 -5.347508789098885E-05 +- 3.910E+04 1 -1.667601702385410E-05 +- 4.378E+03 1 -1.614346303156150E-06 +- 276. 1 -5.912633759139942E-08 +- 8.02 1 6.319970956417620E-02 +- 2.783E+07 1 9.525414012300504E-03 +- 3.132E+06 1 2.704498484726000E-04 +- 5.760E+05 1 -1.331806990347220E-04 +- 8.463E+04 1 1.701260991175848E-06 +- 1.204E+04 1 8.290546980453564E-06 +- 1.770E+03 1 2.175308297642102E-06 +- 238. 1 3.063719509989111E-07 +- 26.3 1 2.333281314912452E-08 +- 1.99 1 7.533626441023104E-10 +- 6.922E-02 ended because abs(chb-chl)/chl<1e-9 CHI=0.5714E-02 FOR 3073 DATA POINTS CHI USED IN CALCULATING ERRORS IS 3052. SUM ((FA-F)/EP)**2 = 170.122405915483724810218893015300 3073 NDAT = Taming the Pade (making a denominator with no zeroes) Write Den x, b, c 1 bx cx 2 b b 2 4c b b 2 4c x x 2 2 2 2 b b 2 4c b b 2 4c b 2 b 2 4c x2 x 2 4 2 2 2 4 x 2 bx c (5) c b / 4 , there are no zeroes on the real axis. Thus a denominator with no zeroes can be written as c Den x, c4 , c5 1 c4 x c52 4 x 2 4 (6) This is overly restrictive for functions over finite or even semi infinite ranges, but for the test function above, allows all desirable variation. The approximation in Error! Reference source not found. however has ln(-x) values from - to for which this is appropriate. Write N c Den x, c4 , c5 ,.., c2 N , c2 N 1 1 c2i x c22i 1 2i 4 i 2 2 x (7) N c ln Den x, c4 , c5 ,.., c2 N , c2 N 1 ln 1 c2i x c22i 1 2i 4 i 2 ln Den x, c4 , c5 ,.., c2 N , c2 N 1 x x2 / 4 c c2i 1 c2i x c22i 1 2i x 2 4 ln Den x, c4 , c5 ,.., c2 N , c2 N 1 2c2i 1 x 2 c c2i 1 1 c2i x c22i 1 2i x 2 4 2 x More Constants The form in Error! Reference source not found. assumes that as xinfinity, Pade constant 2N Pade x, c c x x c i 0 Nd i 1 i i 2 i 1 2 N 2 c22i 2 N (8) Nd 2N 2 ci x i exp ln x c2i 1 2 N c22i 1 2 N i 0 i 1 Equation (8) has 2N+1 terms in the numerator and 2Nd terms in the denominator. The denominator for large x x2Nd, while the numerator x2N.