home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / graphfor.zip / GRAPHFNS.FOR < prev    next >
Text File  |  1990-05-03  |  2KB  |  83 lines

  1.  
  2.       FUNCTION FGRAPH(IFN,P,X)
  3. *
  4. * Fortran source FGRAPH.for v2.0          Copyright (C) D.I. Hoyer, 1990
  5. *
  6. * The list of functions for plotting on IGRAPH.
  7. * This list can be added to as required.
  8. *
  9. * FNUM = Function number
  10. * P    = Array of parameters to be passed to the selected function
  11. * X    = X-value at which the function is to be evaluated
  12. *
  13.       DIMENSION P(*)
  14. * To add more functions, add labels to the following statement:
  15.       GOTO (1,2,3,4,5,6,7,8) IFN 
  16. *
  17. * Function 1. Polynomial (to n-th order). n+2 parameters.
  18. *             P(1)=n,  P(2) to P(n+2) = coeffecients a0, a1, a2, ... an.
  19. *                      [ f(x) = a0 + a1.x + a2.x^2 + ... + an.x^n ]
  20. *
  21.    1  N = INT(P(1)+0.5)
  22.       POLY = P(N+2)
  23.       DO 100 I=N+1, 2, -1
  24.         POLY = X*POLY + P(I)
  25.  100  CONTINUE
  26.       FGRAPH = POLY
  27.       RETURN
  28. *
  29. *  Function 2. Exponential, 3 parameters.
  30. *              f(x) = a + b.exp(c.x)
  31. *
  32.    2  FGRAPH = P(1) + P(2)*EXP(P(3)*X)
  33.       RETURN
  34. *
  35. *  Function 3. Power function, 3 parameters.
  36. *              f(x) = a + b.x^c
  37. *
  38.    3  FGRAPH = P(1) + P(2)*X**P(3)
  39.       RETURN
  40. *
  41. *  Function 4. Logarithmic, 4 parameters.
  42. *              f(x) = a + b.ln(c.x+d)
  43. *
  44.    4  FGRAPH = P(1) + P(2)*ALOG(P(3)*X + P(4))
  45.       RETURN
  46. *
  47. *  Function 5. Base 10 Logarithmic, 4 parameters.
  48. *              f(x) = a + b.log(c.x+d)
  49. *
  50.    5  FGRAPH = P(1) + P(2)*ALOG10(P(3)*X + P(4))
  51.       RETURN
  52. *
  53. *  Function 6. Inverse function, 3 parameters.
  54. *              f(x) = a + b/(c+x)
  55.    6  FGRAPH = P(1) + P(2)/(P(3)+X)
  56.       RETURN
  57. *
  58. *  Function 7. Circle.    4 Parameters.
  59. *              P(1) = 1 for top half of circle, -1 for bottom half.
  60. *              P(2) = radius
  61. *              P(3) = x coordinate of centre of circle
  62. *              P(4) = y coordinate of centre of circle
  63. *
  64.    7  XXX = P(2)*P(2) - (X-P(3))**2.
  65.       IF(XXX.LT.0) XXX = 0.
  66.       FGRAPH = P(1)*SQRT(XXX) + P(4)
  67.       RETURN
  68. *
  69. *  Function 8. Ellipse.    5 Parameters.
  70. *              P(1) = 1 for top half of ellipse, -1 for bottom half.
  71. *              P(2) = max radius in x direction 
  72. *              P(3) = max radius in y direction 
  73. *              P(4) = x coordinate of centre of ellipse
  74. *              P(5) = y coordinate of centre of ellipse
  75. *
  76.    8  XXX = 1.- ((X-P(4))/P(2))**2.
  77.       IF(XXX.LT.0) XXX = 0.
  78.       FGRAPH = P(1)*P(3)*SQRT(XXX) + P(5)
  79.       RETURN
  80.       END
  81.  
  82. *---------------------------------------------------------------------------
  83.