home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 2: PC
/
frozenfish_august_1995.bin
/
bbs
/
d07xx
/
d0713.lha
/
ICalc
/
S
/
icalc.init
next >
Wrap
Text File
|
1992-08-19
|
2KB
|
65 lines
# Standard startup-file for icalc.
# Updated for version 2.1. Also, you may want to include other scripts
# (such as gamma.ic) by read command.
#
# MWS, July 1992.
silent # switch off confirmation of definitions
# function informing you how long icalc session has been running in seconds.
_sessionstart = time(0)
0 # restore ans to zero
func session() = time(_sessionstart)
# simple stopwatch functions
func start() = (_start = time(0))
func stop() = time(_start)
# timer of evaluation
func timer(~expr) = { local t; t = time(0); print(expr); time(t); }
# 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 (works with complex bases too:)
# switch bases - note adjustment of significant figures
func bin() = { outbase(2); prec(35); } # display results in binary
func oct() = { outbase(8); prec(15); } # display results in ocal
func dec() = { outbase(10); prec(12); } # display results in decimal
func hex() = { outbase(16); prec(10); } # display results in hexadecimal
# inverse hyperbolic trig functions
func asinh(z) = -i*asin(i*z)
func acosh(z) = -i*acos(z)
func atanh(z) = i*atan(-i*z)
# combinatorics - could be replaced with defs in gamma.ic
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
# fractional part of a number
func frac(z) = Re(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) = { 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