Пример #1
0
// Newton's method to calculate roots
bigfloat AlgRemez::rtnewt(bigfloat *poly, long i, bigfloat x1, 
			  bigfloat x2, bigfloat xacc) {
  int j;
  bigfloat df, dx, f, rtn;

  rtn=(bigfloat)0.5*(x1+x2);
  for (j=1; j<=JMAX;j++) {
    f = polyEval(rtn, poly, i);
    df = polyDiff(rtn, poly, i);
    dx = f/df;
    rtn -= dx;
    //if ((x1-rtn)*(rtn-x2) < (bigfloat)0.0)
    //printf("Jumped out of brackets in rtnewt\n");
    if (abs_bf(dx) < xacc) return rtn;
  }
  printf("Maximum number of iterations exceeded in rtnewt\n");
  return 0.0;
}
Пример #2
0
// Newton's method to calculate roots
bigfloat AlgRemez::rtnewt(bigfloat *poly, long i, bigfloat x1, bigfloat x2, bigfloat xacc) {
  char *fname = "rtnnewt(bigfloat *, long, bigfloatm bigfloat, bigfloat)";
  VRB.Func(cname,fname);
  int j;
  bigfloat df, dx, f, rtn;
  
  rtn=(bigfloat)0.5*(x1+x2);
  for (j=1; j<=JMAX;j++) {
    f = polyEval(rtn, poly, i);
    df = polyDiff(rtn, poly, i);
    dx = f/df;
    rtn -= dx;
    if ((x1-rtn)*(rtn-x2) < (bigfloat)0.0)
      VRB.Warn(cname,fname,"Jumped out of brackets in rtnewt\n");
    if (abs_bf(dx) < xacc) return rtn;
  }
  VRB.Warn(cname,fname,"Maximum number of iterations exceeded in rtnewt\n");
  return 0.0;
}