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

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