ang[5]=POTN;
for (j=3;j<6;j++) ch[j]=chixy.get(ang[j]);
brent.bracket(ang[0],ang[1],chixy);
ang[0] = brent.ax; ang[1] = brent.bx; ang[2] = brent.cx;
ch[0] = brent.fa; ch[1] = brent.fb; ch[2] = brent.fc;
b = brent.minimize(chixy);
chi2=chixy.get(b);
a=aa;
q=gam.gammq(0.5*(ndat-2),chi2*0.5);
r2=0.0;
for (j=0;j<ndat;j++) r2 += ww[j];