home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-SSP.ARJ / NAAITK.C < prev    next >
Encoding:
Text File  |  1984-06-26  |  746 b   |  35 lines

  1.    naaitk(n,x,f,xx,fx,a,b)
  2.  
  3.       /*this function approximates a function whose value is given*/
  4.       /*at n points on a interval of the x axis. the interpolating*/
  5.       /*polynomial of degree n-1 is developed according to Aitken's*/
  6.       /*algorithm.*/
  7.  
  8.      int n;
  9.      float x[],f[],xx,*fx,a[],b[];
  10.  
  11.     {
  12.      int i,j,k,n1;
  13.  
  14.      for(i = 0; i <= n-1; i++)
  15.      {
  16.       b[i] = f[i];
  17.       a[i] = x[i] - xx;
  18.      }
  19.       n1 = n-1;
  20.  
  21.      for(i = 0; i <= n1-1; i++)
  22.      {
  23.       j = i + 1;
  24.       for(k = 0; k <= n-1; k++)
  25.       {
  26.       b[j] = (a[j]*b[i]- a[i]*b[j])/(a[j] - a[i]);
  27.       j ++;
  28.       if(j >= n ) break;
  29.       }    /* end of k loop */
  30.      }     /* end of i loop */
  31.       *fx = b[n-1];
  32.     }
  33.  
  34.  
  35.