home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / C-SSP.ARJ / PLYIRT.C < prev    next >
Encoding:
Text File  |  1984-07-27  |  664 b   |  29 lines

  1.    plyirt (a,nd,ni,e,root)
  2.  
  3.       /*this subroutine solves any single valued polnomial for a*/
  4.       /*root using newton's approximation method. the polynomial*/
  5.       /*must be of the form a[0]x**nd + a[1]x**(nd-1) + ...     */
  6.       /* + a[nd]x + a(nd).*/
  7.  
  8.       int nd,ni;
  9.       float a[],e,*root;
  10.  
  11.    {
  12.       int n;
  13.       float fa,fb,rt;
  14.       extern double fabs();
  15.  
  16.       for(n = 1; n <= ni; n++)
  17.       {
  18.        rt = *root;
  19.        plyevl(a,nd,rt,&fa);
  20.        plydif(a,nd,rt,&fb);
  21.        *root = *root - (fa/fb);
  22.        rt = *root;
  23.        plyevl(a,nd,rt,&fa);
  24.        if(fabs(fa) <= e) return;
  25.       }
  26.       *root = 999999.;
  27.     }
  28.  
  29.