home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / ANUMR5.ZIP / STEFMAIN.C < prev    next >
C/C++ Source or Header  |  1991-01-13  |  762b  |  54 lines

  1. /* OK */
  2.  
  3. #include <math.h>
  4. #include <stdio.h>
  5.  
  6. #include "anum.h"
  7. #include "sysio.h"
  8.  
  9.  
  10.  
  11. double f1(double x)
  12.  
  13. {    return(cos(x)-x);
  14. }
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. void main(void)
  24.  
  25.  
  26. {    double pt0,rac,tol,val;
  27.     int iter,maxiter,errcode;
  28.  
  29.     pt0=1e6;
  30.     tol=1.e-10;
  31.     maxiter=1000;
  32.  
  33.  
  34.     puts("Test program for function stefensen");
  35.     printf("Initial approximation : %lf\n"
  36.            "Tolerance : %le\n"
  37.            "Maximum number of iterations : %d\n",
  38.            pt0,tol,maxiter);
  39.  
  40.  
  41.  
  42.  
  43.     steffensen(pt0,tol,maxiter,&rac,&val,&iter,
  44.                 &errcode,f1);
  45.         SYSMSG(errcode,stderr);
  46.  
  47.     printf("\n\nResults:\n--------\n"
  48.            "\n\nRoot : %16.12lf\nValue : %12.8le\n"
  49.            "Iteration number : %d\nError code : %d\n",
  50.            rac,val,iter,errcode);
  51.  
  52.  
  53. }
  54.