home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / misc / icalc.lzh / icalc / icalc.init < prev    next >
Encoding:
Text File  |  1992-01-30  |  1.7 KB  |  61 lines

  1. # This is the sample script file with all those unused trig functions 
  2. # removed...
  3. #
  4. # MWS, August 1991.
  5.  
  6. silent        # switch off confirmation of definitions
  7.  
  8. # function informing you how long icalc session has been running in minutes.
  9. _sessionstart = time(0)
  10. func session() = time(_sessionstart) / 60
  11.  
  12. # simple stopwatch functions
  13. func start() = (_start = time(0))
  14. func stop() = time(_start)
  15.  
  16. # a few simple time-savers
  17. func deg(z) = DEG*z        # convert radians to degrees
  18. func rad(z) = z/DEG        # and degrees to radians
  19. func log(z) = ln(z)/LOG10    # base-10 logarithm
  20. func lg(z) = ln(z)/LOG2        # base-2 logarithm
  21. func logn(z,n) = ln(z)/ln(n)    # base-n logarithm
  22.  
  23. # inverse hyperbolic trig functions
  24. func asinh(z) = -i*asin(i*z)
  25. func acosh(z) = -i*acos(z)
  26. func atanh(z) = i*atan(-i*z)
  27.  
  28. # gamma(z+1)...very accurate
  29. # NB: gamma(0) undefined
  30. func gamma(z) = sqrt(2*PI*z)*z^z*exp(-z)*(1+(1+(1-139/(180*z))/(24*z))/(12*z))
  31.  
  32. # combinatorics
  33. func fact(n) = Prod(_n=1,n,_n)
  34. func perm(n,r) = Prod(_n=n-r+1,n,_n)
  35. func comb(n,r) = perm(n,r)/fact(r)
  36.  
  37. # miscellaneous
  38.  
  39. # computes (-1)^n without using exponentials; twice as fast, more accurate
  40. func m1(n) = 1-4*(n/2-floor(n/2))
  41.  
  42. # fractional part of a number
  43. func frac(z) = z - floor(z)
  44.  
  45. # round real & imag parts
  46. func round(z,places) = int(z*10^places)/10^places
  47.  
  48. # create complex number from modulus and argument
  49. func polar(r,theta) = r*exp(i*theta)
  50.  
  51. # create complex number from real and imaginary parts
  52. func complex(real,imag) = real + i*imag
  53.  
  54. # convert decimal hours to hours, mins, seconds
  55. func hms(h) = multi(print(floor(h)), print(floor(_t = frac(h)*60)), frac(_t)*60)
  56.  
  57. # convert hours, mins, seconds to decimal hours
  58. func hours(h,m,s) = h+m/60+s/3600
  59.  
  60. verbose        # restore display of results, messages
  61.