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

  1.      plydif(a,nd,x,ans)
  2.  
  3.         /*this function will differentiate a single variable */
  4.         /*polnomial of the form a(1)*x**nd+a(2)*x**nd-1+...  */
  5.         /*a(nd+1)                                            */
  6.  
  7.         int nd;
  8.         float a[],x,*ans;
  9.  
  10.       {
  11.         int i;
  12.         float pwr;
  13.  
  14.         pwr = nd;
  15.         *ans = a[0]*pwr;
  16.         if (nd <= 1) return;
  17.  
  18.         for(i = 1; i <= nd-1; i++)
  19.         {
  20.          pwr = pwr - 1.;
  21.          *ans = *ans * x + pwr * a[i];
  22.         }
  23.       }
  24.