mm =: +/ . * NB. matrix multiply Re =: {.@+. NB. real part of complex Im =: {:@+. NB. imaginary part of complex cn=. *@(2&#.@(*@])) * |@] NB. convert _d m s -> _d _m _s cno=. cn@([: 0 1 2&{ ] , 0 0"_) NB. add zeros if s or m & s missing dtr =: ((o.%648000)&*)@(360 60 60&#.)@cno f. NB. Convert deg m s -> rad rtd =: **360 60 60&#:@((648000%(o.1))&*)@| NB. rad -> deg m s htr =: ((o.%43200)&*)@(24 60 60&#.)@cno f. NB. Convert hrs m s -> rad rth =: 24 60 60&#:@((43200%(o.1))&*) NB. rad -> hrs m s DEL =: }. - }: NB. the difference between adjacent elements of array BIN =: -:@(}. + }:) NB. the average of adjacent elements NB. rough & ready (trap. rule) integration of y(x): +/(BIN y)*(DEL x) rand=: ?@# 0: NB. random numbers between 0 and 1 int01=: i.@>:%] NB. int01 n --> divides [0 ... 1] into n intervals. print=: ](1!:2)2: NB. print stuff --> prints stuff on screen enter=: [:". 1!:1&1: NB. X =. enter'' --> gets keboard input & applies ". prompt_char=: [:1!:1[:1:](1!:2)2: NB. ch=. prompt_char'message' -> keyboard entry prompt_numb=: [:".[:1!:1[:1:](1!:2)2: NB. prompt & apply ". to keyboard entry each=: &.> precise =: ":!.14 NB. increases the number of decimal places printed sin=: 1&o. NB. sine -- argument in radians cos=: 2&o. NB. cosine ... tan=: 3&o. sinh=: 5&o. cosh=: 6&o. tanh=. 7&o. asin=: _1&o. acos=: _2&o. atan=: _3&o. asinh=: _5&o. acosh=: _6&o. atanh=: _7&o. Sin=: sin@dtr NB. sine -- argument in degrees, arcmin, arcsec Cos=: cos@dtr Tan=: tan@dtr Asin=: rtd@asin Acos=: rtd@acos Atan=: rtd@atan NB. arctan with 2 arguments -- returns result in 0 - 2*pi range: atan2=: 13 : '2p1 | ((0>1{"1 y)*1p1)+2p1+_3 o. %/"1 y' atan3=: 13 : '(_3&o. %/"1 y)+1p1*(0>{:"1 y)*(*{."1 y)' NB. _1p1