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

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