­7È+͈C:)=_ÍgFLUF11 CRCFLUF11 DOCdFLUF11/TPASjnINITCMD PASØ"SP/F PASú SP/F  MM/F MM/F PASÿbo=<áÊ.oÍtoÍÈKÃ.oá:v͈C!v¾ÚoÿG~w£oÍgx·ÈþÚ“o>Ox‘GÅÕͳGÿÁÆo                ¹oÆo CRC Ver 5.0 CTL-S pauses, CTL-C aborts --> FILE: INITCMD .PAS CRC = 76 CE --> FILE: FLUF11 .DOC CRC = A4 98 --> FILE: FLUF11/T.PAS CRC = D2 9D --> FILE: SP/F .PAS CRC = 03 1A --> FILE: SP/F . CRC = 2E FB --> FILE: MM/F . CRC = 62 C7 --> FILE: MM/F .PAS CRC = 9B 05 DONE FLUF Version 1.1 TURBO Pascal (tm) July 11, 1984 D.M. Fritz-Rohner Post Office Box 9080 Akron, Ohio 44305 Thió  prograí  deriveó froí thå BASIà languagå versioî  pre senteä  iî thå articlå 'Á Simplå Minimaø Algorithm§ bù Steveî  A® Ruzinskù founä iî Dr® Dobb'ó Journal¬ Numbeò 93¬ July¬ 1984® FLUÆ  1.± ió aî updatå tï thå FLUÆ 1.° TURBÏ Pascaì version® Seå FLUF10.DOà iî FLUF10.LBR® Thió prograí ió intendeä tï ruî iî CP/Í  (tm©  compatiblå  environments®  Versioî 1.°  ió  á  closå translatioî  oæ thå MBASIà (tm© compatiblå prograí founä iî  thå abovå article® Thió  versioî furtheò reorganizeó anä modifieó thå referencå code. Thå operatinç environmenô interfacå ió modifieä tï  externa lizå  controì  parameteò specificatioî anä tï providå simplå  I/Ï redirectioî oò 'steering'® Prograí controì inpuô ió takeî froí á datá filå anä outpuô maù bå redirecteä tï thå CP/Í lstº devicå oò tï á file® Seå USAGE. Thå controì datá filå haó thå followinç structure; cnx - maximum number of iterations ccS - error convergence value m - number of parameters a(1) cca(1) - initial parameter values and a(2) cca(2) convergence criteria : : a(m) cca(m) n - number of data points ys(1) xs(1) ... - data values ys(2) xs(2) ... : : ys(n) xs(n) ... Notå thaô thå usageó oæ Í anä Î arå interchageä witè respecô tï thå referencå program. Thå  codå  ió  enhanceä tï imposå  reasonablenesó  testó  oî controì data®  Prograí controì ió achieveä througè á combinatioî oæ  testó oî iteratioî count¬  minimaø fit¬  anä parameteò  valuå convergence®  Thå prograí testó eacè iteratioî tï determinå  whe theò  minimaø  fiô  ió equaì oò betteò thaî ccÓ anä  whetheò  thå differenceó  betweeî parameteró foò best-yeô fiô anä presenô  fiô arå closå withiî thå ccá values® FLUÆ convergencå ió noô monotoŠniã sï thaô thió latteò tesô ió onlù looselù relateä tï á  Cauchù criterion. Minimaø fiô ió modifieä tï bå absolutå ratheò thaî relative® Relativå minimaø faultó wheî thå independenô variablå ió zero® Iæ thå ccá parameteró arå seô tï somethinç 'large§ theî iteratioî ió performeä withouô regarä tï parameteò convergence®  Likewiså foò thå  minimaø  criterion®  Thå dependenô variablå valueó  iî  thå controì filå neeä noô bå uniformlù spaced. Thå   initializatioî  oæ  thå  'statå  vector§  list¬   i.e® x[1..N,1..M]¬ ió externalizeä iî á routinå giveî thå generiã namå SVIniô  tï  facilitatå  convenienô  alternatioî  amonç  differenô applications. Thå  parameteò valueó arå useä tï initializå thå  sequentiaì leasô  squareó  segmenô  oæ  thå  processinç  which¬   iî   turn¬ initializeó thå 'fluffing§ process® Thå largå initiaì covariancå matriø  inverså diagonaì valueó makå thå sequentiaì leasô squareó procesó relativelù insensitivå tï thå initiaì coefficienô values. USAGE Selecô  thå  appropriatå SVIniô versioî  foò  inclusioî  anä compilå   thå  prograí  witè  thå  TURBÏ  Com-filå  optioî   set® Otherwiså thå I/Ï redirectioî ió noô meaningful. The command; A>fluf data executeó FLUÆ usinç thå datá filå DATÁ anä outputó thå resultó tï thå CP/Í conº device® A>fluf sp lst: executeó FLUÆ witè datá froí SÐ anä routeó thå outpuô tï thå CP/Í lstº device. A>fluf polyfit results executeó FLUÆ usinç POLYFIÔ anä putó thå outpuô tï filå RESULTS. EXAMPLES Example: 'Simple Polynomial' Thå  filå  SP/Æ  correspondó tï thå  simplesô  caså  iî  thå referencå articlå anä containó thå data; 100 1.e-4 3 1.0 1.0 -.167 1.0 Š .00833 1.0 50 3.141076E-02 2.000000E-02 6.279052E-02 4.000000E-02 : : : : 9.995066E-01 9.800000E-01 1.000000E+00 1.000000E+00 Thå  10°  meanó  tï  iteratå thå  fluffinç  portioî  oæ  thå algorithí  nï morå thaî 10° times®  Thå ccÓ valuå requireó  thaô thå   absolutå  valuå  oæ  thå  maximuí  differencå  betweeî  anù specifieä  independenô variablå valuå anä thå applieä  polynomiaì aô thå correspondinç dependenô variablå valuå bå nï greateò  thaî 1.e-4. Thå ³ specifieó thaô theiò arå threå coefficientó oæ thå odä polynomial®  Therefore¬  thå  polynomiaì  ió  5tè  degree®  Thå followinç  threå pairó oæ numberó arå thå coefficientó anä  theiò convergencå  criteria®  Theså  coefficientó  arå  thå  truncateä valueó  oæ thå firsô threå termó oæ thå Taloò serieó foò thå sinå function® Thå convergencå criteriá arå 'large§ sï thaô iteratioî ió convergencå controlleä bù ccÓ anä looð controlleä bù ncø  witè coefficienô convergencå effectivelù ignored. Thå  5° specifieó thaô therå arå fiftù datá pointó  defininç thå  functioî  tï bå fitted®  Thå valueó listeä herå  arå  thoså computeä  bù TURBÏ usinç thå SIÎ functioî foò thå samå  uniformlù spaceä abscissaå aó thoså iî thå publisheä program. Thå followinç command; A>fluf sp/f test/f processeó thió datá anä putó thå resultó iî TEST/Æ whicè containó thå following; 0 1.567756E+00 -1.70207E-01 8.306739E-03 1.000000E+00 4.058555E-01 1 1.569051E+00 -3.71677E-01 -1.97375E-01 4.961373E-02 4.961373E-02 2 1.570772E+00 -6.43186E-01 7.241231E-02 1.534320E-04 1.534320E-04 3 1.570772E+00 -6.43186E-01 7.241231E-02 1.534320E-04 1.566227E-04 4 1.570678E+00 -6.43058E-01 7.243098E-02 1.244030E-04 1.244030E-04 5 1.570637E+00 -6.43135E-01 7.256355E-02 1.125686E-04 1.125686E-04 6 1.570614E+00 -6.42965E-01 7.243932E-02 1.053334E-04 1.053334E-04 7 1.570587E+00 -6.43024E-01 7.253747E-02 1.006899E-04 1.006899E-04 8 1.570587E+00 -6.43024E-01 7.253747E-02 1.006899E-04 1.035726E-04 9 1.570548E+00 -6.42736E-01 7.225356E-02 1.000070E-04 1.000070E-04 10 1.570524E+00 -6.42757E-01 7.230616E-02 9.094802E-05 9.094802E-05 wherå  thå  firsô  columî ió iteratioî  number¬  thå  nexô  threå columnó  arå coefficienô values¬  thå nexô columî ió best-yeô fiô anä thå lasô columî ió presenô iteratioî minimax® Iteratioî zerï showó  thingó aô thå enä oæ sequentiaì leasô squareó  anä  beforå fluffing®  Therefore¬  thå threå coefficientó foò iteratioî zerï arå thoså foò thå leasô squareó fit® Thå best-yeô ió arbitrarilù Šinitializeä tï somethinç 'large'¬ here¬ one® Thå minimaø fiô foò thå leasô squareó coefficientó ió abouô 0.40¬  whicè ió noô greaô foò á functioî thaô rangeó betweeî zerï anä one. Successivå  iterationó  reducå minimaø tï abouô 9.e-µ  whicè achieveó convergencå tï betteò thaî 1.e-´ withiî 10°  iterations® Thå coefficientó expresó thå relation; 3 5 SIN(1.570796327*x) ~ 1.570524 x - .642757 x + .07230616 x Example: Michaelis-Menten Thå articlå 'Fittinç Curveó tï Data§ bù Marcï S®  Cacecé anä Williaí P®  Cacherió iî BYTÅ Magazine¬  Volumå 9¬  Numbeò 5¬ May¬ 198´  illustrateó applicatioî oæ thå SIMPLEØ algorití usinç leasô squareó  fiô  criterion®  Thå  functioî fitteä  ió  á  so-calleä Michaelis-Menteî function; ^ a' x y = ------ x + b' ~ ~ usinç  siø  measurementó oæ ø anä  y®  Transforí  thió  relatioî using; ~ ~ z = - y / x to form; y = a' + b' z compatible with FLUF. The data file MM/F contains; 200 5.3e-3 2 0.2 1.0 3.0 1.0 6 0.172 1.68 0.250 3.33 0.286 5.00 0.303 6.67 0.334 10.0 0.384 20.0 anä  thå codå iî MM/F.PAÓ foò SVIniô thaô initializeó thå  'statå vector§ lisô x[1..N,1..MÝ contains; x[i,1] := 1.0 ; x[i,2] := -ys[i]/xs[i] ; ŠThen compiling FLUF and executing the command; A>fluf mm/f test/f produceó  á filå thaô containó two hundreä and one lines¬  thå firsô  anä last of which are; 0 4.303436E-01 2.523454E+00 1.000000E+00 1.270990E-02 : : 200 4.209807E-01 2.398137E+00 9.063552E-03 9.087233E-03 PERFORMANCE The command; A>fluf sp/f test/f executeó iî abouô 2³ secondó oî á ´ MHz® Z-8° baseä system® Abouô 1²  secondó  ió requireä foò loaä anä leasô  squareó  completion® Therefore¬ abouô onå seconä peò flufæ ió required. Anù  comparisonó tï resultó reporteä bù Hastingó anä  otheró dependó oî qualificatioî oæ TURBO'ó SIÎ functioî  representation¬ floatinç poinô arithmetic¬ etc® Wå dï noô infeò that; Pi sin( -- x) ~ SIN(1.570796327*x) 2 For comparison, consider the command; A>simp sp test/s wherå thå filå SÐ containó datá comparablå tï SP/F® Therå arå onå hundreä anä onå lineó iî TEST/S¬ thå firsô anä lasô oæ whicè are; 0 1.000000E+00 -1.67000E-01 8.330000E-03 2.477106E-01 6.929252E-01 : : 100 1.548642E+00 -6.22970E-01 8.073769E-02 8.232326E-03 8.428058E-03 wherå  columî usagå correspondó tï FLUF®  Thå algorithí diä  noô convergå anä drovå thå extremuí tï abouô 8.e-3¬  abouô twï orderó oæ  magnitudå greateò thaî specified®  Thå commanä requireä  12± secondó  oò  abouô 1.² secondó peò simp®  Thå  slo÷  convergencå ariseó  mostlù froí thå cusð geometrù oæ thå extremuí spacå whicè forceó  prematurå  contractioî oæ thå  simpleø  figure®  Furtheò convergencå  caî  bå provokeä bù restartinç  thå  iteratioî  witè finaì coefficienô estimateó anä initiaì steð sizes. The command; A>fluf mm/f test/f Š requires about 49 seconds while the command; A>simp mm test/s requireó  abouô  4·  seconds®  Thå filå  SIMP11/T.DOà founä  iî SIMP11/T.LBÒ  discusseó thå resultó oæ applyinç thå minimaø  ver sioî oæ SIMÐ tï thió problem with results; 0 3.000000E-01 3.000000E+00 1.231304E-01 1.835169E-01 : : 200 5.991796E-01 7.085686E+00 5.843624E-02 5.844566E-02 Neitheò  SIMР noò  FLUÆ  convergeä  tï  thå  requireä  fit® However¬  inspectioî oæ thå completå resultó showó FLUÆ unablå tï improvå thå fiô afteò abouô iteratioî 17¹ whilå SIMÐ continueä tï convergå  slowly®  Notå  thaô FLUÆ quiô witè aî erroò abouô  onå fiftè   oæ  SIMP's®   Thå  convergencå  criterioî  ió   probablù infeasible. DISCUSSION Thå  referencå articlå presentó á PolyFORTH (tm© ¯  FMÌ  (c© versioî  oæ thå algorithí whicè incorporateó twï modificationó to thå   fundamentaì   algorithí   intendeä   tï   improvå   runtimå performance. Thå  firsô  computeó  á  modifieä  'gain§  matriø  baseä  oî empiricaì evidencå oæ fasteò convergence® Thå seconä modificatioî contractó  thå  fitteä datá seô bù retaininç  thoså  pointó  witè largesô minimaø values® Thió tendó tï reducå thå fitteä datá seô tï thoså pointó clustereä abouô thå erroò functioî extrema. Neitheò  oæ  theså modificationó  ió  incorporated®  First¬ empiricallù  fudginç thå gaiî matriø detractó froí thå  ingenuitù oæ  FLUÆ  bù failinç tï identifù anä directlù applù  thå  probleí elementó   analogouó   tï   measuremenô   variancå   anä   simplù demonstrateó  thå robustnesó oæ thå underlyinç lineaò  estimatioî formulation®   Foò  example¬   iî  Kalmaî  contexts¬   wheî  thå measuremenô  variancå goeó tï zero¬  thå gaiî goeó tï onå anä thå estimatoò convergeó now. Second¬  thå  datá  seô contractioî  procesó  ió  indirectlù estimatinç  thå coordinateó oæ thå erroò functioî  extrema®  Foò anù  reasonablå functioî thió correspondó tï computinç thå  zeros oæ  thå erroò functioî derivative®  Somå adaptivå formulatioî iî whicè  thå  extremá locationó arå casô intï thå  samå  estimatioî frameworë aó thå coefficientó woulä seeí á desireablå objective. Consideò  estimatioî oæ thå parameteró foò á straighô  line® Iî á mathematicaì sense¬  anù twï pointó suffice® However¬ float inç  poinô representatioî mapó thå reaì numberó tï preservå rela tivå error®  Thió meanó thaô absolutå erroò ió largeò foò largeò Šnumberó  sï  thaô  FLUF'ó datá seô contractioî  wilì  selecô  thå largeò numbers. CP/M (tm) Digital Research MBASIC (tm) MicroSoft TURBO Pascal (tm) Borland International PolyFORTH (tm) Forth Technology FML (c) Steven A. Ruzinsky  { Copyright (C) 1984 D.M. Fritz-Rohner } {$I- suppress default I/O error } program main ; { Name: } { FLUFF - Error FLUFFing Algorithm. } { } { Version: Date: } { 1.1/TURBO (tm) 1984 July 7 } { } { Purpose: } { Demonstrate PASCAL application of error fluff- } { ing algorithm proposed by the reference. } { } { Author: } { D.M. Fritz-Rohner } { Post Office Box 9080 } { Akron, Ohio 44305 } { } { Reference: } { 'A Simple Minimax Algorithm' } { Steven A. Ruzinsky } { Dr. Dobbs Journal } { Number 93, July, 1984 } { pg. 84 et seq } { } { Description: } { This program estimates polynomial coefficients } { for a minimax fit to an elementary transcenden- } { tal function. See FLUFF10.DOC. } { } { This version is written in TURBO Pascal and is } { transliterated from the Basic version pre- } { sented in the reference. See FLUFF10.BAS. } { } { The variable t is substituted for intermediate } { variable usage of the symbols qx and xk. Ex- } { ponentiating operator usage is circumvented. } { Covariance matrix inverse and coefficient } { vector are fully initialized. } { } { The error criterion is made absolute rather } { than relative. } { } { TURBO Pascal (tm) Borland International } { CP/M (tm) Digital Research } const Mx = 8 ; Nx = 64 ; NCxx = 1024 ; BLANK = ' ' ; MAXLINE = 127 ; MAXSTR = 14 ; MAXARG = 8 ; type argstr = string[MAXSTR] ; argvec = array[1..MAXARG] of argstr ; var Narg : integer ; Argv : argvec ; fname : argstr ; fin : text ; Infile : string[14] ; fout : text ; Outfile : string[14] ; err : text ; m : integer ; { number of parameters } mi : integer ; cca : array[1..Mx] of real ; ccS : real ; n : integer ; { number of data } ni : integer ; ys : array[1..Nx] of real ; xs : array[1..Nx] of real ; nc : integer ; ncx : integer ; x : array[1..Nx,1..Mx] of real ; xk : array[1..Mx] of real ; q : array[1..Mx,1..Mx] of real ; qx : array[1..Mx] of real ; a : array[1..Mx] of real ; ak : array[1..Mx] of real ; d : real ; e : real ; e2 : real ; eMax : real ; eBest : real ; t : real ; i, j, k : integer ; jMax : integer ; Done : boolean ; NULL : real ; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} procedure quit ; begin bios(0) end ; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} {--$I b:? state vector initialization} {--$I b:mm/f.pas Michaelis-Menten } {$I b:sp/f.pas simple polynomial } {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} {$I b:initcmd.pas CP/M TURBO command tail parse} {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} procedure HuhEOF ; begin writeln(err,'Premature EOF.') ; quit end ; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} procedure FluffData ; { } { Reads data from disk file FILENAME. Terminate file } { with EOF immediately after last digit. Data in the } { order; } { } { ncx - maximum number of iterations } { ccS - convergence criterion } { m - number of parameters } { a(1) cca(1) - initial parameter values, } { a(2) cca(2) steps sizes, and convergence } { a(3) cca(3) criteria, } { : : : } { a(m) cca(m) } { n - number of points } { ys(1) xs(1) - data values } { ys(2) xs(2) } { ys(3) xs(3) } { : : } { ys(n) xs(n) } { } begin read(fin,ncx) ; { Read maximum iteration count } if eof(fin) then HuhEOF ; if ncx < 1 then begin writeln(err,'Unreasonable Maximum Iteration Count: < 1') ; quit end ; if ncx > ncxx then begin writeln(err,'Unexpected Maximum Iteration Count: > ',ncxx:4) ; ncx := ncxx end ; read(fin,ccS) ; { Read convergence criterion } if eof(fin) then HuhEOF ; if ccS <= 0.0 then begin writeln(err,'Unreasonable Convergence Criterion: <= 0.') ; quit end ; read(fin,mi) ; { Read number of parameters } if eof(fin) then HuhEOF ; if mi < 1 then begin writeln(err,'Unreasonable Parameter Order: < 1') ; quit end ; if mi > mx then begin write(err,'Unexpected Parameter Order: m > ',mx:2) ; writeln(err,' : Excess Ignored') ; m := mx ; end else m := mi ; for j := 1 to m do begin { Read initial parameter values } read(fin,a[j],cca[j]) ; if eof(fin) then HuhEOF ; if cca[j] <= 0.0 then begin writeln(err,'Unreasonable Convergence Parameter: <= 0.') ; quit end end ; if mi > mx then for j := mx+1 to mi do begin { Gobble excess parameter values } read(fin,NULL,NULL) ; if eof(fin) then HuhEOF end ; read(fin,ni) ; { Read number of points } if ni > 0 then begin if eof(fin) then HuhEOF ; if ni < m then begin writeln(err,'Unreasonable Data Order: n < m') ; quit end ; if ni > nx then begin write(err,'Unexpected Data Order: n > ',nx:3) ; writeln(err,' : Excess Ignored') ; n := nx ; end else n := ni ; for i := 1 to n do begin { Read initial parameter values } read(fin,ys[i],xs[i]) ; if ((i < n) and eof(fin)) then HuhEOF end ; if ni > nx then for i := nx+1 to ni do begin { Gobble excess data values } read(fin,NULL,NULL) ; if ((i < ni) and eof(fin)) then HuhEOF end end else n := 0 end ; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} procedure IncludeData ( index : integer ) ; { } { Extract 'state vector' and compute error. } { } begin e := ys[index] ; for i := 1 to M do begin t := x[index,i] ; xk[i] := t ; e := e - ak[i]*t end end ; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} procedure Update ; { } { Update and estimate covariance matrix inverse and } { coefficient vector. } { } begin d := 1.0 ; for j := 1 to M do begin t := 0.0 ; for i := 1 to M do t := t + xk[i]*q[j,i] ; qx[j] := t ; d := d + xk[j]*t ; end ; for j := 1 to M do begin t := qx[j]/d ; for i := 1 to M do q[i,j] := q[i,j] - qx[i]*t ; end ; for j := 1 to M do begin t := 0.0 ; for i := 1 to M do t := t + xk[i]*q[j,i] ; ak[j] := ak[j] + t*e end end ; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} procedure FindMax ; { } { Find maximum absolute error and corresponding index.} { } begin eMax := 0.0 ; jMax := 1 ; for j := 1 to N do begin e := ys[j] ; for i := 1 to M do e := e - x[j,i]*ak[i] ; e := ABS(e) ; if e > eMax then begin eMax := e ; jMax := j end end ; e := ys[jMax] ; for i := 1 to M do begin t := x[jMax,i] ; xk[i] := t ; e := e - ak[i]*t end ; end ; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} procedure FluffInit ; { } { The following initiates the q matrix. It may be } { necessary to to adjust the number below for } { best results. } { } begin SVInit ; for i := 1 to M do begin ak[i] := a[i] ; xk[i] := 0.0 ; q[i,i] := 1.0e+06 ; if i < M then begin for j := i+1 to M do begin q[i,j] := 0.0 ; q[j,i] := 0.0 end end end ; for i := 1 to N do begin IncludeData(i) ; Update end ; for i := 1 to M do a[i] := ak[i] ; FindMax end ; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} procedure SaveBest ; { } { Save coefficients of best fit. } { } begin eBest := eMax ; for i := 1 to M do a[i] := ak[i] end ; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} procedure Results ; { } { Print the results. } { } begin write(fout,nc:4) ; for j := 1 to M do begin write(fout,' ',a[j]:12) end ; writeln(fout,' ',eBest:12,' ',eMax:12) end ; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} procedure Fluff ; { } { Update, find minimax, and select. } { } begin Update ; FindMax ; if eMax < eBest then SaveBest end; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} begin nc := 0 ; ArgInit(Narg,Argv) ; assign(err,'con:') ; rewrite(err) ; if Narg < 1 then begin writeln(err,'Usage: fluff Infile [Outfile]') ; quit end ; if GetArg(1,Infile,MAXARG) then begin assign(fin,Infile) ; reset(fin) ; if IOresult <> 0 then begin writeln(err,'Unable to Open ',Infile,' for Input.') ; quit end end ; if GetArg(2,Outfile,MAXARG) then begin assign(fout,Outfile) ; rewrite(fout) ; if IOresult <> 0 then begin writeln(err,'Unable to Open ',Outfile,' for Outpur.') ; quit end end else begin assign(fout,'con:') ; rewrite(fout) end ; eBest := 1.0 ; FluffData ; FluffInit ; Results ; repeat Fluff ; Done := true ; j := 1 ; while Done and (j <= M) do begin if ABS(ak[j] - a[j]) > cca[j] then Done := false ; j := j + 1 end ; if eBest > ccS then Done := false ; nc := nc + 1 ; results until (Done or ( nc = ncx )) ; close(fout) end.  { Copyright (C) 1984 D.M. Fritz-Rohner } procedure ArgInit ( var narg : integer; var argv : argvec ) ; { } { Name: ArgInit - ARGument vector INITialization. } { } { Version: 1.0/TURBO (tm) Date: 1984 May 16 } { } { Purpose: Parse reduced command tail just enough to } { extract argument strings. Note that argument } { counting conforms to Pascal's one origin indexing } { so that argument indices run from 1 to narg. } { } { Notice that command tail length is limited because } { TURBO writes a jump vector over the command buffer } { beginning at offset 20H. Therefore, only 31 bytes } { of the command tail are available in default line } { buffer. See ALTCMD.PAS if the entire command line } { must be parsed. } { } { Author: D.M. Fritz-Rohner } { Post Office Box 9080 } { Akron, Ohio 44305 } { } const MAXLINE = 31 ; type xstrptr = ^xstr ; xstr = record len : char ; tail : array[1..MAXLINE] of char ; end ; var arg : argstr ; { intermediate variable } cptr : xstrptr ; { command tail pointer } icl : integer ; { command tail index } ncl : integer ; { number command chars } begin cptr := ptr(128) ; { command line tail } ncl := ord(cptr^.len) ; if (ncl > MAXLINE) then ncl := MAXLINE ; narg := 0 ; icl := 1 ; while ((icl <= ncl) and (narg < MAXARG)) do begin arg := '' ; { gobble leading blanks } while ((icl <= ncl) and (cptr^.tail[icl] = BLANK)) do icl := icl + 1 ; { extract argument } while ((icl <= ncl) and (cptr^.tail[icl] <> BLANK) and (length(arg) < MAXSTR)) do begin arg := concat(arg,cptr^.tail[icl]) ; icl := icl + 1 end ; { skip argument tail if truncated } while ((icl <= ncl) and (cptr^.tail[icl] <> BLANK)) do icl := icl + 1 ; { update argument vector } if (length(arg) > 0) then begin narg := narg + 1 ; argv[narg] := arg end end end ; {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~} function GetArg (n : integer; var s : argstr; maxstr : integer) : boolean ; { } { Name: GetArg - GET and copy command line ARGument. } { } { Version: 1.0/Turbo (tm) Date: 1984 May 16 } { } { Purpose: Copy n-th argument from command line argu- } { ment vector to string s. Note that maxstr is dummy. } { } { Author: D.M. Fritz-Rohner } { Post Office Box 9080 } { Akron, Ohio 44305 } { } { Reference: 'Software Tools in Pascal' } { Brian W. Kernighan and P. J. Plauger } { Addison-Wesley Publishing Company, 1981 } { pp. 350 } { } begin if (n > 0) and (n <= Narg) then begin s := Argv[n] ; GetArg := true end else GetArg := false end ;  { Copyright (C) 1984 D.M. Fritz-Rohner } procedure SVInit ; { } { Name: SVInit - State Vector Initialization } { } { Version: 1.1/TURBO (tm) Date: 1984 July 11 } { } { Purpose: Compute cofactor list for coefficients } { in simple odd polynomial form; } { } { y = x * (a[1] + x2 * (a[2] + x2 * a[m]))..) } { } { where: } { } { x2 = x * x } { } { Author: D.M. Fritz-Rohner } { Post Office Box 9080 } { Akron, Ohio 44305 } { } { ys dependent variable } { xs independent variable } { } var e2 : real ; begin for i := 1 to N do begin e := xs[i] ; e2 := e*e ; for j := 1 to M do begin x[i,j] := e ; e := e*e2 end end end ;100 1.e-4 3 1.0 1.0 -.167 1.0 .00833 1.0 50 3.141076E-02 2.000000E-02 6.279052E-02 4.000000E-02 9.410831E-02 6.000000E-02 1.253332E-01 8.000000E-02 1.564345E-01 1.000000E-01 1.873813E-01 1.200000E-01 2.181432E-01 1.400000E-01 2.486899E-01 1.600000E-01 2.789911E-01 1.800000E-01 3.090170E-01 2.000000E-01 3.387379E-01 2.200000E-01 3.681246E-01 2.400000E-01 3.971479E-01 2.600000E-01 4.257793E-01 2.800000E-01 4.539905E-01 3.000000E-01 4.817537E-01 3.200000E-01 5.090414E-01 3.400000E-01 5.358268E-01 3.600000E-01 5.620834E-01 3.800000E-01 5.877853E-01 4.000000E-01 6.129071E-01 4.200000E-01 6.374240E-01 4.400000E-01 6.613119E-01 4.600000E-01 6.845471E-01 4.800000E-01 7.071068E-01 5.000000E-01 7.289686E-01 5.200000E-01 7.501111E-01 5.400000E-01 7.705132E-01 5.600000E-01 7.901550E-01 5.800000E-01 8.090170E-01 6.000000E-01 8.270806E-01 6.200000E-01 8.443279E-01 6.400000E-01 8.607420E-01 6.600000E-01 8.763067E-01 6.800000E-01 8.910065E-01 7.000000E-01 9.048271E-01 7.200000E-01 9.177546E-01 7.400000E-01 9.297765E-01 7.600000E-01 9.408808E-01 7.800000E-01 9.510565E-01 8.000000E-01 9.602937E-01 8.200000E-01 9.685832E-01 8.400000E-01 9.759168E-01 8.600000E-01 9.822873E-01 8.800000E-01 9.876883E-01 9.000000E-01 9.921147E-01 9.200000E-01 9.955620E-01 9.400000E-01 9.980267E-01 9.600000E-01 9.995066E-01 9.800000E-01 1.000000E+00 1.000000E+00 200 5.3e-3 2 0.2 1.0 3.0 1.0 6 0.172 1.68 0.250 3.33 0.286 5.00 0.303 6.67 0.334 10.0 0.384 20.0 { Copyright (C) 1984 D.M. Fritz-Rohner } procedure SVInit ; { } { Name: SVInit - State Vector Initialization } { } { Version: 1.1/TURBO (tm) Date: 1984 July 11 } { } { Purpose: Compute cofactor list for coefficients } { in Michaelis-Menten form; } { } { ^ a' x } { y = ------ } { x + b' } { } { Iæ wå transforí thió relatioî using: } { } { ~ ~ } { z = - y / x } { } { then: } { } { y = a' + b' z } { } { Author: D.M. Fritz-Rohner } { Post Office Box 9080 } { Akron, Ohio 44305 } { } { ys dependent variable } { xs independent variable } { } begin for i := 1 to N do begin x[i,1] := 1.0 ; x[i,2] := -ys[i]/xs[i] end end ;