PRO Fsp_mrqcof, tyspec, ma, yo, s2, a, alpha, beta, chisq, ffx=ffx
   
   COMMON Rsp, nch, nsc, esc, rsc ;characteristics of the detector
   
   c = countrate(tyspec, ma, a) ;get count rate
   dcda = cdcda(tyspec, ma, a)  ;and its derivatives

;deal with fixed parameters here, jmm, 9-jul-1996
   IF(KEYWORD_SET(ffx)) THEN BEGIN
      IF(N_ELEMENTS(ffx) NE ma) THEN BEGIN
         message, 'N_elements(ffx) ne ma. This will crash', /info
         RETURN
      ENDIF
      fix_ed = where(ffx NE 0)
      not_fix = where(ffx EQ 0)
      IF(not_fix(0) NE -1) THEN dcda = dcda(*, not_fix) ELSE BEGIN
         message, 'All fixed parameters? This will crash', /info
         RETURN
      ENDELSE
   ENDIF
   ma1 = N_ELEMENTS(dcda(0, *))

   dy = (yo-c)
   chisq = total((dy^2)/s2) ;is chisq
   IF(chisq LT 0.0) THEN chisq = 1.0e38
   
   t = transpose(dy/s2)         ;a 1,nch column vector
   beta = t#dcda                ;a 1,ma1 column vector
   
   t = dblarr(nch, ma1)         ;an nch,ma array
   FOR i = 0, nch-1 DO t(i, *) = dcda(i, *)/s2(i) ;divide all rows of 
                                                  ;dcda by the weight
   alpha = transpose(dcda)#t    ;transpose dcda to an ma1,nch array
                                ;and get alpha, and ma1 by ma1 symmetric array. 
   RETURN
END