home *** CD-ROM | disk | FTP | other *** search
- plyirt (a,nd,ni,e,root)
-
- /*this subroutine solves any single valued polnomial for a*/
- /*root using newton's approximation method. the polynomial*/
- /*must be of the form a[0]x**nd + a[1]x**(nd-1) + ... */
- /* + a[nd]x + a(nd).*/
-
- int nd,ni;
- float a[],e,*root;
-
- {
- int n;
- float fa,fb,rt;
- extern double fabs();
-
- for(n = 1; n <= ni; n++)
- {
- rt = *root;
- plyevl(a,nd,rt,&fa);
- plydif(a,nd,rt,&fb);
- *root = *root - (fa/fb);
- rt = *root;
- plyevl(a,nd,rt,&fa);
- if(fabs(fa) <= e) return;
- }
- *root = 999999.;
- }
-