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

  1. #include <stdio.h>  /* OK */
  2. #include <math.h>
  3. #include <stdlib.h>
  4.  
  5.  
  6. /*#pragma warn -stv*/
  7.  
  8.  
  9.  
  10. #include "anum.h"
  11. #include "sysio.h"
  12.  
  13.  
  14.  
  15.  
  16.  
  17. COMPLEX bf(COMPLEX z)
  18.  
  19. {    COMPLEX res;
  20.  
  21.     res.x=cos(z.x)*(exp(-z.y)+exp(z.y)) /2 -z.x;
  22.     res.y=sin(z.x)*(exp(-z.y)-exp(z.y)) /2 -z.y;
  23.     return(res);
  24. }
  25.  
  26.  
  27.  
  28. void results(COMPLEX guess, COMPLEX racine, COMPLEX yracine,
  29.          double tol,
  30.          int maxiter,
  31.          int iter,
  32.          int errcode)
  33.  
  34. {    printf("Initial approximation: "
  35.            "%lf +%lfi\n",guess.x,guess.y);
  36.     printf("Tolerance : %lf\n",tol);
  37.     printf("Maximum number of iterations: %d\n\n",maxiter);
  38.         SYSMSG(errcode,stderr);
  39.  
  40.     printf("Iterations number : %d\n",iter);
  41.     printf("Calculated root: %16.12lf + %16.12lfi\n",racine.x,racine.y);
  42.     puts("Function value at this root : ");
  43.     printf("(%16.12le) + (%16.12le) i\n\n",yracine.x,yracine.y);
  44. }
  45.  
  46.  
  47. void main()
  48.  
  49.  
  50. {       COMPLEX z0={1,1};
  51.     COMPLEX racine,yracine;
  52.     double tol=1e-8;
  53.     int maxiter=100;
  54.     int errcode,iter;
  55.  
  56.     puts("Test program for function muller\n");
  57.     muller(z0,tol,maxiter,
  58.         &racine,&yracine,&iter,&errcode,bf);
  59.  
  60.     puts("\n\nResults :\n-------\n");
  61.  
  62.     results(z0,racine,yracine,tol,maxiter,iter,errcode);
  63. }
  64.