home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / ANUMR5.ZIP / ROMBTEST.C < prev    next >
C/C++ Source or Header  |  1991-03-16  |  764b  |  42 lines

  1. #include <math.h>
  2. #include <stdio.h>
  3.  
  4.  
  5. #include "anum.h"
  6. #include "sysio.h"
  7.  
  8.  
  9.  
  10. double bf(double x)
  11.  
  12. {    return exp(3.0*x) + x*x/3.0; }
  13.  
  14.  
  15. void main(void)
  16.  
  17. {       double integ;
  18.  
  19.     double lb=1.0;
  20.     double ub=10.0;
  21.     double tol=1.e-08;
  22.     int maxiter=30;
  23.     int errcode, iter;
  24.  
  25.     puts("Test for romberg function\n"
  26.          "-------------------------");
  27.     printf("Lower bound                  : %lf\n",lb);
  28.     printf("Upper bound                  : %lf\n",ub);
  29.     printf("Maximum number of iterations : %d\n",maxiter);
  30.  
  31.     romberg(lb,ub,
  32.         tol, maxiter,
  33.         &integ,
  34.         &iter,
  35.         &errcode,
  36.         bf);
  37.         SYSMSG(errcode,stderr);
  38.  
  39.     printf("Value                        : %le\n",integ);
  40.     printf("Ran through                  : %d iterations\n",iter);
  41. }
  42.