home *** CD-ROM | disk | FTP | other *** search
- # This is the sample script file with all those unused trig functions
- # removed...
- #
- # MWS, August 1991.
-
- silent # switch off confirmation of definitions
-
- # function informing you how long icalc session has been running in minutes.
- _sessionstart = time(0)
- func session() = time(_sessionstart) / 60
-
- # simple stopwatch functions
- func start() = (_start = time(0))
- func stop() = time(_start)
-
- # a few simple time-savers
- func deg(z) = DEG*z # convert radians to degrees
- func rad(z) = z/DEG # and degrees to radians
- func log(z) = ln(z)/LOG10 # base-10 logarithm
- func lg(z) = ln(z)/LOG2 # base-2 logarithm
- func logn(z,n) = ln(z)/ln(n) # base-n logarithm
-
- # inverse hyperbolic trig functions
- func asinh(z) = -i*asin(i*z)
- func acosh(z) = -i*acos(z)
- func atanh(z) = i*atan(-i*z)
-
- # gamma(z+1)...very accurate
- # NB: gamma(0) undefined
- func gamma(z) = sqrt(2*PI*z)*z^z*exp(-z)*(1+(1+(1-139/(180*z))/(24*z))/(12*z))
-
- # combinatorics
- func fact(n) = Prod(_n=1,n,_n)
- func perm(n,r) = Prod(_n=n-r+1,n,_n)
- func comb(n,r) = perm(n,r)/fact(r)
-
- # miscellaneous
-
- # computes (-1)^n without using exponentials; twice as fast, more accurate
- func m1(n) = 1-4*(n/2-floor(n/2))
-
- # fractional part of a number
- func frac(z) = z - floor(z)
-
- # round real & imag parts
- func round(z,places) = int(z*10^places)/10^places
-
- # create complex number from modulus and argument
- func polar(r,theta) = r*exp(i*theta)
-
- # create complex number from real and imaginary parts
- func complex(real,imag) = real + i*imag
-
- # convert decimal hours to hours, mins, seconds
- func hms(h) = multi(print(floor(h)), print(floor(_t = frac(h)*60)), frac(_t)*60)
-
- # convert hours, mins, seconds to decimal hours
- func hours(h,m,s) = h+m/60+s/3600
-
- verbose # restore display of results, messages
-