home *** CD-ROM | disk | FTP | other *** search
- nalagr(n,x,f,xx,fx)
-
- /*this function approximates a function whose value is given */
- /*at n points on a n interval of the x axis. The interpolating*/
- /*polynomial is LaGrangian. */
-
- int n;
- float x[],f[],xx,*fx;
-
- {
- int i,j;
- float p;
-
- *fx = 0.;
- for(j = 0; j <= n-1; j++)
- {
- p = f[j];
- for(i = 0; i <= n-1; i++)
- {
- if(j != i)
- p *= (xx - x[i])/(x[j] - x[i]);
- }
- *fx += p;
- }
- }
-