pedz@smu.UUCP (06/11/84)
#R:sdccsu3:-190500:smu:19700002:000:1277 smu!pedz Jun 11 13:48:00 1984 I am not sure I understand your question. Basically you need to write a library of functions which implement the apropriate algorithm for each function, e.g., trig fuctions are done by taylor series, square root can be done by logrithms or by a successive approximation. There is a great deal of science which goes into a math package in order to get the most amount of precision. The package is then stored somewhere (in compiled form hopefully) and linked in when needed. If the language is such that external items do not exist, then the source code can be included with each compilation much like includes are done in C. When the compiler sees a reference to a function, it can set a flag when will cause the proper file to get included eventually. Yet another way is to place the compiled code in a file. When a function is referenced, it is treated as a reference to a function with a jump to a yet unknown address. Then the binary code is appended to the code just produced and the jumps are back patched. This is simular to having external procedures except the references get resolved at "compile" time. Is this what you wanted to know? I can give you references for books which detail how to design your functions if you need that. Perry convex!smu!pedz
johnl@haddock.UUCP (06/13/84)
#R:sdccsu3:-190500:haddock:12300003:000:641 haddock!johnl Jun 9 19:41:00 1984 People have been studying numerical algorithms for a long time, and there are many references that you could look up. For most transcendental functions, the usual approach is to precondition the arguments and check for special cases, and then compute a polynomial which approximates the desired function. Look at the sources for the C math library where there are comments referring you back to their origins both to see some algorithms and get the name of the source book they used. In the particular case of square root, Newton's method provides an interative method which converges in log2(wordsize), i.e. fast. John Levine, ima!johnl