Index: trunk/Ohana/src/opihi/lib.data/mrq2dmin.c
===================================================================
--- trunk/Ohana/src/opihi/lib.data/mrq2dmin.c	(revision 2598)
+++ trunk/Ohana/src/opihi/lib.data/mrq2dmin.c	(revision 2843)
@@ -2,11 +2,7 @@
 
 /* need to pass in a function of the form:
-
-   funcs (x, t, a, Npar, dyda) 
-
-   returns f (x, t) for Npar parameters a, also df/da at x,t 
-
+   funcs (x, t, a, Npar, dy/da) 
+   returns y (x,t) for Npar parameters a along with dy/da at (x,t)
    dy carries 1/sig^2 
-
 */
 
@@ -21,5 +17,5 @@
 
   int k, j, i;
-  float ydiff, wt, chisq, value;
+  float ydiff, wt, chisq;
 
   for (j = 0; j < Npar; j++) {
@@ -32,11 +28,6 @@
 
     ydiff = funcs (x[i], t[i], par, Npar, dyda) - y[i];
-    value = SQ(ydiff) * fabs(dy[i]);
-    if (value < 0.0) fprintf (stderr, "neg chi: %f %f\n", value, chisq);
-    chisq += value; 
+    chisq += SQ(ydiff) * dy[i];
     
-    if (!finite (dyda[i])) { dyda[i] = 1e10; }
-    if (!finite (dy[i])) { dyda[i] = 1e10; }
-
     for (j = 0; j < Npar; j++) {
       wt = dyda[j] * dy[i];
@@ -56,5 +47,5 @@
 float mrq2dmin (float *x, float *t, float *y, float *dy, int Npts, 
 	      float *par, int Npar, 
-	      float (funcs)(float, float, float *, int, float *)) {
+	      float (funcs)(float, float, float *, int, float *), int VERBOSE) {
 
   int j, k;
@@ -68,4 +59,5 @@
   }
 
+  /* keep this test in here? */
   if (!fgaussj (talpha, Npar, tbeta, 1)) {
     lambda *= 10.0;
@@ -73,10 +65,15 @@
   }
 
-  /* if we keep some fixed, set partry to just them 
-     for (j = 0; j < Npar; j++) partry[j] = par[j]; */
-
   for (j = 0; j < Npar; j++) partry[j] = par[j] - tbeta[j][0];
 
   chisq = mrq2dcof (x, t, y, dy, Npts, partry, Npar, talpha, tbeta, funcs);
+  if (VERBOSE) { 
+    fprintf (stderr, "chisq: %f  ", chisq);
+    fprintf (stderr, "lambda: %f  ", lambda);
+    for (j = 0; j < Npar; j++) {
+      fprintf (stderr, "%f ", partry[j]);
+    }
+    fprintf (stderr, "\n");
+  }
 
   /* if good, save temp values */
@@ -100,5 +97,5 @@
 float mrq2dinit (float *x, float *t, float *y, float *dy, int Npts, 
 	      float *par, int Npar, 
-	      float (funcs)(float, float, float *, int, float *)) {
+	      float (funcs)(float, float, float *, int, float *), int VERBOSE) {
 
   int i;
@@ -121,4 +118,12 @@
   
   ochisq = mrq2dcof (x, t, y, dy, Npts, par, Npar, alpha, beta, funcs);
+  if (VERBOSE) {
+    fprintf (stderr, "chisq: %f  ", ochisq);
+    fprintf (stderr, "lambda: %f  ", lambda);
+    for (i = 0; i < Npar; i++) {
+      fprintf (stderr, "%f ", par[i]);
+    }
+    fprintf (stderr, "\n");
+  }
 
   return (ochisq);
